From: <jbo...@li...> - 2006-05-30 21:26:23
|
Author: adamw Date: 2006-05-30 17:26:16 -0400 (Tue, 30 May 2006) New Revision: 4496 Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/FilesFromRepoFilter.java Log: Synchronizing file copying Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/FilesFromRepoFilter.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/FilesFromRepoFilter.java 2006-05-30 20:15:47 UTC (rev 4495) +++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/FilesFromRepoFilter.java 2006-05-30 21:26:16 UTC (rev 4496) @@ -39,7 +39,8 @@ /** * A filter for reading JSP (and html, text etc) files from a file repository * and including them in the response. - * + * + * @deprecated - Move to Shotoku version. * @author adamw * @author Tomasz Szymanski */ @@ -47,7 +48,12 @@ private final static String WRONG_REQ_RESP = "Error accessing the " + "requested resource."; - /** + /** + * Field on which synchronization of copying file is done. + */ + private final static Object synchronizer = new Object(); + + /** * <code>COPIED_TO_REPO_DIR</code> - name of a directory to which files * will be copied; this will be a subdirectory of the deployment directory * of a web application using this filter. @@ -111,9 +117,11 @@ long lastModified = new File(filePath).lastModified(); if ((lastModified == 0) || (lastModified < requestedNode.getLastModification())) { - new File(filePath.substring(0, - filePath.lastIndexOf(separator))).mkdirs(); - requestedNode.copyToFile(filePath); + synchronized(synchronizer) { + new File(filePath.substring(0, + filePath.lastIndexOf(separator))).mkdirs(); + requestedNode.copyToFile(filePath); + } } request.getRequestDispatcher( |