Search in sources :

Example 11 with RepositoryFile

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;
}
Also used : RepositoryRequest(org.pentaho.platform.api.repository2.unified.RepositoryRequest) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile)

Example 12 with RepositoryFile

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;
}
Also used : ObjectId(org.pentaho.di.repository.ObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) StringObjectId(org.pentaho.di.repository.StringObjectId)

Example 13 with RepositoryFile

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);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) ArrayList(java.util.ArrayList) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) StringObjectId(org.pentaho.di.repository.StringObjectId) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) UnifiedRepositoryCreateFileException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryCreateFileException) UnifiedRepositoryUpdateFileException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryUpdateFileException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) KettleException(org.pentaho.di.core.exception.KettleException) IdNotFoundException(org.pentaho.di.core.exception.IdNotFoundException) KettleSecurityException(org.pentaho.di.core.exception.KettleSecurityException)

Example 14 with RepositoryFile

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;
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) ArrayList(java.util.ArrayList) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile)

Example 15 with RepositoryFile

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());
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) NodeRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile)

Aggregations

RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)455 Test (org.junit.Test)183 ITenant (org.pentaho.platform.api.mt.ITenant)87 Matchers.anyString (org.mockito.Matchers.anyString)86 ArrayList (java.util.ArrayList)85 RepositoryFileAcl (org.pentaho.platform.api.repository2.unified.RepositoryFileAcl)83 Serializable (java.io.Serializable)56 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)53 SimpleRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData)49 KettleException (org.pentaho.di.core.exception.KettleException)40 NodeRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData)40 ByteArrayInputStream (java.io.ByteArrayInputStream)39 UnifiedRepositoryException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryException)39 IOException (java.io.IOException)37 File (java.io.File)34 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)34 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)33 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)33 IdNotFoundException (org.pentaho.di.core.exception.IdNotFoundException)32 KettleFileException (org.pentaho.di.core.exception.KettleFileException)32