Hi,
Just a simple post concerning a useful functionality provided by Documentum in com.documentum.xml.xdql DFC package.
As you would see in my previous post http://www.javablog.fr/xstream-presentation-serialization-deserialization-xml.html, there is another solutions/frameworks like Xstream for the serialization and deserialization of XML in Java applications.
SOLUTION 1
This package com.documentum.xml.xdql contains only the Interface IDfXmlQuery. This interface provides functionality for running queries against a repository, returning the results as XML.
The structure of the XML output is a root element, specified by setRootTag, followed by each query result row. The following is an example of the XML output:
<?xml version="1.0"?>
<root>
<object ID="09017e1080001932">
<r_object_id>09017e1080001932</r_object_id>
<object_name>catalog A</object_name>
</object>
<object ID="09017e10800019aa">
<r_object_id>09017e10800019aa</r_object_id>
<object_name>catalog B</object_name>
</object>
</root>
There are many options available for customizing the XML output, such as specifying the whether object content should be included in the output. Each option has a default value, so you only need to set the options that you want to override.
Sample DFC code to get document as XML
package com.huo.test.ecm.test2;
import java.io.FileOutputStream;
import java.io.IOException;
import com.documentum.fc.client.DfClient;
import com.documentum.fc.client.IDfClient;
import com.documentum.fc.client.IDfQuery;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSessionManager;
import com.documentum.fc.client.IDfSysObject;
import com.documentum.fc.common.DfException;
import com.documentum.fc.common.DfLoginInfo;
import com.documentum.fc.common.IDfLoginInfo;
import com.documentum.xml.xdql.DfXmlQuery;
import com.documentum.xml.xdql.IDfXmlQuery;
/*
Documentum DFC Standalone Sample Program
Sample DFC code to get document as XML
*/
public class DocumentRecordsAsXMLTest {
IDfSysObject sysObject = null;
IDfSession idfSession = null;
IDfSessionManager sessMgr = null;
public DocumentRecordsAsXMLTest(String user, String passwd, String docbase) throws Exception {
getDfSession(user, passwd, docbase);
}
public IDfSession getDfSession(String args1, String args2, String args3) throws Exception {
IDfLoginInfo login = new DfLoginInfo();
login.setUser(args1);
login.setPassword(args2);
IDfClient client = DfClient.getLocalClient(); //new DfClient();
sessMgr = client.newSessionManager();
sessMgr.setIdentity(args3, login);
idfSession = sessMgr.getSession(args3);
if (idfSession != null)
System.out.println("Session created successfully");
return idfSession;
}
public void releaseSession() throws Exception {
sessMgr.release(idfSession);
}
public String getdm_documentRecordsAsXML(String dql, String fileStoring) throws DfException {
System.out.println("#################################################");
IDfXmlQuery objDfXmlQuery = new DfXmlQuery();
objDfXmlQuery.init();
objDfXmlQuery.setDql(dql);
objDfXmlQuery.setContentAsLink(true);
objDfXmlQuery.setMetaDataAsAttributes(false);
//objDfXmlQuery.setPreserveSpace(true);
objDfXmlQuery.setRepeatingAsNested(true);
objDfXmlQuery.setRepeatingIncludeIndex(true);
objDfXmlQuery.includeMetaData(true);
objDfXmlQuery.useNullAttributeIndicator(true);
objDfXmlQuery.includeDCTMChunkInfo(true);
objDfXmlQuery.includeContent(true);
objDfXmlQuery.execute(IDfQuery.DF_READ_QUERY, idfSession);
String xml = objDfXmlQuery.getXMLString();
System.out.println("XML is : " + xml);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(fileStoring);
objDfXmlQuery.getXMLString(fos);
} catch (Exception e) {
e.printStackTrace();
}finally{
if(fos != null){
try { fos.flush(); } catch (IOException e) { e.printStackTrace(); }
try { fos.close(); } catch (IOException e) { e.printStackTrace(); }
}
}
return xml;
}
public static void main(String[] args) throws Exception {
String user = "myuser";
String passwd = "passeord4myus";
String docbase = "MY_DOC_BASE";
DocumentRecordsAsXMLTest object = new DocumentRecordsAsXMLTest(user, passwd, docbase);
try {
// To get document as XML
object.getdm_documentRecordsAsXML("select * from dm_document where r_object_id='090xxxxxxxxxxxxf1d'", "C:\\Workspaces\\TestDCTMHUO\\src\\com\\huo\\test\\ecm\\test2\\documentXML.xml");
} finally {
// to release a docbase session
object.releaseSession();
}
}
}
….outputs:
Session created successfully
#################################################
XML is : <?xml version="1.0"?>
<root>
<object ID="090xxxxxxxxxxxxf1d">
<r_object_id>090xxxxxxxxxxxxf1d</r_object_id>
<object_name>Test 12</object_name>
<title>null</title>
<subject>null</subject>
<resolution_label>null</resolution_label>
<owner_name>gedadm</owner_name>
<owner_permit>6</owner_permit>
<group_name>null</group_name>
<group_permit>1</group_permit>
<world_permit>1</world_permit>
<log_entry>null</log_entry>
<acl_domain>MYDOCBASEDEV</acl_domain>
<acl_name>dm_450220c580068103_8005a971</acl_name>
<language_code>null</language_code>
<r_object_type>huo_client_document</r_object_type>
<r_creation_date>12/02/2014 15:20:56</r_creation_date>
<r_modify_date>18/11/2016 15:18:21</r_modify_date>
<a_content_type>dxl</a_content_type>
<content r_object_id="090xxxxxxxxxxxxf1d">dctm://MY_DOC_BASE/090xxxxxxxxxxxxf1d?DMS_OBJECT_SPEC=OBJECT_ID</content>
</object>
</root>
Document with aspect attached
// To get document-aspect as XML
object.getdm_documentRecordsAsXML("select r_object_id, r_modifier, r_modify_date, r_aspect_name, object_name, aspect_huo.huo_request_num from dm_document where r_object_id='090xxxxxxxxxxxx36'", "C:\\Workspaces\\TestDCTMHUO\\src\\com\\huo\\test\\ecm\\test2\\documentXML.xml");
….outputs:
Session created successfully
#################################################
XML is : <?xml version="1.0"?>
<root>
<object ID="090xxxxxxxxxxxx36">
<r_object_id>090xxxxxxxxxxxx36</r_object_id>
<r_modifier>gedadm</r_modifier>
<r_modify_date>19/10/2016 14:38:41</r_modify_date>
<r_aspect_name>
<r_aspect_name-value index="0">aspect_huo</r_aspect_name-value>
<r_aspect_name-value index="1">aspect_copy</r_aspect_name-value>
<r_aspect_name-value index="2">aspect_email</r_aspect_name-value>
</r_aspect_name>
<object_name>HUO value object name.
Residential II S.A.</object_name>
<aspect_huo.huo_request_num>900971</aspect_huo.huo_request_num>
<content r_object_id="090xxxxxxxxxxxx36">dctm://MY_DOC_BASE/090xxxxxxxxxxxx36?DMS_OBJECT_SPEC=OBJECT_ID</content>
</object>
</root>
SOLUTION 2
Documentum proposes methods accessible via API and DFC:
System.out.println(dfDocument.getString("_xml_string"));
API> get,c,090XXXXXXXXXXXXXXX03,_xml_string
...
<dctm-attr name="r_object_id" type="ID" repeating="true" index="0"><![CDATA[090XXXXXXXXXXXXXXX03]]></dctm-attr>
<dctm-attr name="object_name" type="STRING"><![CDATA[My doc name]]></dctm-attr>
<dctm-attr name="r_object_type" type="STRING"><![CDATA[my_document]]></dctm-attr>
<dctm-attr name="title" type="STRING"><![CDATA[]]></dctm-attr>
<dctm-attr name="subject" type="STRING"><![CDATA[]]></dctm-attr>
<dctm-attr name="authors" type="STRING" repeating="true" index="0"><![CDATA[]]></dctm-attr>
<dctm-attr name="keywords" type="STRING" repeating="true" index="0"><![CDATA[]]></dctm-attr>
<dctm-attr name="a_application_type" type="STRING"><![CDATA[]]></dctm-attr>
<dctm-attr name="a_status" type="STRING"><![CDATA[]]></dctm-attr>
<dctm-attr name="r_creation_date" type="TIME"><![CDATA[2015-09-22 11:38:22]]></dctm-attr>
<dctm-attr name="r_modify_date" type="TIME"><![CDATA[2015-09-22 11:38:22]]></dctm-attr>
<dctm-attr name="r_modifier" type="STRING"><![CDATA[useradm]]></dctm-attr>
<dctm-attr name="r_access_date" type="TIME"><![CDATA[2018-12-18 13:49:03]]></dctm-attr>
<dctm-attr name="a_is_hidden" type="BOOL"><![CDATA[F]]></dctm-attr>
<dctm-attr name="i_is_deleted" type="BOOL"><![CDATA[F]]></dctm-attr>
<dctm-attr name="a_retention_date" type="TIME"><![CDATA[]]></dctm-attr>
<dctm-attr name="a_archive" type="BOOL"><![CDATA[F]]></dctm-attr>
<dctm-attr name="a_compound_architecture" type="STRING"><![CDATA[]]></dctm-attr>
<dctm-attr name="a_link_resolved" type="BOOL"><![CDATA[F]]></dctm-attr>
<dctm-attr name="i_reference_cnt" type="INT"><![CDATA[1]]></dctm-attr>
<dctm-attr name="i_has_folder" type="BOOL"><![CDATA[T]]></dctm-attr>
<dctm-attr name="i_folder_id" type="ID" repeating="true" index="0"><![CDATA[0bXXXXXXXXXXXXXXXXXf9]]></dctm-attr>
<dctm-attr name="r_composite_id" type="ID" repeating="true" index="0"><![CDATA[]]></dctm-attr>
<dctm-attr name="r_composite_label" type="STRING" repeating="true" index="0"><![CDATA[]]></dctm-attr>
<dctm-attr name="r_component_label" type="STRING" repeating="true" index="0"><![CDATA[]]></dctm-attr>
<dctm-attr name="r_order_no" type="INT" repeating="true" index="0"><![CDATA[]]></dctm-attr>
<dctm-attr name="r_link_cnt" type="INT"><![CDATA[0]]></dctm-attr>
<dctm-attr name="r_link_high_cnt" type="INT"><![CDATA[0]]></dctm-attr>
<dctm-attr name="r_assembled_from_id" type="ID"><![CDATA[0000000000000000]]></dctm-attr>
<dctm-attr name="r_frzn_assembly_cnt" type="INT"><![CDATA[0]]></dctm-attr>
<dctm-attr name="r_has_frzn_assembly" type="BOOL"><![CDATA[F]]></dctm-attr>
<dctm-attr name="resolution_label" type="STRING"><![CDATA[]]></dctm-attr>
<dctm-attr name="r_is_virtual_doc" type="INT"><![CDATA[0]]></dctm-attr>
<dctm-attr name="i_contents_id" type="ID"><![CDATA[060XXXXXXXXXXXXXXXXX7]]></dctm-attr>
<dctm-attr name="a_content_type" type="STRING"><![CDATA[pdf]]></dctm-attr>
<dctm-attr name="r_page_cnt" type="INT"><![CDATA[1]]></dctm-attr>
<dctm-attr name="r_content_size" type="INT"><![CDATA[183446]]></dctm-attr>
<dctm-attr name="a_full_text" type="BOOL"><![CDATA[T]]></dctm-attr>
<dctm-attr name="a_storage_type" type="STRING"><![CDATA[filestore_01]]></dctm-attr>
<dctm-attr name="i_cabinet_id" type="ID"><![CDATA[0cXXXXXXXXXXXXXXXX02]]></dctm-attr>
<dctm-attr name="owner_name" type="STRING"><![CDATA[useradm]]></dctm-attr>
<dctm-attr name="owner_permit" type="INT"><![CDATA[1]]></dctm-attr>
<dctm-attr name="group_name" type="STRING"><![CDATA[docu]]></dctm-attr>
<dctm-attr name="group_permit" type="INT"><![CDATA[1]]></dctm-attr>
<dctm-attr name="world_permit" type="INT"><![CDATA[1]]></dctm-attr>
<dctm-attr name="i_antecedent_id" type="ID"><![CDATA[0000000000000000]]></dctm-attr>
<dctm-attr name="i_chronicle_id" type="ID"><![CDATA[09XXXXXXXXXXXXXX03]]></dctm-attr>
<dctm-attr name="i_latest_flag" type="BOOL"><![CDATA[T]]></dctm-attr>
<dctm-attr name="r_lock_owner" type="STRING"><![CDATA[]]></dctm-attr>
<dctm-attr name="r_lock_date" type="TIME"><![CDATA[]]></dctm-attr>
<dctm-attr name="r_lock_machine" type="STRING"><![CDATA[]]></dctm-attr>
<dctm-attr name="log_entry" type="STRING"><![CDATA[]]></dctm-attr>
<dctm-attr name="r_version_label" type="STRING" repeating="true" index="0"><![CDATA[1.0]]></dctm-attr>
<dctm-attr name="r_version_label" type="STRING" repeating="true" index="1"><![CDATA[CURRENT]]></dctm-attr>
<dctm-attr name="i_branch_cnt" type="INT"><![CDATA[0]]></dctm-attr>
<dctm-attr name="i_direct_dsc" type="BOOL"><![CDATA[F]]></dctm-attr>
<dctm-attr name="r_immutable_flag" type="BOOL"><![CDATA[F]]></dctm-attr>
<dctm-attr name="r_frozen_flag" type="BOOL"><![CDATA[F]]></dctm-attr>
<dctm-attr name="r_has_events" type="BOOL"><![CDATA[F]]></dctm-attr>
<dctm-attr name="acl_domain" type="STRING"><![CDATA[MYDOCBASEDEV]]></dctm-attr>
<dctm-attr name="acl_name" type="STRING"><![CDATA[dm_450XXXXXXXXXXXXXXXea_8YYY5]]></dctm-attr>
<dctm-attr name="a_special_app" type="STRING"><![CDATA[]]></dctm-attr>
<dctm-attr name="i_is_reference" type="BOOL"><![CDATA[F]]></dctm-attr>
<dctm-attr name="r_creator_name" type="STRING"><![CDATA[useradm]]></dctm-attr>
<dctm-attr name="r_is_public" type="BOOL"><![CDATA[F]]></dctm-attr>
<dctm-attr name="r_policy_id" type="ID"><![CDATA[0000000000000000]]></dctm-attr>
<dctm-attr name="r_resume_state" type="INT"><![CDATA[0]]></dctm-attr>
<dctm-attr name="r_current_state" type="INT"><![CDATA[0]]></dctm-attr>
<dctm-attr name="r_alias_set_id" type="ID"><![CDATA[0000000000000000]]></dctm-attr>
<dctm-attr name="a_effective_date" type="TIME" repeating="true" index="0"><![CDATA[]]></dctm-attr>
<dctm-attr name="a_expiration_date" type="TIME" repeating="true" index="0"><![CDATA[]]></dctm-attr>
<dctm-attr name="a_publish_formats" type="STRING" repeating="true" index="0"><![CDATA[]]></dctm-attr>
<dctm-attr name="a_effective_label" type="STRING" repeating="true" index="0"><![CDATA[]]></dctm-attr>
<dctm-attr name="a_effective_flag" type="STRING" repeating="true" index="0"><![CDATA[]]></dctm-attr>
<dctm-attr name="a_category" type="STRING"><![CDATA[]]></dctm-attr>
<dctm-attr name="language_code" type="STRING"><![CDATA[]]></dctm-attr>
<dctm-attr name="a_is_template" type="BOOL"><![CDATA[F]]></dctm-attr>
<dctm-attr name="a_controlling_app" type="STRING"><![CDATA[]]></dctm-attr>
<dctm-attr name="r_full_content_size" type="DOUBLE"><![CDATA[183446]]></dctm-attr>
<dctm-attr name="a_extended_properties" type="STRING" repeating="true" index="0"><![CDATA[]]></dctm-attr>
<dctm-attr name="a_is_signed" type="BOOL"><![CDATA[F]]></dctm-attr>
<dctm-attr name="a_last_review_date" type="TIME"><![CDATA[]]></dctm-attr>
<dctm-attr name="i_retain_until" type="TIME"><![CDATA[]]></dctm-attr>
<dctm-attr name="r_aspect_name" type="STRING" repeating="true" index="0"><![CDATA[my_aspect]]></dctm-attr>
<dctm-attr name="i_retainer_id" type="ID" repeating="true" index="0"><![CDATA[]]></dctm-attr>
<dctm-attr name="i_partition" type="INT"><![CDATA[0]]></dctm-attr>
<dctm-attr name="i_is_replica" type="BOOL"><![CDATA[F]]></dctm-attr>
<dctm-attr name="i_vstamp" type="INT"><![CDATA[1]]></dctm-attr>
....
<dctm-attr name="metdata_id" type="INT"><![CDATA[121231]]></dctm-attr>
<dctm-attr name="metdata_name" type="STRING"><![CDATA[MY DOC user Name]]></dctm-attr>
<dctm-attr name="business_year" type="STRING"><![CDATA[2014]]></dctm-attr>
....
That’s all!!!
Huseyin OZVEREN
