Thursday 25 July 2013

API Commands

To get attribute values for a document or any other object.
dump,c,r_object_id

 To get r_object_id of any object
retrieve,c,dm_method where object_name='Delete'

Dump object which is just retrieved or created in current session. (i.e.r_object_id retrieved in previous command)
dump,c,l

To make method object available as workflow method
retrieve,c,dm_method where object_name=’Method Name’
set,c,l,a_special_app
SET>Workflow
save,c,l

Create new ACL
create,c,dm_acl
set,c,l,object_name
your_acl_name
set,c,l,owner_name
dm_dbo
grant,c,l,dm_world,1
revoke,c,l,dm_world,execute_proc,change_permit
grant,c,l,your_admin,7,execute_proc,change_permit
save,c,l


Flush cache
flush,c,persistentcache
flush,c,persistentobjcache
flushcache,c

Publish data dictionary for an object type
publish_dd,c,,<object type>,T

Publish entire datadictionary
publish_dd,c

Requeue Rendition
queue,c,<doc_id>,dm_autorender_win31,rendition,0,F,,rendition_req_ps_pdf​​

To  get User login ticket
getlogin,c,<user_name>

Install workflow template
retrieve,c,dm_process where object_name=’workflow_name';
save,c,l
validate,c,l
install,c,l

To get document storage path
getpath,c,'r_object_id of document'

Wednesday 24 July 2013

DFC\WDK coding -Reusable code snippets

WDK\DFC Coding

How to format datetime input and update document attributes?
Date  test_date = ((DateTime)this.getControl("testDate", DateTime.class)).toDate();

//IDfTime diariseDateTime = new DfTime(test_date);
       
SimpleDateFormat dm = new SimpleDateFormat("M/d/yyyy h:mm:ss a");
String  testDate = dm.format(test_date).toString();
idfsysobj.setString("attribute name", testDate);


Generalized function to execute query.
public IDfCollection executeQuery(String query, IDfSession session)
   {
         writeToLog(this," Execute query="+query);
         IDfQuery dfquery = new DfQuery();
       dfquery.setDQL(query);
       IDfCollection coll = null;
            try
            {
                  coll = dfquery.execute(session, IDfQuery.DF_READ_QUERY);
            }
            catch (DfException e)
            {
                  e.printStackTrace();
            }
             return coll;
   }

   To get current server time

   public IDfTime getDocbaseTime ( IDfSession session ) throws DfException
{
         IDfQuery query = new DfQuery();
         query.setDQL("select DATE(NOW) as systime from dm_server_config");
         IDfCollection col = query.execute(session,IDfQuery.DF_READ_QUERY);
         IDfTime serverTime = null;
         try {
         if (col.next()){
         serverTime = col.getTime("systime");
         }
}
         finally {
         if (col != null) col.close();
         }
   return serverTime;
         }
         



       To remove dm_bp_resume from the queue.
  
   public void removeBPEvent(IDfWorkitem workitemObj, IDfSession session)
   {
     
      String query = null;
            try
            {
            query = "select stamp from dm_queue where event = 'dm_bp_resume' and item_id = '" + workitemObj.getWorkflowId() + "'";                  IDfCollection coll = executeQuery(query,session);
                  while (coll.next())
            {
                  IDfId queueID = coll.getId("stamp");
                  session.dequeue(queueID);
            }
            coll.close();
                        }
            catch (DfException e) {
                 
                  e.printStackTrace();
            }
}
  



To get workflow parameters for a workflow method.

 protected void initWorkflowParams(Map params)
    {
        // get the 4 WF-related parameters always passed in by Server
       Set keys = params.keySet();
       Iterator iter = keys.iterator();
       while (iter.hasNext())
       {
           String key = (String) iter.next();
           if( (key == null) || (key.length() == 0) )
           {
               continue;
           }
           String []value = (String[])params.get(key);

           if ( key.equalsIgnoreCase(USER_KEY) )
               m_userName = (value.length > 0) ? value[0] : "";
           else if ( key.equalsIgnoreCase(DOCBASE_KEY) )
               m_docbase = (value.length > 0) ? value[0] : "";
           else if ( key.equalsIgnoreCase(WORKITEM_KEY_2 ) )
               m_workitemId = (value.length > 0) ? value[0] : "";
           else if ( key.equalsIgnoreCase(WORKITEM_KEY ) )
               m_workitemId = (value.length > 0) ? value[0] : "";
           else if ( key.equalsIgnoreCase(TICKET_KEY) )
               m_ticket = (value.length > 0) ? value[0] : "";
              
       }
     
   }

  

