use of org.pentaho.platform.api.repository2.unified.RepositoryRequest in project pentaho-kettle by pentaho.
the class PurRepository method getChildren.
@Override
public List<RepositoryObjectInterface> getChildren(String path, String filter) {
RepositoryRequest repoRequest = new RepositoryRequest();
repoRequest.setDepth(-1);
repoRequest.setChildNodeFilter("*" + filter + "*");
repoRequest.setIncludeAcls(false);
repoRequest.setTypes(FILES_TYPE_FILTER.FILES_FOLDERS);
repoRequest.setPath(path);
repoRequest.setShowHidden(false);
readWriteLock.readLock().lock();
List<RepositoryFile> repositoryFiles;
try {
repositoryFiles = pur.getChildren(repoRequest);
} finally {
readWriteLock.readLock().unlock();
}
List<RepositoryObjectInterface> repositoryElementInterfaces = new ArrayList<>();
for (RepositoryFile repositoryFile : repositoryFiles) {
if (repositoryFile.isFolder()) {
RepositoryDirectoryInterface repositoryDirectory = new RepositoryDirectory();
repositoryDirectory.setName(repositoryFile.getName());
repositoryDirectory.setObjectId(() -> repositoryFile.getId().toString());
repositoryElementInterfaces.add(repositoryDirectory);
} else {
RepositoryObject repositoryObject = new RepositoryObject();
repositoryObject.setName(repositoryFile.getName());
repositoryObject.setObjectId(() -> repositoryFile.getId().toString());
RepositoryObjectType repositoryObjectType = RepositoryObjectType.UNKNOWN;
if (repositoryFile.getName().endsWith(".ktr")) {
repositoryObjectType = RepositoryObjectType.TRANSFORMATION;
}
if (repositoryFile.getName().endsWith(".kjb")) {
repositoryObjectType = RepositoryObjectType.JOB;
}
repositoryObject.setObjectType(repositoryObjectType);
repositoryElementInterfaces.add(repositoryObject);
}
}
return repositoryElementInterfaces;
}
use of org.pentaho.platform.api.repository2.unified.RepositoryRequest in project pentaho-kettle by pentaho.
the class LazyUnifiedRepositoryDirectory method getAllURChildrenFiles.
private List<RepositoryFile> getAllURChildrenFiles() {
RepositoryRequest repositoryRequest = new RepositoryRequest();
repositoryRequest.setShowHidden(showHidden);
repositoryRequest.setTypes(RepositoryRequest.FILES_TYPE_FILTER.FOLDERS);
repositoryRequest.setPath(this.self.getId().toString());
List<RepositoryFile> children = repository.getChildren(repositoryRequest);
// Special case: /etc should not be returned from a directory listing.
RepositoryFile etcFile = null;
if (this.isRoot()) {
etcFile = repository.getFile(ClientRepositoryPaths.getEtcFolderPath());
}
// Filter for Folders only doesn't appear to work
Iterator<RepositoryFile> iterator = children.iterator();
while (iterator.hasNext()) {
RepositoryFile next = iterator.next();
if (!next.isFolder()) {
iterator.remove();
}
// Special case: /etc should not be returned from a directory listing.
if (this.isRoot() && next.equals(etcFile)) {
iterator.remove();
}
}
return children;
}
use of org.pentaho.platform.api.repository2.unified.RepositoryRequest in project pentaho-kettle by pentaho.
the class LazyUnifiedRepositoryDirectory method getRepositoryObjects.
@Override
public List<RepositoryElementMetaInterface> getRepositoryObjects() {
if (fileChildren == null) {
fileChildren = new ArrayList<>();
synchronized (fileChildren) {
UnifiedRepositoryLockService lockService = (UnifiedRepositoryLockService) registry.getService(ILockService.class);
RepositoryFileTree tree = repository.getTree(new RepositoryRequest(this.self.getPath(), showHidden, 1, null));
for (RepositoryFileTree tchild : tree.getChildren()) {
RepositoryFile child = tchild.getFile();
if (!child.isFolder()) {
RepositoryLock lock = null;
try {
lock = lockService.getLock(child);
RepositoryObjectType objectType = PurRepository.getObjectType(child.getName());
EERepositoryObject repositoryObject = new EERepositoryObject(child, this, null, objectType, null, lock, false);
repositoryObject.setVersioningEnabled(tchild.getVersioningEnabled());
repositoryObject.setVersionCommentEnabled(tchild.getVersionCommentEnabled());
fileChildren.add(repositoryObject);
} catch (KettleException e) {
logger.error("Error converting Unified Repository file to PDI RepositoryObject: " + child.getPath() + ". File will be skipped", e);
}
}
}
}
}
return fileChildren;
}
use of org.pentaho.platform.api.repository2.unified.RepositoryRequest in project pentaho-kettle by pentaho.
the class UnifiedRepositoryPurgeService method processRevisionDeletion.
private void processRevisionDeletion(PurgeUtilitySpecification purgeSpecification) throws PurgeDeletionException {
RepositoryRequest repositoryRequest = new RepositoryRequest(purgeSpecification.getPath(), true, -1, purgeSpecification.getFileFilter());
repositoryRequest.setTypes(FILES_TYPE_FILTER.FILES_FOLDERS);
repositoryRequest.setIncludeMemberSet(new HashSet<String>(Arrays.asList(new String[] { "name", "id", "folder", "path", "versioned", "versionId", "locked" })));
getLogger().debug("Creating file list");
RepositoryFileTreeDto tree = getRepoWs().getTreeFromRequest(repositoryRequest);
processPurgeForTree(tree, purgeSpecification);
}
use of org.pentaho.platform.api.repository2.unified.RepositoryRequest in project pentaho-kettle by pentaho.
the class PurRepository method loadRepositoryFileTree.
private RepositoryFileTree loadRepositoryFileTree(String path, String filter, int depth, boolean showHidden, boolean includeAcls, FILES_TYPE_FILTER types) {
RepositoryRequest repoRequest = new RepositoryRequest();
repoRequest.setPath(Utils.isEmpty(path) ? "/" : path);
repoRequest.setChildNodeFilter(filter == null ? "*" : filter);
repoRequest.setDepth(depth);
repoRequest.setShowHidden(showHidden);
repoRequest.setIncludeAcls(includeAcls);
repoRequest.setTypes(types == null ? FILES_TYPE_FILTER.FILES_FOLDERS : types);
readWriteLock.readLock().lock();
RepositoryFileTree fileTree;
try {
fileTree = pur.getTree(repoRequest);
} finally {
readWriteLock.readLock().unlock();
}
return fileTree;
}
Aggregations