Tuesday, January 31, 2012

To retrieve the Oracle BPM worklist payload in ADF taskflow


// Get the faces context object
FacesContext context = FacesContext.getCurrentInstance();

// get the worklist context and taskid (of the task selected), these are by default part of the page
//flowscope in the BPM workspace where the taskflow will be included
String ctx = (String) context.getApplication().evaluateExpressionGet(context, "#{pageFlowScope.bpmWorklistContext}", String.class);
String tskId = (String)context.getApplication().evaluateExpressionGet(context, "#{pageFlowScope.bpmWorklistTaskId}", String.class);

// Get the workflow service client and task query service
IWorkflowServiceClient workflowSvcClient = WorkflowService.getWorkflowServiceClient();
ITaskQueryService wfQueryService = workflowSvcClient.getTaskQueryService();
IWorkflowContext wfContext = wfQueryService.getWorkflowContext(ctx);
Task myTask = wfQueryService.getTaskDetailsById(wfContext, tskId);

// Now get the payload
Element rootelement= myTask.getPayloadAsElement();

// parse the payload to get the required information.
NodeList nl= rootelement.getElementsByTagName("Information");
Node fstnode= nl.item(0);
Element fstElmnt = (Element) fstnode;
NodeList tstNmElmntLst = fstElmnt.getElementsByTagName("Id");
Element tstNmElmnt = (Element) tstNmElmntLst.item(0);
String Id = tstNmElmnt.getFirstChild().getNodeValue();
NodeList tstNmElmntLst1 = fstElmnt.getElementsByTagName("po");
Element tstNmElmnt1 = (Element) tstNmElmntLst.item(0);
String po = tstNmElmnt1.getFirstChild().getNodeValue();
context.getExternalContext().getRequestMap().put("Id", Id);
context.getExternalContext().getRequestMap().put("po", po);

Sunday, January 22, 2012

Why you may get weblogic-application.xml load error for ADF 11g R2 release

If you are getting a below given error when trying to run the ADF application in 11g R2 Jdev release, in integrated weblogic server:


<Unable to load descriptor C:\Jdev\xxx\................/weblogic-application.xml of module AnApp. The error is weblogic.descriptor.DescriptorException: Unmarshaller failed


Goto Application resources tab in your Jdev Application Navigator and open weblogic-application.xml. Check for the duplicate entries in the xml file for the lib refs. Remove all the duplicate entries and try running it again.


This should work, to remove the above mentioned error.

Thursday, January 19, 2012

Using RIDC lib to checkin file into UCM from ADF application.


       Below given code snippet shows, checking in file into UCM repository from ADF application    
       using RIDC lib to . So if you are not using Webcenter, and do not have an access to OOTB  
        taskflow for file upload , this code can help you.


       // Get the file using the file upload component in ADF
       UploadedFile newFile = (UploadedFile)getIf1().getValue();

        // store the file in a temporary location on server
        String tempFold = "C:/tempFold/";
        String fileName =  newFile.getFilename();
        String filetype =  newFile.getContentType();
        InputStream is = null;
        try {
            is = newFile.getInputStream();
            File f= new File(tempFold + fileName);
            OutputStream out=new FileOutputStream(f);
            byte buf[]=new byte[1024];
            int len;
            while((len=is.read(buf))>0)
            out.write(buf,0,len);
            out.close();
            is.close();
        } catch (IOException e) {
        }
       
        // Get Ridc client manager
        IdcClientManager manager = new IdcClientManager();
        IdcClient idcClient = null;
       
        try {
              // create the client to check in the file in the ucm
              idcClient = manager.createClient(<UCM url as string>);
              IdcContext userContext = new IdcContext("weblogic", "welcome1");    
              DataBinder binder = idcClient.createBinder();

              binder.putLocal ("IdcService", "CHECKIN_UNIVERSAL");
              // get the binder
             
              binder.putLocal ("dDocTitle", "File1");
              binder.putLocal ("dDocName", "Despicableme");
              binder.putLocal ("dDocType", "DigitalMedia");
              binder.putLocal ("dSecurityGroup", "Public");
              // add a file
           
              binder.addFile ("primaryFile", new TransferFile( new java.io.File(tempFold + fileName)));
              // checkin the file
              ServiceResponse response = idcClient.sendRequest(userContext, binder);
              // get the response as a string
              String responseString = response.getResponseAsString ();
           
              System.out.println("done");
              System.out.println("st:"+responseString);
        } catch (IdcClientException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
          }