Search in sources :

Example 11 with IContentItem

use of org.pentaho.platform.api.repository.IContentItem in project pentaho-platform by pentaho.

the class ApacheVFSOutputHandlerIT method testAudit.

public void testAudit() {
    startTest();
    ApacheVFSOutputHandler handler = new ApacheVFSOutputHandler();
    IContentItem contentItem = handler.getFileOutputContentItem();
    // $NON-NLS-1$
    System.out.println("Content Item for VFS" + contentItem);
    assertTrue(true);
    finishTest();
}
Also used : IContentItem(org.pentaho.platform.api.repository.IContentItem) ApacheVFSOutputHandler(org.pentaho.platform.plugin.outputs.ApacheVFSOutputHandler)

Example 12 with IContentItem

use of org.pentaho.platform.api.repository.IContentItem in project pentaho-platform by pentaho.

the class ActionRunner method markContentAsGenerated.

private void markContentAsGenerated(IPostProcessingAction actionBean) {
    IUnifiedRepository repo = PentahoSystem.get(IUnifiedRepository.class);
    String lineageId = (String) params.get(ActionUtil.QUARTZ_LINEAGE_ID);
    for (IContentItem contentItem : actionBean.getActionOutputContents()) {
        RepositoryFile sourceFile = getRepositoryFileSafe(repo, contentItem.getPath());
        // add metadata if we have access and we have file
        if (sourceFile != null) {
            Map<String, Serializable> metadata = repo.getFileMetadata(sourceFile.getId());
            metadata.put(ActionUtil.QUARTZ_LINEAGE_ID, lineageId);
            repo.setFileMetadata(sourceFile.getId(), metadata);
        } else {
            String fileName = getFSFileNameSafe(contentItem);
            logger.warn(Messages.getInstance().getSkipRemovingOutputFile(fileName));
        }
    }
}
Also used : Serializable(java.io.Serializable) IContentItem(org.pentaho.platform.api.repository.IContentItem) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository)

Example 13 with IContentItem

use of org.pentaho.platform.api.repository.IContentItem in project pentaho-platform by pentaho.

the class MemoryOutputHandler method getFileOutputContentItem.

public IContentItem getFileOutputContentItem() {
    path = getContentRef();
    IContentItem item = new BufferedContentItem(this);
    item.setName(path);
    item.setMimeType(getMimeType());
    return item;
}
Also used : IContentItem(org.pentaho.platform.api.repository.IContentItem) BufferedContentItem(org.pentaho.platform.engine.core.output.BufferedContentItem)

Example 14 with IContentItem

use of org.pentaho.platform.api.repository.IContentItem in project pentaho-platform by pentaho.

the class RuntimeContext method getOutputContentItem.

public IContentItem getOutputContentItem(final String outputName, final String mimeType) {
    IContentItem contentItem = null;
    IActionParameter parameter = (IActionParameter) actionSequence.getOutputDefinitions().get(outputName);
    if (parameter == null) {
        warn(Messages.getInstance().getErrorString("RuntimeContext.ERROR_0021_INVALID_OUTPUT_REQUEST", outputName, // $NON-NLS-1$
        actionSequence.getSequenceName()));
    } else {
        List destinationsList = parameter.getVariables();
        Iterator destinationsIterator = destinationsList.iterator();
        if (destinationsList.size() > 1) {
            contentItem = new MultiContentItem();
        }
        while (destinationsIterator.hasNext()) {
            ActionParameterSource destination = (ActionParameterSource) destinationsIterator.next();
            String objectName = destination.getSourceName();
            String contentName = destination.getValue();
            contentName = TemplateUtil.applyTemplate(contentName, this);
            outputHandler.setSession(session);
            IContentItem tmpContentItem = outputHandler.getOutputContentItem(objectName, contentName, instanceId, mimeType);
            addOutputContentItem(tmpContentItem);
            if (contentItem instanceof MultiContentItem) {
                ((MultiContentItem) contentItem).addContentItem(tmpContentItem);
            } else {
                contentItem = tmpContentItem;
                break;
            }
        }
    }
    return contentItem;
}
Also used : ActionParameterSource(org.pentaho.platform.engine.services.actionsequence.ActionParameterSource) MultiContentItem(org.pentaho.platform.engine.core.output.MultiContentItem) IContentItem(org.pentaho.platform.api.repository.IContentItem) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) IActionParameter(org.pentaho.platform.api.engine.IActionParameter)

Example 15 with IContentItem

use of org.pentaho.platform.api.repository.IContentItem in project pentaho-platform by pentaho.

the class RuntimeContext method getInputStream.

public InputStream getInputStream(final String parameterName) {
    InputStream inputStream = null;
    IActionParameter inputParameter = getInputParameter(parameterName);
    if (inputParameter == null) {
        throw new InvalidParameterException(Messages.getInstance().getErrorString("RuntimeContext.ERROR_0019_INVALID_INPUT_REQUEST", parameterName, // $NON-NLS-1$
        actionSequence.getSequenceName()));
    }
    Object value = inputParameter.getValue();
    if (value instanceof IContentItem) {
        IContentItem contentItem = (IContentItem) value;
        inputStream = contentItem.getInputStream();
    }
    return inputStream;
}
Also used : InvalidParameterException(org.pentaho.platform.api.engine.InvalidParameterException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IContentItem(org.pentaho.platform.api.repository.IContentItem) IActionParameter(org.pentaho.platform.api.engine.IActionParameter)

Aggregations

IContentItem (org.pentaho.platform.api.repository.IContentItem)49 OutputStream (java.io.OutputStream)20 Test (org.junit.Test)8 IActionParameter (org.pentaho.platform.api.engine.IActionParameter)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)6 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 Iterator (java.util.Iterator)5 List (java.util.List)5 Element (org.dom4j.Element)5 SimpleContentItem (org.pentaho.platform.engine.core.output.SimpleContentItem)5 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4 Document (org.dom4j.Document)4 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)4 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)4 InvalidParameterException (org.pentaho.platform.api.engine.InvalidParameterException)4 Set (java.util.Set)3 IActionSequenceResource (org.pentaho.platform.api.engine.IActionSequenceResource)3