From: <st...@us...> - 2010-11-01 14:27:09
|
Revision: 8426 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8426&view=rev Author: steve_l Date: 2010-11-01 14:27:00 +0000 (Mon, 01 Nov 2010) Log Message: ----------- SFOS-1541 add DeleteFile component to delete a file on deployment Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/Chmod.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/ChmodImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/CopyFile.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/CopyFileImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/DeployByCopyImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileExists.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileExistsImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileIntf.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileSystem.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileUsingComponent.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileUsingComponentImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileUsingCompoundImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FilepathFunction.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/Mkdir.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/MkdirImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/SelfDeletingFileImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TempDirImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TempFile.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TempFileImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TextFile.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TextFileImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TextListFileImplImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TouchFileImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TouchFileIntf.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TupleReaderThread.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/append/AppendLinesImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/components.sf trunk/core/smartfrog/src/org/smartfrog/services/filesystem/files/FilenamePatternFilter.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/files/Files.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/files/FilesCompoundImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/files/FilesImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/files/Fileset.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/files/components.sf trunk/core/smartfrog/src/org/smartfrog/services/filesystem/filestore/AddedFilestore.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/filestore/FileEntryImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/replacevar/DataParser.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/replacevar/ParserVar.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/replacevar/ReplaceVar.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/replacevar/SFReplaceFileVar.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/selfdeletingfile.sf Added Paths: ----------- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/DeleteFileImpl.java trunk/core/smartfrog/src/org/smartfrog/services/filesystem/deletefile.sf Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/Chmod.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/Chmod.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/Chmod.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -38,28 +38,28 @@ /** * The target file or directory which access permissions should be changed. */ - static final String ATTR_TARGET = "file"; + String ATTR_TARGET = "file"; /** * The permissions for the owner. */ - static final String ATTR_USER_PERMISSIONS = "userPermissions"; + String ATTR_USER_PERMISSIONS = "userPermissions"; /** * The permissions for the group members. */ - static final String ATTR_GROUP_PERMISSIONS = "groupPermissions"; + String ATTR_GROUP_PERMISSIONS = "groupPermissions"; /** * The permissions for the other users. */ - static final String ATTR_OTHER_PERMISSIONS = "otherPermissions"; + String ATTR_OTHER_PERMISSIONS = "otherPermissions"; /** * Octal notation of the permissions. */ - static final String ATTR_OCTAL_CODE = "octalCode"; + String ATTR_OCTAL_CODE = "octalCode"; /** * If true permissions will be set recursively. */ - static final String ATTR_RECURSIVELY = "recursively"; + String ATTR_RECURSIVELY = "recursively"; } Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/ChmodImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/ChmodImpl.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/ChmodImpl.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -32,16 +32,15 @@ package org.smartfrog.services.filesystem; +import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.prim.PrimImpl; import org.smartfrog.sfcore.prim.TerminationRecord; -import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.common.SmartFrogDeploymentException; import org.smartfrog.sfcore.utils.ComponentHelper; +import java.io.IOException; import java.rmi.RemoteException; +import java.util.ArrayList; import java.util.List; -import java.util.ArrayList; -import java.io.IOException; /** * Component to set the access permissions of a file or directory. @@ -91,9 +90,9 @@ recursively = sfResolve(ATTR_RECURSIVELY, false, true); if (userPermissions.equals("") && - groupPermissions.equals("") && - otherPermissions.equals("") && - octalNotation.equals("")) { + groupPermissions.equals("") && + otherPermissions.equals("") && + octalNotation.equals("")) { sfLog().error(ERROR_NO_PERMISSIONS_SPECIFIED); throw new SmartFrogException(ERROR_NO_PERMISSIONS_SPECIFIED); } @@ -107,11 +106,11 @@ * failure while starting * @throws java.rmi.RemoteException In case of network/rmi error */ - public synchronized void sfStart() throws SmartFrogException, RemoteException { + public synchronized void sfStart() throws SmartFrogException, RemoteException { super.sfStart(); // compose the options - List<String> commands=new ArrayList<String>(4); + List<String> commands = new ArrayList<String>(4); commands.add("chmod"); if (recursively) { @@ -128,7 +127,7 @@ } if (groupPermissions.length() != 0) { // multiple user classes have to be comma-separated - modeString += (modeString.length()!=0 ? "," : "") + 'g' + groupPermissions; + modeString += (modeString.length() != 0 ? "," : "") + 'g' + groupPermissions; } if (otherPermissions.length() != 0) { // multiple user classes have to be comma-separated @@ -136,7 +135,8 @@ } //sanity check - assert modeString.length()==0 || modeString.charAt(0)!=',':" bad modes: '"+modeString+"'"; + assert modeString.length() == 0 || modeString.charAt(0) != ',' : + " bad modes: '" + modeString + "'"; commands.add(modeString); } @@ -144,10 +144,10 @@ // execute the command String[] commandArray = commands.toArray(new String[commands.size()]); - String details=""; - for(String s:commandArray) { - details+=s; - details+=" "; + String details = ""; + for (String s : commandArray) { + details += s; + details += " "; } sfLog().info(details); try { Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/CopyFile.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/CopyFile.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/CopyFile.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -19,9 +19,10 @@ */ package org.smartfrog.services.filesystem; -import java.rmi.Remote; import org.smartfrog.sfcore.compound.Compound; +import java.rmi.Remote; + /** * Defines attributes for CopyFile component. */ @@ -31,8 +32,8 @@ String ATTR_FROM = "source"; /** new file copy {@value} */ String ATTR_TO = "destination"; - - String ATTR_COPY_ON_DEPLOY= "copyOnDeploy"; - - String ATTR_OVERWRITE ="overwrite"; + + String ATTR_COPY_ON_DEPLOY = "copyOnDeploy"; + + String ATTR_OVERWRITE = "overwrite"; } Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/CopyFileImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/CopyFileImpl.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/CopyFileImpl.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -32,7 +32,7 @@ import java.rmi.RemoteException; /** - * Implemetation for CopyFile component. + * Implementation for CopyFile component. */ public class CopyFileImpl extends CompoundImpl implements CopyFile, Compound { Copied: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/DeleteFileImpl.java (from rev 8425, trunk/core/smartfrog/src/org/smartfrog/services/filesystem/SelfDeletingFileImpl.java) =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/DeleteFileImpl.java (rev 0) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/DeleteFileImpl.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -0,0 +1,81 @@ +/** (C) Copyright 2005 Hewlett-Packard Development Company, LP + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + For more information: www.smartfrog.org + + */ +package org.smartfrog.services.filesystem; + +import org.smartfrog.sfcore.common.SmartFrogDeploymentException; +import org.smartfrog.sfcore.common.SmartFrogException; + +import java.io.File; +import java.rmi.RemoteException; + +/** + * This is a component which will delete a file that it is bound do at + * startup. + */ + +public class DeleteFileImpl extends FileUsingComponentImpl + implements FileUsingComponent { + + /** + * Constructor. + * @throws RemoteException In case of network/rmi error + */ + public DeleteFileImpl() throws RemoteException { + } + + /** + * + * Bind to the attributes defining filename; fail if not set + * @throws SmartFrogException error while deploying + * @throws RemoteException In case of network/rmi error + */ + public synchronized void sfDeploy() throws SmartFrogException, + RemoteException { + super.sfDeploy(); + bindWithDir(true, null); + } + + /** + * Can be called to start components. Subclasses should override to provide + * functionality Do not block in this call, but spawn off any main loops! + * + * @throws SmartFrogException failure while starting + * @throws RemoteException In case of network/rmi error + */ + public synchronized void sfStart() throws SmartFrogException, RemoteException { + super.sfStart(); + File target = getFile(); + try { + if (target != null && target.exists()) { + if (!target.delete()) { + sfLog().warn("Failed to delete " + target); + } + } + } catch (SecurityException e) { + //failure is turned into a security problem; we catch it and make it meaningful + throw new SmartFrogDeploymentException( + "Security blocked the deletion of the file directories " + target, + e, + this); + } + maybeStartTerminator("Deleted file"); + } + +} Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/DeployByCopyImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/DeployByCopyImpl.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/DeployByCopyImpl.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -21,14 +21,15 @@ package org.smartfrog.services.filesystem; +import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.prim.TerminationRecord; -import org.smartfrog.sfcore.common.SmartFrogException; import java.rmi.RemoteException; /** - * a component that deletes a file when terminated - * */ + * Deploy an application by copying the file and deleting the destination file + * when terminating. + */ public class DeployByCopyImpl extends CopyFileImpl implements CopyFile { private boolean shouldDelete; Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileExists.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileExists.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileExists.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -10,15 +10,15 @@ /** * {@value} */ - String ATTR_MIN_SIZE="minSize"; + String ATTR_MIN_SIZE = "minSize"; /** the maximum size : {@value}*/ - String ATTR_MAX_SIZE ="maxSize"; + String ATTR_MAX_SIZE = "maxSize"; /** * Boolean to indicate the file can be a directory: {@value} */ - String ATTR_CAN_BE_DIR="canBeDirectory"; + String ATTR_CAN_BE_DIR = "canBeDirectory"; /** * Boolean to indicate the file can be a file:{@value} @@ -26,7 +26,7 @@ String ATTR_CAN_BE_FILE = "canBeFile"; /** Check on startup : {@value}*/ - String ATTR_CHECKONSTARTUP ="checkOnStartup"; + String ATTR_CHECKONSTARTUP = "checkOnStartup"; } Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileExistsImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileExistsImpl.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileExistsImpl.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -31,21 +31,20 @@ */ package org.smartfrog.services.filesystem; -import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.common.SmartFrogDeploymentException; -import org.smartfrog.sfcore.utils.ComponentHelper; +import org.smartfrog.sfcore.common.SmartFrogException; -import java.rmi.RemoteException; import java.io.File; +import java.rmi.RemoteException; /** * A component to validate files */ public class FileExistsImpl extends FileUsingComponentImpl implements FileExists { - private long minSize = -1, maxSize=-1; + private long minSize = -1, maxSize = -1; private boolean canBeFile, canBeDir; - private String lastError=""; + private String lastError = ""; public FileExistsImpl() throws RemoteException { } @@ -69,14 +68,14 @@ canBeFile = sfResolve(ATTR_CAN_BE_FILE, true, true); canBeDir = sfResolve(ATTR_CAN_BE_DIR, true, true); //maybe check on startup - boolean checkOnStartup= sfResolve(ATTR_CHECKONSTARTUP, true, true); - if(checkOnStartup) { - if(!evaluate()) { + boolean checkOnStartup = sfResolve(ATTR_CHECKONSTARTUP, true, true); + if (checkOnStartup) { + if (!evaluate()) { //on failure, throw the last error - throw new SmartFrogDeploymentException(lastError,this); + throw new SmartFrogDeploymentException(lastError, this); } //and look at workflow options - new ComponentHelper(this).sfSelfDetachAndOrTerminate(null,null,null,null); + maybeStartTerminator("Checked for file "); } } Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileImpl.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileImpl.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -23,9 +23,7 @@ import org.smartfrog.sfcore.common.SmartFrogLivenessException; import org.smartfrog.sfcore.common.SmartFrogResolutionException; import org.smartfrog.sfcore.common.SmartFrogRuntimeException; -import org.smartfrog.sfcore.utils.ComponentHelper; - import java.io.File; import java.rmi.RemoteException; @@ -242,9 +240,7 @@ * If subclassed, the polling for sfShouldTerminate can be delayed */ protected void triggerTerminationInStartup() { - new ComponentHelper(this).sfSelfDetachAndOrTerminate(null, - "File "+getFile() - .getAbsolutePath(),sfCompleteNameSafe(),null); + maybeStartTerminator("File"); } /** @@ -279,10 +275,10 @@ } /** - * do our file state test - * - * @throws SmartFrogLivenessException if a test failed - */ + * do our file state test + * + * @throws SmartFrogLivenessException if a test failed + */ protected void testFileState() throws SmartFrogLivenessException { if (sfLog().isDebugEnabled()) { sfLog().debug("liveness check will look for " + getFile().toString()); Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileIntf.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileIntf.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileIntf.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -119,6 +119,6 @@ * @return String * @throws RemoteException In case of network/rmi error */ - public String getAbsolutePath() throws RemoteException; + String getAbsolutePath() throws RemoteException; } Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileSystem.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileSystem.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileSystem.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -19,43 +19,43 @@ */ package org.smartfrog.services.filesystem; -import org.smartfrog.sfcore.common.SmartFrogResolutionException; import org.smartfrog.sfcore.common.MessageUtil; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.common.SmartFrogLivenessException; +import org.smartfrog.sfcore.common.SmartFrogResolutionException; +import org.smartfrog.sfcore.componentdescription.ComponentDescription; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.reference.Reference; +import org.smartfrog.sfcore.utils.ComponentHelper; import org.smartfrog.sfcore.utils.PlatformHelper; -import org.smartfrog.sfcore.utils.ComponentHelper; -import org.smartfrog.sfcore.componentdescription.ComponentDescription; -import java.io.InputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.Writer; -import java.io.Reader; +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.Closeable; import java.io.File; -import java.rmi.RemoteException; -import java.nio.channels.FileChannel; -import java.nio.charset.Charset; import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.FileReader; -import java.io.BufferedReader; -import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; -import java.io.BufferedInputStream; +import java.io.OutputStream; import java.io.OutputStreamWriter; -import java.io.FileNotFoundException; -import java.io.Closeable; -import java.net.URL; -import java.util.List; +import java.io.Reader; +import java.io.Writer; import java.net.MalformedURLException; import java.net.Socket; +import java.net.URL; +import java.nio.channels.FileChannel; +import java.nio.charset.Charset; +import java.rmi.RemoteException; import java.util.ArrayList; +import java.util.List; import java.util.Vector; /** - * Filesystem operations + * Static Filesystem operations */ public final class FileSystem { @@ -291,9 +291,11 @@ if (component instanceof Prim) { pathAttr = ((Prim) component).sfResolve(attribute, mandatory); } else if (component instanceof ComponentDescription) { - pathAttr =( (ComponentDescription) component).sfResolve(attribute, mandatory); + pathAttr = ((ComponentDescription) component).sfResolve(attribute, mandatory); } else { - throw new SmartFrogResolutionException ("Wrong object type. It does not implement Resolve() interfaces: "+component.getClass().getName()); + throw new SmartFrogResolutionException( + "Wrong object type. It does not implement Resolve() interfaces: " + component.getClass() + .getName()); } if (pathAttr == null) { //mandatory must be false, because we did not get a value. @@ -320,10 +322,10 @@ * @throws RemoteException In case of network/rmi error */ public static Vector<String> resolveFileList(Prim component, - String attribute, - File baseDir, - boolean mandatory, - PlatformHelper platform) + String attribute, + File baseDir, + boolean mandatory, + PlatformHelper platform) throws SmartFrogResolutionException, RemoteException { Reference reference = new Reference(attribute); return resolveFileList(component, @@ -378,10 +380,10 @@ * @throws SmartFrogResolutionException if the reference cannot be converted to a path */ public static Vector<String> convertPathVector(Vector<?> paths, - File baseDir, - PlatformHelper platform, - Object component, - Reference attribute) + File baseDir, + PlatformHelper platform, + Object component, + Reference attribute) throws RemoteException, SmartFrogResolutionException { Vector<String> results = new Vector<String>(paths.size()); for (Object element : paths) { @@ -401,7 +403,8 @@ * @throws RemoteException for network problems * @throws SmartFrogResolutionException if the reference cannot be converted to a path */ - public static String convertToAbsolutePath(Object pathSource, File baseDir, PlatformHelper platform, Object component, Reference attribute) + public static String convertToAbsolutePath(Object pathSource, File baseDir, PlatformHelper platform, + Object component, Reference attribute) throws RemoteException, SmartFrogResolutionException { String path = null; if (pathSource instanceof FileIntf) { @@ -542,9 +545,10 @@ * @throws RemoteException for network problems * @throws SmartFrogResolutionException if an element cannot be converted to a path */ - public static Vector<File> resolveFileList(Vector fileReferences, File baseDir, Prim component, Reference attribute) + public static Vector<File> resolveFileList(Vector fileReferences, File baseDir, Prim component, + Reference attribute) throws SmartFrogResolutionException, RemoteException { - Vector<File> results=new Vector<File>(fileReferences.capacity()); + Vector<File> results = new Vector<File>(fileReferences.capacity()); for (Object entry : fileReferences) { String path = FileSystem.convertToAbsolutePath(entry, baseDir, null, component, attribute); results.add(new File(path)); @@ -563,10 +567,11 @@ * @throws RemoteException for network problems * @throws SmartFrogResolutionException if an element cannot be converted to a path */ - public static Vector<File> resolveFileList(Prim component, Reference attribute, File baseDir, boolean mandatory) + public static Vector<File> resolveFileList(Prim component, Reference attribute, File baseDir, + boolean mandatory) throws SmartFrogResolutionException, RemoteException { - Vector fileReferences=component.sfResolve(attribute,(Vector)null, mandatory); - if(fileReferences==null) { + Vector fileReferences = component.sfResolve(attribute, (Vector) null, mandatory); + if (fileReferences == null) { return null; } Vector<File> results = new Vector<File>(fileReferences.capacity()); @@ -589,7 +594,8 @@ * @throws IOException Thrown when dir is not a directory. */ - public static List<String> scanDir(File dir, List<String> filePaths, String extensionsRegex, boolean recursive) throws IOException { + public static List<String> scanDir(File dir, List<String> filePaths, String extensionsRegex, + boolean recursive) throws IOException { if (!dir.isDirectory()) throw new IOException(dir + " is not a directory."); File[] files = dir.listFiles(); for (File file : files) { @@ -616,7 +622,7 @@ */ public static List<URL> toFileURLs(List filePaths) throws MalformedURLException { List<URL> urls = new ArrayList<URL>(); - for(Object o:filePaths) { + for (Object o : filePaths) { urls.add(toFileURL(o.toString())); } return urls; @@ -646,7 +652,8 @@ * @param minSize minimum size to accept if the target is a file * @throws SmartFrogLivenessException if the file is not found, of the wrong type, or too small */ - public static void requireFileToExist(String path, boolean fileOnly, int minSize) throws SmartFrogLivenessException { + public static void requireFileToExist(String path, boolean fileOnly, int minSize) + throws SmartFrogLivenessException { File target = new File(path); if (!target.exists()) { throw new SmartFrogLivenessException("File not found: \"" + path + "\""); @@ -1009,9 +1016,10 @@ * @param suffix suffix, e,g. ".ext"; * @param dir parent dir; can be null * @return the directory. - * @throws SmartFrogException a wrapper for any IOException. + * @throws SmartFrogException a wrapper for any IOException. */ - public static File createTempFile(final String prefix, final String suffix, final String dir) throws SmartFrogException { + public static File createTempFile(final String prefix, final String suffix, final String dir) + throws SmartFrogException { File file; try { if (dir == null) { @@ -1162,7 +1170,7 @@ */ public static Vector<File> convertToFiles(Vector<String> filesAsStrings) { Vector<File> dataDirFiles = new Vector<File>(filesAsStrings.size()); - for(String dir: filesAsStrings) { + for (String dir : filesAsStrings) { dataDirFiles.add(new File(dir)); } return dataDirFiles; Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileUsingComponent.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileUsingComponent.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileUsingComponent.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -22,8 +22,8 @@ import java.rmi.Remote; /** - * A file using component has an attribute bound to a file - * This interface defines no operations, merely well-known attributes + * A file using component has an attribute bound to a file. + * This interface defines no operations, merely well-known attributes. * created 30-Mar-2005 16:30:30 */ @@ -34,16 +34,16 @@ * The attribute that is used for extracting file strings/file components * {@value } */ - public static final String ATTR_FILENAME = "filename"; + String ATTR_FILENAME = "filename"; /** * Absolute path {@value} */ - public static final String ATTR_ABSOLUTE_PATH = "absolutePath"; + String ATTR_ABSOLUTE_PATH = "absolutePath"; /** * URI attribute {@value} */ - public static final String ATTR_URI = UriIntf.ATTR_URI; + String ATTR_URI = UriIntf.ATTR_URI; } Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileUsingComponentImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileUsingComponentImpl.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileUsingComponentImpl.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -19,13 +19,13 @@ */ package org.smartfrog.services.filesystem; -import org.smartfrog.sfcore.common.SmartFrogRuntimeException; import org.smartfrog.sfcore.common.SmartFrogDeploymentException; import org.smartfrog.sfcore.common.SmartFrogResolutionException; +import org.smartfrog.sfcore.common.SmartFrogRuntimeException; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.prim.PrimImpl; +import org.smartfrog.sfcore.utils.ComponentHelper; - import java.io.File; import java.net.URI; import java.rmi.RemoteException; @@ -45,7 +45,7 @@ /** * Constructor . * - *@exception RemoteException In case of network/rmi error + *@exception RemoteException In case of network/rmi error */ public FileUsingComponentImpl() throws RemoteException { } @@ -55,7 +55,7 @@ * * @return path of the file */ - public String getAbsolutePath() { + public String getAbsolutePath() { if (file == null) { return null; } else { @@ -68,7 +68,7 @@ * * @return URI of the file */ - public URI getURI() { + public URI getURI() { if (file == null) { return null; } else { @@ -131,7 +131,7 @@ */ protected void setAbsolutePath(String absolutePath) throws SmartFrogRuntimeException, RemoteException { - File newfile=new File(absolutePath); + File newfile = new File(absolutePath); bind(newfile); } @@ -145,8 +145,8 @@ */ public void bind(File newfile) throws SmartFrogRuntimeException, RemoteException { - file=newfile; - bind(this,newfile); + file = newfile; + bind(this, newfile); } @@ -163,7 +163,7 @@ * @throws RemoteException In case of network/rmi error * @throws SmartFrogRuntimeException runtime error */ - public static String bindWithDir(Prim component,boolean mandatory, String defval) + public static String bindWithDir(Prim component, boolean mandatory, String defval) throws RemoteException, SmartFrogRuntimeException { File parentDir = null; String dir = FileSystem.lookupAbsolutePath(component, @@ -221,12 +221,12 @@ parentDir, mandatory, null); - if (absolutePath != null && absolutePath.length()>0) { + if (absolutePath != null && absolutePath.length() > 0) { File newfile = new File(absolutePath); bind(component, newfile); } else { - if(mandatory) { - throw new SmartFrogDeploymentException("No filename supplied",component); + if (mandatory) { + throw new SmartFrogDeploymentException("No filename supplied", component); } } return absolutePath; @@ -252,7 +252,6 @@ } - /** * Returns the name of the file we are bound to. * @@ -266,7 +265,8 @@ /** * Helper method for all components that support delete-on-clearup; - * This should be called from the {@link Prim#sfTerminatedWith(org.smartfrog.sfcore.prim.TerminationRecord, org.smartfrog.sfcore.prim.Prim)} + * This should be called from the {@link Prim#sfTerminatedWith(org.smartfrog.sfcore.prim.TerminationRecord, + * org.smartfrog.sfcore.prim.Prim)} * implementation -after calling the superclass. * Will delete the file if {@link FileIntf#ATTR_DELETE_ON_EXIT } is set to * true, and there is a file to delete. If the file cannot be deleted immediately, @@ -277,7 +277,7 @@ try { boolean delete; //see if anyone changed the delete settings during our life - delete = sfResolve(ATTR_DELETE_ON_EXIT,false,false); + delete = sfResolve(ATTR_DELETE_ON_EXIT, false, false); if (delete && getFile() != null && getFile().exists()) { if (!getFile().delete()) { getFile().deleteOnExit(); @@ -290,4 +290,13 @@ } } + /** + * something that is called in the {@link #sfStart()} method to optionally start the termination + * process. It can be overridden, or called from an overridden sfStart method. + * @param action action that happened for use in the termination message + */ + protected void maybeStartTerminator(final String action) { + new ComponentHelper(this).sfSelfDetachAndOrTerminate(null, action + " " + getFile(), + sfCompleteNameSafe(), null); + } } Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileUsingCompoundImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileUsingCompoundImpl.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FileUsingCompoundImpl.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -13,13 +13,13 @@ */ package org.smartfrog.services.filesystem; +import org.smartfrog.sfcore.common.SmartFrogRuntimeException; +import org.smartfrog.sfcore.compound.CompoundImpl; + import java.io.File; import java.net.URI; import java.rmi.RemoteException; -import org.smartfrog.sfcore.common.SmartFrogRuntimeException; -import org.smartfrog.sfcore.compound.CompoundImpl; - /** * This is a compound object that has the {@link FileUsingComponent} interfaces * and attributes. @@ -29,7 +29,7 @@ * files synchronised. */ public class FileUsingCompoundImpl extends CompoundImpl implements - FileUsingComponent,FileIntf { + FileUsingComponent, FileIntf { /** * the file we are bonded to @@ -46,9 +46,10 @@ /** * get the absolute path of this file * - * @return path + * @return path to the file + * @throws NullPointerException if the file is null */ - public String getAbsolutePath() { + public String getAbsolutePath() { return file.getAbsolutePath(); } @@ -56,14 +57,15 @@ * get the URI of this file * * @return URI + * @throws NullPointerException if the file is null */ - public URI getURI() { + public URI getURI() { return file.toURI(); } /** * get the file we are using - * @return File + * @return File or null if it isn't set yet. */ public File getFile() { return file; @@ -71,15 +73,16 @@ /** - * Bind the class to the filename; indicate in the operation whether to - * dema + * Bind the class to the filename; indicate in the operation whether + * the file should be mandatory or not * @param mandatory flag to indicate mandatoryness * @param defval a default value to use if not mandatory (can be null) * @throws RemoteException In case of network/rmi error * @throws SmartFrogRuntimeException runtime error */ - protected void bind(boolean mandatory,String defval) throws RemoteException, SmartFrogRuntimeException { - String absolutePath = FileSystem.lookupAbsolutePath(this, ATTR_FILENAME, defval, null, mandatory, null); + protected void bind(boolean mandatory, String defval) throws RemoteException, SmartFrogRuntimeException { + String absolutePath = FileSystem + .lookupAbsolutePath(this, ATTR_FILENAME, defval, null, mandatory, null); if (absolutePath != null) { setAbsolutePath(absolutePath); } Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FilepathFunction.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FilepathFunction.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/FilepathFunction.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -24,7 +24,7 @@ import org.smartfrog.sfcore.utils.PlatformHelper; /** - + * function to work with file paths */ public class FilepathFunction extends BaseOperator { /** @@ -52,7 +52,7 @@ } - return directory+childPath; + return directory + childPath; } } Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/Mkdir.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/Mkdir.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/Mkdir.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -28,11 +28,14 @@ public interface Mkdir extends Remote { /** - * new directory to create + * new directory to create: {@value} */ String ATTR_DIR = "dir"; - /** parent directory {@value} */ + /** parent directory: {@value} */ String ATTR_PARENT = "parentDir"; - - String ATTR_CLEAN_ON_START="cleanOnStartup"; + + /** + * Should the directory be cleaned up on startup: {@value} + */ + String ATTR_CLEAN_ON_START = "cleanOnStartup"; } Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/MkdirImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/MkdirImpl.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/MkdirImpl.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -21,11 +21,10 @@ import org.smartfrog.sfcore.common.SmartFrogDeploymentException; import org.smartfrog.sfcore.common.SmartFrogException; +import org.smartfrog.sfcore.prim.TerminationRecord; import java.io.File; import java.rmi.RemoteException; -import org.smartfrog.sfcore.utils.ComponentHelper; -import org.smartfrog.sfcore.prim.TerminationRecord; /** * Component to create directories; can clean them up too. @@ -53,20 +52,20 @@ String dir; - File parentDir=null; + File parentDir = null; String parent; - parent= FileSystem.lookupAbsolutePath(this, + parent = FileSystem.lookupAbsolutePath(this, ATTR_PARENT, null, null, false, null); - if (parent!=null) { - parentDir=new File(parent); + if (parent != null) { + parentDir = new File(parent); } - dir=FileSystem.lookupAbsolutePath(this,Mkdir.ATTR_DIR,null,parentDir,true,null); - File directory=new File(dir); + dir = FileSystem.lookupAbsolutePath(this, Mkdir.ATTR_DIR, null, parentDir, true, null); + File directory = new File(dir); bind(directory); //get the delete flag //this is only done if the directory does not yet exist. @@ -84,13 +83,13 @@ super.sfStart(); File directory = getFile(); boolean clean = sfResolve(ATTR_CLEAN_ON_START, false, false); - if(directory.exists()) { + if (directory.exists()) { if (clean) { FileSystem.recursiveDelete(directory); } //it already exists. that may be harmless, but it warns the component to not //delete the directory during termination. - delete=false; + delete = false; } directory.mkdirs(); if (!directory.exists() || !directory.isDirectory()) { @@ -100,10 +99,7 @@ throw new SmartFrogDeploymentException("Failed to create directory " + directory.getAbsolutePath()); } - new ComponentHelper(this).sfSelfDetachAndOrTerminate(null, - "Mkdir "+getFile().getAbsolutePath(), - sfCompleteNameSafe(), - null); + maybeStartTerminator("Mkdir"); } Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/SelfDeletingFileImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/SelfDeletingFileImpl.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/SelfDeletingFileImpl.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -21,7 +21,6 @@ import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.prim.TerminationRecord; -import org.smartfrog.sfcore.utils.ComponentHelper; import java.rmi.RemoteException; @@ -62,22 +61,14 @@ */ public synchronized void sfStart() throws SmartFrogException, RemoteException { super.sfStart(); - startTerminator(); + maybeStartTerminator("Deleting file"); } /** - * something that is called in the {@link #sfStart()} method to start the termination - * process. It can be overridden, or called from an overridden sfStart method. + * delete the file if needed + * + * @param status termination status */ - protected void startTerminator() { - new ComponentHelper(this).sfSelfDetachAndOrTerminate(null,"SelfDeletingFile terminating",null,null); - } - - /** - * delete the file if needed - * - * @param status termination status - */ public synchronized void sfTerminateWith(TerminationRecord status) { super.sfTerminateWith(status); deleteFileIfNeeded(); Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TempDirImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TempDirImpl.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TempDirImpl.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -21,7 +21,6 @@ import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.prim.TerminationRecord; -import org.smartfrog.sfcore.utils.ComponentHelper; import java.rmi.RemoteException; @@ -31,7 +30,7 @@ */ public class TempDirImpl extends FileUsingComponentImpl implements TempFile { - private boolean delete=false; + private boolean delete = false; private boolean createOnDeploy; /** @@ -73,10 +72,7 @@ readAttributesAndCreateDir(); } //maybe terminate - new ComponentHelper(this).sfSelfDetachAndOrTerminate(null, - "Created temp dir " + file, - null, - null); + maybeStartTerminator("Created temp dir "); } /** @@ -96,7 +92,7 @@ if (sfLog().isDebugEnabled()) { sfLog().debug("Creating temp file in dir [" + dir + "], prefix=" + prefix - + ", suffix=" + suffix ); + + ", suffix=" + suffix); } //bind to the temp file Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TempFile.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TempFile.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TempFile.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -35,20 +35,20 @@ String ATTR_TEXT = "text"; /** * text encoding {@value} - */ + */ String ATTR_TEXT_ENCODING = "encoding"; /** * temp filename prefix {@value} - */ - String ATTR_PREFIX="prefix"; + */ + String ATTR_PREFIX = "prefix"; /** * temp filename suffix {@value} - */ + */ String ATTR_SUFFIX = "suffix"; /** * temp file directory {@value} - */ + */ String ATTR_DIRECTORY = "dir"; //this is the filename that is created //String ATTR_FILENAME = "filename"; @@ -65,8 +65,8 @@ * get the filename of this file * * @return the filename - * @exception RemoteException In case of network/rmi error + * @exception RemoteException In case of network/rmi error */ - String getFilename() throws RemoteException ; + String getFilename() throws RemoteException; } Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TempFileImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TempFileImpl.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TempFileImpl.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -21,14 +21,13 @@ import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.prim.TerminationRecord; -import org.smartfrog.sfcore.utils.ComponentHelper; +import java.io.FileOutputStream; import java.io.IOException; -import java.rmi.RemoteException; +import java.io.OutputStream; import java.io.OutputStreamWriter; -import java.io.FileOutputStream; import java.io.Writer; -import java.io.OutputStream; +import java.rmi.RemoteException; /** * created 18-May-2004 11:46:09 @@ -116,10 +115,7 @@ } //maybe terminate - new ComponentHelper(this).sfSelfDetachAndOrTerminate(null, - "Created temp file " + file, - null, - null); + maybeStartTerminator("Created temp file"); } /** Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TextFile.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TextFile.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TextFile.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -23,7 +23,7 @@ * created 30-Mar-2005 16:37:45 */ -public interface TextFile extends FileUsingComponent { +public interface TextFile extends FileUsingComponent { /** * any optional text */ Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TextFileImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TextFileImpl.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TextFileImpl.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -20,7 +20,6 @@ package org.smartfrog.services.filesystem; import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.common.SmartFrogResolutionException; import java.io.File; import java.rmi.RemoteException; @@ -41,7 +40,6 @@ } - /** * when we deploy, we write out our text stream * @throws SmartFrogException error while starting @@ -53,7 +51,7 @@ String text = buildText(); String encoding = null; if (text != null) { - encoding = sfResolve(ATTR_TEXT_ENCODING, (String)null, true); + encoding = sfResolve(ATTR_TEXT_ENCODING, (String) null, true); File textFile = getFile(); File parentDir = textFile.getParentFile(); if (!parentDir.exists()) { Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TextListFileImplImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TextListFileImplImpl.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TextListFileImplImpl.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -20,8 +20,8 @@ package org.smartfrog.services.filesystem; import org.smartfrog.sfcore.common.SmartFrogException; +import org.smartfrog.sfcore.reference.Reference; import org.smartfrog.sfcore.utils.ListUtils; -import org.smartfrog.sfcore.reference.Reference; import java.rmi.RemoteException; import java.util.Vector; Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TouchFileImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TouchFileImpl.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TouchFileImpl.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -19,13 +19,13 @@ */ package org.smartfrog.services.filesystem; +import org.smartfrog.sfcore.common.SmartFrogDeploymentException; import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.common.SmartFrogDeploymentException; +import org.smartfrog.sfcore.utils.ComponentHelper; import java.io.File; import java.io.IOException; import java.rmi.RemoteException; -import org.smartfrog.sfcore.utils.ComponentHelper; /** * This is a minimal component whose aim in life is to touch files. @@ -34,7 +34,7 @@ */ public class TouchFileImpl extends FileUsingComponentImpl implements TouchFileIntf { - private long age=-1; + private long age = -1; /** * Constructor. @@ -61,7 +61,7 @@ super.sfStart(); touch(); new ComponentHelper(this).sfSelfDetachAndOrTerminate(null, - "TouchFile "+getFile().getAbsolutePath()+", "+age, + "TouchFile " + getFile().getAbsolutePath() + ", " + age, sfCompleteNameSafe(), null); } @@ -93,15 +93,17 @@ public synchronized void touch(String filename, long newAge) throws IOException, SmartFrogException { File target = new File(filename); File parentFile = target.getParentFile(); - if(sfLog().isDebugEnabled()) { - sfLog().debug("About to touch file "+filename); + if (sfLog().isDebugEnabled()) { + sfLog().debug("About to touch file " + filename); } - if(parentFile!=null) { + if (parentFile != null) { try { parentFile.mkdirs(); } catch (SecurityException e) { //failure to mkdir is turned into a security problem; we catch it and make it meaningful - throw new SmartFrogDeploymentException("Security blocked the creation of the parent directories "+parentFile, + throw new SmartFrogDeploymentException( + "Security blocked the creation of the parent directories " + + parentFile, e, this); } @@ -112,8 +114,8 @@ target.setLastModified(newAge); } } catch (SecurityException e) { - throw new SmartFrogDeploymentException("Security blocked the touching of file " + target, e, this); - + throw new SmartFrogDeploymentException("Security blocked the touching of file " + target, e, + this); } } } Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TouchFileIntf.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TouchFileIntf.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TouchFileIntf.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -34,7 +34,7 @@ /** * its age in milliseconds since 1970-01-01 */ - final static String ATTR_AGE = "timestamp"; + String ATTR_AGE = "timestamp"; /** Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TupleReaderThread.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TupleReaderThread.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/TupleReaderThread.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -19,10 +19,9 @@ */ package org.smartfrog.services.filesystem; +import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.utils.WorkflowThread; -import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.services.filesystem.TupleDataSource; import java.rmi.RemoteException; @@ -91,6 +90,7 @@ protected void onStarted() throws SmartFrogException, RemoteException { } + /** * we've finished (successfully) * Modified: trunk/core/smartfrog/src/org/smartfrog/services/filesystem/append/AppendLinesImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/services/filesystem/append/AppendLinesImpl.java 2010-10-29 14:58:38 UTC (rev 8425) +++ trunk/core/smartfrog/src/org/smartfrog/services/filesystem/append/AppendLinesImpl.java 2010-11-01 14:27:00 UTC (rev 8426) @@ -19,27 +19,26 @@ */ package org.smartfrog.services.filesystem.append; -import org.smartfrog.sfcore.common.SmartFrogException; +import org.smartfrog.services.filesystem.FileSystem; +import org.smartfrog.services.filesystem.FileUsingComponent; +import org.smartfrog.services.filesystem.FileUsingComponentImpl; import org.smartfrog.sfcore.common.SmartFrogDeploymentException; -import org.smartfrog.sfcore.utils.ListUtils; -import org.smartfrog.sfcore.utils.ComponentHelper; +import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.reference.Reference; -import org.smartfrog.services.filesystem.FileUsingComponentImpl; -import org.smartfrog.services.filesystem.FileUsingComponent; -import org.smartfrog.services.filesystem.FileSystem; +import org.smartfrog.sfcore.utils.ListUtils; -import java.rmi.RemoteException; -import java.util.Vector; -import java.util.Set; -import java.util.HashSet; +import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; -import java.io.Writer; -import java.io.BufferedWriter; +import java.io.FileReader; import java.io.IOException; -import java.io.OutputStreamWriter; import java.io.LineNumberReader; -import java.io.FileReader; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.rmi.RemoteException; +import java.util.HashSet; +import java.util.Set; +import java.util.Vector; /** * @@ -59,7 +58,7 @@ linesAdded 0; */ - int linesAdded=0; + int linesAdded = 0; private String lineEnding, encoding; private boolean addOnlyMissingLines; private Vector<String> lines; @@ -84,13 +83,13 @@ */ public synchronized void sfStart() throws SmartFrogException, RemoteException { super.sfStart(); - bind(true,""); - addOnlyMissingLines=sfResolve(REF_MISSING_LINES_ONLY,true,true); + bind(true, ""); + addOnlyMissingLines = sfResolve(REF_MISSING_LINES_ONLY, true, true); lineEnding = sfResolve(REF_LINE_ENDING, "", true); encoding = sfResolve(REF_ENCODING, "", true); - lines= ListUtils.resolveStringList(this, REF_LINES,true); + lines = ListUtils.resolveStringList(this, REF_LINES, true); appendLines(); - new ComponentHelper(this).sfSelfDetachAndOrTerminate(null,null,null,null); + maybeStartTerminator("Appending lines to file "); } /** @@ -100,13 +99,13 @@ */ private void appendLines() throws SmartFrogDeploymentException { try { - if(!getFile().exists()) { + if (!getFile().exists()) { buildNewFile(); } else { appendExistingFile(); } } catch (IOException e) { - throw new SmartFrogDeploymentException("When writing to "+getFile(),e,this); + throw new SmartFrogDeploymentException("When writing to " + getFile(), e, this); } } @@ -116,9 +115,9 @@ * @throws IOException for IO problems */ private void appendExistingFile() throws IOException { - Vector<String> linesToAdd = addOnlyMissingLines?filterExistingLines():lines; - if(linesToAdd.size()>0) { - appendLines(new FileOutputStream(getFile(),true), linesToAdd); + Vector<String> linesToAdd = addOnlyMissingLines ? filterExistingLines() : lines; + if (linesToAdd.size() > 0) { + appendLines(new FileOutputStream(getFile(), true), linesToAdd); return; } } @@ -129,10 +128,10 @@ * @throws IOException for IO problems */ private Vector<String> filterExistingLines() throws IOException { - Set<String> existingLines=loadExistingLines(); - Vector<String> linesToAdd=new Vector<String>(lines.size()); + Set<String> existingLines = loadExistingLines(); + Vector<String> linesToAdd = new Vector<String>(lines.size()); for (String line : lines) { - if(!existingLines.contains(line)) { + if (!existingLines.contains(line)) { linesToAdd.add(line); } } @@ -146,12 +145,12 @@ * @throws IOException for IO problems */ private Set<String> loadExistingLines() throws IOException { - LineNumberReader reader=null; + LineNumberReader reader = n... [truncated message content] |