@Override public void setSize(long size) { verifyInitialized(); super.setSize(size); }
private FileData createFileData(ResultSet rs) throws SQLException { FileData fileData = new FileData(); fileData.setName(rs.getString("file_name")); fileData.setSize(rs.getLong("file_size")); fileData.setAuthor(rs.getString("author")); fileData.setComment(rs.getString("file_comment")); fileData.setModifiedAt(rs.getTimestamp("modified_at")); fileData.setVersion(rs.getString("id")); fileData.setDeleted(rs.getBoolean("deleted")); return fileData; }
private FileData getFileData(File file) throws IOException { if (!file.exists()) { throw new FileNotFoundException("File [" + file + "] does not exist."); } if (rootPathLength == 0) { init(); } FileData data = new FileData(); String canonicalPath = file.getCanonicalPath(); String relativePath = canonicalPath.substring(rootPathLength); String converted = relativePath.replace('\\', '/'); data.setName(converted); long timestamp = file.lastModified(); Date date = new Date(timestamp); data.setModifiedAt(date); if (file.isFile()) { long size = file.length(); data.setSize(size); } return data; }
private FileData getFileData(File file) throws IOException { if (!file.exists()) { throw new FileNotFoundException("File [" + file + "] does not exist."); } if (!file.isFile()) { throw new FileNotFoundException("File [" + file + "] is not a file."); } if (rootPathLength == 0) { init(); } FileData data = new FileData(); String canonicalPath = file.getCanonicalPath(); String relativePath = canonicalPath.substring(rootPathLength); String converted = relativePath.replace('\\', '/'); data.setName(converted); long timestamp = file.lastModified(); Date date = new Date(timestamp); data.setModifiedAt(date); long size = file.length(); data.setSize(size); return data; }
private FileData createFileData(ZipEntry entry) { FileData fileData = new FileData(); fileData.setName(zipPath + "/" + entry.getName()); fileData.setSize(entry.getSize()); fileData.setModifiedAt(new Date(entry.getTime())); fileData.setComment(entry.getComment()); return fileData; } }
private FileData createFileData(ResultSet rs) throws SQLException { FileData fileData = new FileData(); fileData.setName(rs.getString("file_name")); fileData.setSize(rs.getLong("file_size")); fileData.setAuthor(rs.getString("author")); fileData.setComment(rs.getString("file_comment")); fileData.setModifiedAt(rs.getTimestamp("modified_at")); fileData.setVersion(rs.getString("id")); fileData.setDeleted(rs.getBoolean("deleted")); return fileData; }
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); } }
fileData.setAuthor(author); fileData.setModifiedAt(new SimpleDateFormat(DATE_FORMAT).parse(modifiedAt)); fileData.setSize(Long.parseLong(size)); fileData.setComment(comment);
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); 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); } }
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());
private FileData createFileData(String name, ArtefactAPI project) throws PropertyException { FileData fileData = new FileData(); fileData.setName(name); // It's impossible to calculate zip size if project contains artefacts if (((FolderAPI) project).getArtefacts().size() == 0) { fileData.setSize(0); } fileData.setDeleted(project.hasProperty(ArtefactProperties.PROP_PRJ_MARKED_4_DELETION)); if (project.hasProperty(ArtefactProperties.VERSION_COMMENT)) { Property property = project.getProperty(ArtefactProperties.VERSION_COMMENT); fileData.setComment(property.getString()); } ProjectVersion version = project.getVersion(); fileData.setAuthor(version.getVersionInfo().getCreatedBy()); fileData.setModifiedAt(version.getVersionInfo().getCreatedAt()); fileData.setVersion(String.valueOf(version.getRevision())); return fileData; }
private FileData createFileData(String name, ArtefactAPI project) throws PropertyException { FileData fileData = new FileData(); fileData.setName(name); // It's impossible to calculate zip size if project contains artefacts if (((FolderAPI) project).getArtefacts().size() == 0) { fileData.setSize(0); } fileData.setDeleted(project.hasProperty(ArtefactProperties.PROP_PRJ_MARKED_4_DELETION)); if (project.hasProperty(ArtefactProperties.VERSION_COMMENT)) { Property property = project.getProperty(ArtefactProperties.VERSION_COMMENT); fileData.setComment(property.getString()); } ProjectVersion version = project.getVersion(); fileData.setAuthor(version.getVersionInfo().getCreatedBy()); fileData.setModifiedAt(version.getVersionInfo().getCreatedAt()); fileData.setVersion(String.valueOf(version.getRevision())); return fileData; }
private FileData createFileData(S3VersionSummary latest) { FileData data = latest.isDeleteMarker() ? new FileData() : new LazyFileData(s3, bucketName); data.setName(latest.getKey()); data.setSize(latest.getSize()); data.setModifiedAt(latest.getLastModified()); data.setVersion(latest.getVersionId()); data.setDeleted(latest.isDeleteMarker()); return data; }
fileData.setSize(loader.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()); } } }
fullLocalFileData.setName(localFileData.getName()); fullLocalFileData.setVersion(designFileData.getVersion()); fullLocalFileData.setSize(designFileData.getSize()); fullLocalFileData.setAuthor(designFileData.getAuthor()); fullLocalFileData.setModifiedAt(designFileData.getModifiedAt());