List of usage examples for org.springframework.core.io Resource getFilename
@Nullable String getFilename();
From source file:de.langmi.spring.batch.examples.complex.support.CustomMultiResourcePartitioner.java
/** * Creates distinct output file name per partition. * * @param partitionId// w w w .j a va 2 s . c om * @param context * @param resource * @return */ private String createOutputFilename(int partitionId, Resource resource) { String outputFileName = "output-" + String.valueOf(partitionId) + ".txt"; LOG.info("for inputfile:'" + resource.getFilename() + "' outputfilename:'" + outputFileName + "' was created"); return outputFileName; }
From source file:net.sourceforge.vulcan.spring.jdbc.JdbcSchemaMigrator.java
public void setMigrationScripts(Resource[] migrationScripts) { this.migrationScripts = migrationScripts; Arrays.sort(this.migrationScripts, new Comparator<Resource>() { public int compare(Resource o1, Resource o2) { return o1.getFilename().compareTo(o2.getFilename()); }//w w w . j av a 2 s . c om }); }
From source file:com.medvision360.medrecord.engine.ArchetypeLoader.java
private void load(Resource resource) throws IOException, ParseException { InputStream is = resource.getInputStream(); load(resource.getFilename().replaceFirst("\\.adl$", ""), is); }
From source file:de.codecentric.boot.admin.web.servlet.resource.ConcatenatingResourceResolverTest.java
@Test public void test_concatenation() throws IOException { Resource testResource = new ClassPathResource("/testResource.txt"); List<Resource> resources = asList(testResource, testResource, testResource); Resource resolvedResource = new ConcatenatingResourceResolver(";".getBytes()).resolveResource(null, "/foo.txt", resources, null); assertThat(resolvedResource.getFilename(), is("foo.txt")); assertThat(resolvedResource.lastModified(), is(testResource.lastModified())); assertThat(resolvedResource.getDescription(), is( "Byte array resource [(class path resource [testResource.txt], class path resource [testResource.txt], class path resource [testResource.txt])]")); assertThat(copyToByteArray(resolvedResource.getInputStream()), is("Foobar;Foobar;Foobar".getBytes())); }
From source file:org.eclipse.swordfish.core.test.util.base.TargetPlatformOsgiTestCase.java
private int getPriority(Resource bundle) { for (String key : bundlePriorities.keySet()) { if (bundle.getFilename().contains(key)) { return bundlePriorities.get(key); }//from ww w .ja va2s .c o m } return 0; }
From source file:com.greglturnquist.springagram.fileservice.s3.ApplicationController.java
@RequestMapping(method = RequestMethod.GET, value = "/files") public ResponseEntity<?> listFiles() { try {/*from ww w.jav a 2s . c o m*/ Resource[] files = this.fileService.findAll(); ResourceSupport resources = new ResourceSupport(); for (Resource file : files) { resources.add(linkTo(methodOn(ApplicationController.class).getFile(file.getFilename())) .withRel(file.getFilename())); } return ResponseEntity.ok(resources); } catch (IOException e) { return ResponseEntity.badRequest().body(e.getMessage()); } }
From source file:fr.acxio.tools.agia.io.ResourceCopyFactory.java
@Override public Resource getResource(Map<? extends Object, ? extends Object> sParameters) throws ResourceCreationException { Resource aResult = null;/*from w w w. j a va 2 s.c o m*/ try { Resource aSourceResource = (Resource) sParameters.get(ResourceFactoryConstants.PARAM_SOURCE); String aFilename = aSourceResource.getFilename(); String aFileNameWOExtension = aFilename.substring(0, aFilename.lastIndexOf('.')); String aExtension = extension; if (aExtension == null) { aExtension = aFilename.substring(aFilename.lastIndexOf('.')); } File aParentPath = (parentFolder != null) ? parentFolder.getFile() : null; if (aParentPath == null) { aParentPath = aSourceResource.getFile().getParentFile(); } StringBuilder aNewFilename = new StringBuilder(); if (prefix != null) { aNewFilename.append(prefix); } aNewFilename.append(aFileNameWOExtension); if (suffix != null) { aNewFilename.append(suffix); } aNewFilename.append(aExtension); File aNewFile = new File(aParentPath, aNewFilename.toString()); aResult = new FileSystemResource(aNewFile); } catch (Exception e) { throw new ResourceCreationException(e); } return aResult; }
From source file:com.epam.catgenome.common.AbstractJUnitTest.java
protected File getResourceFileCopy(String resourcePath) throws IOException { Resource resource = context.getResource(resourcePath); final File tmp = new File(fileManager.getTempDir(), resource.getFilename()); FileUtils.copyFile(resource.getFile(), tmp); FileUtils.forceDeleteOnExit(tmp);/*w ww . jav a 2 s .com*/ return tmp; }
From source file:org.mongeez.reader.XmlChangeSetReader.java
@Override public List<ChangeSet> getChangeSets(Resource file) { List<ChangeSet> changeSets = new ArrayList<ChangeSet>(); try {//from w ww. ja v a 2 s . c o m logger.info("Parsing XML Change Set File {}", file.getFilename()); ChangeSetList changeFileSet = (ChangeSetList) digester.parse(file.getInputStream()); if (changeFileSet == null) { logger.warn("Ignoring change file {}, the parser returned null. Please check your formatting.", file.getFilename()); } else { for (ChangeSet changeSet : changeFileSet.getList()) { ChangeSetReaderUtil.populateChangeSetResourceInfo(changeSet, file); } changeSets.addAll(changeFileSet.getList()); } } catch (IOException e) { logger.error("IOException", e); } catch (org.xml.sax.SAXException e) { logger.error("SAXException", e); } return changeSets; }
From source file:com.wavemaker.commons.classloader.ThrowawayFileClassLoader.java
@Override protected URL findResource(String name) { URL ret = null;/* ww w . j av a 2s . c om*/ JarFile jarFile = null; try { for (Resource entry : this.classPath) { if (entry.getFilename().toLowerCase().endsWith(".jar")) { jarFile = new JarFile(entry.getFile()); ZipEntry ze = jarFile.getEntry(name); jarFile.close(); if (ze != null) { ret = new URL("jar:" + entry.getURL() + "!/" + name); break; } } else { Resource file = entry.createRelative(name); if (file.exists()) { ret = file.getURL(); break; } } } } catch (IOException e) { throw new WMRuntimeException(e); } return ret; }