private LocalArtefactAPI getArtefactForChild(File child) { if (child.isDirectory()) { return new LocalFolderAPI(child, path.withSegment(child.getName()), workspace); } else { return new LocalResourceAPI(child, path.withSegment(child.getName()), workspace); } }
public LocalFolderAPI addFolder(String name) throws ProjectException { File newFolder = new File(source, name); if (!newFolder.mkdir() && !newFolder.exists()) { throw new ProjectException(String.format("Can't create the folder '%s'", newFolder.getAbsolutePath())); } LocalFolderAPI localFolder = new LocalFolderAPI(newFolder, path.withSegment(name), workspace); notifyModified(); return localFolder; }
public LocalResourceAPI addResource(String name, InputStream content) throws ProjectException { File newFile = new File(source, name); if (newFile.isFile()) { throw new ProjectException(String.format("The file '%s' exists in the folder.", newFile.getAbsolutePath()), new IOException()); } try { if (!newFile.createNewFile()) { throw new IOException(String.format("The file '%s' exists in the folder.", newFile.getAbsolutePath())); } LocalResourceAPI newResource = new LocalResourceAPI(newFile, path.withSegment(name), workspace); newResource.setContent(content); notifyModified(); return newResource; } catch (IOException e) { throw new ProjectException("Failed to create resource", e); } }
public JcrFolderAPI addFolder(String name) throws ProjectException { try { return JcrFolderAPI.createFolder(this, name, getArtefactPath().withSegment(name)); } catch (RepositoryException e) { throw new ProjectException(String.format("Failed to Create Sub Folder \"%s\". Reason: %s", name, e.getMessage()), e); } }
public JcrFolderAPI addFolder(String name) throws ProjectException { try { return JcrFolderAPI.createFolder(this, name, getArtefactPath().withSegment(name)); } catch (RepositoryException e) { throw new ProjectException(String.format("Failed to Create Sub Folder \"%s\". Reason: %s", name, e.getMessage()), e); } }
public JcrFileAPI addResource(String name, InputStream content) throws ProjectException { try { JcrFileAPI file = JcrFileAPI.createFile(this, name, getArtefactPath().withSegment(name)); file.setContent(content); return file; } catch (RepositoryException e) { throw new ProjectException(String.format("Failed to Create File \"%s\". Reason: %s", name, e.getMessage()), e); } }
public JcrFileAPI addResource(String name, InputStream content) throws ProjectException { try { JcrFileAPI file = JcrFileAPI.createFile(this, name, getArtefactPath().withSegment(name)); file.setContent(content); return file; } catch (RepositoryException e) { throw new ProjectException(String.format("Failed to Create File \"%s\". Reason: %s", name, e.getMessage()), e); } }
public JcrEntityAPI getArtefact(String name) throws ProjectException { try { Node n = node().getNode(name); boolean isFolder; if(isOldVersion()){ Node frozenNode = NodeUtil.normalizeOldNode(n, getVersion()); isFolder = frozenNode.getProperty("jcr:frozenPrimaryType").getString().equals(JcrNT.NT_FOLDER); n = frozenNode; }else{ isFolder = n.isNodeType(JcrNT.NT_FOLDER); } if (isFolder) { return new JcrFolderAPI(n, getArtefactPath().withSegment(name), isOldVersion()); } else { return new JcrFileAPI(n, getArtefactPath().withSegment(name), isOldVersion()); } } catch (RepositoryException e) { throw new ProjectException("Failed to list nodes.", e); } }
if (isFile) { if (listFiles) { list2add.add(new JcrFileAPI(n, getArtefactPath().withSegment(name), isOldVersion())); list2add.add(new JcrFolderAPI(n, getArtefactPath().withSegment(name), isOldVersion()));
public JcrEntityAPI getArtefact(String name) throws ProjectException { try { Node n = node().getNode(name); boolean isFolder; if(isOldVersion()){ Node frozenNode = NodeUtil.normalizeOldNode(n, getVersion()); isFolder = frozenNode.getProperty("jcr:frozenPrimaryType").getString().equals(JcrNT.NT_FOLDER); n = frozenNode; }else{ isFolder = n.isNodeType(JcrNT.NT_FOLDER); } if (isFolder) { return new JcrFolderAPI(n, getArtefactPath().withSegment(name), isOldVersion()); } else { return new JcrFileAPI(n, getArtefactPath().withSegment(name), isOldVersion()); } } catch (RepositoryException e) { throw new ProjectException("Failed to list nodes.", e); } }
if (isFile) { if (listFiles) { list2add.add(new JcrFileAPI(n, getArtefactPath().withSegment(name), isOldVersion())); list2add.add(new JcrFolderAPI(n, getArtefactPath().withSegment(name), isOldVersion()));