Search in sources :

Example 1 with RepositoryDirectory

use of org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryDirectory in project pentaho-kettle by pentaho.

the class RepositoryFileProvider method getFiles.

@Override
public List<RepositoryFile> getFiles(RepositoryFile file, String filters) {
    RepositoryDirectoryInterface repositoryDirectoryInterface = findDirectory(file.getType().equalsIgnoreCase(RepositoryDirectory.DIRECTORY) ? file.getPath() : file.getParent());
    RepositoryDirectory repositoryDirectory = RepositoryDirectory.build(null, repositoryDirectoryInterface);
    populateFolders(repositoryDirectory, repositoryDirectoryInterface);
    try {
        populateFiles(repositoryDirectory, repositoryDirectoryInterface, FILTER);
    } catch (KettleException ke) {
        ke.printStackTrace();
    }
    return repositoryDirectory.getChildren();
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) KettleException(org.pentaho.di.core.exception.KettleException) RepositoryDirectory(org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryDirectory)

Example 2 with RepositoryDirectory

use of org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryDirectory in project pentaho-kettle by pentaho.

the class RepositoryFileProvider method loadDirectoryTree.

public RepositoryTree loadDirectoryTree() {
    if (getRepository() != null) {
        try {
            if (getRepository() instanceof RepositoryExtended) {
                rootDirectory = ((RepositoryExtended) getRepository()).loadRepositoryDirectoryTree(false);
            } else {
                rootDirectory = getRepository().loadRepositoryDirectoryTree();
            }
            RepositoryTree repositoryTree = new RepositoryTree(null);
            RepositoryDirectory repositoryDirectory = RepositoryDirectory.build(null, rootDirectory);
            populateFolders(repositoryDirectory, rootDirectory);
            boolean isPentahoRepository = getRepository().getRepositoryMeta().getId().equals(PENTAHO_ENTERPRISE_REPOSITORY);
            if (!isPentahoRepository) {
                populateFiles(repositoryDirectory, rootDirectory, FILTER);
            }
            for (RepositoryFile child : repositoryDirectory.getChildren()) {
                repositoryTree.addChild(child);
            }
            return repositoryTree;
        } catch (Exception e) {
            return null;
        }
    }
    return null;
}
Also used : RepositoryDirectory(org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryDirectory) RepositoryExtended(org.pentaho.di.repository.RepositoryExtended) RepositoryTree(org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryTree) RepositoryFile(org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryFile) KettleException(org.pentaho.di.core.exception.KettleException) InvalidFileTypeException(org.pentaho.di.plugins.fileopensave.api.providers.exception.InvalidFileTypeException) FileException(org.pentaho.di.plugins.fileopensave.api.providers.exception.FileException) KettleObjectExistsException(org.pentaho.di.core.exception.KettleObjectExistsException) KettleTransException(org.pentaho.di.core.exception.KettleTransException) KettleJobException(org.pentaho.di.core.exception.KettleJobException) InvalidFileOperationException(org.pentaho.di.plugins.fileopensave.api.providers.exception.InvalidFileOperationException) FileExistsException(org.pentaho.di.plugins.fileopensave.api.providers.exception.FileExistsException)

Example 3 with RepositoryDirectory

use of org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryDirectory in project pentaho-kettle by pentaho.

the class RepositoryFileProvider method getParent.

@Override
public RepositoryFile getParent(RepositoryFile file) {
    RepositoryDirectory repositoryDirectory = new RepositoryDirectory();
    repositoryDirectory.setPath(file.getParent());
    return repositoryDirectory;
}
Also used : RepositoryDirectory(org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryDirectory)

Example 4 with RepositoryDirectory

use of org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryDirectory in project pentaho-kettle by pentaho.

the class RepositoryFileProvider method add.

