use of org.mifos.framework.util.ConfigurationLocator in project head by mifos.
the class FileStorageManager method getStorageLocation.
public static synchronized String getStorageLocation() {
if (location == null) {
ConfigurationLocator cl = new ConfigurationLocator();
location = cl.getConfigurationDirectory() + BASE_DIR;
checkStoragePermission();
}
return location;
}
use of org.mifos.framework.util.ConfigurationLocator in project head by mifos.
the class MifosSchedulerIntegrationTest method getMifosScheduler.
private MifosScheduler getMifosScheduler(String taskConfigurationPath) throws TaskSystemException, IOException, FileNotFoundException {
ConfigurationLocator mockConfigurationLocator = createMock(ConfigurationLocator.class);
expect(mockConfigurationLocator.getResource(SchedulerConstants.CONFIGURATION_FILE_NAME)).andReturn(MifosResourceUtil.getClassPathResourceAsResource(taskConfigurationPath));
expectLastCall().times(2);
replay(mockConfigurationLocator);
MifosScheduler mifosScheduler = new MifosScheduler();
mifosScheduler.setConfigurationLocator(mockConfigurationLocator);
mifosScheduler.initialize();
return mifosScheduler;
}
use of org.mifos.framework.util.ConfigurationLocator in project head by mifos.
the class UploadLogoController method getMifosLogo.
@RequestMapping("/getMifosLogo")
public ResponseEntity<byte[]> getMifosLogo() throws IOException {
ConfigurationLocator configurationLocator = new ConfigurationLocator();
Resource logo = configurationLocator.getUploadedMifosLogo();
InputStream in = logo.getInputStream();
byte[] logoContent = IOUtils.toByteArray(in);
in.close();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.IMAGE_PNG);
return new ResponseEntity<byte[]>(logoContent, headers, HttpStatus.OK);
}
use of org.mifos.framework.util.ConfigurationLocator in project head by mifos.
the class ProductStatusHelperIntegrationTest method getMifosScheduler.
private MifosScheduler getMifosScheduler(String taskConfigurationPath) throws TaskSystemException, IOException, FileNotFoundException {
ConfigurationLocator mockConfigurationLocator = createMock(ConfigurationLocator.class);
expect(mockConfigurationLocator.getResource(SchedulerConstants.CONFIGURATION_FILE_NAME)).andReturn(MifosResourceUtil.getClassPathResourceAsResource(taskConfigurationPath));
expectLastCall().times(2);
replay(mockConfigurationLocator);
MifosScheduler mifosScheduler = new MifosScheduler();
mifosScheduler.setConfigurationLocator(mockConfigurationLocator);
mifosScheduler.initialize();
return mifosScheduler;
}
use of org.mifos.framework.util.ConfigurationLocator in project head by mifos.
the class LogoServiceFacadeWebTier method uploadNewLogo.
public void uploadNewLogo(CommonsMultipartFile logo) throws IOException {
BufferedImage bufferedImage = ImageIO.read(logo.getInputStream());
BufferedImage finalImage = null;
if (bufferedImage.getWidth() > MAX_WIDTH || bufferedImage.getHeight() > MAX_HEIGHT) {
float wRatio, hRatio;
if (bufferedImage.getWidth() >= bufferedImage.getHeight()) {
wRatio = MAX_WIDTH / bufferedImage.getWidth();
hRatio = MAX_HEIGHT / bufferedImage.getHeight();
} else {
wRatio = MAX_HEIGHT / bufferedImage.getWidth();
hRatio = MAX_WIDTH / bufferedImage.getHeight();
}
float resizeRatio = Math.min(wRatio, hRatio);
float newHeight = bufferedImage.getHeight() * resizeRatio;
float newWidth = bufferedImage.getWidth() * resizeRatio;
finalImage = new BufferedImage((int) newWidth, (int) newHeight, bufferedImage.getType());
Graphics2D g = finalImage.createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.drawImage(bufferedImage, 0, 0, (int) newWidth, (int) newHeight, 0, 0, bufferedImage.getWidth(), bufferedImage.getHeight(), null);
g.dispose();
} else {
finalImage = bufferedImage;
}
ConfigurationLocator configurationLocator = new ConfigurationLocator();
File dir = new File(configurationLocator.getConfigurationDirectory() + File.separator + configurationLocator.getLogoDirectory() + File.separator);
dir.mkdirs();
File file = new File(dir, configurationLocator.getLogoName());
ImageIO.write(finalImage, "png", file);
}
Aggregations