use of org.pentaho.platform.api.engine.IActionSequenceResource in project pentaho-platform by pentaho.
the class JFreeReportLoadComponent method validateAction.
@Override
protected boolean validateAction() {
if (isDefinedResource(AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTDEFN)) {
return true;
}
if (isDefinedInput(AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTDEFN)) {
IActionParameter o = getInputParameter(AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTDEFN);
if ((o != null) && (o.getValue() instanceof String)) {
return true;
}
return false;
}
// Handle late-bind of report resource name
if (isDefinedInput(AbstractJFreeReportComponent.REPORTLOAD_RESOURCENAME)) {
if (isDefinedResource(getInputStringValue(AbstractJFreeReportComponent.REPORTLOAD_RESOURCENAME))) {
return true;
} else {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("JFreeReport.ERROR_0004_REPORT_DEFINITION_UNREADABLE"));
return false;
}
}
if (isDefinedResource(AbstractJFreeReportComponent.DATACOMPONENT_JARINPUT)) {
if (!isDefinedInput(AbstractJFreeReportComponent.REPORTLOAD_REPORTLOC)) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("JFreeReport.ERROR_0011_REPORT_LOCATION_MISSING"));
return false;
}
final IActionSequenceResource resource = getResource(AbstractJFreeReportComponent.DATACOMPONENT_JARINPUT);
final InputStream in;
in = resource.getInputStream(RepositoryFilePermission.READ, LocaleHelper.getLocale());
try {
// not being able to read a single char is definitly a big boo ..
if (in.read() == -1) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("JFreeReport.ERROR_0009_REPORT_JAR_UNREADABLE"));
return false;
}
} catch (Exception e) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("JFreeReport.ERROR_0009_REPORT_JAR_UNREADABLE"));
return false;
}
if (!isDefinedInput(AbstractJFreeReportComponent.REPORTLOAD_REPORTLOC)) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("JFreeReport.ERROR_0012_CLASS_LOCATION_MISSING"));
return false;
}
return true;
}
return false;
}
use of org.pentaho.platform.api.engine.IActionSequenceResource in project pentaho-platform by pentaho.
the class TestComponent method validateAction.
@Override
protected boolean validateAction() {
// describe the inputs, outputs and resources available to us
Set inputNames = getInputNames();
Iterator inputNamesIterator = inputNames.iterator();
String inputName;
IActionParameter actionParameter;
while (inputNamesIterator.hasNext()) {
inputName = (String) inputNamesIterator.next();
actionParameter = getInputParameter(inputName);
message(Messages.getInstance().getString("TestComponent.DEBUG_INPUT_DESCRIPTION", inputName, // $NON-NLS-1$
actionParameter.getType()));
}
Set outputNames = getOutputNames();
Iterator outputNamesIterator = outputNames.iterator();
String outputName;
while (outputNamesIterator.hasNext()) {
outputName = (String) outputNamesIterator.next();
actionParameter = getOutputItem(outputName);
message(Messages.getInstance().getString("TestComponent.DEBUG_OUTPUT_DESCRIPTION", outputName, // $NON-NLS-1$
actionParameter.getType()));
}
Set resourceNames = getResourceNames();
Iterator resourceNamesIterator = resourceNames.iterator();
String resourceName;
IActionSequenceResource actionResource;
while (resourceNamesIterator.hasNext()) {
resourceName = (String) resourceNamesIterator.next();
actionResource = getResource(resourceName);
message(Messages.getInstance().getString("TestComponent.DEBUG_RESOURCE_DESCRIPTION", resourceName, actionResource.getMimeType(), // $NON-NLS-1$
actionResource.getAddress()));
try {
String content = getResourceAsString(actionResource);
message(Messages.getInstance().getString("TestComponent.DEBUG_RESOURCE_CONTENTS", // $NON-NLS-1$ //$NON-NLS-2$
((content == null) ? "null" : content.substring(0, 100))));
} catch (Exception e) {
// $NON-NLS-1$
message(Messages.getInstance().getString("TestComponent.ERROR_0005_RESOURCE_NOT_LOADED", e.getMessage()));
}
}
return true;
}
use of org.pentaho.platform.api.engine.IActionSequenceResource in project pentaho-platform by pentaho.
the class PentahoResourceData method getResourceAsStream.
/**
* gets a resource stream from the runtime context.
*
* @param caller
* resource manager
* @return input stream
*/
public InputStream getResourceAsStream(final ResourceManager caller) throws ResourceLoadingException {
int resourceType = IActionResource.SOLUTION_FILE_RESOURCE;
if (filename.contains("://")) {
resourceType = IActionResource.URL_RESOURCE;
}
final IActionSequenceResource resource = // $NON-NLS-1$ //$NON-NLS-2$
new ActionSequenceResource("", resourceType, "application/binary", (String) key.getIdentifier());
return resource.getInputStream(RepositoryFilePermission.READ, LocaleHelper.getLocale());
}
Aggregations