private RepositoryFile createOrUpdateFile(final RepositoryFolder folder, final String filename, final Action<OutputStream> writeAction) { RepositoryFile file = folder.getFile(filename); if (file == null) { file = folder.createFile(filename, writeAction); } else { file.writeFile(writeAction); } return file; } }
@SuppressWarnings("deprecation") @Override public InputStream read() throws ResourceException { return getRepositoryFile().readFile(); }
@SuppressWarnings("deprecation") @Override public OutputStream write() throws ResourceException { return getRepositoryFile().writeFile(false); }
private void deleteChildren(RepositoryFolder folder) { List<RepositoryFile> files = folder.getFiles(); for (RepositoryFile file : files) { file.delete(); } List<RepositoryFolder> folders = folder.getFolders(); for (RepositoryFolder subFolder : folders) { deleteChildren(subFolder); subFolder.delete(); } }
public ComponentStoreImpl(Repository repository, String tenantId) { RepositoryFolder tenantFolder = repository.getFolder(tenantId); componentsFolder = tenantFolder.getOrCreateFolder(FOLDER_NAME); }
@Override public RepositoryFolder getTenantRootFolder() { RepositoryFolder tenantFolder = _repository.getFolder(_tenantId); if (tenantFolder == null) { logger.info("Creating tenant folder '{}' for tenant '{}'", _tenantId, _tenantId); tenantFolder = _repository.createFolder(_tenantId); tenantFolder.createFolder(PATH_JOBS); tenantFolder.createFolder(PATH_RESULTS); tenantFolder.createFolder(PATH_TIMELINES); } return tenantFolder; }
@Override public void run(final OutputStream out) throws Exception { existingFile.readFile(new Action<InputStream>() { @Override public void run(final InputStream in) throws Exception { FileHelper.copy(in, out); } }); } });
@Override public long getLastModified() { return getRepositoryFile().getLastModified(); }
@Override public long getSize() { return getRepositoryFile().getSize(); }
@Override public String getName() { return getRepositoryFile().getName(); }
/** * Recreates the {@link RepositoryFileResource} after deserialization, if * the {@link RepositoryFile} could not be included in the serialized * object. * * @param repository * @return */ public RepositoryFileResource recreate(final Repository repository) { return new RepositoryFileResource(repository, _qualifiedPath); }
@Override public final boolean equals(final Object obj) { if (obj == null) { return false; } if (obj instanceof RepositoryNode) { final String otherQualifiedPath = ((RepositoryNode) obj).getQualifiedPath(); return getQualifiedPath().equals(otherQualifiedPath); } return false; }
public RepositoryFileResourceTypeHandler(final Repository repository, final String tenantId) { _repository = repository; _homeFolder = repository.getFolder(tenantId); }
@Override public final String toString() { return getQualifiedPath(); } }
@SuppressWarnings("deprecation") @Override public OutputStream append() throws ResourceException { return getRepositoryFile().writeFile(true); }
@Override public void toXml(final OutputStream out) { _file.readFile(new Action<InputStream>() { @Override public void run(InputStream in) throws Exception { FileHelper.copy(in, out); } }); }
@Override public final int compareTo(final RepositoryNode o) { if (o == null) { return 1; } return getQualifiedPath().compareTo(o.getQualifiedPath()); }
@Override public void run(final OutputStream out) throws Exception { existingFile.readFile(new Action<InputStream>() { @Override public void run(InputStream in) throws Exception { FileHelper.copy(in, out); } }); } };
@Override public void run(final OutputStream out) throws Exception { oldScheduleFile.readFile(new Action<InputStream>() { @Override public void run(final InputStream in) throws Exception { FileHelper.copy(in, out); } }); } };
@Override public void toXml(final OutputStream out) { _file.readFile(new Action<InputStream>() { @Override public void run(InputStream in) throws Exception { FileHelper.copy(in, out); } }); }