/** * Returns the latest zipped project. * * @param name a project name * @return a zipped project */ @GET @Path("project/{name}") @Produces("application/zip") public Response getLastProject(@PathParam("name") String name) throws WorkspaceException { try { if (!isGranted(Privileges.VIEW_PROJECTS)) { return Response.status(Status.FORBIDDEN).entity("Doesn't have VIEW privilege").build(); } FileItem fileItem = getRepository().read(getFileName(name)); if (fileItem == null) { throw new FileNotFoundException("File '" + name + "' not found."); } String zipFileName = String.format("%s-%s.zip", name, fileItem.getData().getVersion()); return Response.ok(fileItem.getStream()) .header("Content-Disposition", "attachment;filename=\"" + zipFileName + "\"") .build(); } catch (IOException ex) { return Response.status(Status.NOT_FOUND).entity(ex.getMessage()).build(); } }
/** * Returns the latest zipped project. * * @param name a project name * @return a zipped project */ @GET @Path("project/{name}") @Produces("application/zip") public Response getLastProject(@PathParam("name") String name) throws WorkspaceException { try { if (!isGranted(Privileges.VIEW_PROJECTS)) { return Response.status(Status.FORBIDDEN).entity("Doesn't have VIEW privilege").build(); } FileItem fileItem = getRepository().read(getFileName(name)); if (fileItem == null) { throw new FileNotFoundException("File '" + name + "' not found."); } String zipFileName = String.format("%s-%s.zip", name, fileItem.getData().getVersion()); return Response.ok(fileItem.getStream()) .header("Content-Disposition", "attachment;filename=\"" + zipFileName + "\"") .build(); } catch (IOException ex) { return Response.status(Status.NOT_FOUND).entity(ex.getMessage()).build(); } }
fileItem = readHistory(srcName, version); destData.setSize(fileItem.getData().getSize());
@Override public FileData copyHistory(String srcName, FileData destData, String version) throws IOException { FileItem fileItem = null; try { fileItem = readHistory(srcName, version); FileData copy = new FileData(); copy.setName(destData.getName()); copy.setComment(destData.getComment()); copy.setAuthor(destData.getAuthor()); copy.setSize(fileItem.getData().getSize()); return save(copy, fileItem.getStream()); } finally { if (fileItem != null) { IOUtils.closeQuietly(fileItem.getStream()); } } }
@Override public FileData copyHistory(String srcName, FileData destData, String version) throws IOException { FileItem fileItem = null; try { fileItem = readHistory(srcName, version); FileData copy = new FileData(); copy.setName(destData.getName()); copy.setComment(destData.getComment()); copy.setAuthor(destData.getAuthor()); copy.setSize(fileItem.getData().getSize()); return save(copy, fileItem.getStream()); } finally { if (fileItem != null) { IOUtils.closeQuietly(fileItem.getStream()); } } }
FileItem srcPrj = designRepo.readHistory(rulesPath + projectName, version); stream = srcPrj.getStream(); dest.setSize(srcPrj.getData().getSize()); deployRepo.save(dest, stream);
fileItem = projectFrom.getRepository().read(projectFrom.getFolderPath()); fileData.setSize(fileItem.getData().getSize()); stream = fileItem.getStream(); fileData.setAuthor(user == null ? null : user.getUserName());