private void doDeploy(String name, Integer contentSize, InputStream inputStream) throws IOException { FileData dest = new FileData(); dest.setName(name); dest.setAuthor(DEFAULT_AUTHOR_NAME); if (deployRepo instanceof FolderRepository) { ((FolderRepository) deployRepo).save(dest, new FileChangesFromZip(new ZipInputStream(inputStream), name)); } else { dest.setSize(contentSize); deployRepo.save(dest, inputStream); } }
private Iterator<FileChange> getProjectIterator(String projectName, String version) { try { if (designRepo instanceof FolderRepository) { // Project in design repository is stored as a folder String srcProjectPath = rulesPath + projectName + "/"; return new FolderIterator(((FolderRepository) designRepo).listFiles(srcProjectPath, version)); } else { // Project in design repository is stored as a zip file FileItem srcPrj = designRepo.readHistory(rulesPath + projectName, version); if (srcPrj == null) { throw new FileNotFoundException("File '" + rulesPath + projectName + "' for version " + version + " is not found"); } IOUtils.closeQuietly(openedStream); ZipInputStream stream = new ZipInputStream(srcPrj.getStream()); openedStream = stream; return new FileChangesFromZip(stream, deploymentPath + projectName).iterator(); } } catch (Exception e) { log.error(e.getMessage(), e); return null; } }
((FolderRepository) deployRepo).save(dest, new FileChangesFromZip((ZipInputStream) stream, target)); } else { stream = new FileInputStream(zipFile);
private void unpack(AProject projectFrom, Repository repositoryTo, String folderTo, CommonUser user) throws ProjectException { ZipInputStream stream = null; try { FileItem fileItem; if (projectFrom.isHistoric()) { fileItem = projectFrom.getRepository() .readHistory(projectFrom.getFolderPath(), projectFrom.getFileData().getVersion()); } else { fileItem = projectFrom.getRepository().read(projectFrom.getFolderPath()); } if (fileItem == null) { return; } stream = new ZipInputStream(fileItem.getStream()); FileData fileData = getFileData(); fileData.setAuthor(user == null ? null : user.getUserName()); ((FolderRepository) repositoryTo).save(fileData, new FileChangesFromZip(stream, folderTo)); } catch (IOException e) { throw new ProjectException("Can't update: " + e.getMessage(), e); } finally { IOUtils.closeQuietly(stream); } }
if (repository instanceof FolderRepository) { try (ZipInputStream stream = new ZipInputStream(zipFile)) { save = ((FolderRepository) repository).save(data, new FileChangesFromZip(stream, fileName));