Search in sources :

Example 1 with IdNotFoundException

use of org.pentaho.di.core.exception.IdNotFoundException in project pentaho-kettle by pentaho.

the class JobMeta method lookupRepositoryReferences.

/**
 * Look up the references after import
 *
 * @param repository the repository to reference.
 */
public void lookupRepositoryReferences(Repository repository) throws KettleException {
    KettleException lastThrownException = null;
    Map<String, RepositoryObjectType> notFoundedReferences = new HashMap<>();
    for (JobEntryCopy copy : jobcopies) {
        if (copy.getEntry().hasRepositoryReferences()) {
            try {
                copy.getEntry().lookupRepositoryReferences(repository);
            } catch (IdNotFoundException e) {
                lastThrownException = e;
                String path = e.getPathToObject();
                String name = e.getObjectName();
                String key = StringUtils.isEmpty(path) || path.equals("null") ? name : path + "/" + name;
                notFoundedReferences.put(key, e.getObjectType());
            }
        }
    }
    if (lastThrownException != null && !notFoundedReferences.isEmpty()) {
        throw new LookupReferencesException(lastThrownException, notFoundedReferences);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) LookupReferencesException(org.pentaho.di.core.exception.LookupReferencesException) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) HashMap(java.util.HashMap) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) IdNotFoundException(org.pentaho.di.core.exception.IdNotFoundException)

Aggregations

HashMap (java.util.HashMap)1 IdNotFoundException (org.pentaho.di.core.exception.IdNotFoundException)1 KettleException (org.pentaho.di.core.exception.KettleException)1 LookupReferencesException (org.pentaho.di.core.exception.LookupReferencesException)1 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)1 RepositoryObjectType (org.pentaho.di.repository.RepositoryObjectType)1