Uploading a file
To upload a file to an Encyclopedia volume, you must identify the file to upload and the Encyclopedia volume in which to place the file. You can also specify how to work with existing versions of the file you upload. Using Actuate’s open server technology, you can upload third-party file types and native Actuate file types.
About ways of uploading a file
When you upload a file, the content streams to the Encyclopedia volume. You can stream a report with a SOAP message in two ways:
*Embed the file in the response.
In embedding a file, the application specifies the ContentLength in the HTTP header. If you use HTTP 1.0, you typically choose to embed the file.
*Send the file as a MIME attachment.
A MIME attachment transmits the contents of the file outside the boundary of the SOAP message.
A SOAP message with a MIME attachment consists of three parts:
*HTTP header
*Actuate SOAP message
*File attachment
The following example uses a MIME attachment and relevant Actuate Information Delivery API classes to build an application that uploads a file to an Encyclopedia volume.
Using com.actuate.schemas.UploadFile
Use the com.actuate.schemas.UploadFile class to upload a file to an Encyclopedia volume. The file content streams to BIRT iHub as unchunked MIME attachment to the request. The UploadFile class contains the following attributes:
*NewFile is the com.actuate.schemas.NewFile object to upload.
*CopyFromLatestVersion is an array of Strings used to copy one or more of the following properties from the latest version of the file, if one exists, to the version of the file that you upload:
*Description is a description of the file.
*Permissions, the access control list (ACL) specifying the users and roles that can access the file.
*ArchiveRule specifies the autoarchive rules for the file, which determine how BIRT iHub ages the file and when the file expires.
*Content is the com.actuate.schemas.Attachment object that specifies the content Id, content type, content length, content encoding, locale, and content data.
How to build an application that uploads a file
The following application derives from the code in the BIRT iHub Integration Technology example applications for the Apache Axis 2 client. In this example application, AcUploadFile.uploadFile( ) performs the following operations:
*Instantiates a NewFile object, then sets the Encyclopedia volume file location and name
public class AcUploadFile {
public static void uploadFile (String locFileName, String
encycFileName) throws RemoteException,
ServiceException {
// set new file information
 
com.actuate.schemas.NewFile newFile =
new com.actuate.schemas.NewFile( );
newFile.setName(encycFileName);
*Instantiates the Attachment object, then sets contentID attribute to the file location and name
// set MIME content ID (must be same as AttachmentPart)
 
com.actuate.schemas.Attachment content =
new com.actuate.schemas.Attachment( );
content.setContentId(locFileName);
*Instantiates the UploadFile object, then passes the references to the NewFile and Attachment objects
// set upload message
 
com.actuate.schemas.UploadFile request =
new com.actuate.schemas.UploadFile( );
request.setNewFile(newFile);
request.setContent(content);
*Sets up the data handler to read the file
// use input file as data source
 
javax.activation.DataHandler dhSource =
new javax.activation.DataHandler(new
javax.activation.FileDataSource(locFileName));
*Instantiates the org.apache.axis.attachments.AttachmentPart object to contain the data, passes the reference to the data handler, then sets contentID attribute to the file location and name
// set attachment in call
org.apache.axis.attachments.AttachmentPart attachmentPart =
new org.apache.axis.attachments.AttachmentPart( );
attachmentPart.setDataHandler(dhSource);
attachmentPart.setContentId(locFileName);
*Performs the UploadFile administration operation by making a call to ActuateControl.uploadFile( )
// call upload file
com.actuate.schemas.UploadFileResponse response =
actuateControl.uploadFile(request, attachmentPart);
}
ActuateControl.uploadFile( ) performs the following operations:
*Sets up org.apache.axis.client.Call object:
*Obtains a reference to the Call object using createCall( )
public com.actuate.schemas.UploadFileResponse uploadFile(
com.actuate.schemas.UploadFile request,
org.apache.axis.attachments.AttachmentPart
attachmentPart)
throws RemoteException, RemoteException,
ServiceException {
org.apache.axis.client.Call call = createCall( );
*Calls addParameter( ) specifying the following UploadFile parameters:
*Parameter name
*XML datatype for the parameter
*Java class for the parameter
*Parameter mode, indicating whether it is ParameterMode.IN, OUT or INOUT
call.addParameter(
new javax.xml.namespace.QName(
"http://schemas.actuate.com/actuate11",
"UploadFile"),
new javax.xml.namespace.QName(
"http://schemas.actuate.com/actuate11",
"UploadFile"),
com.actuate.schemas.UploadFile.class,
javax.xml.rpc.ParameterMode.IN);
*Sets the return type for the operation by specifying parameters that indicate the XML data type and Java class for UploadFileResponse
call.setReturnType(
new javax.xml.namespace.QName(
"http://schemas.actuate.com/actuate11",
"UploadFileResponse"));
*Sets the UseSOAPAction and SOAPAction URI parameters
call.setUseSOAPAction(true);
call.setSOAPActionURI("");
*Sets the encoding style URI to null to use the default, binary
call.setEncodingStyle(null);
*Sets org.apache.axis.AxisEngine.PROP_DOMULTIREFS to False
call.setProperty(
org.apache.axis.AxisEngine.PROP_DOMULTIREFS,
Boolean.FALSE);
PROP_DOMULTIREFS controls the serialization and deserialization processes and the way the client engine handles complex type parameters with multiple references.
*Sets org.apache.axis.client.Call.SEND_TYPE_ATTR to False
call.setProperty(
org.apache.axis.client.Call.SEND_TYPE_ATTR,
Boolean.FALSE);
SEND_TYPE_ATTR controls whether to send xsi type attributes.
*Sets the operation style to document
call.setOperationStyle("document");
*Converts the operation name String to a QName
call.setOperationName(
new javax.xml.namespace.QName(
"http://schemas.actuate.com/actuate11",
"UploadFile"));
*Adds the MIME attachment
// set the actual MIME attachment
call.addAttachmentPart(attachmentPart);
*Makes the call, passing the reference to the UploadFile request in an Object array as required by the Apache Axis framework
Object resp = call.invoke(new Object[ ] { request });
*If it occurs, handles a RemoteException, otherwise, casts the response into an UploadFileResponse object and returns it to AcUploadFile.uploadFile( )
if (resp instanceof java.rmi.RemoteException) {
throw (java.rmi.RemoteException) resp;
}
else {
try {
return (com.actuate.schemas.UploadFileResponse) resp;
}
catch (java.lang.Exception e) {
return (com.actuate.schemas.UploadFileResponse) org
.apache
.axis
.utils
.JavaUtils
.convert(resp,
com.actuate.schemas.UploadFileResponse.class);
}
}
}
For more information about the Apache Axis 2 client Java-based framework for implementing a SOAP processor, see http://ws.apache.org/axis/java.