Search in sources :

Example 1 with JobDelegate

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

the class StreamToJobNodeConverter method convert.

/**
 * @param inputStream
 * @param charset
 * @param mimeType
 * @return
 */
public IRepositoryFileData convert(final InputStream inputStream, final String charset, final String mimeType) {
    try {
        long size = inputStream.available();
        JobMeta jobMeta = new JobMeta();
        Repository repository = connectToRepository();
        Document doc = PDIImportUtil.loadXMLFrom(inputStream);
        if (doc != null) {
            jobMeta.loadXML(doc.getDocumentElement(), repository, null);
            JobDelegate delegate = new JobDelegate(repository, this.unifiedRepository);
            delegate.saveSharedObjects(jobMeta, null);
            return new NodeRepositoryFileData(delegate.elementToDataNode(jobMeta), size);
        } else {
            return null;
        }
    } catch (Exception e) {
        return null;
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) Repository(org.pentaho.di.repository.Repository) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) JobDelegate(org.pentaho.di.repository.pur.JobDelegate) NodeRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData) Document(org.w3c.dom.Document) KettleException(org.pentaho.di.core.exception.KettleException)

Aggregations

KettleException (org.pentaho.di.core.exception.KettleException)1 JobMeta (org.pentaho.di.job.JobMeta)1 Repository (org.pentaho.di.repository.Repository)1 JobDelegate (org.pentaho.di.repository.pur.JobDelegate)1 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)1 NodeRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData)1 Document (org.w3c.dom.Document)1