top-image

OLDER ARTICLES

Hi,

After the post concerning the Documentum : Ticketed Authentication, Generation Of DM_TICKET, I would expose in this post the principal-mode authentication via the use of IDfPrincipalSupport interface.

The DFC javadoc describes this interface: An interface supported by classes that can establish sessions using principal-mode authentication. Principal-mode authentication is a form of authentication in which the caller has already established the validity of the user and therefore an explicit password verification is not needed.
 
 

IDfPrincipalSupport Interface

In order to use principal support, the IDfPrincipalSupport object must be a custom class that implements IDfPrincipalSupport and overrides its IDfSession IDfPrincipalSupport.getSession(String docbaseName, String principalName) method. More, this class must could have a constructor with Constructor(IDfTrustManager trustManager) parameter for an established authentication within the admin-user.
 
A getSession method with String docbaseName, String principalName parameters corresponding to the docbase and login of user for which a session must be created. First a session is created for the admin-user with the established dfSessionManager

synchronized (dfSessionManager) {
	if (!dfSessionManager.hasIdentity(docbaseName)) {
		dfSessionManager.setIdentity(docbaseName, dfTrustManager.getTrustCredential(docbaseName));
	}
}
IDfSession dfSession = dfSessionManager.getSession(docbaseName);

 
….and second, a LoginTicket is created for principalName user via the previously created session:

IDfClientX dfClientX = new DfClientX();
IDfClient dfClient = dfClientX.getLocalClient();
result = dfClient.newSession(docbaseName, new DfLoginInfo(principalName, dfSession.getLoginTicketForUser(principalName)));

 
…. and last, the first created session of admin-user is released:

dfSessionManager.release(dfSession);

 
Here the full code of MyPrincipalSupport class:


	private static class MyPrincipalSupport implements IDfPrincipalSupport {

		private final IDfTrustManager dfTrustManager;
		private final IDfSessionManager dfSessionManager;

		public MyPrincipalSupport(IDfTrustManager trustManager) throws DfException {
			if (trustManager == null) {
				throw new IllegalArgumentException("trustManager cannot be null");
			}
			this.dfTrustManager = trustManager;
			IDfClientX dfClientX = new DfClientX();
			IDfClient dfClient = dfClientX.getLocalClient();
			this.dfSessionManager = dfClient.newSessionManager();
		}

		@Override
		public IDfSession getSession(String docbaseName, String principalName) throws DfPrincipalException {
			try {
				if (!dfSessionManager.hasIdentity(docbaseName)) {
					synchronized (dfSessionManager) {
						if (!dfSessionManager.hasIdentity(docbaseName)) {
							dfSessionManager.setIdentity(docbaseName, dfTrustManager.getTrustCredential(docbaseName));
						}
					}
				}
				IDfSession result;
				IDfSession dfSession = dfSessionManager.getSession(docbaseName);
				try {
					IDfClientX dfClientX = new DfClientX();
					IDfClient dfClient = dfClientX.getLocalClient();
					result = dfClient.newSession(docbaseName, new DfLoginInfo(principalName, dfSession.getLoginTicketForUser(principalName)));
				} finally {
					dfSessionManager.release(dfSession);
				}
				return result;
			} catch (DfPrincipalException e) {
				throw e;
			} catch (Exception e) {
				throw new DfPrincipalException(MessageFormat.format("Unable to retrieve IdfSession for user \"{0}\" and docbase {1}", principalName, docbaseName), e);
			}
		}
	}

 
 

Identity Mode VS Principal Support Mode

The Identity Mode is the classic authentication method via the parameters String userAdmin, String passwdAdmin, String docbase:

		IDfLoginInfo login = new DfLoginInfo();
		login.setUser(userAdmin);
		login.setPassword(passwdAdmin);
		IDfClientX clientx = new DfClientX();
		IDfClient client = clientx.getLocalClient();

		this.sessMgr = client.newSessionManager();
		this.sessMgr.setIdentity(docbase, login);
	
		this.idfSession = sessMgr.getSession(docbase);
		if (this.idfSession != null)
			System.out.println("Session created successfully");

 
