List of usage examples for org.apache.commons.vfs Selectors SELECT_ALL
FileSelector SELECT_ALL
To view the source code for org.apache.commons.vfs Selectors SELECT_ALL.
Click Source Link
From source file:org.josso.tooling.gshell.install.installer.WasceInstaller.java
@Override public void performAdditionalTasks(FileObject libsDir) throws InstallException { try {/*from ww w .j a v a 2 s . co m*/ // undeploy wasce tomcat6 module if exists FileObject tomcatModule = targetDir.resolveFile("repository/org/apache/geronimo/configs/tomcat6"); if (tomcatModule.exists()) { getPrinter().printMsg("Undeploying tomcat6 module"); int status = undeploy("tomcat6"); if (status == 0) { getPrinter().printOkStatus("Undeploy tomcat6 module", "Successful"); } else { getPrinter().printErrStatus("Undeploy tomcat6 module", "Error"); throw new InstallException("Error undeploying tomcat6 module!!!"); } } // undeploy old josso wasce agent if exists FileObject jossoWasceAgentModule = targetDir.resolveFile("repository/org/josso/josso-wasce-agent"); if (jossoWasceAgentModule.exists()) { getPrinter().printMsg("Undeploying old josso wasce agent"); int status = undeploy("josso-wasce-agent"); if (status == 0) { getPrinter().printOkStatus("Undeploy josso wasce agent", "Successful"); } else { getPrinter().printErrStatus("Undeploy josso wasce agent", "Error"); throw new InstallException("Error undeploying josso wasce agent!!!"); } } // install jars to wasce repository try { getPrinter().printMsg("Installing new jars to WASCE repository"); FileObject wasceRepo = targetDir.resolveFile("repository"); FileObject wasceRepoFolder = libsDir.resolveFile("repository"); wasceRepo.copyFrom(wasceRepoFolder, Selectors.SELECT_ALL); getPrinter().printOkStatus("Install new jars", "Successful"); } catch (FileSystemException e) { getPrinter().printErrStatus("Install new jars", "Error"); throw new InstallException("Error copying jars to wasce repository!!!"); } // deploy josso wasce agent getPrinter().printMsg("Deploying josso wasce agent"); FileObject jossoWasceCarFile = null; FileObject[] agentBins = libsDir.getChildren(); for (int i = 0; i < agentBins.length; i++) { FileObject agentBin = agentBins[i]; if (agentBin.getName().getBaseName().startsWith("josso-wasce")) { jossoWasceCarFile = agentBin; break; } } if (jossoWasceCarFile == null) { throw new InstallException("Josso wasce agent car file doesn't exist!!!"); } int status = installPlugin(jossoWasceCarFile); if (status == 0) { getPrinter().printOkStatus("Install josso wasce agent", "Successful"); } else { getPrinter().printErrStatus("Install josso wasce agent", "Error"); throw new InstallException("Error installing josso wasce agent!!!"); } // start stopped services getPrinter().printMsg("Starting tomcat related services"); status = startTomcatRelatedServices(); if (status == 0) { getPrinter().printOkStatus("Start tomcat related services", "Successful"); } else { getPrinter().printErrStatus("Start tomcat related services", "Error"); throw new InstallException("Error starting tomcat related services!!!"); } } catch (IOException e) { throw new InstallException(e.getMessage(), e); } }
From source file:org.objectweb.proactive.extensions.dataspaces.vfs.adapter.VFSFileObjectAdapter.java
/** * @param selector/* w w w. j a va2 s. c o m*/ * may be null */ private static org.apache.commons.vfs.FileSelector buildFVSSelector(FileSelector selector) { switch (selector) { case EXCLUDE_SELF: return Selectors.EXCLUDE_SELF; case SELECT_ALL: return Selectors.SELECT_ALL; case SELECT_FILES: return Selectors.SELECT_FILES; case SELECT_FOLDERS: return Selectors.SELECT_FOLDERS; case SELECT_CHILDREN: return Selectors.SELECT_CHILDREN; case SELECT_SELF: return Selectors.SELECT_SELF; case SELECT_SELF_AND_CHILDREN: return Selectors.SELECT_SELF_AND_CHILDREN; default: return null; } }
From source file:org.objectweb.proactive.extensions.dataspaces.vfs.VFSNodeScratchSpaceImpl.java
public synchronized void close() throws IllegalStateException { logger.debug("Closing node scratch space"); checkIfConfigured();/*from ww w. ja va 2s .c o m*/ try { final FileObject fRuntime = partialSpaceFile.getParent(); // rm -r node partialSpaceFile.delete(Selectors.SELECT_ALL); // try to remove runtime file // IMPORTANT FIXME: it seems that despite of VFS FileObject documentation, // looking at AbstractFileObject docs suggests that it does not implement this // delete-if-empty behavior! at least, it appears to be not atomic (and probably may be never atomic // as some protocols may not support this kind of atomic operation?) // refreshing file before deleting may minimize the risk of delete-when-non-empty behavior fRuntime.refresh(); try { final boolean deleted = fRuntime.delete(); if (deleted) logger.debug("Scratch directory for whole runtime was deleted (considered as empty)"); else logger.debug("Scratch directory for whole runtime was not deleted (not considered as empty)"); } catch (org.apache.commons.vfs.FileSystemException x) { logger.debug("Could not delete scratch directory for whole runtime - perhaps it was not empty", x); } // it is probably not needed to close files if manager is closed, but with VFS you never know... fRuntime.close(); partialSpaceFile.close(); } catch (org.apache.commons.vfs.FileSystemException x) { ProActiveLogger.logEatedException(logger, "Could not close correctly node scratch space", x); } finally { this.fileSystemManager.close(); } logger.debug("Closed node scratch space"); }
From source file:org.sonatype.gshell.commands.vfs.CopyCommand.java
public Object execute(final CommandContext context) throws Exception { assert context != null; IO io = context.getIo();/*from www . jav a2 s.c om*/ FileObject source = resolveFile(context, sourcePath); FileObject target = resolveFile(context, targetPath); new FileObjectAssert(source).exists(); // TODO: Validate more if (target.exists() && target.getType().hasChildren()) { target = target.resolveFile(source.getName().getBaseName()); } log.info("Copying {} -> {}", source, target); target.copyFrom(source, Selectors.SELECT_ALL); FileObjects.close(source, target); return Result.SUCCESS; }
From source file:pt.webdetails.cpf.repository.VfsRepositoryTest.java
/** * Please do note this will remove the folder and all subfolders and files Used for testing purposes only * * @param file/*from w w w . j a v a2 s.c o m*/ * @return */ public int removeUnsafe(String file) { try { if (file.equals(".")) { return repo.delete(Selectors.EXCLUDE_SELF); } FileObject f = resolveFile(repo, file); if (f.exists()) { return f.delete(Selectors.SELECT_ALL); } return -1; } catch (Exception e) { throw new RuntimeException("Cannot delete file: " + file, e); } }
From source file:unitTests.dataspaces.AbstractLimitingFileObjectTest.java
@Test public void testReadOnlyDeleteFileSelector() throws FileSystemException { createRealFile();//from w w w.j a v a 2 s .com try { readOnlyFile.delete(Selectors.SELECT_ALL); fail("Expected exception"); } catch (FileSystemException e) { } assertTrue(readOnlyFile.exists()); }
From source file:unitTests.dataspaces.AbstractLimitingFileObjectTest.java
@Test public void testReadOnlyCopyFromFileObjectFileSelector() throws FileSystemException { try {/*w w w . j ava 2s . c o m*/ readOnlyFile.copyFrom(anotherFile, Selectors.SELECT_ALL); fail("Expected exception"); } catch (FileSystemException e) { } assertFalse(readOnlyFile.exists()); }
From source file:unitTests.dataspaces.AbstractLimitingFileObjectTest.java
@Test public void testReadWriteDeleteFileSelector() throws FileSystemException { createRealFile();/*from w ww . ja va 2 s .co m*/ readWriteFile.delete(Selectors.SELECT_ALL); assertFalse(readWriteFile.exists()); }
From source file:unitTests.dataspaces.AbstractLimitingFileObjectTest.java
@Test public void testReadWriteCopyFromFileObjectFileSelector() throws FileSystemException { readWriteFile.copyFrom(anotherFile, Selectors.SELECT_ALL); assertTrue(readWriteFile.exists());/* www.j a v a2 s. c o m*/ }