@Override public long getSize() { verifyInitialized(); return super.getSize(); }
@Override public int getFirstRevisionIndex() { List<FileData> fileDatas = getHistoryFileDatas(); if (fileDatas.isEmpty()) { return 0; } // In JCR repository first revision is "technical". It doesn't contain any file and comment. // In this case first real revision is 1, not 0. // In other situations it's impossible to create empty project in repository. // In other repository types first revision is always 0. FileData fd = fileDatas.get(0); boolean technicalRevision = fd.getSize() == 0 && StringUtils.isEmpty(fd.getComment()); return technicalRevision ? 1 : 0; }
@Override public boolean hasArtefacts() { return isFolder() ? super.hasArtefacts() : getFileData().getSize() != 0; }
@Override public void saveFileData(FileData fileData) { if (fileData.getVersion() == null || fileData.getAuthor() == null || fileData.getModifiedAt() == null) { // No need to save empty fileData return; } Properties properties = new Properties(); properties.setProperty(VERSION_PROPERTY, fileData.getVersion()); properties.setProperty(AUTHOR_PROPERTY, fileData.getAuthor()); properties.setProperty(MODIFIED_AT_PROPERTY, new SimpleDateFormat(DATE_FORMAT).format(fileData.getModifiedAt())); properties.setProperty(SIZE_PROPERTY, "" + fileData.getSize()); if (fileData.getComment() != null) { properties.setProperty(COMMENT_PROPERTY, fileData.getComment()); } FileOutputStream os = null; try { File file = propertiesEngine.createPropertiesFile(pathInProject, VERSION_FILE_NAME); os = new FileOutputStream(file); properties.store(os, "Project version"); } catch (IOException e) { throw new IllegalStateException(e.getMessage(), e); } finally { IOUtils.closeQuietly(os); } }
private void verifyInitialized() { if (project != null) { List<FileData> fileDatas = project.getHistoryFileDatas(); if (!fileDatas.isEmpty()) { FileData repoData = null; String version = getVersion(); if (version == null) { repoData = fileDatas.get(fileDatas.size() - 1); } else { for (FileData data : fileDatas) { if (data.getVersion().equals(version)) { repoData = data; break; } } } if (repoData != null) { super.setAuthor(repoData.getAuthor()); super.setModifiedAt(repoData.getModifiedAt()); super.setComment(repoData.getComment()); super.setSize(repoData.getSize()); super.setDeleted(repoData.isDeleted()); } } project = null; } } }
fileItem = readHistory(srcName, version); destData.setSize(fileItem.getData().getSize());
@Override public FileData save(FileData data, InputStream stream) throws IOException { try { ObjectMetadata metaData = new ObjectMetadata(); metaData.setContentType("application/zip"); if (data.getSize() != FileData.UNDEFINED_SIZE) { metaData.setContentLength(data.getSize()); } if (!StringUtils.isBlank(data.getAuthor())) { metaData.addUserMetadata(LazyFileData.METADATA_AUTHOR, LazyFileData.encode(data.getAuthor())); } if (!StringUtils.isBlank(data.getComment())) { metaData.addUserMetadata(LazyFileData.METADATA_COMMENT, LazyFileData.encode(data.getComment())); } s3.putObject(bucketName, data.getName(), stream, metaData); onModified(); return check(data.getName()); } catch (SdkClientException e) { throw new IOException(e); } }
dest.setAuthor(userName); dest.setComment(srcPrj.getData().getComment()); dest.setSize(srcPrj.getData().getSize()); deployRepo.save(dest, stream); } finally {
@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());
fullLocalFileData.setName(localFileData.getName()); fullLocalFileData.setVersion(designFileData.getVersion()); fullLocalFileData.setSize(designFileData.getSize()); fullLocalFileData.setAuthor(designFileData.getAuthor()); fullLocalFileData.setModifiedAt(designFileData.getModifiedAt());