The Principal Support Mode is a proxy authentication method using the class implementing IDfPrincipalSupport with the parameters String userAdmin, String passwdAdmin, String docbase, String principalName. The void setPrincipalSupport(IDfPrincipalSupport support) method changes the session manager mode from “Identity” mode to “Principal Support” mode in order to support single sign in. This method allows a client to define a handler that creates sessions on behalf of principal users.

		IDfLoginInfo login = new DfLoginInfo();
		login.setUser(userAdmin);
		login.setPassword(passwdAdmin);
		IDfClientX clientx = new DfClientX();
		IDfClient client = clientx.getLocalClient();

		client.setPrincipalSupport(new MyPrincipalSupport(new DfSimpleTrustManager(new DfLoginInfo(userAdmin, passwdAdmin))));
		this.sessMgr = client.newSessionManager();
		this.sessMgr.setPrincipalName(principalName);
		
		this.idfSession = sessMgr.getSession(docbase);
		if (this.idfSession != null)
			System.out.println("Session created successfully");

 
 

TESTS : Identity Mode VS Principal Support Mode

Here, a test class creating a document using these 2 modes:

package com.huo.test.ecm.test5;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.text.MessageFormat;

import org.apache.commons.io.IOUtils;

import com.documentum.com.DfClientX;
import com.documentum.com.IDfClientX;
import com.documentum.fc.client.DfPrincipalException;
import com.documentum.fc.client.DfSimpleTrustManager;
import com.documentum.fc.client.IDfClient;
import com.documentum.fc.client.IDfDocument;
import com.documentum.fc.client.IDfPrincipalSupport;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSessionManager;
import com.documentum.fc.client.IDfTrustManager;
import com.documentum.fc.common.DfException;
import com.documentum.fc.common.DfLoginInfo;
import com.documentum.fc.common.IDfLoginInfo;
import com.documentum.fc.common.impl.MessageHelper;



/**
 * Documentum DFC - Principal-Mode Authentication : Use of IDfPrincipalSupport
 * 
 * Use of "IDfPrincipalSupport" interface:
 * 			An interface supported by classes that can establish sessions using principal-mode authentication. 
 * 			Principal-mode authentication is a form of authentication in which the caller has already established the validity of the user and therefore an explicit 
 * 			password verification is not needed.
 * 
 */
public class DfcPrincipalSupportLoginTest {


	IDfSession idfSession = null;
	IDfSessionManager sessMgr = null;

	private static class MyPrincipalSupport implements IDfPrincipalSupport {

		private final IDfTrustManager dfTrustManager;
		private final IDfSessionManager dfSessionManager;

		public MyPrincipalSupport(IDfTrustManager trustManager) throws DfException {
			if (trustManager == null) {
				throw new IllegalArgumentException("trustManager cannot be null");
			}
			this.dfTrustManager = trustManager;
			IDfClientX dfClientX = new DfClientX();
			IDfClient dfClient = dfClientX.getLocalClient();
			this.dfSessionManager = dfClient.newSessionManager();
		}

		@Override
		public IDfSession getSession(String docbaseName, String principalName) throws DfPrincipalException {
			try {
				if (!dfSessionManager.hasIdentity(docbaseName)) {
					synchronized (dfSessionManager) {
						if (!dfSessionManager.hasIdentity(docbaseName)) {
							dfSessionManager.setIdentity(docbaseName, dfTrustManager.getTrustCredential(docbaseName));
						}
					}
				}
				IDfSession result;
				IDfSession dfSession = dfSessionManager.getSession(docbaseName);
				try {
					IDfClientX dfClientX = new DfClientX();
					IDfClient dfClient = dfClientX.getLocalClient();
					result = dfClient.newSession(docbaseName, new DfLoginInfo(principalName, dfSession.getLoginTicketForUser(principalName)));
				} finally {
					dfSessionManager.release(dfSession);
				}
				return result;
			} catch (DfPrincipalException e) {
				throw e;
			} catch (Exception e) {
				throw new DfPrincipalException(MessageFormat.format("Unable to retrieve IdfSession for user \"{0}\" and docbase {1}", principalName, docbaseName), e);
			}
		}
	}
	



