List of usage examples for org.springframework.core.io FileSystemResource FileSystemResource
public FileSystemResource(Path filePath)
From source file:com.ar.dev.tierra.api.controller.FiscalController.java
@RequestMapping(value = "/regalo", method = RequestMethod.POST) @ResponseBody/* w ww . j av a 2s . c o m*/ public FileSystemResource getRegalo(@PathParam("factura") int factura, @PathParam("serial") String serial) throws IOException, InterruptedException { List<DetalleFactura> detalles = facadeService.getDetalleFacturaDAO().facturaDetalle(factura); facadeService.getFiscalDAO().regalo(detalles, serial); return new FileSystemResource("command/regalo.200"); }
From source file:be.jacobsvanroy.springsqlunit.sql.SqlRunner.java
private void executeSqlScript(DataSource dataSource, File file) { logger.debug("Running sql file: " + file.getName()); sqlExecutor.executeSqlScript(dataSource, new FileSystemResource(file)); }
From source file:de.langmi.spring.batch.examples.readers.file.gzip.GZipBufferedReaderFactoryTest.java
@Test public void testWithGzipFileOtherSuffix() throws Exception { // adjust suffixes gzbrf.getGzipSuffixes().add(".gzfoo"); // suffixes still ok? assertNotNull(gzbrf.getGzipSuffixes()); assertTrue(gzbrf.getGzipSuffixes().size() > 0); // suffixes really changed? for (String suffix : gzbrf.getGzipSuffixes()) { assertTrue(".gz".equals(suffix) || ".gzip".equals(suffix) || ".gzfoo".equals(suffix)); }/*from www .j ava 2 s . com*/ // try to create BufferedReader reader = gzbrf.create(new FileSystemResource(PATH_TO_COMPRESSED_TEST_FILE_OTHERSUFFIX), Charset.defaultCharset().name()); // creation successful? assertNotNull(reader); // clean up, close the reader reader.close(); }
From source file:org.cbio.portal.pipelines.foundation.ClinicalDataWriter.java
@Override public void open(ExecutionContext executionContext) throws ItemStreamException { String stagingFile = outputDirectory + "data_clinical.txt"; PassThroughLineAggregator aggr = new PassThroughLineAggregator(); flatFileItemWriter.setLineAggregator(aggr); flatFileItemWriter.setHeaderCallback(new FlatFileHeaderCallback() { @Override/*from ww w . jav a2s. c o m*/ public void writeHeader(Writer writer) throws IOException { writer.write(getHeader()); } }); flatFileItemWriter.setResource(new FileSystemResource(stagingFile)); flatFileItemWriter.open(executionContext); }
From source file:com.netflix.genie.web.services.impl.LocalJobKillServiceImplUnitTests.java
/** * Setup for the tests.//from w ww . j av a2s .c o m * * @throws IOException if the job directory cannot be created */ @Before public void setup() throws IOException { Assume.assumeTrue(SystemUtils.IS_OS_UNIX); final File tempDirectory = Files.createTempDir(); this.genieWorkingDir = new FileSystemResource(tempDirectory); Files.createParentDirs(new File(tempDirectory.getPath() + "/" + ID + "/genie/x")); this.jobSearchService = Mockito.mock(JobSearchService.class); this.executor = Mockito.mock(Executor.class); this.genieEventBus = Mockito.mock(GenieEventBus.class); this.service = new LocalJobKillServiceImpl(HOSTNAME, this.jobSearchService, this.executor, false, this.genieEventBus, this.genieWorkingDir, GenieObjectMapper.getMapper()); this.killCommand = new CommandLine("kill"); this.killCommand.addArguments(Integer.toString(PID)); }
From source file:com.mondora.chargify.ChargifyFactory.java
BeanFactory readFromSenseDirConf() throws FileNotFoundException { String fPath = System.getProperty("sense.dir.conf") + "/charge-context.xml"; if (logger.isTraceEnabled()) logger.trace("Try loading charge-context.xml from " + fPath); File chargeContext = new File(fPath); if (chargeContext.exists()) { return new XmlBeanFactory(new FileSystemResource(chargeContext)); }//from w w w . j ava 2 s . c o m throw new FileNotFoundException("file " + fPath + " don't exists"); }
From source file:org.cbio.portal.pipelines.foundation.CnaDataWriter.java
@Override public void open(ExecutionContext executionContext) throws ItemStreamException { // retrieve list of foundation cases from execution context final Map<String, CaseType> fmiCaseTypeMap = (Map<String, CaseType>) executionContext.get("fmiCaseTypeMap"); String stagingFile = outputDirectory + "data_CNA.txt"; PassThroughLineAggregator aggr = new PassThroughLineAggregator(); flatFileItemWriter.setLineAggregator(aggr); flatFileItemWriter.setHeaderCallback(new FlatFileHeaderCallback() { @Override/*from ww w. j a v a 2 s .co m*/ public void writeHeader(Writer writer) throws IOException { writer.write(getHeader(fmiCaseTypeMap.keySet())); } }); flatFileItemWriter.setResource(new FileSystemResource(stagingFile)); flatFileItemWriter.open(executionContext); }
From source file:org.cbio.portal.pipelines.foundation.FusionDataWriter.java
@Override public void open(ExecutionContext executionContext) throws ItemStreamException { String stagingFile = outputDirectory + "data_fusions.txt"; PassThroughLineAggregator aggr = new PassThroughLineAggregator(); flatFileItemWriter.setLineAggregator(aggr); flatFileItemWriter.setHeaderCallback(new FlatFileHeaderCallback() { @Override/*w ww . ja v a 2s . c om*/ public void writeHeader(Writer writer) throws IOException { writer.write(getHeader()); } }); flatFileItemWriter.setResource(new FileSystemResource(stagingFile)); flatFileItemWriter.open(executionContext); }
From source file:com.netflix.genie.web.services.impl.JobKillServiceV3Test.java
/** * Setup for the tests.//from w w w . j av a2s . co m * * @throws IOException if the job directory cannot be created */ @Before public void setup() throws IOException { Assume.assumeTrue(SystemUtils.IS_OS_UNIX); final File tempDirectory = Files.createTempDir(); this.genieWorkingDir = new FileSystemResource(tempDirectory); Files.createParentDirs(new File(tempDirectory.getPath() + "/" + ID + "/genie/x")); this.jobSearchService = Mockito.mock(JobSearchService.class); this.executor = Mockito.mock(Executor.class); this.genieEventBus = Mockito.mock(GenieEventBus.class); this.processCheckerFactory = Mockito.mock(ProcessChecker.Factory.class); this.processChecker = Mockito.mock(ProcessChecker.class); this.service = new JobKillServiceV3(HOSTNAME, this.jobSearchService, this.executor, false, this.genieEventBus, this.genieWorkingDir, GenieObjectMapper.getMapper(), processCheckerFactory); this.killCommand = new CommandLine("kill"); this.killCommand.addArguments(Integer.toString(PID)); }
From source file:org.pac4j.saml.metadata.SAML2IdentityProviderMetadataResolver.java
@Override public final MetadataResolver resolve() { try {//from ww w . j a v a 2 s. c o m Resource resource = null; if (this.idpMetadataPath.startsWith(CommonHelper.RESOURCE_PREFIX)) { String path = this.idpMetadataPath.substring(CommonHelper.RESOURCE_PREFIX.length()); if (!path.startsWith("/")) { path = "/" + path; } resource = ResourceHelper.of(new ClassPathResource(path)); } else if (this.idpMetadataPath.startsWith("file:")) { resource = ResourceHelper.of(new FileSystemResource(this.idpMetadataPath)); } else if (this.idpMetadataPath.startsWith("http")) { resource = ResourceHelper.of(new UrlResource(this.idpMetadataPath)); } if (resource == null) { throw new XMLParserException("idp metadata cannot be resolved from " + this.idpMetadataPath); } final InputStream in = resource.getInputStream(); final Document inCommonMDDoc = Configuration.getParserPool().parse(in); final Element metadataRoot = inCommonMDDoc.getDocumentElement(); idpMetadataProvider = new DOMMetadataResolver(metadataRoot); idpMetadataProvider.setParserPool(Configuration.getParserPool()); idpMetadataProvider.setFailFastInitialization(true); idpMetadataProvider.setRequireValidMetadata(true); idpMetadataProvider.setId(idpMetadataProvider.getClass().getCanonicalName()); idpMetadataProvider.initialize(); // If no idpEntityId declared, select first EntityDescriptor entityId as our IDP entityId if (this.idpEntityId == null) { final Iterator<EntityDescriptor> it = idpMetadataProvider.iterator(); while (it.hasNext()) { final EntityDescriptor entityDescriptor = it.next(); if (SAML2IdentityProviderMetadataResolver.this.idpEntityId == null) { SAML2IdentityProviderMetadataResolver.this.idpEntityId = entityDescriptor.getEntityID(); } } } if (this.idpEntityId == null) { throw new SAMLException("No idp entityId found"); } } catch (final ComponentInitializationException e) { throw new SAMLException("Error initializing idpMetadataProvider", e); } catch (final XMLParserException e) { throw new TechnicalException("Error parsing idp Metadata", e); } catch (final IOException e) { throw new TechnicalException("Error getting idp Metadata resource", e); } return idpMetadataProvider; }