To get  IDfSessionManager

protected IDfSessionManager login() throws DfException
   {
       if (m_docbase == null || m_userName == null || m_ticket == null )
           return null;
          
       // now login
       IDfClient dfClient = DfClient.getLocalClient();

       if (dfClient != null)
       {
           IDfLoginInfo li = new DfLoginInfo();
           li.setUser(m_userName);
           li.setPassword(m_ticket);
           li.setDomain(null);
           IDfSessionManager sessionMgr = dfClient.newSessionManager();
           sessionMgr.setIdentity(m_docbase, li);
           return sessionMgr;
       }
       return null;
   }


To handle Apostrophe(‘) in code.
private String getRefineAttr(String clientName) {
        String name = clientName;
        if (name.contains("'")) {
            name = name.replace("'", "''");
        }
        return name;
    }

Sunday 21 July 2013

Write a Workflow Method(DFC Methods)

Do you want to add a processing logic on your document attached to the workflow as a package?

Here are the few easy steps to do the same.

1)      Create a documentum project in your composer workspace.
2)        Write a java method with the processing logic which you want to perform on your document. Make sure that a java file implements IDmMethod  interface.
Method  public void execute(Map params, OutputStream ostream) throws Exception
    {
//processing logic
}

Should include all the logic.

3)       Create a method artifact and give attribute values as below:
·         Name: Method Name
·         Type: Java
·         Command: The java file name along with the package e.g.  com.myProject.methods.workflowMethods. WorkflowTestMethod
Select the checkbox: use as workflow method(This attribute will make this method as a workflow method and you can select the same while designing your workflow template.)

Other setting depends how and where you want to run your method i.e To run on Content Server or Application Server.
Run on Content Server or Method server.

4)      Save the method and install into repository.
5)      Login to content server and deploy the java class files in method server methods.
6)      Restart the content server.
7)      Login to workflow builder\process builder. Select the workflow template for which you want to add workflow method.
8)      Create an auto activity and select above defined method as workflow method for the activity.
9)      Select Performer as Docbase Owner for the activity.
10)  Save and Install the template into repository.

Your workflow method is ready for testing. Now do you feel it’s so difficult to create workflow methods…I am sure you won’t J

HAPPY LEARING!!!

Thursday 18 July 2013

Dynamic Groups In Documentum

Sometimes application User needs to perform task for which they might need Superuser privileges. As client policies won't allow Application Users to have Superuser permissions, some workaround is needed to solve this issue.
This is the time when Dynamic groups come into picture.
A dynamic group is a group, of any group class, whose list of members is considered
a list of potential members. A setting in the group’s definition defines whether the
potential members are treated as members of the group or not when a repository session
is started. Depending on that setting, an application can issue a session call to add or
remove a user from the group when the session starts.
To simplify above lines let me give one example.
Scenario: For one of the wdk component users needs link\move permission on folders. As folder security is on, it's not possible to move\link folders with user session for which he\she doesn't have permission.
Solution:
1) Create a dynamic protected role(dynamic_superuser_role).
2) Add Groups or Users which needs to have Superuser access in application. These members are called Potential members.
3) Add dynamic_superuser_role in admingroup and docu group.
4) Login to DA as dmadmin. Browse to Administration/Client Rights Management/Privileged Clients node. Click on Manage Client button on right upper corner of screen.Add your client application entry in this list. This will provide access to your client application to use dynamic protected group using user sessions.
5) To identify your application dfc, you can give dfc.name=MyApplicationDFC in dfc.properties file of application.
Above settings allow user sessions to perform tasks with Superuser privileges.
In wdk application, you can write below lines of code
getDfSession().addDynamicGroup("dynamic_superuser_role ");
//Perform your operations.
getDfSession().removeDynamicGroup("dynamic_superuser_role ");