Search in sources :

Example 76 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class KettleFileRepository method createRepositoryDirectory.

@Override
public RepositoryDirectoryInterface createRepositoryDirectory(RepositoryDirectoryInterface parentDirectory, String directoryPath) throws KettleException {
    String folder = calcDirectoryName(parentDirectory);
    String newFolder = folder;
    if (folder.endsWith("/")) {
        newFolder += directoryPath;
    } else {
        newFolder += "/" + directoryPath;
    }
    FileObject parent = KettleVFS.getFileObject(newFolder);
    try {
        parent.createFolder();
    } catch (FileSystemException e) {
        throw new KettleException("Unable to create folder " + newFolder, e);
    }
    // Incremental change of the directory structure...
    // 
    RepositoryDirectory newDir = new RepositoryDirectory(parentDirectory, directoryPath);
    parentDirectory.addSubdirectory(newDir);
    newDir.setObjectId(new StringObjectId(calcObjectId(newDir)));
    return newDir;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) FileSystemException(org.apache.commons.vfs2.FileSystemException) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) FileObject(org.apache.commons.vfs2.FileObject) StringObjectId(org.pentaho.di.repository.StringObjectId)

Example 77 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class KettleFileRepository method loadRepositoryDirectoryTree.

public RepositoryDirectoryInterface loadRepositoryDirectoryTree(RepositoryDirectoryInterface dir) throws KettleException {
    try {
        String folderName = calcDirectoryName(dir);
        FileObject folder = KettleVFS.getFileObject(folderName);
        for (FileObject child : folder.getChildren()) {
            if (child.getType().equals(FileType.FOLDER)) {
                if (!child.isHidden() || !repositoryMeta.isHidingHiddenFiles()) {
                    if (!".meta".equals(child.getName().getBaseName())) {
                        RepositoryDirectory subDir = new RepositoryDirectory(dir, child.getName().getBaseName());
                        subDir.setObjectId(new StringObjectId(calcObjectId(subDir)));
                        dir.addSubdirectory(subDir);
                        loadRepositoryDirectoryTree(subDir);
                    }
                }
            }
        }
        return dir;
    } catch (Exception e) {
        throw new KettleException("Unable to load the directory tree from this file repository", e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) FileObject(org.apache.commons.vfs2.FileObject) StringObjectId(org.pentaho.di.repository.StringObjectId) KettleFileException(org.pentaho.di.core.exception.KettleFileException) FileSystemException(org.apache.commons.vfs2.FileSystemException) KettleException(org.pentaho.di.core.exception.KettleException) IOException(java.io.IOException)

Example 78 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryMetaStore method deleteElementType.

@Override
public void deleteElementType(String namespace, IMetaStoreElementType elementType) throws MetaStoreException, MetaStoreDependenciesExistsException {
    try {
        Collection<RowMetaAndData> elementTypeRows = delegate.getElements(new LongObjectId(new StringObjectId(elementType.getId())));
        if (!elementTypeRows.isEmpty()) {
            List<String> dependencies = new ArrayList<String>();
            for (RowMetaAndData elementTypeRow : elementTypeRows) {
                Long elementTypeId = elementTypeRow.getInteger(KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_ELEMENT_TYPE);
                dependencies.add(Long.toString(elementTypeId));
            }
            throw new MetaStoreDependenciesExistsException(dependencies, "The namespace to delete, '" + namespace + "' is not empty");
        }
        delegate.deleteElementType(new LongObjectId(new StringObjectId(elementType.getId())));
        repository.commit();
    } catch (MetaStoreDependenciesExistsException e) {
        throw e;
    } catch (Exception e) {
        repository.rollback();
        throw new MetaStoreException(e);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ArrayList(java.util.ArrayList) LongObjectId(org.pentaho.di.repository.LongObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) MetaStoreElementExistException(org.pentaho.metastore.api.exceptions.MetaStoreElementExistException) MetaStoreElementTypeExistsException(org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)

Example 79 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryMetaStore method deleteElement.

@Override
public void deleteElement(String namespace, IMetaStoreElementType elementType, String elementId) throws MetaStoreException {
    try {
        IMetaStoreElementType type = getElementTypeByName(namespace, elementType.getName());
        if (type == null) {
            throw new MetaStoreException("Unable to find element type with name '" + elementType.getName() + "'");
        }
        delegate.deleteElement(new LongObjectId(new StringObjectId(elementId)));
        repository.commit();
    } catch (Exception e) {
        repository.rollback();
        throw new MetaStoreException("Unable to delete element with id '" + elementId + "' of type '" + elementType.getName() + "'", e);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) LongObjectId(org.pentaho.di.repository.LongObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) MetaStoreElementExistException(org.pentaho.metastore.api.exceptions.MetaStoreElementExistException) MetaStoreElementTypeExistsException(org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)

Example 80 with StringObjectId

use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositorySecurityProviderTest method testSaveUserInfo_Passes.

private void testSaveUserInfo_Passes(String login, String expectedLogin, String existing) throws Exception {
    doReturn(new StringObjectId(existing)).when(repository.userDelegate).getUserID(eq(existing));
    provider.saveUserInfo(new UserInfo(login));
    ArgumentCaptor<UserInfo> captor = ArgumentCaptor.forClass(UserInfo.class);
    verify(repository.userDelegate).saveUserInfo(captor.capture());
    assertEquals("UserInfo should be passed", expectedLogin, captor.getValue().getLogin());
}
Also used : UserInfo(org.pentaho.di.repository.UserInfo) StringObjectId(org.pentaho.di.repository.StringObjectId)

Aggregations

StringObjectId (org.pentaho.di.repository.StringObjectId)123 KettleException (org.pentaho.di.core.exception.KettleException)49 ObjectId (org.pentaho.di.repository.ObjectId)38 Test (org.junit.Test)34 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)25 KettleFileException (org.pentaho.di.core.exception.KettleFileException)21 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)18 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)18 ArrayList (java.util.ArrayList)16 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)15 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)14 RepositoryObject (org.pentaho.di.repository.RepositoryObject)14 TransMeta (org.pentaho.di.trans.TransMeta)14 IdNotFoundException (org.pentaho.di.core.exception.IdNotFoundException)13 KettleSecurityException (org.pentaho.di.core.exception.KettleSecurityException)13 UnifiedRepositoryCreateFileException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryCreateFileException)13 UnifiedRepositoryUpdateFileException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryUpdateFileException)13 Repository (org.pentaho.di.repository.Repository)11 IOException (java.io.IOException)10 FileObject (org.apache.commons.vfs2.FileObject)10