View Javadoc
1   /*
2    * Copyright (c) 2002-2025, City of Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.portal.web.stylesheet;
35  
36  import java.io.ByteArrayInputStream;
37  import java.io.File;
38  import java.io.FileOutputStream;
39  import java.io.IOException;
40  import java.util.Collection;
41  import java.util.Collections;
42  import java.util.HashMap;
43  import java.util.List;
44  import java.util.Map;
45  
46  import javax.servlet.http.HttpServletRequest;
47  import javax.xml.parsers.SAXParser;
48  import javax.xml.parsers.SAXParserFactory;
49  
50  import org.apache.commons.fileupload.FileItem;
51  import org.xml.sax.InputSource;
52  
53  import fr.paris.lutece.portal.business.portalcomponent.PortalComponentHome;
54  import fr.paris.lutece.portal.business.portlet.PortletType;
55  import fr.paris.lutece.portal.business.portlet.PortletTypeHome;
56  import fr.paris.lutece.portal.business.style.Mode;
57  import fr.paris.lutece.portal.business.style.ModeHome;
58  import fr.paris.lutece.portal.business.style.Style;
59  import fr.paris.lutece.portal.business.style.StyleHome;
60  import fr.paris.lutece.portal.business.stylesheet.StyleSheet;
61  import fr.paris.lutece.portal.business.stylesheet.StyleSheetHome;
62  import fr.paris.lutece.portal.service.admin.AccessDeniedException;
63  import fr.paris.lutece.portal.service.fileupload.FileUploadService;
64  import fr.paris.lutece.portal.service.i18n.I18nService;
65  import fr.paris.lutece.portal.service.message.AdminMessage;
66  import fr.paris.lutece.portal.service.message.AdminMessageService;
67  import fr.paris.lutece.portal.service.security.SecurityTokenService;
68  import fr.paris.lutece.portal.service.template.AppTemplateService;
69  import fr.paris.lutece.portal.service.util.AppLogService;
70  import fr.paris.lutece.portal.service.xsl.XslSecurityService;
71  import fr.paris.lutece.portal.service.util.AppPathService;
72  import fr.paris.lutece.portal.service.util.AppPropertiesService;
73  import fr.paris.lutece.portal.web.admin.AdminFeaturesPageJspBean;
74  import fr.paris.lutece.portal.web.constants.Messages;
75  import fr.paris.lutece.portal.web.constants.Parameters;
76  import fr.paris.lutece.portal.web.upload.MultipartHttpServletRequest;
77  import fr.paris.lutece.portal.web.util.LocalizedPaginator;
78  import fr.paris.lutece.util.ReferenceList;
79  import fr.paris.lutece.util.file.FileUtil;
80  import fr.paris.lutece.util.html.AbstractPaginator;
81  import fr.paris.lutece.util.html.HtmlTemplate;
82  import fr.paris.lutece.util.sort.AttributeComparator;
83  
84  /**
85   * This class provides the user interface to manage StyleSheet features
86   */
87  public class StyleSheetJspBean extends AdminFeaturesPageJspBean
88  {
89      // //////////////////////////////////////////////////////////////////////////
90      // Constants
91  
92      // Right
93      /**
94       * Right to manage stylesheets
95       */
96      public static final String RIGHT_MANAGE_STYLESHEET = "CORE_STYLESHEET_MANAGEMENT";
97  
98      /**
99       * Serial version UID
100      */
101     private static final long serialVersionUID = 8176263113722225633L;
102 
103     // Markers
104     private static final String MARK_MODE_ID = "mode_id";
105     private static final String MARK_MODE_LIST = "mode_list";
106     private static final String MARK_STYLESHEET_LIST = "stylesheet_list";
107     private static final String MARK_STYLE_LIST = "style_list";
108     private static final String MARK_STYLESHEET = "stylesheet";
109     private static final String MARK_PAGINATOR = "paginator";
110     private static final String MARK_NB_ITEMS_PER_PAGE = "nb_items_per_page";
111     private static final String MARK_PORTAL_COMPONENT_NAME = "portal_component_name";
112     private static final String MARK_PORTLET_TYPE_NAME = "portlet_type_name";
113     private static final String MARK_STYLE_DESCRIPTION = "style_description";
114 
115     // Templates files path
116     private static final String TEMPLATE_MANAGE_STYLESHEETS = "admin/stylesheet/manage_stylesheets.html";
117     private static final String TEMPLATE_CREATE_STYLESHEET = "admin/stylesheet/create_stylesheet.html";
118     private static final String TEMPLATE_MODIFY_STYLESHEET = "admin/stylesheet/modify_stylesheet.html";
119     private static final String TEMPLATE_STYLE_SELECT_OPTION = "admin/stylesheet/style_select_option.html";
120 
121     // Properties
122     private static final String PROPERTY_PATH_XSL = "path.stylesheet";
123     private static final String PROPERTY_STYLESHEETS_PER_PAGE = "paginator.stylesheet.itemsPerPage";
124     private static final String MESSAGE_STYLESHEET_ALREADY_EXISTS = "portal.style.message.stylesheetAlreadyExists";
125     private static final String MESSAGE_STYLESHEET_NOT_VALID = "portal.style.message.stylesheetNotValid";
126     private static final String MESSAGE_STYLESHEET_SECURITY_VIOLATION = "portal.style.message.stylesheetSecurityViolation";
127     private static final String MESSAGE_CONFIRM_DELETE_STYLESHEET = "portal.style.message.stylesheetConfirmDelete";
128     private static final String LABEL_ALL = "portal.util.labelAll";
129     private static final String JSP_DO_REMOVE_STYLESHEET = "jsp/admin/style/DoRemoveStyleSheet.jsp";
130     private static final String JSP_REMOVE_STYLE = "RemoveStyle.jsp";
131     private int _nItemsPerPage;
132     private String _strCurrentPageIndex;
133 
134     /**
135      * Displays the stylesheets list
136      * 
137      * @return the html code for displaying the stylesheets list
138      * @param request
139      *            The request
140      */
141     public String getManageStyleSheet( HttpServletRequest request )
142     {
143         // Parameters processing
144         String strModeId = request.getParameter( Parameters.MODE_ID );
145         strModeId = ( strModeId != null ) ? strModeId : "-1";
146 
147         int nModeId = Integer.parseInt( strModeId );
148 
149         ReferenceList listModes = ModeHome.getModes( );
150         String strComboItem = I18nService.getLocalizedString( LABEL_ALL, getLocale( ) );
151         listModes.addItem( -1, strComboItem );
152 
153         List<StyleSheet> listStyleSheets = (List<StyleSheet>) StyleSheetHome.getStyleSheetList( nModeId );
154 
155         String strSortedAttributeName = request.getParameter( Parameters.SORTED_ATTRIBUTE_NAME );
156         String strAscSort = null;
157 
158         if ( strSortedAttributeName != null )
159         {
160             strAscSort = request.getParameter( Parameters.SORTED_ASC );
161 
162             boolean bIsAscSort = Boolean.parseBoolean( strAscSort );
163 
164             Collections.sort( listStyleSheets, new AttributeComparator( strSortedAttributeName, bIsAscSort ) );
165         }
166 
167         int defaultItemsPerPage = AppPropertiesService.getPropertyInt( PROPERTY_STYLESHEETS_PER_PAGE, 50 );
168         _strCurrentPageIndex = AbstractPaginator.getPageIndex( request, AbstractPaginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex );
169         _nItemsPerPage = AbstractPaginator.getItemsPerPage( request, AbstractPaginator.PARAMETER_ITEMS_PER_PAGE, _nItemsPerPage, defaultItemsPerPage );
170 
171         String strURL = getHomeUrl( request );
172 
173         if ( strSortedAttributeName != null )
174         {
175             strURL += ( "?" + Parameters.SORTED_ATTRIBUTE_NAME + "=" + strSortedAttributeName );
176         }
177 
178         if ( strAscSort != null )
179         {
180             strURL += ( "&" + Parameters.SORTED_ASC + "=" + strAscSort );
181         }
182 
183         LocalizedPaginator<StyleSheet> paginator = new LocalizedPaginator<>( listStyleSheets, _nItemsPerPage, strURL, AbstractPaginator.PARAMETER_PAGE_INDEX,
184                 _strCurrentPageIndex, getLocale( ) );
185 
186         Map<String, Object> model = new HashMap<>( );
187         model.put( MARK_MODE_ID, strModeId );
188         model.put( MARK_NB_ITEMS_PER_PAGE, "" + _nItemsPerPage );
189         model.put( MARK_PAGINATOR, paginator );
190         model.put( MARK_STYLESHEET_LIST, paginator.getPageItems( ) );
191         model.put( MARK_MODE_LIST, listModes );
192 
193         HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_MANAGE_STYLESHEETS, getLocale( ), model );
194 
195         return getAdminPage( template.getHtml( ) );
196     }
197 
198     /**
199      * Returns the create form of a new stylesheet with the upload field
200      * 
201      * @param request
202      *            the http request
203      * @return the html code for the create form of a new stylesheet
204      */
205     public String getCreateStyleSheet( HttpServletRequest request )
206     {
207         String strModeId = request.getParameter( Parameters.MODE_ID );
208 
209         Map<String, Object> model = new HashMap<>( );
210         model.put( MARK_STYLE_LIST, getStyleList( ) );
211         model.put( MARK_MODE_LIST, ModeHome.getModes( ) );
212         model.put( MARK_MODE_ID, strModeId );
213         model.put( SecurityTokenService.MARK_TOKEN, SecurityTokenService.getInstance( ).getToken( request, TEMPLATE_CREATE_STYLESHEET ) );
214 
215         HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_CREATE_STYLESHEET, getLocale( ), model );
216 
217         return getAdminPage( template.getHtml( ) );
218     }
219 
220     /**
221      * Processes the creation form of a new stylesheet by recovering the parameters in the http request
222      * 
223      * @param request
224      *            the http request
225      * @return The Jsp URL of the process result
226      * @throws AccessDeniedException
227      *             if the security token is invalid
228      */
229     public String doCreateStyleSheet( HttpServletRequest request ) throws AccessDeniedException
230     {
231         StyleSheets/stylesheet/StyleSheet.html#StyleSheet">StyleSheet stylesheet = new StyleSheet( );
232         MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
233         String strErrorUrl = getData( multipartRequest, stylesheet );
234 
235         if ( strErrorUrl != null )
236         {
237             return strErrorUrl;
238         }
239         if ( !SecurityTokenService.getInstance( ).validate( multipartRequest, TEMPLATE_CREATE_STYLESHEET ) )
240         {
241             throw new AccessDeniedException( ERROR_INVALID_TOKEN );
242         }
243 
244         // insert in the table stylesheet of the database
245         StyleSheetHome.create( stylesheet );
246 
247 //        // create a local file
248 //        localStyleSheetFile( stylesheet );
249 
250         // Displays the list of the stylesheet files
251         return getHomeUrl( request );
252     }
253 
254     /**
255      * Reads stylesheet's data
256      * 
257      * @param multipartRequest
258      *            The request
259      * @param stylesheet
260      *            The style sheet
261      * @return An error message URL or null if no error
262      */
263     private String getData( MultipartHttpServletRequest multipartRequest, StyleSheet stylesheet )
264     {
265         String strErrorUrl = null;
266         String strDescription = multipartRequest.getParameter( Parameters.STYLESHEET_NAME );
267         String strStyleId = multipartRequest.getParameter( Parameters.STYLES );
268         String strModeId = multipartRequest.getParameter( Parameters.MODE_STYLESHEET );
269 
270         FileItem fileSource = multipartRequest.getFile( Parameters.STYLESHEET_SOURCE );
271         byte [ ] baXslSource = fileSource.get( );
272         String strFilename = FileUploadService.getFileNameOnly( fileSource );
273 
274         // Mandatory fields
275         if ( strDescription.equals( "" ) || ( strFilename == null ) || strFilename.equals( "" ) )
276         {
277             return AdminMessageService.getMessageUrl( multipartRequest, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP );
278         }
279 
280         // test the existence of style or mode already associate with this stylesheet
281         int nStyleId = Integer.parseInt( strStyleId );
282         int nModeId = Integer.parseInt( strModeId );
283         int nCount = StyleSheetHome.getStyleSheetNbPerStyleMode( nStyleId, nModeId );
284 
285         // Do not create a stylesheet of there is already one
286         if ( ( nCount >= 1 ) && ( stylesheet.getId( ) == 0 /* creation */ ) )
287         {
288             return AdminMessageService.getMessageUrl( multipartRequest, MESSAGE_STYLESHEET_ALREADY_EXISTS, AdminMessage.TYPE_STOP );
289         }
290 
291         // Check the XML validity of the XSL stylesheet
292         if ( isValid( baXslSource ) != null )
293         {
294             return AdminMessageService.getMessageUrl( multipartRequest, MESSAGE_STYLESHEET_NOT_VALID, AdminMessage.TYPE_STOP );
295         }
296 
297         // Check the XSL stylesheet for security threats
298         List<String> listSecurityViolations = XslSecurityService.validateXslSecurity( baXslSource );
299 
300         if ( !listSecurityViolations.isEmpty( ) )
301         {
302             return AdminMessageService.getMessageUrl( multipartRequest, MESSAGE_STYLESHEET_SECURITY_VIOLATION, AdminMessage.TYPE_STOP );
303         }
304 
305         stylesheet.setDescription( strDescription );
306         stylesheet.setStyleId( Integer.parseInt( strStyleId ) );
307         stylesheet.setModeId( Integer.parseInt( strModeId ) );
308         stylesheet.setSource( baXslSource );
309         stylesheet.setFile( strFilename );
310 
311         return strErrorUrl;
312     }
313 
314     /**
315      * Returns the form to update a stylesheet whose identifer is stored in the http request
316      * 
317      * @param request
318      *            The http request
319      * @return The html code
320      */
321     public String getModifyStyleSheet( HttpServletRequest request )
322     {
323         String strStyleSheetId = request.getParameter( Parameters.STYLESHEET_ID );
324         int nId = Integer.parseInt( strStyleSheetId );
325 
326         Map<String, Object> model = new HashMap<>( );
327         model.put( MARK_STYLE_LIST, getStyleList( ) );
328         model.put( MARK_MODE_LIST, ModeHome.getModes( ) );
329         model.put( MARK_STYLESHEET, StyleSheetHome.findByPrimaryKey( nId ) );
330         model.put( SecurityTokenService.MARK_TOKEN, SecurityTokenService.getInstance( ).getToken( request, TEMPLATE_MODIFY_STYLESHEET ) );
331 
332         HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_MODIFY_STYLESHEET, getLocale( ), model );
333 
334         return getAdminPage( template.getHtml( ) );
335     }
336 
337     /**
338      * Return a ReferenceList with id style for code and a concatenation of portal name + portlet type name + style description for name.
339      * 
340      * @return The {@link ReferenceList}
341      */
342     public ReferenceList getStyleList( )
343     {
344         Collection<Style> stylesList = StyleHome.getStylesList( );
345         ReferenceList stylesListWithLabels = new ReferenceList( );
346 
347         for ( Style style : stylesList )
348         {
349             HashMap<String, Object> model = new HashMap<>( );
350             model.put( MARK_PORTAL_COMPONENT_NAME, PortalComponentHome.findByPrimaryKey( style.getPortalComponentId( ) ).getName( ) );
351 
352             PortletType portletType = PortletTypeHome.findByPrimaryKey( style.getPortletTypeId( ) );
353 
354             model.put( MARK_PORTLET_TYPE_NAME,
355                     ( ( portletType != null ) ? ( I18nService.getLocalizedString( portletType.getNameKey( ), getLocale( ) ) ) : "" ) );
356             model.put( MARK_STYLE_DESCRIPTION, style.getDescription( ) );
357 
358             HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_STYLE_SELECT_OPTION, getLocale( ), model );
359             stylesListWithLabels.addItem( style.getId( ), template.getHtml( ) );
360         }
361 
362         return stylesListWithLabels;
363     }
364 
365     /**
366      * Processes the updating form of a stylesheet whose new parameters are stored in the http request
367      * 
368      * @param request
369      *            The http request
370      * @return The Jsp URL of the process result
371      * @throws AccessDeniedException
372      *             if the security token is invalid
373      */
374     public String doModifyStyleSheet( HttpServletRequest request ) throws AccessDeniedException
375     {
376         MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
377         int nId = Integer.parseInt( multipartRequest.getParameter( Parameters.STYLESHEET_ID ) );
378         StyleSheet stylesheet = StyleSheetHome.findByPrimaryKey( nId );
379         String strErrorUrl = getData( multipartRequest, stylesheet );
380 
381         if ( strErrorUrl != null )
382         {
383             return strErrorUrl;
384         }
385         if ( !SecurityTokenService.getInstance( ).validate( multipartRequest, TEMPLATE_MODIFY_STYLESHEET ) )
386         {
387             throw new AccessDeniedException( ERROR_INVALID_TOKEN );
388         }
389 
390 //        // Remove the old local file
391 //        removeOldLocalStyleSheet( nId );
392 
393         // Update the stylesheet in database
394         StyleSheetHome.update( stylesheet );
395 
396 //        // Recreate the local file
397 //        localStyleSheetFile( stylesheet );
398 
399         // Displays the management stylesheet page
400         return getHomeUrl( request );
401     }
402 
403     /**
404      * Returns the confirm of removing the style whose identifier is in the http request
405      *
406      * @param request
407      *            The Http request
408      * @return the html code for the remove confirmation page
409      */
410     public String getRemoveStyleSheet( HttpServletRequest request )
411     {
412         String strId = request.getParameter( Parameters.STYLESHEET_ID );
413 
414         StyleSheet stylesheet = StyleSheetHome.findByPrimaryKey( Integer.parseInt( strId ) );
415         Object [ ] args = {
416                 stylesheet.getDescription( )
417         };
418 
419         Map<String, Object> parameters = new HashMap<>( );
420         parameters.put( Parameters.STYLESHEET_ID, strId );
421         parameters.put( Parameters.STYLE_ID, stylesheet.getStyleId( ) );
422         parameters.put( SecurityTokenService.PARAMETER_TOKEN, SecurityTokenService.getInstance( ).getToken( request, JSP_DO_REMOVE_STYLESHEET ) );
423         return AdminMessageService.getMessageUrl( request, MESSAGE_CONFIRM_DELETE_STYLESHEET, args, null, JSP_DO_REMOVE_STYLESHEET, null,
424                 AdminMessage.TYPE_CONFIRMATION, parameters );
425     }
426 
427     /**
428      * Processes the deletion of a stylesheet
429      * 
430      * @param request
431      *            the http request
432      * @return The Jsp URL of the process result
433      * @throws AccessDeniedException
434      *             if the security token is invalid
435      */
436     public String doRemoveStyleSheet( HttpServletRequest request ) throws AccessDeniedException
437     {
438         if ( !SecurityTokenService.getInstance( ).validate( request, JSP_DO_REMOVE_STYLESHEET ) )
439         {
440             throw new AccessDeniedException( ERROR_INVALID_TOKEN );
441         }
442         int nId = Integer.parseInt( request.getParameter( Parameters.STYLESHEET_ID ) );
443         int nIdStyle = Integer.parseInt( request.getParameter( Parameters.STYLE_ID ) );
444         StyleSheet stylesheet = StyleSheetHome.findByPrimaryKey( nId );
445         String strFile = stylesheet.getFile( );
446         StyleSheetHome.remove( nId );
447 
448         // removal of the XSL file
449         int nModeId = stylesheet.getModeId( );
450         Mode mode = ModeHome.findByPrimaryKey( nModeId );
451         String strPathStyleSheet = AppPathService.getPath( PROPERTY_PATH_XSL ) + mode.getPath( );
452         File fileToDelete = new File( strPathStyleSheet, strFile );
453         FileUtil.deleteFile( fileToDelete );
454 
455         return JSP_REMOVE_STYLE + "?" + Parameters.STYLE_ID + "=" + nIdStyle;
456     }
457 
458     // ////////////////////////////////////////////////////////////////////////////////
459     // Private implementation
460 
461     /**
462      * Use parsing for validate the modify xsl file
463      *
464      * @param baXslSource
465      *            The XSL source
466      * @return the message exception when the validation is false
467      */
468     private String isValid( byte [ ] baXslSource )
469     {
470         String strError = null;
471 
472         try
473         {
474             SAXParserFactory factory = SAXParserFactory.newInstance( );
475             factory.setFeature( "http://apache.org/xml/features/disallow-doctype-decl", true );
476             factory.setFeature( "http://xml.org/sax/features/external-general-entities", false );
477             factory.setFeature( "http://xml.org/sax/features/external-parameter-entities", false );
478             SAXParser analyzer = factory.newSAXParser( );
479             InputSource is = new InputSource( new ByteArrayInputStream( baXslSource ) );
480             analyzer.getXMLReader( ).parse( is );
481         }
482         catch( Exception e )
483         {
484             strError = "invalid XSL stylesheet";
485             AppLogService.error( "XSL validation error: {}", e.getMessage( ), e );
486         }
487 
488         return strError;
489     }
490 
491 //    /**
492 //     * Create and Update the local download file
493 //     *
494 //     * @param stylesheet
495 //     *            The style sheet
496 //     */
497 //    private void localStyleSheetFile( StyleSheet stylesheet )
498 //    {
499 //        int nModeId = stylesheet.getModeId( );
500 //        Mode mode = ModeHome.findByPrimaryKey( nModeId );
501 //        String strPathStyleSheet = AppPathService.getPath( PROPERTY_PATH_XSL ) + mode.getPath( );
502 //        String strFileName = stylesheet.getFile( );
503 //        String strFilePath = strPathStyleSheet + strFileName;
504 //
505 //        File file = new File( strFilePath );
506 //        FileUtil.deleteFile( file );
507 //        try ( FileOutputStream fos = new FileOutputStream( file ) )
508 //        {
509 //            fos.write( stylesheet.getSource( ) );
510 //        }
511 //        catch( IOException e )
512 //        {
513 //            AppLogService.error( e.getMessage( ), e );
514 //        }
515 //    }
516 //
517 //    /**
518 //     * remove the xsl file from the tmp directory
519 //     * 
520 //     * @param nId
521 //     *            the identifier of the file
522 //     */
523 //    private void removeOldLocalStyleSheet( int nId )
524 //    {
525 //        // Remove the file which been modify
526 //        StyleSheet stylesheet = StyleSheetHome.findByPrimaryKey( nId );
527 //        int nMode = stylesheet.getModeId( );
528 //        Mode mode = ModeHome.findByPrimaryKey( nMode );
529 //        String strPathStyleSheet = AppPathService.getPath( PROPERTY_PATH_XSL ) + mode.getPath( );
530 //        String strOldFileName = stylesheet.getFile( );
531 //        String strOldFilePath = strPathStyleSheet + strOldFileName;
532 //        File oldFile = new File( strOldFilePath );
533 //        FileUtil.deleteFile( oldFile );
534 //    }
535 }