Search in sources :

Example 36 with RepositoryFile

use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.

the class PurRepository method loadRepositoryDirectoryTree.

@Deprecated
@Override
public RepositoryDirectoryInterface loadRepositoryDirectoryTree(boolean eager) throws KettleException {
    // this method forces a reload of the repository directory tree structure
    // a new rootRef will be obtained - this is a SoftReference which will be used
    // by any calls to getRootDir()
    RepositoryDirectoryInterface rootDir;
    if (eager) {
        RepositoryFileTree rootFileTree = loadRepositoryFileTree(ClientRepositoryPaths.getRootFolderPath());
        rootDir = initRepositoryDirectoryTree(rootFileTree);
    } else {
        RepositoryFile root = pur.getFile("/");
        rootDir = new LazyUnifiedRepositoryDirectory(root, null, pur, purRepositoryServiceRegistry);
    }
    rootRef.setRef(rootDir);
    return rootDir;
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) RepositoryFileTree(org.pentaho.platform.api.repository2.unified.RepositoryFileTree)

Example 37 with RepositoryFile

use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.

the class PurRepository method getClusterIDs.

@Override
public ObjectId[] getClusterIDs(boolean includeDeleted) throws KettleException {
    try {
        List<RepositoryFile> children = getAllFilesOfType(null, RepositoryObjectType.CLUSTER_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 cluster 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 38 with RepositoryFile

use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.

the class PurRepository method loadJobs.

/**
 * Load all jobs referenced by {@code files}.
 *
 * @param monitor
 * @param log
 * @param files
 *          Job files to load.
 * @param setInternalVariables
 *          Should internal variables be set when loading? (Note: THIS IS IGNORED, they are always set)
 * @return Loaded jobs
 * @throws KettleException
 *           Error loading data for jobs from repository
 */
protected List<JobMeta> loadJobs(final ProgressMonitorListener monitor, final LogChannelInterface log, final List<RepositoryFile> files, final boolean setInternalVariables) throws KettleException {
    List<JobMeta> jobs = new ArrayList<JobMeta>(files.size());
    List<NodeRepositoryFileData> filesData = pur.getDataForReadInBatch(files, NodeRepositoryFileData.class);
    List<VersionSummary> versions = pur.getVersionSummaryInBatch(files);
    Iterator<RepositoryFile> filesIter = files.iterator();
    Iterator<NodeRepositoryFileData> filesDataIter = filesData.iterator();
    Iterator<VersionSummary> versionsIter = versions.iterator();
    while ((monitor == null || !monitor.isCanceled()) && filesIter.hasNext()) {
        RepositoryFile file = filesIter.next();
        NodeRepositoryFileData fileData = filesDataIter.next();
        VersionSummary version = versionsIter.next();
        try {
            String dirPath = file.getPath().substring(0, file.getPath().lastIndexOf(RepositoryDirectory.DIRECTORY_SEPARATOR));
            log.logDetailed("Loading/Exporting job [{0} : {1}]  ({2})", dirPath, file.getTitle(), // $NON-NLS-1$
            file.getPath());
            if (monitor != null) {
                // $NON-NLS-1$ //$NON-NLS-2$
                monitor.subTask("Exporting job [" + file.getPath() + "]");
            }
            JobMeta jobMeta = buildJobMeta(file, findDirectory(dirPath), fileData, createObjectRevision(version));
            ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.JobMetaLoaded.id, jobMeta);
            jobs.add(jobMeta);
        } catch (Exception ex) {
            // $NON-NLS-1$ //$NON-NLS-2$
            log.logError("Unable to load job [" + file.getPath() + "]", ex);
        }
    }
    return jobs;
}
Also used : EEJobMeta(org.pentaho.di.repository.pur.model.EEJobMeta) JobMeta(org.pentaho.di.job.JobMeta) ArrayList(java.util.ArrayList) 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) NodeRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData) VersionSummary(org.pentaho.platform.api.repository2.unified.VersionSummary) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile)

Example 39 with RepositoryFile

use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.

the class PurRepository method getFilesByType.

