Search in sources :

Example 1 with SLF4JLoggerFacade

use of com.openmeap.util.SLF4JLoggerFacade in project OpenMEAP by OpenMEAP.

the class FileOperationManagerImpl method _setup.

private void _setup() throws FileOperationException {
    if (fileResourceManager != null) {
        return;
    }
    GlobalSettings settings = (GlobalSettings) modelService.findByPrimaryKey(GlobalSettings.class, 1L);
    if (settings.getTemporaryStoragePath() == null || !new File(settings.getTemporaryStoragePath()).exists()) {
        String msg = "The storage path has not been set in GlobalSettings.  Use the settings page to fix this.";
        logger.error(msg);
        throw new FileOperationException(msg);
    }
    FileResourceManager resMgr = new FileResourceManager(settings.getTemporaryStoragePath(), settings.getTemporaryStoragePath() + "/tmp", false, new SLF4JLoggerFacade(LoggerFactory.getLogger(FileResourceManager.class)));
    fileResourceManager = resMgr;
}
Also used : SLF4JLoggerFacade(com.openmeap.util.SLF4JLoggerFacade) FileResourceManager(org.apache.commons.transaction.file.FileResourceManager) GlobalSettings(com.openmeap.model.dto.GlobalSettings) File(java.io.File) ZipFile(java.util.zip.ZipFile)

Example 2 with SLF4JLoggerFacade

use of com.openmeap.util.SLF4JLoggerFacade in project OpenMEAP by OpenMEAP.

the class FileOperationManagerImplTest method setUp.

/**
	 * Creates the working/store directories, sets up the logger, and creates the FileOperationManager. 
	 * @throws IOException
	 */
@BeforeClass
public static void setUp() throws IOException {
    org.apache.log4j.BasicConfigurator.configure();
    org.apache.log4j.Logger.getLogger("org.apache.commons").setLevel(Level.OFF);
    org.apache.log4j.Logger.getLogger("Locking").setLevel(Level.OFF);
    org.apache.log4j.Logger.getLogger("com.openmeap").setLevel(Level.TRACE);
    new File(STOREDIR).mkdir();
    new File(WORKDIR).mkdir();
    File f = new File(STOREDIR + File.separator + TEST_FILE);
    OutputStream stream = new BufferedOutputStream(new FileOutputStream(f));
    InputStream inputStream = new ByteArrayInputStream(TEST_TEXT.getBytes());
    try {
        Utils.pipeInputStreamIntoOutputStream(inputStream, stream);
    } finally {
        if (stream != null) {
            stream.close();
        }
    }
    mgr = new FileOperationManagerImpl();
    FileResourceManager resMgr = new FileResourceManager(STOREDIR, WORKDIR, false, new SLF4JLoggerFacade(LoggerFactory.getLogger("org.apache.commons.transaction.file")));
    mgr.setFileResourceManager(resMgr);
}
Also used : SLF4JLoggerFacade(com.openmeap.util.SLF4JLoggerFacade) FileResourceManager(org.apache.commons.transaction.file.FileResourceManager) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) FileOutputStream(java.io.FileOutputStream) File(java.io.File) ZipFile(java.util.zip.ZipFile) BufferedOutputStream(java.io.BufferedOutputStream) BeforeClass(org.junit.BeforeClass)

Aggregations

SLF4JLoggerFacade (com.openmeap.util.SLF4JLoggerFacade)2 File (java.io.File)2 ZipFile (java.util.zip.ZipFile)2 FileResourceManager (org.apache.commons.transaction.file.FileResourceManager)2 GlobalSettings (com.openmeap.model.dto.GlobalSettings)1 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 BeforeClass (org.junit.BeforeClass)1