Search in sources :

Example 71 with StringObjectId

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

the class KettleFileRepository method getRootObjectIDs.

private ObjectId[] getRootObjectIDs(String extension) throws KettleException {
    try {
        // Get all the files in the root directory with a certain extension...
        // 
        List<ObjectId> list = new ArrayList<ObjectId>();
        String folderName = repositoryMeta.getBaseDirectory();
        FileObject folder = KettleVFS.getFileObject(folderName);
        for (FileObject child : folder.getChildren()) {
            if (child.getType().equals(FileType.FILE)) {
                if (!child.isHidden() || !repositoryMeta.isHidingHiddenFiles()) {
                    String name = child.getName().getBaseName();
                    if (name.endsWith(extension)) {
                        list.add(new StringObjectId(name));
                    }
                }
            }
        }
        return list.toArray(new ObjectId[list.size()]);
    } catch (Exception e) {
        throw new KettleException("Unable to get root object ids for extension [" + extension + "]", 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) 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 72 with StringObjectId

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

the class KettleFileRepository method loadJob.

@Override
public JobMeta loadJob(String jobname, RepositoryDirectoryInterface repdir, ProgressMonitorListener monitor, String versionName) throws KettleException {
    // This is a standard load of a transformation serialized in XML...
    // 
    String filename = calcDirectoryName(repdir) + jobname + EXT_JOB;
    JobMeta jobMeta = new JobMeta(filename, this);
    jobMeta.setFilename(null);
    jobMeta.setName(jobname);
    jobMeta.setObjectId(new StringObjectId(calcObjectId(repdir, jobname, EXT_JOB)));
    jobMeta.setRepository(this);
    jobMeta.setMetaStore(getMetaStore());
    readDatabases(jobMeta, true);
    jobMeta.clearChanged();
    return jobMeta;
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) StringObjectId(org.pentaho.di.repository.StringObjectId)

Example 73 with StringObjectId

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

the class KettleFileRepository method renameRepositoryDirectory.

@Override
public ObjectId renameRepositoryDirectory(ObjectId id, RepositoryDirectoryInterface newParentDir, String newName) throws KettleException {
    if (newParentDir != null || newName != null) {
        try {
            // In case of a root object, the ID is the same as the relative filename...
            RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree();
            RepositoryDirectoryInterface dir = tree.findDirectory(id);
            if (dir == null) {
                throw new KettleException("Could not find folder [" + id + "]");
            }
            // If newName is null, keep the current name
            newName = (newName != null) ? newName : dir.getName();
            FileObject folder = KettleVFS.getFileObject(dir.getPath());
            String newFolderName = null;
            if (newParentDir != null) {
                FileObject newParentFolder = KettleVFS.getFileObject(newParentDir.getPath());
                newFolderName = newParentFolder.toString() + "/" + newName;
            } else {
                newFolderName = folder.getParent().toString() + "/" + newName;
            }
            FileObject newFolder = KettleVFS.getFileObject(newFolderName);
            folder.moveTo(newFolder);
            return new StringObjectId(dir.getObjectId());
        } catch (Exception e) {
            throw new KettleException("Unable to rename directory folder to [" + id + "]");
        }
    }
    return (id);
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) KettleException(org.pentaho.di.core.exception.KettleException) 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 74 with StringObjectId

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

the class KettleFileRepository method insertLogEntry.

@Override
public ObjectId insertLogEntry(String description) throws KettleException {
    String logfile = calcDirectoryName(null) + LOG_FILE;
    try {
        OutputStream outputStream = KettleVFS.getOutputStream(logfile, true);
        outputStream.write(description.getBytes());
        outputStream.write(Const.CR.getBytes());
        outputStream.close();
        return new StringObjectId(logfile);
    } catch (IOException e) {
        throw new KettleException("Unable to write log entry to file [" + logfile + "]");
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) OutputStream(java.io.OutputStream) IOException(java.io.IOException) StringObjectId(org.pentaho.di.repository.StringObjectId)

Example 75 with StringObjectId

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

the class KettleFileRepository method loadTransformation.

@Override
public TransMeta loadTransformation(String transname, RepositoryDirectoryInterface repdir, ProgressMonitorListener monitor, boolean setInternalVariables, String versionName) throws KettleException {
    // This is a standard load of a transformation serialized in XML...
    // 
    String filename = calcDirectoryName(repdir) + transname + ".ktr";
    TransMeta transMeta = new TransMeta(filename, this, setInternalVariables);
    transMeta.setRepository(this);
    transMeta.setMetaStore(getMetaStore());
    transMeta.setFilename(null);
    transMeta.setName(transname);
    transMeta.setObjectId(new StringObjectId(calcObjectId(repdir, transname, EXT_TRANSFORMATION)));
    readDatabases(transMeta, true);
    transMeta.clearChanged();
    return transMeta;
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) 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