	/**
	 * Create a Session in "Identity Mode" OR "Principal Support Mode"
	 * @param userAdmin
	 * @param passwdAdmin
	 * @param docbase
	 * @param principalName
	 * @throws Exception
	 */
	public DfcPrincipalSupportLoginTest(String userAdmin, String passwdAdmin, String docbase, String principalName) throws Exception {

		IDfLoginInfo login = new DfLoginInfo();
		login.setUser(userAdmin);
		login.setPassword(passwdAdmin);
		IDfClientX clientx = new DfClientX();
		IDfClient client = clientx.getLocalClient();

		// Principal Support Mode 
		if(principalName!=null){
			client.setPrincipalSupport(new MyPrincipalSupport(new DfSimpleTrustManager(new DfLoginInfo(userAdmin, passwdAdmin))));
			this.sessMgr = client.newSessionManager();
			this.sessMgr.setPrincipalName(principalName);
			
		// Identity Mode
		}else{
			this.sessMgr = client.newSessionManager();
			this.sessMgr.setIdentity(docbase, login);
		}
		
		this.idfSession = sessMgr.getSession(docbase);
		if (this.idfSession != null)
			System.out.println("Session created successfully");
	}	
	


	public void releaseSession() throws Exception {
		if(sessMgr!=null && idfSession!=null){
			sessMgr.release(idfSession);
		}
	}
	




	public static void main(String[] args) throws Exception {
		testWithSession();
		
		testWithSessionOfPrincipalNameViaPrincipalSupport();
	}
	
	public static void testWithSession() throws Exception {
		long startTime = 0;
		long stopTime = 0;
		
		String userAdmin = "adminuser";
		String passwdAdmin = "pass_4adminuser";
		String docbase = "MY_DOCBASE";
		
		DfcPrincipalSupportLoginTest object = new DfcPrincipalSupportLoginTest(userAdmin, passwdAdmin, docbase, null);
		
		boolean isTransactionalSession = false;
		boolean noErrorWithCurrentDocument = false;
		try {
			if (!object.idfSession.isTransactionActive()) {
				object.idfSession.beginTrans();
				isTransactionalSession = true;
			}

			startTime = System.currentTimeMillis();
			
			// --- MetaData
			IDfDocument dfDocument = (IDfDocument) object.idfSession.newObject("my_huo_document");
			dfDocument.setObjectName("Object's name");
			dfDocument.setTitle("Object's title");
			dfDocument.setString("owner_name", userAdmin);
			dfDocument.setString("year", "2018");
			dfDocument.setString("status_label", "DRAFT");
			dfDocument.setContentType("excel12book");

			// --- Content
			ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
			InputStream inputStream = null;
			try {
				File contentFile = new File("C:\\Users\\principalName\\Desktop\\temp.pdf");
				inputStream = new FileInputStream(contentFile);
				IOUtils.copy(inputStream, byteArrayOutputStream);
				dfDocument.setContent(byteArrayOutputStream);
				dfDocument.save();
			} finally {
				if(inputStream!=null){
					inputStream.close();
				}

				byteArrayOutputStream.close();
			}
			System.out.println("New document created successfully : " + dfDocument.getObjectId().getId());
			System.out.println("---------------------- ");
			System.out.println("object_name : " + dfDocument.getString("object_name"));
			System.out.println("title : " + dfDocument.getString("title"));
			System.out.println("owner_name : " + dfDocument.getString("owner_name"));
			System.out.println("r_modifier : " + dfDocument.getString("r_modifier"));
			System.out.println("r_creator_name : " + dfDocument.getString("r_creator_name"));
			for(int i=0 ; i<dfDocument.getVersionLabelCount(); i++){
				System.out.println("r_version_label ["+i+"]: " + dfDocument.getVersionLabel(i));
			}

			stopTime = System.currentTimeMillis();
			
			noErrorWithCurrentDocument = true;
			
		} catch (Throwable e) {
			StringBuilder sb = new StringBuilder(MessageFormat.format("ERROR : {0}", "java.lu"));
			sb.append(IOUtils.LINE_SEPARATOR);
			sb.append(MessageHelper.getStackTraceAsString(e));
			System.out.println(sb.toString());
			
		} finally {
			if (isTransactionalSession) {
				if (noErrorWithCurrentDocument) {
					object.idfSession.commitTrans();
				} else {
					object.idfSession.abortTrans();
				}
			}
			// to release a docbase session
			object.releaseSession();
			
			long elapsedTime = stopTime - startTime;
			System.out.println(MessageFormat.format("Execute() total execution time : {0} ms ", elapsedTime));
		}
	}
	



