public void renameFile(String path, String newPath) { try { String workspacePathOld = RCPWorkspaceMapper.getMappedName(path); String workspacePathNew = RCPWorkspaceMapper.getMappedName(newPath); FileUtils.moveFile(workspacePathOld, workspacePathNew); } catch (IOException e) { throw new RCPBaseException(e); } }
public static void zip(List<String> inputFolders, ZipOutputStream zipOutputStream) throws IOException { for (String inputFolder : inputFolders) { String workspaceFolder = RCPWorkspaceMapper.getMappedName(inputFolder); zip(workspaceFolder, zipOutputStream); } }
public RCPObject getObjectByPath(String path) { RCPObject rcpObject = null; try { String workspacePath = RCPWorkspaceMapper.getMappedName(path); File objectFile = new File(workspacePath); if (!objectFile.exists()) { // This is folder, that was not created if (ContentTypeHelper.getExtension(workspacePath).isEmpty()) { FileUtils.createFolder(workspacePath); } } if (objectFile.isFile()) { String contentType = ContentTypeHelper.getContentType(FileUtils.getExtension(workspacePath)); rcpObject = new RCPFile(repository, ContentTypeHelper.isBinary(contentType), contentType); // FileUtils.createFile(workspacePath); } else { rcpObject = new RCPFolder(repository); // FileUtils.createFolder(workspacePath); } rcpObject.setName(objectFile.getName()); rcpObject.setPath(workspacePath); // TODO createBy and createAt exists? rcpObject.setCreatedBy(FileUtils.getOwner(workspacePath)); rcpObject.setCreatedAt(FileUtils.getModifiedAt(workspacePath)); rcpObject.setModifiedBy(FileUtils.getOwner(workspacePath)); rcpObject.setModifiedAt(FileUtils.getModifiedAt(workspacePath)); } catch (IOException e) { throw new RCPBaseException(e); } return rcpObject; }
public void createFolder(String normalizePath) { try { String workspacePath = RCPWorkspaceMapper.getMappedName(normalizePath); FileUtils.createFolder(workspacePath); } catch (IOException e) { throw new RCPBaseException(e); } }
public void removeFolderByPath(String path) { try { String workspacePath = RCPWorkspaceMapper.getMappedName(path); FileUtils.removeFile(workspacePath); } catch (IOException e) { throw new RCPBaseException(e); } }
public byte[] getFileContent(RCPFile rcpFile) { try { String workspacePath = RCPWorkspaceMapper.getMappedName(rcpFile.getPath()); return FileUtils.loadFile(workspacePath); } catch (IOException e) { throw new RCPBaseException(e); } }
public void setFileContent(RCPFile rcpFile, byte[] content) { try { String workspacePath = RCPWorkspaceMapper.getMappedName(rcpFile.getPath()); FileUtils.saveFile(workspacePath, content); } catch (IOException e) { throw new RCPBaseException(e); } }
public void createFile(String path, byte[] content, boolean isBinary, String contentType) throws RCPBaseException { try { String workspacePath = RCPWorkspaceMapper.getMappedName(path); FileUtils.saveFile(workspacePath, content); } catch (IOException e) { throw new RCPBaseException(e); } }
public List<RCPObject> getChildrenByFolder(String path) { List<RCPObject> rcpObjects = new ArrayList<RCPObject>(); try { String workspacePath = RCPWorkspaceMapper.getMappedName(path); File objectFile = new File(workspacePath); if (objectFile.isDirectory()) { File[] children = objectFile.listFiles(); if (children != null) { for (File file : children) { rcpObjects.add(getObjectByPath(file.getCanonicalPath())); } } } } catch (IOException e) { throw new RCPBaseException(e); } return rcpObjects; }