use of org.springframework.core.io.InputStreamResource in project opennms by OpenNMS.
the class AccessPointMonitorConfigDaoJaxbTest method testAfterPropertiesSetWithGoodConfigFile.
public void testAfterPropertiesSetWithGoodConfigFile() throws Exception {
AccessPointMonitorConfigDaoJaxb dao = new AccessPointMonitorConfigDaoJaxb();
InputStream in = ConfigurationTestUtils.getInputStreamForConfigFile("access-point-monitor-configuration.xml");
dao.setConfigResource(new InputStreamResource(in));
dao.afterPropertiesSet();
assertNotNull("access point monitor config should not be null", dao.getConfig());
}
use of org.springframework.core.io.InputStreamResource in project Activiti by Activiti.
the class ProcessEngineMvcEndpoint method processDefinitionDiagram.
/**
* Look up the process definition by key. For example,
* this is <A href="http://localhost:8080/activiti/processes/fulfillmentProcess">process-diagram for</A>
* a process definition named {@code fulfillmentProcess}.
*/
@RequestMapping(value = "/processes/{processDefinitionKey:.*}", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE)
@ResponseBody
public ResponseEntity processDefinitionDiagram(@PathVariable String processDefinitionKey) {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey(processDefinitionKey).latestVersion().singleResult();
if (processDefinition == null) {
return ResponseEntity.status(NOT_FOUND).body(null);
}
ProcessDiagramGenerator processDiagramGenerator = new DefaultProcessDiagramGenerator();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
if (bpmnModel.getLocationMap().size() == 0) {
BpmnAutoLayout autoLayout = new BpmnAutoLayout(bpmnModel);
autoLayout.execute();
}
InputStream is = processDiagramGenerator.generateJpgDiagram(bpmnModel);
return ResponseEntity.ok(new InputStreamResource(is));
}
use of org.springframework.core.io.InputStreamResource in project geode by apache.
the class ExportLogController method getErrorResponse.
private ResponseEntity<InputStreamResource> getErrorResponse(String result) {
HttpHeaders respHeaders = new HttpHeaders();
// if the command is successful, the output is the filepath,
InputStreamResource isr;
// into a Result object
try {
isr = new InputStreamResource(IOUtils.toInputStream(result, "UTF-8"));
respHeaders.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
return new ResponseEntity<InputStreamResource>(isr, respHeaders, HttpStatus.OK);
} catch (Exception e) {
throw new RuntimeException("IO Error writing file to output stream", e);
}
}
use of org.springframework.core.io.InputStreamResource in project geode by apache.
the class ExportLogController method getOKResponse.
private ResponseEntity<InputStreamResource> getOKResponse(Result commandResult) {
HttpHeaders respHeaders = new HttpHeaders();
// if the command is successful, the output is the filepath,
InputStreamResource isr;
String filePath = commandResult.nextLine().trim();
File zipFile = new File(filePath);
try {
isr = new InputStreamResource(new FileInputStream(zipFile));
respHeaders.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE);
return new ResponseEntity<InputStreamResource>(isr, respHeaders, HttpStatus.OK);
} catch (Exception e) {
throw new RuntimeException("IO Error writing file to output stream", e);
} finally {
FileUtils.deleteQuietly(zipFile);
}
}
use of org.springframework.core.io.InputStreamResource in project dhis2-core by dhis2.
the class DefaultDhisConfigurationProvider method loadDhisConf.
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
private Properties loadDhisConf() throws IllegalStateException {
try (InputStream in = locationManager.getInputStream(CONF_FILENAME)) {
Properties conf = PropertiesLoaderUtils.loadProperties(new InputStreamResource(in));
substituteEnvironmentVariables(conf);
return conf;
} catch (LocationManagerException | IOException | SecurityException ex) {
log.debug(String.format("Could not load %s", CONF_FILENAME), ex);
throw new IllegalStateException("Properties could not be loaded", ex);
}
}
Aggregations