	public static void testWithSessionOfPrincipalNameViaPrincipalSupport() throws Exception {
		long startTime = 0;
		long stopTime = 0;
		
		String userAdmin = "adminuser";
		String passwdAdmin = "pass_4adminuser";
		String docbase = "MY_DOCBASE";
		String principalName = "principalName";
		
		DfcPrincipalSupportLoginTest object = new DfcPrincipalSupportLoginTest(userAdmin, passwdAdmin, docbase, principalName);
		
		boolean isTransactionalSession = false;
		boolean noErrorWithCurrentDocument = false;
		try {
			if (!object.idfSession.isTransactionActive()) {
				object.idfSession.beginTrans();
				isTransactionalSession = true;
			}

			startTime = System.currentTimeMillis();
			
			// --- MetaData
			IDfDocument dfDocument = (IDfDocument) object.idfSession.newObject("my_huo_document");
			dfDocument.setObjectName("Object's name");
			dfDocument.setTitle("Object's title");
			dfDocument.setString("owner_name", principalName);
			dfDocument.setString("year", "2018");
			dfDocument.setString("status_label", "DRAFT");
			dfDocument.setContentType("excel12book");

			// --- Content
			ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
			InputStream inputStream = null;
			try {
				File contentFile = new File("C:\\Users\\principalName\\Desktop\\temp.pdf");
				inputStream = new FileInputStream(contentFile);
				IOUtils.copy(inputStream, byteArrayOutputStream);
				dfDocument.setContent(byteArrayOutputStream);
				dfDocument.save();
			} finally {
				if(inputStream!=null){
					inputStream.close();
				}

				byteArrayOutputStream.close();
			}
			
			System.out.println("New document created successfully : " + dfDocument.getObjectId().getId());

			System.out.println("---------------------- ");
			System.out.println("object_name : " + dfDocument.getString("object_name"));
			System.out.println("title : " + dfDocument.getString("title"));
			System.out.println("owner_name : " + dfDocument.getString("owner_name"));
			System.out.println("r_modifier : " + dfDocument.getString("r_modifier"));
			System.out.println("r_creator_name : " + dfDocument.getString("r_creator_name"));
			for(int i=0 ; i<dfDocument.getVersionLabelCount(); i++){
				System.out.println("r_version_label ["+i+"]: " + dfDocument.getVersionLabel(i));
			}

			stopTime = System.currentTimeMillis();
			
			noErrorWithCurrentDocument = true;
			
		} catch (Throwable e) {
			StringBuilder sb = new StringBuilder(MessageFormat.format("ERROR : {0}", "java.lu"));
			sb.append(IOUtils.LINE_SEPARATOR);
			sb.append(MessageHelper.getStackTraceAsString(e));
			System.out.println(sb.toString());
			
		} finally {
			if (isTransactionalSession) {
				if (noErrorWithCurrentDocument) {
					object.idfSession.commitTrans();
				} else {
					object.idfSession.abortTrans();
				}
			}
			// to release a docbase session
			object.releaseSession();
			
			long elapsedTime = stopTime - startTime;
			System.out.println(MessageFormat.format("Execute() total execution time : {0} ms ", elapsedTime));
		}
	}
	
}

 
 
