Search in sources :

Example 21 with ConfigurationLocator

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;
}
Also used : ConfigurationLocator(org.mifos.framework.util.ConfigurationLocator)

Example 22 with ConfigurationLocator

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;
}
Also used : ConfigurationLocator(org.mifos.framework.util.ConfigurationLocator)

Example 23 with ConfigurationLocator

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);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) InputStream(java.io.InputStream) Resource(org.springframework.core.io.Resource) ConfigurationLocator(org.mifos.framework.util.ConfigurationLocator) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 24 with ConfigurationLocator

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;
}
Also used : ConfigurationLocator(org.mifos.framework.util.ConfigurationLocator) MifosScheduler(org.mifos.framework.components.batchjobs.MifosScheduler)

Example 25 with ConfigurationLocator

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);
}
Also used : ConfigurationLocator(org.mifos.framework.util.ConfigurationLocator) CommonsMultipartFile(org.springframework.web.multipart.commons.CommonsMultipartFile) File(java.io.File) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Aggregations

ConfigurationLocator (org.mifos.framework.util.ConfigurationLocator)25 File (java.io.File)9 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 URL (java.net.URL)3 ArrayList (java.util.ArrayList)3 MifosScheduler (org.mifos.framework.components.batchjobs.MifosScheduler)3 Resource (org.springframework.core.io.Resource)3 FileInputStream (java.io.FileInputStream)2 Properties (java.util.Properties)2 JarInputStream (java.util.jar.JarInputStream)2 Graphics2D (java.awt.Graphics2D)1 BufferedImage (java.awt.image.BufferedImage)1 BufferedReader (java.io.BufferedReader)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 URLClassLoader (java.net.URLClassLoader)1 SQLException (java.sql.SQLException)1