protected RepositoryFile getTopFolder() { RepositoryFile topFolder = parent; if (topFolder == null) { return this; } while (!topFolder.isRoot()) { topFolder = (RepositoryFile) topFolder.retrieveParent(); } return topFolder; }
/** * Chains up to find the access controls that are in force on this object. Could end up chaining * all the way to the root. * * <p>Note that (1) defining no access control entries of your own and (2) removing all of your * access control entries is indistiguishable in the current design. In #1, we chain up because we * inherit. But in #2, it might be expected that by explicitly removing all access control * entries, the chaining up ends. That is not the case in the current design. */ public List<IPentahoAclEntry> getEffectiveAccessControls() { List acls = this.getAccessControls(); if (acls.size() == 0) { RepositoryFile chain = this; while (!chain.isRoot() && (acls.size() == 0)) { chain = (RepositoryFile) chain.retrieveParent(); acls = chain.getAccessControls(); } } return acls; }
@Override public boolean equals(final Object other) { if (this == other) { return true; } if (!(other instanceof RepositoryFile)) { return false; } final RepositoryFile that = (RepositoryFile) other; return getFileId().equals(that.getFileId()); }
public boolean containsActions() { boolean hasActions = false; if (this.isDirectory()) { Set children = getChildrenFiles(); Iterator iter = children.iterator(); while (iter.hasNext() && !hasActions) { RepositoryFile file = (RepositoryFile) iter.next(); hasActions = file.getFileName().toLowerCase().endsWith(".xaction"); // $NON-NLS-1$ } } return hasActions; }
public int compareTo(final Object o) { if (o == null) { return 1; } else if (o instanceof RepositoryFile) { RepositoryFile that = (RepositoryFile) o; if ((this.getFullPath() == null) && (that.getFullPath() == null)) { return 0; } else if ((this.getFullPath() == null) && (that.getFullPath() != null)) { return -1; } else if ((this.getFullPath() != null) && (that.getFullPath() == null)) { return 1; } else { return this.getFullPath().compareTo(((RepositoryFile) o).getFullPath()); } } else { return this.getFullPath().compareTo(o.toString()); } }
protected void resolvePath() { StringBuffer buffer = new StringBuffer(RepositoryFile.EMPTY_STRING); if (parent != null) { buffer.append(parent.getFullPath()); } buffer.append(org.pentaho.platform.api.repository2.unified.RepositoryFile.SEPARATOR); buffer.append(fileName); setFullPath(buffer.toString()); }
public RepositoryFile( final String fileName, final RepositoryFile parent, final byte[] data, final long lastModified) { this(); this.fileId = UUIDUtil.getUUIDAsString(); this.fileName = fileName; if (parent != null) { parent.addChildFile(this); } setParent(parent); setData(data); setLastModified(lastModified); directory = data == null; }
public void removeChildFile(final RepositoryFile file) { getChildrenFiles().remove(file); file.setParent(null); // as of now this file has no parent. }