public VWAttachment[] getFolderDocuments(VWAttachment folderAttachment ) throws Exception {
Folder folder = getFolderFromAttachment(folderAttachment);
DocumentSet containedDocuments = getContainedDocuments(folder);
Iterator<?> iterator = containedDocuments.iterator();
ArrayList<VWAttachment> containedDocumentList = new ArrayList<VWAttachment>();
while ( iterator.hasNext() ) {
Document document = (Document) iterator.next();
VWAttachment documentAttachment = getAsVWAttachment(document);
containedDocumentList.add( documentAttachment );
}
return containedDocumentList.toArray( new VWAttachment[0] );
}
private DocumentSet getContainedDocuments(Folder folder) {
PropertyFilter propertyFilter = getContainedDocumentsPropertyFilter();
folder.fetchProperties( propertyFilter );
DocumentSet containedDocuments = folder.get_ContainedDocuments();
return containedDocuments;
}
private PropertyFilter getContainedDocumentsPropertyFilter() {
PropertyFilter propertyFilter = new PropertyFilter();
propertyFilter.addIncludeProperty( new FilterElement( null, null, null, PropertyNames.CONTAINED_DOCUMENTS, null ) );
propertyFilter.addIncludeProperty( new FilterElement( 2, null, null, PropertyNames.ID, null ) );
propertyFilter.addIncludeProperty( new FilterElement( 2, null, null, “DocumentTitle”, null ) );
return propertyFilter;
}
private VWAttachment getAsVWAttachment(Document document) throws VWException {
VWAttachment documentAttachment = new VWAttachment();
documentAttachment.setLibraryType( VWLibraryType.LIBRARY_TYPE_CONTENT_ENGINE );
ObjectStore objectStore = document.getObjectStore();
objectStore.fetchProperties( new String[] { PropertyNames.NAME } );
documentAttachment.setLibraryName( objectStore.get_Name() );
document.fetchProperties( new String[] { PropertyNames.ID, PropertyNames.NAME } );
documentAttachment.setId( document.get_Id().toString() );
documentAttachment.setAttachmentName( document.get_Name() );
documentAttachment.setType( VWAttachmentType.ATTACHMENT_TYPE_FOLDER );
return documentAttachment;
}
/**
* Sends a JMS message using a JMS Queue as the target of the Message.
*
* @param documentAttachment the initiating document from the Workflow
* @param Message
* xml Message to be sent to the Queue.
* @param url
* LDAP server URL eg “ldap://ecmukdemo6/o=sample”; where ecmukdemo6 is the server and o=sample is the root organisation for searching.
* @param icf
* the context factory package used for the JNDI object retrieval usually “com.sun.jndi.ldap.LdapCtxFactory”;
* @param qManager
* the name of the MQ Queue Manager eg wasadm
* @param qName
* the name of the MQ Queue eg AUDQAR
* @param cfLookup
* the name of the LDAP lookup Connection Factory to use eg cn=AUDQCF
* @param JNDITopic
* the name of the LDAP lookup for the MQ Topic eg cn=AUDTopic (Not currently used)
* @param JNDIQueue
* the name of the LDAP lookup for the MQ Queue eg cn=AUDQCF
* @param dLookup
* the name of the LDAP lookup for the Message Destination cn=AUDQAR
* @param hostName
* the MQ Server hostname eg ecmukdemo6
* @param channel
* the MQ Server listener channel eg SYSTEM.DEF.CLNT.CONN
* @param MQport
* the MQ Server port eg 1417
* @param MQuser
* the MQ Server connection user name – this is a Linux/windows O/S user on the MQ Server with access authority to the Queue eg wasadm
* @param MQpassword
* the MQ Server connection user name password eg filenet
*
* @throws Exception
*/
public void sendJMSMessage(VWAttachment docAttachment, String Message, String url, String icf, String qManager, String qName,
String cfLookup, String JNDITopic, String JNDIQueue, String dLookup,
String hostName, String channel, String sMQport, String MQuser, String MQpassword
) throws Exception {
{
messageString = Message;
// TODO Production code will be required to have much finer grained
// exception handling.
try {
//
//Lookup initial context
//TODO Get MQ Parameters from passed string values
//ASB – Using LDAP Context
//create initial context properties
//String url = “ldap://ecmukdemo6/o=sample”;
//String icf = “com.sun.jndi.ldap.LdapCtxFactory”;
java.util.Hashtable environment = new java.util.Hashtable();
environment.put(Context.PROVIDER_URL, url);
environment.put(Context.INITIAL_CONTEXT_FACTORY, icf);
Context ctx = new InitialDirContext(environment);
Destination myDest = null;
//ASB – Initial Content code End