static Folder getFolder(final Folder baseFolder, final String subFolder) throws IOException { return new Folder(baseFolder, subFolder); }
public void copyTo(Folder destFolder) throws IOException { checkFolderExists(); destFolder.create(); FileUtils.copyDirectory(this.getFile(), destFolder.getFile()); }
public Map<String, byte[]> listFilesAsResources() throws IOException { checkFolderExists(); final Map<String, byte[]> resources = new HashMap<>(); final File[] files = this.folder.listFiles((FileFilter) FileFileFilter.FILE); if (files != null) { for (File file : files) { resources.put(file.getName(), getFileContent(file)); } } return resources; }
public Folder(final Folder folder, final String subFolder) throws IOException { if (folder == null) { throw new IOException("Folder is null"); } this.folder = new File(folder.getFile(), subFolder); }
static Folder getPlatformLocalClassLoaderFolder(String artifactType, long artifactId) throws IOException { final Folder localFolder = getPlatformLocalClassLoaderFolder(); final Folder artifactTypeFolder = getFolder(localFolder, artifactType); artifactTypeFolder.createIfNotExists(); final Folder artifactIdFolder = getFolder(artifactTypeFolder, Long.toString(artifactId)); artifactIdFolder.createIfNotExists(); return artifactIdFolder; }
static Folder getTempFolder() throws IOException { File systemTempFolder = new File(System.getProperty("java.io.tmpdir")); final Folder tempFolder = getFolder(systemTempFolder, TEMP_FOLDER_NAME_PREFIX + getJvmName()); if (!tempFolder.exists()) { warnIfSomeTempFolderAlreadyExists(systemTempFolder); tempFolder.createAsTemporaryFolder(); } return tempFolder; }
public FileHandler getIncidentFileHandler(long tenantId) throws BonitaHomeNotSetException, IOException { final String incidentLogFolder = System.getProperty(INCIDENT_LOG_FOLDER_PROPERTY); if (incidentLogFolder != null) { final Path tenantFolder = Paths.get(incidentLogFolder).resolve("tenants").resolve("" + tenantId); createFolders(new Folder(tenantFolder.toFile())); return getFileHandler(tenantFolder.resolve(INCIDENTS_LOG_FILENAME).toString()); } else { Folder tenantWorkFolder = getTenantTempFolder(tenantId); final File incidentFile = tenantWorkFolder.getFile(INCIDENTS_LOG_FILENAME); return getFileHandler(incidentFile.getAbsolutePath()); } }
public URI toURI() throws IOException { checkFolderExists(); return this.folder.toURI(); }
public File getSecurityScriptsFolder(long tenantId) throws BonitaHomeNotSetException, IOException { final Folder localFolder = getFolder(getPlatformTempFolder(), "security-scripts").createIfNotExists(); final Folder tenantSecurityScriptsFolder = getFolder(localFolder, String.valueOf(tenantId)).createIfNotExists(); List<BonitaConfiguration> tenantSecurityScripts = getConfigurationService().getTenantSecurityScripts(tenantId); writeBonitaConfiguration(tenantSecurityScriptsFolder.getFile(), tenantSecurityScripts); return tenantSecurityScriptsFolder.getFile(); }
public URI getLocalTemporaryFolder(final String artifactType, final long artifactId) throws BonitaHomeNotSetException, IOException { return FolderMgr.getPlatformLocalClassLoaderFolder(artifactType, artifactId).toURI(); }
public Folder createIfNotExists() throws IOException { if (!this.folder.exists()) { create(); } return this; }
public Folder(final Folder folder, final String subFolder) throws IOException { if (folder == null) { throw new IOException("Folder is null"); } this.folder = new File(folder.getFile(), subFolder); }
static Folder getPlatformLocalClassLoaderFolder(String artifactType, long artifactId) throws IOException { final Folder localFolder = getPlatformLocalClassLoaderFolder(); final Folder artifactTypeFolder = getFolder(localFolder, artifactType); artifactTypeFolder.createIfNotExists(); final Folder artifactIdFolder = getFolder(artifactTypeFolder, Long.toString(artifactId)); artifactIdFolder.createIfNotExists(); return artifactIdFolder; }
static Folder getTempFolder() throws IOException { File systemTempFolder = new File(System.getProperty("java.io.tmpdir")); final Folder tempFolder = getFolder(systemTempFolder, TEMP_FOLDER_NAME_PREFIX + getJvmName()); if (!tempFolder.exists()) { warnIfSomeTempFolderAlreadyExists(systemTempFolder); tempFolder.createAsTemporaryFolder(); } return tempFolder; }
public FileHandler getIncidentFileHandler(long tenantId) throws BonitaHomeNotSetException, IOException { final String incidentLogFolder = System.getProperty(INCIDENT_LOG_FOLDER_PROPERTY); if (incidentLogFolder != null) { final Path tenantFolder = Paths.get(incidentLogFolder).resolve("tenants").resolve("" + tenantId); createFolders(new Folder(tenantFolder.toFile())); return getFileHandler(tenantFolder.resolve(INCIDENTS_LOG_FILENAME).toString()); } else { Folder tenantWorkFolder = getTenantTempFolder(tenantId); final File incidentFile = tenantWorkFolder.getFile(INCIDENTS_LOG_FILENAME); return getFileHandler(incidentFile.getAbsolutePath()); } }
public Map<String, byte[]> listFilesAsResources() throws IOException { checkFolderExists(); final Map<String, byte[]> resources = new HashMap<>(); final File[] files = this.folder.listFiles((FileFilter) FileFileFilter.FILE); if (files != null) { for (File file : files) { resources.put(file.getName(), getFileContent(file)); } } return resources; }
public File getFile(final String name) throws IOException { checkFolderExists(); return new File(folder, name); }
public File getSecurityScriptsFolder(long tenantId) throws BonitaHomeNotSetException, IOException { final Folder localFolder = getFolder(getPlatformTempFolder(), "security-scripts").createIfNotExists(); final Folder tenantSecurityScriptsFolder = getFolder(localFolder, String.valueOf(tenantId)).createIfNotExists(); List<BonitaConfiguration> tenantSecurityScripts = getConfigurationService().getTenantSecurityScripts(tenantId); writeBonitaConfiguration(tenantSecurityScriptsFolder.getFile(), tenantSecurityScripts); return tenantSecurityScriptsFolder.getFile(); }
public URI getGlobalTemporaryFolder() throws BonitaHomeNotSetException, IOException { return FolderMgr.getPlatformGlobalClassLoaderFolder().toURI(); }