/**
 * Fetch {@link RepositoryFile}s by {@code RepositoryObjectType}.
 *
 * @param allFiles
 *          List to add files into.
 * @param types
 *          Types of files to fetch
 * @return Ordered map of object types to list of files.
 * @throws KettleException
 */
private LinkedHashMap<RepositoryObjectType, List<RepositoryFile>> getFilesByType(List<RepositoryFile> allFiles, RepositoryObjectType... types) throws KettleException {
    // Must be ordered or we can't match up files with data and version summary
    LinkedHashMap<RepositoryObjectType, List<RepositoryFile>> filesByType = new LinkedHashMap<RepositoryObjectType, List<RepositoryFile>>();
    // Since type is not preserved in the RepositoryFile we must fetch files by type
    for (RepositoryObjectType type : types) {
        try {
            List<RepositoryFile> files = getAllFilesOfType(null, type, false);
            filesByType.put(type, files);
            allFiles.addAll(files);
        } catch (Exception ex) {
            // $NON-NLS-1$
            throw new KettleException(String.format("Unable to get all files of type [%s]", type), ex);
        }
    }
    return filesByType;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) List(java.util.List) ArrayList(java.util.ArrayList) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) 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) LinkedHashMap(java.util.LinkedHashMap)

Example 40 with RepositoryFile

use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.

the class PurRepository method loadTransformations.

/**
 * Load all transformations referenced by {@code files}.
 *
 * @param monitor
 * @param log
 * @param files
 *          Transformation files to load.
 * @param setInternalVariables
 *          Should internal variables be set when loading? (Note: THIS IS IGNORED, they are always set)
 * @return Loaded transformations
 * @throws KettleException
 *           Error loading data for transformations from repository
 */
protected List<TransMeta> loadTransformations(final ProgressMonitorListener monitor, final LogChannelInterface log, final List<RepositoryFile> files, final boolean setInternalVariables) throws KettleException {
    List<TransMeta> transformations = new ArrayList<TransMeta>(files.size());
    List<NodeRepositoryFileData> filesData = pur.getDataForReadInBatch(files, NodeRepositoryFileData.class);
    List<VersionSummary> versions = pur.getVersionSummaryInBatch(files);
    Iterator<RepositoryFile> filesIter = files.iterator();
    Iterator<NodeRepositoryFileData> filesDataIter = filesData.iterator();
    Iterator<VersionSummary> versionsIter = versions.iterator();
    while ((monitor == null || !monitor.isCanceled()) && filesIter.hasNext()) {
        RepositoryFile file = filesIter.next();
        NodeRepositoryFileData fileData = filesDataIter.next();
        VersionSummary version = versionsIter.next();
        String dirPath = file.getPath().substring(0, file.getPath().lastIndexOf(RepositoryDirectory.DIRECTORY_SEPARATOR));
        try {
            log.logDetailed("Loading/Exporting transformation [{0} : {1}]  ({2})", dirPath, file.getTitle(), file.getPath());
            if (monitor != null) {
                // $NON-NLS-1$ //$NON-NLS-2$
                monitor.subTask("Exporting transformation [" + file.getPath() + "]");
            }
            TransMeta transMeta = buildTransMeta(file, findDirectory(dirPath), fileData, createObjectRevision(version));
            ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.TransformationMetaLoaded.id, transMeta);
            transformations.add(transMeta);
        } catch (Exception ex) {
            // $NON-NLS-1$ //$NON-NLS-2$
            log.logDetailed("Unable to load transformation [" + file.getPath() + "]", ex);
            log.logError("An error occurred reading transformation [" + file.getTitle() + "] from directory [" + dirPath + "] : " + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            ex.getMessage());
            log.logError("Transformation [" + file.getTitle() + "] from directory [" + dirPath + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            "] was not exported because of a loading error!");
        }
    }
    return transformations;
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) EETransMeta(org.pentaho.di.repository.pur.model.EETransMeta) ArrayList(java.util.ArrayList) 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) NodeRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData) VersionSummary(org.pentaho.platform.api.repository2.unified.VersionSummary) 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