… the outputs are:

New document created successfully : 090xxxxxxxxxxxff4
---------------------- 
object_name : Object's name
title : Object's title
owner_name : adminuser
r_modifier : adminuser
r_creator_name : adminuser
r_version_label [0]: 1.0
r_version_label [1]: CURRENT
Execute() total execution time : 8,327 ms 




New document created successfully : 090xxxxxxxxxxxff5
---------------------- 
object_name : Object's name
title : Object's title
owner_name : principalName
r_modifier : principalName
r_creator_name : principalName
r_version_label [0]: 1.0
r_version_label [1]: CURRENT
Execute() total execution time : 600 ms 

Best regards,

Huseyin OZVEREN

Hi,

Just a post concerning the generation of JAVA webservice client for CXF and AXIS web services via an ANT script.

More information on sites on proxies creation:
http://cxf.apache.org/docs/wsdl-to-java.html
http://axis.apache.org/axis/java/ant/axis-wsdl2java.html

  • First, download the CXF and AXIS SDK librairies:
    C:\SDK\axis2-1.7.7
    C:\SDK\cfx-3.0.3
    C:\SDK\jdk1.7.0_17
     
  • Create a specific folder for the generated proxies sources (for example, WSProxyGenerator\src_generated)
     
  • References all needed libairies (JAR) in your project (for example lib/*.jar)
     
  • Create a properties file for the ANT script build.properties:
    cxf.home=C\:/SDK/cfx-3.0.3
    axis.home=C\:/SDK/axis2-1.7.7
    

     

  • Create a ANT script file build.xml containing the ANT targets create_proxy depending of init_proxy, create_proxy_cxf and create_proxy_axis targets:
    <?xml version="1.0" encoding="UTF-8"?>
    <project name="ProxiesGenerator" default="create_proxy" basedir=".">
    	<property file="build.properties" />
    
    	<target name="create_proxy" depends="init_proxy,create_proxy_cxf,create_proxy_axis" >
    	</target>
    	
    	<target name="init_proxy">
    		<fail unless="cxf.home" message="Apache CXF home (cxf.home) not set" />
    		<path id="cxf.classpath">
    			<fileset dir="${cxf.home}/lib">
    				<include name="*.jar" />
    			</fileset>
    		</path>
    
    		<fail unless="axis.home" message="Apache AXIS home (axis.home) not set" />
    
    		<path id="axis.classpath">
    			<fileset dir="${axis.home}/lib">
    				<include name="*.jar" />
    			</fileset>
    			<fileset dir="${basedir}/lib">
    				<include name="*.jar" />
    			</fileset>
    		</path>
    
    		<delete includeemptydirs="true">
    			<fileset dir="${basedir}/src_generated">
    				<include name="**/*.java" />
    			</fileset>
    		</delete>
    		<mkdir dir="${basedir}/src_generated" />
    	</target>
    
    	<target name="create_proxy_cxf">
    	</target>
    
    	<target name="create_proxy_axis">
    	</target>
    </project>
    

     

 

CXF proxy generation

  • Create a file containing the URLs of CXF web services wsdllist_cxf.txt:
    https://myserver1.java.lu/services/core/MyObjectService?wsdl
    https://myserver1.java.lu/services/core/MyObjectService2?wsdl
    

     

  • Create a file for the binding-name simple-binding.xjb
    <?xml version="1.0" encoding="UTF-8"?>
    <jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    	jaxb:version="2.0" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
    	jaxb:extensionBindingPrefixes="xjc">
    	<jaxb:globalBindings>
    		<xjc:simple />
    		<xjc:serializable uid="1397139757393" />
    	</jaxb:globalBindings>
    </jaxb:bindings>
    

     

  • Create in the build.xml file the CXF target:
    	<target name="create_proxy_cxf">
    		<java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true">
    			<arg value="-autoNameResolution" />
    			<arg value="-verbose" />
    			<arg value="-fe" />
    			<arg value="jaxws21" />
    			<arg value="-encoding" />
    			<arg value="Cp1252" />
    			<arg value="-d" />
    			<arg value="${basedir}/src_generated" />
    			<arg value="-b" />
    			<arg value="simple-binding.xjb" />
    			<arg value="-wsdlList" />
    			<arg value="wsdllist_cxf.txt" />
    			<classpath>
    				<path refid="cxf.classpath" />
    			</classpath>
    		</java>
    	</target>
    

     

 

AXIS proxy generation

  • Create in the build.xml file the CXF target:
    	<target name="create_proxy_axis">
    		<java classname="org.apache.axis.wsdl.WSDL2Java" fork="true">
    			<arg value="--verbose" />
    			<arg value="--Debug" />
    			<arg value="--output" />
    			<arg value="${basedir}/src_generated" />
    			<arg value="-u" />
    			<arg value="https://myserver2.java.lu/MyWebServices/services/MyWebService?wsdl" />
    			<classpath>
    				<path refid="axis.classpath" />
    			</classpath>
    		</java>
    	</target>
    

     

 

build.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="ProxiesGenerator" default="create_proxy" basedir=".">
	<property file="build.properties" />

	<target name="create_proxy" depends="init_proxy,create_proxy_cxf,create_proxy_axis" >
	</target>
	
	<target name="init_proxy">
		<fail unless="cxf.home" message="Apache CXF home (cxf.home) not set" />
		<path id="cxf.classpath">
			<fileset dir="${cxf.home}/lib">
				<include name="*.jar" />
			</fileset>
		</path>

		<fail unless="axis.home" message="Apache AXIS home (axis.home) not set" />

		<path id="axis.classpath">
			<fileset dir="${axis.home}/lib">
				<include name="*.jar" />
			</fileset>
			<fileset dir="${basedir}/lib">
				<include name="*.jar" />
			</fileset>
		</path>

		<delete includeemptydirs="true">
			<fileset dir="${basedir}/src_generated">
				<include name="**/*.java" />
			</fileset>
		</delete>
		<mkdir dir="${basedir}/src_generated" />
	</target>

	<target name="create_proxy_cxf">
		<java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true">
			<arg value="-autoNameResolution" />
			<arg value="-verbose" />
			<arg value="-fe" />
			<arg value="jaxws21" />
			<arg value="-encoding" />
			<arg value="Cp1252" />
			<arg value="-d" />
			<arg value="${basedir}/src_generated" />
			<arg value="-b" />
			<arg value="simple-binding.xjb" />
			<arg value="-wsdlList" />
			<arg value="wsdllist_cxf.txt" />
			<classpath>
				<path refid="cxf.classpath" />
			</classpath>
		</java>
	</target>

	<target name="create_proxy_axis">
		<java classname="org.apache.axis.wsdl.WSDL2Java" fork="true">
			<arg value="--verbose" />
			<arg value="--Debug" />
			<arg value="--output" />
			<arg value="${basedir}/src_generated" />
			<arg value="-u" />
			<arg value="https://myserver2.java.lu/MyWebServices/services/MyWebService?wsdl" />
			<classpath>
				<path refid="axis.classpath" />
			</classpath>
		</java>
	</target>
</project>

 
Execute the ANT script build.xml, the proxies are generated in the src_generated folder:

Buildfile: C:\Workspaces\WSProxyGenerator\build.xml
init_proxy:
create_proxy_cxf:
      Loading FrontEnd jaxws21 ...
      Loading DataBinding jaxb ...
      wsdl2java -autoNameResolution -verbose -fe jaxws21 -encoding Cp1252 -d C:\Workspaces\WSProxyGenerator/src_generated -b simple-binding.xjb -wsdlList wsdllist_cxf.txt
      wsdl2java - Apache CXF 3.0.3
create_proxy_axis:
      Parsing XML file:  https://myserver2.java.lu/MyWebServices/services/MyWebService?wsdl
      Symbol Table
      -----------------------
      org.apache.axis.wsdl.symbolTable.DefinedType
...
      -----------------------
      Generating C:\Workspaces\WSProxyGenerator/src_generated\com\myjava\lu\myservice\webservice\services\myserviceWebService.java
      Generating C:\Workspaces\WSProxyGenerator/src_generated\com\myjava\lu\myservice\webservice\services\myserviceWebServiceSoapBindingStub.java
      Generating C:\Workspaces\WSProxyGenerator/src_generated\com\myjava\lu\myservice\webservice\services\myserviceWebServiceService.java
      Generating C:\Workspaces\WSProxyGenerator/src_generated\com\myjava\lu\myservice\webservice\services\myserviceWebServiceServiceLocator.java
create_proxy:
BUILD SUCCESSFUL
Total time: 11 seconds

 

Best regards,

Huseyin

Hello,

Just a mini post concerning the persistence/saving of MAIL document with external/internal attachments. Here, 2 solutions for the relation between MAIL document and its attachments in Documentum.

For external attachment of MAIL document, a simple solution is the creation of dm_document/dmr_content for each external attachment and the creation of dm_relation with specific type (relation_name = ‘mail_attachment’) for the link between attachments and MAIL document:
o parent_id = r_object_id of MAIL document (dm_document -> dmr_content)
o child_id = r_object_id of attachment document (dm_document -> dmr_content)
 
DQL:

select relation_name, parent_id, child_id from dm_relation where relation_name = 'mail_attachment' and parent_id = '090xxxxxxxxcd' ;

 
 

For the internal attachment inside MAIL document (the system generates automaticaly a SHA-1 for each attachment which is stored directly in the MAIL content)
 
Exemple of MAIL document/content:

	"<item name="$FILE" seal="true" sign="true" summary="true"><object><file compression="none" encoding="unknown" flags="storedindoc" hosttype="msdos" name="1540453.htm" size="7759">
	<created><datetime>20141104T065226,37-05</datetime></created>
	<modified><datetime>20141104T065226,37-05</datetime></modified>
	<filedata>1c195c............6e83db</filedata></file></object></item>"

 
So, a solution is the creation of dm_document/dmr_content for each external attachment and the use of the storing of this SHA-1 value in the dmr_content repeating attributes content_attr_name and content_attr_value instead of the dm_relation objects.
 
The DFC javadoc contains several methods for these dmr_content repeating attributes:

o String getStringContentAttr(String name, String formatName, int page, String pageModifier) throws DfException = Return a string content attribute.
Parameters:
– name : the name of the attribute.
– formatName :the name for the content objects format.
– page : the content page.
– pageModifier : the content object’s page modifier.

o void setStringContentAttribute(String name, String value, String formatName, int page, String pageModifier) throws DfException = Set a String content attribute.
Parameters:
– name : the name of the attribute.
– value : the value of the attribute.
– formatName : the name for the content objects format.
– page : the content page.
– pageModifier : the content object’s page modifier.

 

Example:



dm_document
  r_object_id                : 090xxxxxxxxxxeef
  i_contents_id              : 060xxxxxxxxxxa84
  object_name                : binary.gif


dmr_content
  r_object_id                : 060xxxxxxxxxxa84
  parent_id               	[0]: 090xxxxxxxxxxeef
  content_attr_name       	[0]: SHA-1
				[1]: Width
				[2]: Height
				[3]: Format
				[4]: Color Mode
				[5]: Compression
				[6]: Jpeg Quality
				[7]: Gif Interleave
				[8]: Color Components
				[9]: Sample Bands
				[10]: Sample Depth
				[11]: Colorspace
  content_attr_value     	[0]: e97c9xxxxxxxxxxxxxxxxxxf36bc
				[1]: 
				[2]: 
				[3]: GIF
				[4]: Indexed
				[5]: LZW
				[6]: 
				[7]: false
				[8]: 
				[9]: 
				[10]: 
				[11]: RGB

  full_content_size          : 905

 

DQL:

select r_object_id, parent_id, content_attr_name, content_attr_value  from dmr_content where ANY (content_attr_name = 'SHA-1' and content_attr_value='1c195cxxxxxxxxxxxxxxxxxx83db' );
060xxxxxxxxx0ca	090xxxxxxxxbbe	SHA-1	1c195cxxxxxxxxxxxxxxxxxx83db

select r_object_id, r_page_cnt, r_content_size, a_content_type, i_contents_id from my_huo_document where r_object_id ='090xxxxxxxxbbe';
090xxxxxxxxbbe	1	7759	html	060xxxxxxxxx0ca

 

Best regards,

Huseyin OZVEREN

Hi,

Juste a mini-post concerning the configuation of DATASOURCE on Documentum server.
The DATASOURCE (DS) are configurable:

 
Here, the example for the DS “java:/MY_ARCHIVE_DS” :

<?xml version='1.0' encoding='UTF-8'?>
<server xmlns="urn:jboss:domain:1.2">
    <profile>
       <subsystem xmlns="urn:jboss:domain:datasources:1.0">

            <datasources>

                <datasource jndi-name="java:/MY_ARCHIVE_DS" pool-name="MY_ARCHIVE_DS" enabled="true" use-java-context="true">
                    <connection-url>jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MYDBSERVER123)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=MYARCHIVE)))</connection-url>
                    <driver>oracle.jdbc</driver>
                    <pool>
                        <min-pool-size>5</min-pool-size>
                        <max-pool-size>100</max-pool-size>
                    </pool>
                    <security>
                        <user-name>MY_APP_USER</user-name>
                        <password>WD{HUO/dfdfdsfdsfh]-DUHi</password>
                    </security>
                    <validation>
                        <exception-sorter class-name="org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter"/>
                    </validation>
                </datasource>
	        <drivers>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                    <driver name="oracle.jdbc" module="oracle.jdbc">
                        <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
                    </driver>
                    <driver name="sqljdbc" module="com.microsoft.sqlserver">
                        <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
                    </driver>
                </drivers>
            </datasources>
        </subsystem>
    </profile>

    <interfaces>

    </interfaces>

    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">

    </socket-binding-group>
