Search in sources :

Example 1 with InvalidParameterException

use of org.pentaho.platform.api.engine.InvalidParameterException 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)

Example 2 with InvalidParameterException

use of org.pentaho.platform.api.engine.InvalidParameterException in project pentaho-platform by pentaho.

the class RuntimeContext method getDataSource.

public IPentahoStreamSource getDataSource(final String parameterName) {
    IPentahoStreamSource dataSource = null;
    // TODO Temp workaround for content repos bug
    IActionParameter actionParameter = paramManager.getCurrentInput(parameterName);
    if (actionParameter == null) {
        throw new InvalidParameterException(Messages.getInstance().getErrorString("RuntimeContext.ERROR_0019_INVALID_INPUT_REQUEST", parameterName, // $NON-NLS-1$
        actionSequence.getSequenceName()));
    }
    Object locObj = actionParameter.getValue();
    if (locObj != null) {
        if (locObj instanceof IContentItem) {
            // At this point we have an IContentItem so why do anything else?
            dataSource = ((IContentItem) locObj).getDataSource();
        }
    }
    // This will return null if the locObj is null
    return dataSource;
}
Also used : InvalidParameterException(org.pentaho.platform.api.engine.InvalidParameterException) IContentItem(org.pentaho.platform.api.repository.IContentItem) IPentahoStreamSource(org.pentaho.commons.connection.IPentahoStreamSource) IActionParameter(org.pentaho.platform.api.engine.IActionParameter)

Example 3 with InvalidParameterException

use of org.pentaho.platform.api.engine.InvalidParameterException in project pentaho-platform by pentaho.

the class RuntimeContext method setOutputValue.

public void setOutputValue(final String name, final Object output) {
    IActionParameter actionParameter = paramManager.getCurrentOutput(name);
    if (actionParameter == null) {
        throw new InvalidParameterException(Messages.getInstance().getErrorString("RuntimeContext.ERROR_0021_INVALID_OUTPUT_REQUEST", name, // $NON-NLS-1$
        actionSequence.getSequenceName()));
    }
    actionParameter.setValue(output);
    if (output instanceof String) {
        runtimeData.setStringProperty(name, (String) output);
    } else if (output instanceof Date) {
        runtimeData.setDateProperty(name, (Date) output);
    } else if (output instanceof Long) {
        runtimeData.setLongProperty(name, (Long) output);
    } else if (output instanceof List) {
        runtimeData.setListProperty(name, (List) output);
    } else if (output instanceof Map) {
        runtimeData.setMapProperty(name, (Map) output);
    } else if (output instanceof IContentItem) {
        runtimeData.setStringProperty(name, ((IContentItem) output).getPath());
    }
}
Also used : InvalidParameterException(org.pentaho.platform.api.engine.InvalidParameterException) IContentItem(org.pentaho.platform.api.repository.IContentItem) List(java.util.List) ArrayList(java.util.ArrayList) IActionParameter(org.pentaho.platform.api.engine.IActionParameter) Map(java.util.Map) HashMap(java.util.HashMap) Date(java.util.Date)

Example 4 with InvalidParameterException

use of org.pentaho.platform.api.engine.InvalidParameterException in project pentaho-platform by pentaho.

the class MultipleComponentIT method testMiscExceptionClasses.

/*
   * public void testCrosstab() { startTest(); IRuntimeContext context = run("test", "rules", "CrossTabTest.xaction");
   * //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals(
   * Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS,
   * context.getStatus()); //$NON-NLS-1$ IActionParameter rtn = context.getOutputParameter("rule-result"); //$NON-NLS-1$
   * assertNotNull(rtn); IPentahoResultSet resultset = (IPentahoResultSet) rtn.getValue();
   * assertEquals(resultset.getRowCount(), 7); Object[][] colHeaders = resultset.getMetaData().getColumnHeaders();
   * assertEquals(colHeaders[0][0], "DEPARTMENT"); //$NON-NLS-1$ assertEquals(colHeaders[0][1], "Central"); //$NON-NLS-1$
   * assertEquals(colHeaders[0][2], "Western"); //$NON-NLS-1$ assertEquals(colHeaders[0][3], "Southern"); //$NON-NLS-1$
   * assertEquals(colHeaders[0][4], "Eastern"); //$NON-NLS-1$
   * 
   * finishTest(); }
   */
public void testMiscExceptionClasses() {
    // Making sure we create an instance of all the Hitachi Vantara
    // Exception classes.
    startTest();
    Exception ex = new RepositoryException();
    // $NON-NLS-1$
    Exception ex2 = new RepositoryException("Ignored");
    Exception ex3 = new RepositoryException(ex2);
    // $NON-NLS-1$
    Exception ex4 = new RepositoryException("Ignored", ex3);
    Exception ex5 = new AuditException();
    // $NON-NLS-1$
    Exception ex6 = new AuditException("Ignored");
    // $NON-NLS-1$
    Exception ex7 = new AuditException("Ignored", ex);
    Exception ex8 = new AuditException(ex4);
    // $NON-NLS-1$
    ex = new ContentException("Ignored");
    // $NON-NLS-1$
    ex = new ContentException("Ignored", ex5);
    ex = new ContentException(ex6);
    ex = new InvalidParameterException();
    ex = new SQLResultSetException();
    ex = new PentahoChainedException();
    // $NON-NLS-1$
    ex = new PentahoChainedException("Ignored");
    // $NON-NLS-1$
    ex = new PentahoChainedException("Ignored", ex7);
    ex = new PentahoChainedException(ex8);
    finishTest();
}
Also used : InvalidParameterException(org.pentaho.platform.api.engine.InvalidParameterException) SQLResultSetException(org.pentaho.platform.plugin.services.connections.sql.SQLResultSetException) PentahoChainedException(org.pentaho.platform.api.util.PentahoChainedException) AuditException(org.pentaho.platform.api.engine.AuditException) ContentException(org.pentaho.platform.api.repository.ContentException) RepositoryException(org.pentaho.platform.api.repository.RepositoryException) SQLResultSetException(org.pentaho.platform.plugin.services.connections.sql.SQLResultSetException) InvalidParameterException(org.pentaho.platform.api.engine.InvalidParameterException) AuditException(org.pentaho.platform.api.engine.AuditException) ContentException(org.pentaho.platform.api.repository.ContentException) PentahoChainedException(org.pentaho.platform.api.util.PentahoChainedException) RepositoryException(org.pentaho.platform.api.repository.RepositoryException)

Aggregations

InvalidParameterException (org.pentaho.platform.api.engine.InvalidParameterException)4 IActionParameter (org.pentaho.platform.api.engine.IActionParameter)3 IContentItem (org.pentaho.platform.api.repository.IContentItem)3 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 IPentahoStreamSource (org.pentaho.commons.connection.IPentahoStreamSource)1 AuditException (org.pentaho.platform.api.engine.AuditException)1 ContentException (org.pentaho.platform.api.repository.ContentException)1 RepositoryException (org.pentaho.platform.api.repository.RepositoryException)1 PentahoChainedException (org.pentaho.platform.api.util.PentahoChainedException)1 SQLResultSetException (org.pentaho.platform.plugin.services.connections.sql.SQLResultSetException)1