private void archiveAndSave(FolderRepository designRepo, String projectPath, String version, Repository deployRepo, FileData dest) throws ProjectException { ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zipOutputStream = null; try { zipOutputStream = new ZipOutputStream(out); List<FileData> files = designRepo.listFiles(projectPath, version); for (FileData file : files) { String internalPath = file.getName().substring(projectPath.length()); zipOutputStream.putNextEntry(new ZipEntry(internalPath)); FileItem fileItem = designRepo.readHistory(file.getName(), file.getVersion()); try (InputStream content = fileItem.getStream()) { IOUtils.copy(content, zipOutputStream); } zipOutputStream.closeEntry(); } zipOutputStream.finish(); dest.setSize(out.size()); deployRepo.save(dest, new ByteArrayInputStream(out.toByteArray())); } catch (IOException e) { throw new ProjectException(e.getMessage(), e); } finally { IOUtils.closeQuietly(zipOutputStream); } }
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 void doDeploy(String name, Integer contentSize, InputStream inputStream) throws IOException { FileData dest = new FileData(); dest.setName(name); dest.setAuthor(DEFAULT_AUTHOR_NAME); dest.setSize(contentSize); deployRepo.save(dest, inputStream); }
private void transformAndArchive(AProject projectFrom, CommonUser user) throws ProjectException { // Archive the folder using zip FileData fileData = getFileData(); ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zipOutputStream = null; try { zipOutputStream = new ZipOutputStream(out); for (AProjectArtefact artefact : projectFrom.getArtefacts()) { writeArtefact(zipOutputStream, artefact); } zipOutputStream.finish(); fileData.setAuthor(user == null ? null : user.getUserName()); fileData.setSize(out.size()); setFileData(getRepository().save(fileData, new ByteArrayInputStream(out.toByteArray()))); } catch (IOException e) { throw new ProjectException(e.getMessage(), e); } finally { IOUtils.closeQuietly(zipOutputStream); } }
stream = new FileInputStream(zipFile); dest.setSize(zipFile.length()); deployRepo.save(dest, stream);
fileData.setAuthor(user == null ? null : user.getUserName()); fileData.setSize(out.size()); setFileData(getRepository().save(fileData, new ByteArrayInputStream(out.toByteArray()))); } catch (IOException e) { throw new ProjectException(e.getMessage(), e);
data.setAuthor(getUserName()); data.setSize(zipSize); FileData save = getRepository().save(data, zipFile); userWorkspace.getProject(name).unlock(); return Response.created(new URI(uri + "/" + StringTool.encodeURL(save.getVersion()))).build();
public AProjectResource addResource(String name, InputStream content) throws ProjectException { try { getProject().lock(); FileData fileData = new FileData(); String fullName = folderPath + "/" + name; fileData.setName(fullName); Repository repository = getRepository(); if (repository.check(fullName) != null) { throw new ProjectException(String.format("The file '%s' exists in the folder.", name), new IOException()); } fileData = repository.save(fileData, content); AProjectResource createdResource = new AProjectResource(getProject(), repository, fileData); getArtefactsInternal().put(name, createdResource); return createdResource; } catch (IOException ex) { throw new ProjectException("Cannot add a resource", ex); } finally { IOUtils.closeQuietly(content); } }
public void setContent(InputStream inputStream) throws ProjectException { try { getProject().lock(); setFileData(getRepository().save(getFileData(), inputStream)); } catch (IOException ex) { throw new ProjectException("Cannot set content", ex); } finally { IOUtils.closeQuietly(inputStream); } }
save = repository.save(data, zipFile);
dest.setComment(srcPrj.getData().getComment()); dest.setSize(srcPrj.getData().getSize()); deployRepo.save(dest, stream); } finally { IOUtils.closeQuietly(stream);
stream = srcPrj.getStream(); dest.setSize(srcPrj.getData().getSize()); deployRepo.save(dest, stream);
stream = fileItem.getStream(); fileData.setAuthor(user == null ? null : user.getUserName()); setFileData(repositoryTo.save(fileData, stream)); } catch (IOException ex) { throw new ProjectException("Can't update: " + ex.getMessage(), ex);