</server>

 
 
The use of this DS in the JOB/JAVA code could be:

	private static final String DS = "MY_ARCHIVE_DS";
	private static final String JNDI_PREFIX[] = { "java:/", "java:", "jdbc/" };

	//...
		InitialContext ic = new InitialContext();
		for (int i = 0; i < JNDI_PREFIX.length && dataSource == null; i++) {
			try {
				dataSource = (DataSource) ic.lookup(JNDI_PREFIX[i] + DS);
			} catch (NamingException e) {
			}
		}
		if (dataSource == null) {
			throw new Exception("Unable to find datasource " + DS);
		}
	//...

	Connection connection = dataSource.getConnection();
	try {
		connection.setAutoCommit(false);

		PreparedStatement statement = connection.prepareStatement(MessageFormat.format(sql.toString(), StringUtils.upperCase(StringUtils.trimToEmpty(table)), year.format(coll.getTime("time_stamp").getDate())));

		//... Save the original data in a BLOB field in ARCHIVE database
		Blob blob = connection.createBlob();

		//...
		statement.executeUpdate();

		//...
		blob.free();

		//...
		statement.close();

		//...

	} finally {

		if(connection!=null){
	
			if (commit) {
				connection.commit();
				println("SqlConnection transaction commited !");
			} else {
				connection.rollback();
				println("SqlConnection transaction rollbacked !");
			}
			connection.close();
		}
	}

That’s all!!!

Huseyin OZVEREN

Page 4 of 55:« First« 1 2 3 4 5 6 7 »Last »
bottom-img
Copyright ® 2012 Huseyin Ozveren. No reproduction, even partial, can be used from this site and all its contents including text, documents, images, etc.. without the express permission of the author.