}
public Object getValue( String name ) throws Exception {
// fail early if we cannot handle stream outputs
if ( !streamingCheckPerformed && !( actionBean instanceof IStreamingAction ) ) {
throw new ActionExecutionException( Messages.getInstance().getErrorString(
"ActionDelegate.ERROR_0002_ACTION_CANNOT_ACCEPT_STREAM", //$NON-NLS-1$
name, actionBean.getClass().getSimpleName() ) );
}
streamingCheckPerformed = true;
String mimeType = ( (IStreamingAction) actionBean ).getMimeType( name );
if ( StringUtils.isEmpty( mimeType ) ) {
throw new ActionValidationException( Messages.getInstance().getErrorString(
"ActionDelegate.ERROR_0001_MIMETYPE_NOT_DECLARED" ) ); //$NON-NLS-1$
}
IContentItem contentItem = null;
//
// If the output is mapped publicly and has a destination associated with it, then we will be asking
// the current IOuputHandler to create an IContentItem (OuputStream) for us. Otherwise, we will asking the
// IContentOutputHandler impl registered to handle content destined for "contentrepo" to create
// an IContentItem (OutputStream) for us.
//
if ( hasPublicDestination( curActionOutput ) ) {
// most output handlers will manage multiple destinations for us and hand us back a MultiContentItem
contentItem = getRuntimeContext().getOutputContentItem( curActionOutput.getPublicName(), mimeType );
} else {
String extension = MimeHelper.getExtension( mimeType );
if ( extension == null ) {
extension = ".bin"; //$NON-NLS-1$
}
contentItem = getRuntimeContext().getOutputItem( curActionOutput.getName(), mimeType, extension );
}
if ( contentItem == null ) {
// this is the best I can do here to point users to a tangible problem without unwrapping code in
// RuntimeEngine
// - AP
throw new ActionValidationException( Messages.getInstance().getErrorString(
"ActionDelegate.ERROR_0003_OUTPUT_STREAM_NOT_AVAILABLE_1", //$NON-NLS-1$
curActionOutput.getPublicName() ) );
}
// this will be a MultiOutputStream in the case where there is more than one destination for the content
// output
OutputStream contentOutputStream = contentItem.getOutputStream( getActionName() );
if ( contentOutputStream == null ) {
throw new ActionExecutionException( Messages.getInstance().getErrorString(
"ActionDelegate.ERROR_0004_OUTPUT_STREAM_NOT_AVAILABLE_2", //$NON-NLS-1$
actionBean.getClass().getSimpleName() ) );
}
// save this for later when we set the action outputs