Wednesday, May 25, 2016

IBM FileNet: Bulk Processing using JavaScript



The IBM FileNet Content Platform Engine server uses the Mozilla Rhino scripting engine to execute the JavaScript.
Prerequisites for running the JavaScript examples: Content Platform Engine 5.2.0 or later

Downloading document content  

This JavaScript example downloads the document content to a specified directory. Because the JavaScript code is executed on a Content Platform Engine server, the content download directory that you specify in the code must exists on the CPE server and should have write permissions 

Procedure

  1. Open an object store and create an object store search.
  2. On the SQL view tab, enter the following query:

    SELECT TOP 100 This FROM Document 
  3. Select Enable bulk action on the bulk action tab. 
  4. In the Script section, click Run script
  5. Copy the following JavaScript code and paste it into the Script field: 

    importClass(Packages.com.filenet.api.collection.ContentElementList);
    importClass(Packages.com.filenet.api.core.ContentTransfer);
    importClass(java.io.FileOutputStream);
    importClass(java.io.InputStream);
    importClass(java.lang.Byte);

    function OnCustomProcess (CEObject)
    {
       CEObject.refresh();
       var ce = CEObject.get_ContentElements();
       if(ce.size() > 0)
       {
         var ct = ce.get(0);
         var folderName = "D://Content/";
         this._downloadContent(folderName, ct);
      }
    }

    function _downloadContent(folderName, ct)
    {
       var out = new FileOutputStream(folderName + ct.get_RetrievalName());
       var docLen = ct.get_ContentSize().intValue();
       var buf = java.lang.reflect.Array.newInstance(Byte.TYPE, docLen)
       var stream = ct.accessContentStream();

       stream.read(buf, 0, docLen);
       out.write(buf);
       out.flush();
       stream.close();
       out.close();
    }
  6. Click Run. The administration console runs the query and the JavaScript action. 

Deleting a document

  1. Open an object store and create an object store search. 
  2. On the SQL view tab, enter following query:

    SELECT This FROM Document WHERE DocumentTitle = '<Criteria>'
     
  3. Select Enable bulk action on the bulk action tab. 
  4. In the Script section, click Run script. 
  5. Copy the following JavaScript code and paste it into the Script field:

    importClass(java.lang.System);
    importClass(Packages.com.filenet.api.property.Properties);
    importClass(Packages.com.filenet.api.constants.RefreshMode);

    function OnCustomProcess (CEObject)
    {
       System.out.println("Executing Delete Document script");
       CEObject.delete();
       CEObject.save(RefreshMode.REFRESH);
       System.out.println("Document deleted successfully");
    }
      
  6. Click Run. 

Fetching document properties

  1. Open an object store and create an object store search. 
  2. On the SQL view tab, enter the following query:

    SELECT TOP 5 This FROM Document
  3. Select Enable bulk action on the bulk action tab. 
  4. In the Script section, click Run script. 
  5. Copy the following JavaScript code and paste it into the Script field:

    importClass(java.lang.System);
    importClass(Packages.com.filenet.api.property.Properties);

    function OnCustomProcess (CEObject)
    {
       System.out.println("Executing Fetch Properties script");
       CEObject.refresh();
       var props = CEObject.getProperties();

       System.out.println("ClassName................... "
         + CEObject.getClassName());
       System.out.println("Has DocumentTitle property.. "
         + props.isPropertyPresent("DocumentTitle"));
       System.out.println("Propertites size............ "
         + props.size());
    }

    6. Click Run

 Setting document properties

  1. Open an object store and copy the Id of the document that you want to change. 
  2. Create an object store search. 
  3. On the SQL view tab, enter the following query with the appropriate document Id:

    SELECT This FROM Document WHERE Id = <Document-Id>
  4. Select Enable bulk action on the bulk action tab. 
  5. In the Script section, click Run script. 
  6. Copy the following JavaScript code and paste it into the Script field:

    importClass(Packages.com.filenet.api.property.Properties);
    importClass(Packages.com.filenet.api.constants.RefreshMode);

    function OnCustomProcess (CEObject)
    {
       CEObject.refresh();
       CEObject.getProperties().putValue("DocumentTitle", "Test1");
       CEObject.save(RefreshMode.REFRESH);
    }

     
  7. Click Run 
 

Promote event on a document 

  1.  Open an object store and create an object store search. 
  2. On the SQL view tab, enter the following query:

    SELECT TOP 5 This FROM Document
     
  3.  Select Enable bulk action on the bulk action tab. 
  4.  In the Script section, click Run script. 
  5. Copy the following JavaScript code and paste it into the Script field:

    importClass(Packages.com.filenet.api.constants.RefreshMode);

    function OnCustomProcess (CEObject)
    {
       CEObject.demoteVersion();
       CEObject.save(RefreshMode.REFRESH);
       CEObject.promoteVersion();
       CEObject.save(RefreshMode.REFRESH);
    }
  6. Click Run

Thursday, February 25, 2016

Oracle VirtualBox – Error Code 0x000000C4



Getting below error message while starting Windows Server 2012 R2 64 Bit.

Your PC needs to restart.
Please hold down the power button.
Error code: 0x000000C4
Parameters:
0x0000000000000091
0x000000000000000F
0xFFFFF801E5962A80
0x0000000000000000


1. Execute the below command on Windows command prompt to get the name of the VM.(Check the VBox location)
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" list vms

2. Then execute the below command on Windows command prompt
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setextradata <<vmname>> VBoxInternal/CPUM/CMPXCHG16B 1

Note1: Replace the <<vmname>> with the name returned in step 1.
Note2: Please set the VM name in quotes if it contains blanks.