@Override
public RepositoryFile add(RepositoryFile folder) throws FileException {
    if (hasDupeFolder(folder.getParent(), folder.getName())) {
        throw new FileExistsException();
    }
    try {
        RepositoryDirectoryInterface repositoryDirectoryInterface = getRepository().createRepositoryDirectory(findDirectory(folder.getParent()), folder.getName());
        RepositoryDirectory repositoryDirectory = new RepositoryDirectory();
        repositoryDirectory.setName(repositoryDirectoryInterface.getName());
        repositoryDirectory.setPath(repositoryDirectoryInterface.getPath());
        repositoryDirectory.setObjectId(repositoryDirectoryInterface.getObjectId().getId());
        repositoryDirectory.setParent(folder.getParent());
        return RepositoryDirectory.build(folder.getPath(), repositoryDirectoryInterface);
    } catch (Exception e) {
        return null;
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) RepositoryDirectory(org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryDirectory) KettleException(org.pentaho.di.core.exception.KettleException) InvalidFileTypeException(org.pentaho.di.plugins.fileopensave.api.providers.exception.InvalidFileTypeException) FileException(org.pentaho.di.plugins.fileopensave.api.providers.exception.FileException) KettleObjectExistsException(org.pentaho.di.core.exception.KettleObjectExistsException) KettleTransException(org.pentaho.di.core.exception.KettleTransException) KettleJobException(org.pentaho.di.core.exception.KettleJobException) InvalidFileOperationException(org.pentaho.di.plugins.fileopensave.api.providers.exception.InvalidFileOperationException) FileExistsException(org.pentaho.di.plugins.fileopensave.api.providers.exception.FileExistsException) FileExistsException(org.pentaho.di.plugins.fileopensave.api.providers.exception.FileExistsException)

Example 5 with RepositoryDirectory

use of org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryDirectory in project pentaho-kettle by pentaho.

the class RepositoryFileProvider method populateFoldersLazy.

public void populateFoldersLazy(RepositoryDirectory repositoryDirectory) {
    RepositoryRequest repositoryRequest = new RepositoryRequest(repositoryDirectory.getPath(), true, 1, null);
    repositoryRequest.setTypes(RepositoryRequest.FILES_TYPE_FILTER.FOLDERS);
    repositoryRequest.setIncludeSystemFolders(false);
    RepositoryFileTree tree = getRepository().getUnderlyingRepository().getTree(repositoryRequest);
    for (RepositoryFileTree repositoryFileTree : tree.getChildren()) {
        org.pentaho.platform.api.repository2.unified.RepositoryFile repositoryFile = repositoryFileTree.getFile();
        RepositoryDirectory repositoryDirectory1 = RepositoryDirectory.build(repositoryDirectory.getPath(), repositoryFile, isAdmin());
        repositoryDirectory.addChild(repositoryDirectory1);
    }
}
Also used : RepositoryDirectory(org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryDirectory) RepositoryRequest(org.pentaho.platform.api.repository2.unified.RepositoryRequest) RepositoryFileTree(org.pentaho.platform.api.repository2.unified.RepositoryFileTree)

Aggregations

RepositoryDirectory (org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryDirectory)6 KettleException (org.pentaho.di.core.exception.KettleException)3 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)3 KettleJobException (org.pentaho.di.core.exception.KettleJobException)2 KettleObjectExistsException (org.pentaho.di.core.exception.KettleObjectExistsException)2 KettleTransException (org.pentaho.di.core.exception.KettleTransException)2 FileException (org.pentaho.di.plugins.fileopensave.api.providers.exception.FileException)2 FileExistsException (org.pentaho.di.plugins.fileopensave.api.providers.exception.FileExistsException)2 InvalidFileOperationException (org.pentaho.di.plugins.fileopensave.api.providers.exception.InvalidFileOperationException)2 InvalidFileTypeException (org.pentaho.di.plugins.fileopensave.api.providers.exception.InvalidFileTypeException)2 RepositoryFile (org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryFile)2 RepositoryExtended (org.pentaho.di.repository.RepositoryExtended)2 ArrayList (java.util.ArrayList)1 RepositoryTree (org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryTree)1 RepositoryObject (org.pentaho.di.repository.RepositoryObject)1 RepositoryObjectInterface (org.pentaho.di.repository.RepositoryObjectInterface)1 RepositoryFileTree (org.pentaho.platform.api.repository2.unified.RepositoryFileTree)1 RepositoryRequest (org.pentaho.platform.api.repository2.unified.RepositoryRequest)1