List of usage examples for org.apache.commons.io FilenameUtils EXTENSION_SEPARATOR_STR
String EXTENSION_SEPARATOR_STR
To view the source code for org.apache.commons.io FilenameUtils EXTENSION_SEPARATOR_STR.
Click Source Link
From source file:es.urjc.mctwp.bbeans.research.image.DownloadBean.java
private ZipOutputStream prepareZOS(String cntDesc) throws IOException { ZipOutputStream result = null; HttpServletResponse response = prepareResponse(); //Get file name without parents and prepare header String fileName = cntDesc + FilenameUtils.EXTENSION_SEPARATOR_STR + contentType; configResponseHeader(response, contentType, fileName); result = new ZipOutputStream(response.getOutputStream()); return result; }
From source file:es.urjc.mctwp.image.impl.collection.fs.ImageContentCollectionFSImpl.java
/** * Finds any content into a collection/*from w ww.ja v a 2 s. c om*/ * * @param collection * @param imageId * @return file content */ private File findContent(File collection, String imageId) { File result = null; File[] auxLst = collection.listFiles(icff); if (auxLst != null) { for (File file : auxLst) { String id = StringUtils.substringBeforeLast(file.getName(), FilenameUtils.EXTENSION_SEPARATOR_STR); if (id.equals(imageId)) { result = file; break; } } } return result; }
From source file:es.urjc.mctwp.image.impl.dicom.DicomImagePlugin.java
/** * Obtains a DICOM representation for single image * //w w w . j a v a 2 s .com * @param single * @return * @throws ImageException */ private List<File> toDicom(SingleImage single, File outputDir) throws ImageException { List<File> result = new ArrayList<File>(); File content = single.getContent(); try { String ext = StringUtils.substringAfterLast(content.getName(), FilenameUtils.EXTENSION_SEPARATOR_STR); if (ext == null) ext = SingleImageDicomImpl.DCM_EXT; File dest = new File(FilenameUtils.concat(outputDir.getAbsolutePath(), single.getId() + FilenameUtils.EXTENSION_SEPARATOR_STR + ext)); FileUtils.copyFile(content, dest); result.add(dest); } catch (Exception e) { logger.error(e.getMessage()); throw new ImageException(e); } return result; }
From source file:edu.ku.brc.util.FileStoreAttachmentManager.java
/** * @param fileName/*from w w w. ja v a2 s .c o m*/ * @param scale * @return */ private String getScaledFileName(final String fileName, final Integer scale) { String newPath = baseDirectory + File.separator + THUMBNAILS + File.separator + FilenameUtils.getBaseName(fileName); String ext = FilenameUtils.getExtension(fileName); String newFileName = String.format("%s_%d%s%s", newPath, scale, FilenameUtils.EXTENSION_SEPARATOR_STR, ext); return newFileName; }
From source file:edu.ku.brc.util.WebStoreAttachmentMgr.java
/** * @param fileName//from w w w . j ava 2 s .c o m * @param scale * @return */ private String getScaledFileName(final String fileName, final Integer scale) { String newPath = FilenameUtils.removeExtension(fileName); String ext = FilenameUtils.getExtension(fileName); return String.format("%s_%d%s%s", newPath, scale, FilenameUtils.EXTENSION_SEPARATOR_STR, ext); }
From source file:eu.cloud4soa.cli.roo.addon.Cloud4soaOperationsImpl.java
@Override public void deployApplication(final Integer localAppId, final Integer paasId, final File file) { String successMessage = "Application deployed"; String failureMessage = "Failed to deploy the Application"; executeCommand(new Cloud4soaCommand(failureMessage, successMessage) { @Override//from ww w . j a v a 2s . c o m public void execute() throws Exception { Assert.isTrue(cloud4SoaSessionDeveloper.isApplicationsCacheValid()); Assert.isTrue(cloud4SoaSessionDeveloper.isPaaSProfilesCacheValid()); logger.info("Deploying the application..."); String applicationInstanceUriId = cloud4SoaSessionDeveloper.getCachedApplicationId(localAppId); if (applicationInstanceUriId == null) { this.displaySuccessMessage = false; logger.severe("appId parameter must be one of the following: " + cloud4SoaSessionDeveloper.getCachedApplicationProfiles().keySet()); return; } String paaSInstanceUriId = cloud4SoaSessionDeveloper.getCachedPaaSProfileId(paasId); if (paaSInstanceUriId == null) { this.displaySuccessMessage = false; logger.severe("paasId parameter must be one of the following: " + cloud4SoaSessionDeveloper.getCachedPaaSProfiles().keySet()); return; } ClassLoader originalCL = Thread.currentThread().getContextClassLoader(); ClassLoader jaxrsExtCL = ApplicationDeploymentClient.class.getClassLoader(); Thread.currentThread().setContextClassLoader(jaxrsExtCL); try { UserPaaSCredentials userCredentialsForPaaS = userManagementAndSecurityModuleClient .readUserCredentialsForPaaS(cloud4SoaSessionDeveloper.getUserInstanceUriId(), paaSInstanceUriId); } catch (SOAException e) { this.displaySuccessMessage = false; logger.severe("No stored Credentials for the specific PaaS"); Thread.currentThread().setContextClassLoader(originalCL); return; } Thread.currentThread().setContextClassLoader(originalCL); // retrieve the SLA template id; if it's not cached, try to generate an SLATemplate. String slaTemplateId = null; slaTemplateId = cloud4SoaSessionDeveloper.getSlaTemplateId(paaSInstanceUriId); final InputStream fileInputStream = openFile(file); if (fileInputStream == null) { logger.severe("Cannot open the file: " + file); this.displaySuccessMessage = false; logger.severe(this.failureMessage); return; } originalCL = Thread.currentThread().getContextClassLoader(); jaxrsExtCL = ApplicationDeploymentClient.class.getClassLoader(); Thread.currentThread().setContextClassLoader(jaxrsExtCL); flash(Level.FINE, "Deploying application: " + cloud4SoaSessionDeveloper.getCachedApplicationProfile(localAppId).getTitle(), MY_SLOT); // boolean isApplicationDeployed = false; boolean isApplicationDeployed = applicationDeploymentClient.deployApplication( applicationInstanceUriId, paaSInstanceUriId, fileInputStream, slaTemplateId); Thread.currentThread().setContextClassLoader(originalCL); if (!isApplicationDeployed) { this.displaySuccessMessage = false; logger.severe(this.failureMessage); } else { // ApplicationInstance cachedApplicationProfile = null; // originalCL = Thread.currentThread().getContextClassLoader(); // jaxrsExtCL = ModelManagerClient.class.getClassLoader(); // Thread.currentThread().setContextClassLoader(jaxrsExtCL); // List<ApplicationInstance> retrieveAllApplicationProfile = modelManagerClient.retrieveAllApplicationProfile(cloud4SoaSessionDeveloper.getUserInstanceUriId()); // Thread.currentThread().setContextClassLoader(originalCL); // // cloud4SoaSessionDeveloper.setCachedApplicationProfiles(retrieveAllApplicationProfile); // for (ApplicationInstance applicationInstance : retrieveAllApplicationProfile) { // if(applicationInstance.getUriId().equals(applicationInstanceUriId)) // cachedApplicationProfile = applicationInstance; // } //Updating SizeQuantity, ArchiveFileName, ExtensionName, (Digest?) ApplicationInstance cachedApplicationProfile = cloud4SoaSessionDeveloper .getCachedApplicationProfile(localAppId); cachedApplicationProfile.setSizeQuantity(new Float(file.length())); String extension = FilenameUtils.getExtension(file.getName()); String baseName = FilenameUtils.getBaseName(file.getName()); cachedApplicationProfile.setArchiveFileName(baseName); cachedApplicationProfile .setArchiveExtensionName(FilenameUtils.EXTENSION_SEPARATOR_STR + extension); originalCL = Thread.currentThread().getContextClassLoader(); jaxrsExtCL = ModelManagerClient.class.getClassLoader(); Thread.currentThread().setContextClassLoader(jaxrsExtCL); try { modelManagerClient.updateApplicationProfile(cachedApplicationProfile); } catch (SOAException ex) { logger.log(Level.SEVERE, "{0}: {1}", new Object[] { failureMessage, ex.getMessage() }); this.displaySuccessMessage = false; return; } Thread.currentThread().setContextClassLoader(originalCL); cloud4SoaSessionDeveloper.invalidateApplicationsCache(); cloud4SoaSessionDeveloper.invalidateDeployedApplications(); } } }); }
From source file:nl.mpi.lamus.archive.implementation.LamusArchiveFileHelper.java
/** * @see ArchiveFileHelper#getFinalFile(java.lang.String, java.lang.String) *///www.ja va 2 s. c o m @Override public File getFinalFile(File baseDirectory, String fileNameAttempt) { int suffix = 0; String attemptSuffix = ""; File fileAttempt = new File(baseDirectory, FilenameUtils.getBaseName(fileNameAttempt) + attemptSuffix + FilenameUtils.EXTENSION_SEPARATOR_STR + FilenameUtils.getExtension(fileNameAttempt)); while ((fileAttempt.exists()) && (suffix < 10000)) { suffix++; fileAttempt = new File(baseDirectory, FilenameUtils.getBaseName(fileNameAttempt) + "_" + suffix + FilenameUtils.EXTENSION_SEPARATOR_STR + FilenameUtils.getExtension(fileNameAttempt)); } if (suffix >= 10000) { return null; } // give up return fileAttempt; }
From source file:nl.mpi.lamus.archive.implementation.LamusArchiveFileHelperTest.java
@Test public void getFinalFileExistingSeveralNames() throws IOException { final String fileName = "file.cmdi"; prepareExistingTempDirectory();/*from w w w. j a va 2s.co m*/ File file = new File(existingTempDirectory, fileName); FileUtils.touch(file); for (int suffix = 1; suffix < 11; suffix++) { String currentFileName = FilenameUtils.getBaseName(fileName) + "_" + suffix + FilenameUtils.EXTENSION_SEPARATOR_STR + FilenameUtils.getExtension(fileName); File currentFile = new File(existingTempDirectory, currentFileName); FileUtils.touch(currentFile); } String expectedName = "file_11.cmdi"; File expectedFile = new File(existingTempDirectory, expectedName); File retrievedFile = testArchiveFileHelper.getFinalFile(existingTempDirectory, fileName); assertEquals("Retrieved file different from expected", expectedFile, retrievedFile); }
From source file:nl.mpi.lamus.archive.implementation.LamusArchiveFileHelperTest.java
@Test public void getFinalFileExistingAllNames() throws IOException { final String fileName = "file.cmdi"; prepareExistingTempDirectory();//from w ww. j ava 2 s . c o m File file = new File(existingTempDirectory, fileName); FileUtils.touch(file); for (int suffix = 1; suffix < 10000; suffix++) { String currentFileName = FilenameUtils.getBaseName(fileName) + "_" + suffix + FilenameUtils.EXTENSION_SEPARATOR_STR + FilenameUtils.getExtension(fileName); File currentFile = new File(existingTempDirectory, currentFileName); FileUtils.touch(currentFile); } File retrievedFile = testArchiveFileHelper.getFinalFile(existingTempDirectory, fileName); assertNull("Retrieved file should be null when all suffixes exist already", retrievedFile); }
From source file:nl.mpi.lamus.workspace.exporting.implementation.AddedNodeExporterTest.java
private WorkspaceNode getParentNode(boolean isInArchive, String parentNodeName, String basepath) throws MalformedURLException, URISyntaxException { final int parentNodeWsID = 1; final String parentFilename = parentNodeName + FilenameUtils.EXTENSION_SEPARATOR_STR + metadataExtension; final URL parentNodeWsURL = new URL( "file:/workspace/" + testWorkspace.getWorkspaceID() + File.separator + parentFilename); final URI parentNodeOriginURI = URI.create(basepath + parentFilename); final URL parentNodeArchiveURL = parentNodeOriginURI.toURL(); final URI parentNodeArchiveURI; if (isInArchive) { parentNodeArchiveURI = new URI(UUID.randomUUID().toString()); } else {//from w w w. j a v a 2s .c o m parentNodeArchiveURI = null; } final WorkspaceNodeType parentNodeType = WorkspaceNodeType.METADATA; final WorkspaceNodeStatus parentNodeStatus = WorkspaceNodeStatus.ARCHIVE_COPY; final boolean parentNodeProtected = Boolean.FALSE; final String parentNodeFormat = "text/x-cmdi+xml"; final URI nodeSchemaLocation = new URI("http://some.location"); return new LamusWorkspaceNode(parentNodeWsID, testWorkspace.getWorkspaceID(), nodeSchemaLocation, parentNodeName, "", parentNodeType, parentNodeWsURL, parentNodeArchiveURI, parentNodeArchiveURL, parentNodeOriginURI, parentNodeStatus, parentNodeProtected, parentNodeFormat); }