use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.
the class LazyUnifiedRepositoryDirectory method getAllURChildrenFiles.
private List<RepositoryFile> getAllURChildrenFiles() {
RepositoryRequest repositoryRequest = new RepositoryRequest();
repositoryRequest.setShowHidden(true);
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.RepositoryFile in project pentaho-kettle by pentaho.
the class LazyUnifiedRepositoryDirectory method getDirectoryIDs.
@Override
public ObjectId[] getDirectoryIDs() {
List<RepositoryFile> children = this.getAllURChildrenFiles();
ObjectId[] objectIds = new ObjectId[children.size()];
for (int i = 0; i < children.size(); i++) {
objectIds[i] = new StringObjectId(children.get(i).getId().toString());
}
return objectIds;
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.
the class PurRepository method getPartitionSchemaIDs.
@Override
public ObjectId[] getPartitionSchemaIDs(boolean includeDeleted) throws KettleException {
try {
List<RepositoryFile> children = getAllFilesOfType(null, RepositoryObjectType.PARTITION_SCHEMA, includeDeleted);
List<ObjectId> ids = new ArrayList<ObjectId>();
for (RepositoryFile file : children) {
ids.add(new StringObjectId(file.getId().toString()));
}
return ids.toArray(new ObjectId[0]);
} catch (Exception e) {
throw new KettleException("Unable to get all partition schema IDs", e);
}
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.
the class PurRepositoryMetaStore method getElementTypes.
@Override
public List<IMetaStoreElementType> getElementTypes(String namespace) throws MetaStoreException {
List<IMetaStoreElementType> elementTypes = new ArrayList<IMetaStoreElementType>();
RepositoryFile namespaceFile = validateNamespace(namespace);
List<RepositoryFile> children = getChildren(namespaceFile.getId());
for (RepositoryFile child : children) {
if (!child.isHidden()) {
elementTypes.add(getElementType(namespace, child.getId().toString()));
}
}
return elementTypes;
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.
the class PurRepositoryMetaStore method updateElement.
@Override
public synchronized void updateElement(String namespace, IMetaStoreElementType elementType, String elementId, IMetaStoreElement element) throws MetaStoreException {
//
if (elementType.getMetaStoreName() == null || !elementType.getName().equals(getName())) {
String elementTypeName = elementType.getName();
elementType = getElementTypeByName(namespace, elementTypeName);
if (elementType == null) {
throw new MetaStoreException("The element type '" + elementTypeName + "' could not be found in the meta store in which you are updating.");
}
}
RepositoryFile existingFile = pur.getFileById(elementId);
if (existingFile == null) {
throw new MetaStoreException("The element to update with id " + elementId + " could not be found in the store");
}
DataNode elementDataNode = new DataNode(PurRepository.checkAndSanitize(element.getName()));
elementToDataNode(element, elementDataNode);
RepositoryFile updatedFile = pur.updateFile(existingFile, new NodeRepositoryFileData(elementDataNode), null);
element.setId(updatedFile.getId().toString());
}
Aggregations