use of org.pentaho.platform.api.repository2.unified.RepositoryFileTree in project pentaho-platform by pentaho.
the class MockUnifiedRepository method getTree.
@Override
public RepositoryFileTree getTree(final String path, final int depth, final String filter, final boolean showHidden) {
FileRecord r = root.getFileRecord(path);
RepositoryFile rootFile = r.getFile();
if ((!showHidden && rootFile.isHidden()) || rootFile.isAclNode()) {
return null;
}
List<RepositoryFileTree> children;
if (depth != 0) {
children = new ArrayList<RepositoryFileTree>();
if (rootFile.isFolder()) {
List<RepositoryFile> childrenTmp = getChildren(rootFile.getId(), filter);
for (RepositoryFile child : childrenTmp) {
RepositoryFileTree repositoryFileTree = getTree(child.getPath(), depth - 1, filter, showHidden);
if (repositoryFileTree != null) {
children.add(repositoryFileTree);
}
}
}
Collections.sort(children);
} else {
children = null;
}
return new RepositoryFileTree(rootFile, children);
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFileTree in project pentaho-platform by pentaho.
the class JcrRepositoryFileDao method getTree.
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public RepositoryFileTree getTree(final String relPath, final int depth, final String filter, final boolean showHidden) {
Assert.hasText(relPath);
final RepositoryRequest repositoryRequest = new RepositoryRequest(relPath, showHidden, depth, filter);
return (RepositoryFileTree) jcrTemplate.execute(new JcrCallback() {
@Override
public Object doInJcr(final Session session) throws RepositoryException, IOException {
PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants(session);
String absPath = pathConversionHelper.relToAbs(relPath);
return JcrRepositoryFileUtils.getTree(session, pentahoJcrConstants, pathConversionHelper, lockHelper, absPath, repositoryRequest, accessVoterManager);
}
});
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFileTree in project pentaho-platform by pentaho.
the class JcrRepositoryFileUtils method checkNodeForTree.
/**
* This method is called twice by <code>getTreeNode</code>. It's job is to determine whether the current child node
* should be added to the list of children for the node being processed. It is a separate method simply because it is
* too much code to appear twice in the above <code>getTreeNode</code> method. It also makes the recursive call back
* to getTreeByNode to process the next lower level of folder node (it must process the lower levels to know if the
* folder should be added). Finally, it returns the foundFiltered boolean to let the caller know if a file was found
* that satisfied the childNodeFilter.
*/
static void checkNodeForTree(final Node childNode, List<RepositoryFileTree> children, final Session session, final PentahoJcrConstants pentahoJcrConstants, final IPathConversionHelper pathConversionHelper, final String childNodeFilter, final ILockHelper lockHelper, final int depth, final boolean showHidden, final IRepositoryAccessVoterManager accessVoterManager, RepositoryRequest.FILES_TYPE_FILTER types, MutableBoolean foundFiltered, boolean isRootFiltered, final boolean includeSystemFolders, final String rootPath) throws RepositoryException {
RepositoryFile file = nodeToFile(session, pentahoJcrConstants, pathConversionHelper, lockHelper, childNode);
if (isSupportedNodeType(pentahoJcrConstants, childNode)) {
RepositoryFileAcl fileAcl;
try {
fileAcl = JcrRepositoryFileAclUtils.getAcl(session, pentahoJcrConstants, file.getId());
} catch (AccessDeniedException e) {
return;
}
if (accessVoterManager.hasAccess(file, RepositoryFilePermission.READ, fileAcl, PentahoSessionHolder.getSession())) {
MutableBoolean foundFilteredAtomic = new MutableBoolean(!isPentahoFolder(pentahoJcrConstants, childNode));
RepositoryFileTree repositoryFileTree = getTreeByNode(session, pentahoJcrConstants, pathConversionHelper, lockHelper, childNode, depth - 1, childNodeFilter, showHidden, accessVoterManager, types, foundFilteredAtomic, includeSystemFolders, rootPath);
if (repositoryFileTree != null && (foundFilteredAtomic.booleanValue() || isRootFiltered)) {
foundFiltered.setValue(true);
children.add(repositoryFileTree);
}
}
}
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFileTree in project pentaho-platform by pentaho.
the class GeneratedContentCleaner method execute.
/*
* This method performs the actual work of the GeneratedContentCleaner by calling deleteFile with 'true' passed down
* for the 'permanent' flag.
*
* (non-Javadoc)
*
* @see org.pentaho.platform.api.action.IAction#execute()
*/
public void execute() throws Exception {
// scan the repository for all files with a RESERVEDMAPKEY_LINEAGE_ID
// we need to find and delete hidden generated files too (like .css and .png)
RepositoryFileTree tree = repository.getTree(ClientRepositoryPaths.getRootFolderPath(), -1, null, true);
ArrayList<RepositoryFile> generatedContentList = new ArrayList<RepositoryFile>();
findGeneratedContent(generatedContentList, tree);
for (RepositoryFile deleteMe : generatedContentList) {
repository.deleteFile(deleteMe.getId(), true, GeneratedContentCleaner.class.getName());
logger.info("GeneratedContentCleaner deleting: " + deleteMe.getPath());
}
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFileTree in project pentaho-platform by pentaho.
the class RepositoryFileTreeAdapter method unmarshal.
@Override
public RepositoryFileTree unmarshal(final RepositoryFileTreeDto v) {
List<RepositoryFileTree> children = null;
if (v.children != null) {
children = new ArrayList<RepositoryFileTree>();
for (RepositoryFileTreeDto child : v.children) {
children.add(unmarshal(child));
}
}
RepositoryFileTree repositoryFileTree = new RepositoryFileTree(RepositoryFileAdapter.toFile(v.file), children);
if (v.file.getVersioningEnabled() != null) {
repositoryFileTree.setVersioningEnabled(v.file.getVersioningEnabled());
}
if (v.file.getVersionCommentEnabled() != null) {
repositoryFileTree.setVersionCommentEnabled(v.file.getVersionCommentEnabled());
}
return repositoryFileTree;
}
Aggregations