top-image

OLDER ARTICLES

Hi,

After the post on creation of audittrail (http://www.javablog.fr/documentum-creation-of-audit-trail-entries-dm_audittrail.html), I would like to present the purge of audittrail because “DELL ECM/OpenTxt” advises to purge/archive the audittrail data in order to improve the system’s performances.
 
So, several solutions are possibles:

  • archiving the audittrail in external database, then, deleting these events in audittrail via custom jobs,
  • deleting the useless audittrail of technical events (custom indexation,…) via a DQL/API scripts or custom jobs,

 
In this post, the audittrail will be archived in a dedicated database then purged via custom generic method called by several jobs. First, we need to configure the DATASOURCE (DS) on DCTM server in order to access to archive database : http://www.javablog.fr/documentum-datasource-configuration-ds.html.
 

Below, the steps in archiving and purge of audittrails in a generic and custom dm_method :

  • STEP 1: Select the audittrail which must be removed
    		SELECT DISTINCT r_object_id, time_stamp, event_name, event_description, user_name ,user_id, owner_name, audited_obj_id, chronicle_id, object_name, version_label, 
    		host_name, attribute_list, attribute_list_id, string_1, string_2, string_3, string_4, string_5, id_1, id_2, id_3, id_4, id_5, object_type, application_code
    		FROM dm_audittrail
    		WHERE DATEDIFF(MONTH,TIME_STAMP,DATE(NOW)) >= <grace_period>
    			AND 
    			(
    				<qualification>
    
    			)
    		ORDER BY r_object_id ASC
    		ENABLE(RETURN_TOP <commit_size>)
    
    	-table MYDATA1, 
    	-qualification "event_name like 'huo\_%' ESCAPE '\' OR object_type IN (select name from dm_type where r_object_id in (select r_type_id from dmi_type_info where any r_supertype LIKE 'huo\_%' ESCAPE '\'))", 
    	-grace_period 3, 
    	-commit_size 2000  
    

     

  • STEP 2 : Insert audittrail in a database table for docbase and year (AUDIT_TRAIL.AUDIT_TRAILS_MYDATA1_2017)
     --- insertAuditTrails
    INSERT INTO AUDIT_TRAIL.AUDIT_TRAILS_<table>_<year> 
     (ATTRIBUTE_LIST, AUDITED_OBJ_ID, CHRONICLE_ID, EVENT_DESCRIPTION, 
    EVENT_NAME, HOST_NAME, ID_1, ID_2, ID_3, ID_4, ID_5, OBJECT_NAME, 
    OWNER_NAME, STRING_1, STRING_2, STRING_3, STRING_4, STRING_5, 
    TIME_STAMP, USER_ID, USER_NAME, VERSION_LABEL, OBJECT_TYPE, 
    APPLICATION_CODE)
     VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
    

     

  • STEP 3 : Purge the audittrail entries via the administrative method “PURGE_AUDIT” which removes an audit trail entry from the Docbase.
    Use and arguments: see p.252 in Content Server DQL Reference Manual at http://ec.europa.eu/ipg/tools/wcm-portal/documentation/assets/dql_reference_guide_en.pdf and my previous
    post concerning the use of Documentum administration methods http://www.javablog.fr/documentum-administration-methods-presentation-and-examples-migrate_content-get_path-do_method-check_security-get_file_url.html.
     
    Examples from “Content Server DQL Reference Manual”:
    o This example deletes all audit trail entries generated from January 1, 2003 to January 1, 2004, including unarchived entries. The number of entries deleted in each transaction is set to 500:

    EXECUTE purge_audit WITH delete_mode=’DATE_RANGE’, date_start=’01/01/2003 00:00:00 AM’, date_end=’01/01/2004 00:00:00 AM’ purge_non_archived=T,commit_size=500

    o This example deletes all archived audit trail entries that identify the document 090xxxxxxxxxx94ef as the audited object:

    EXECUTE purge_audit WITH delete_mode=’ALL_VERSIONS’, object_id=’090xxxxxxxxxx94ef’

    o This example deletes the single audit trail entry whose object ID is 5f0000021372ac6f:

    EXECUTE purge_audit WITH delete_mode=’AUDIT_RECORD’, object_id=’5f0000021372ac6f’

    o This example deletes all audit trail entries whose object IDs range from 5f1xxxxxxxx901 to 5f1xxxxxxx925, including unarchived entries:

    EXECUTE purge_audit WITH delete_mode=’ID_RANGE’, id_start=’5f1xxxxxxxx901’,id_end=’5f1xxxxxxx925’, purge_non_archived=T

    o This example deletes all audit trail entries that satisfy the specified DQL predicate:

    EXECUTE purge_audit WITH delete_mode=’PREDICATE’, dql_predicate=’dm_audittrail where event_name like ’’dcm%’’and r_gen_source=0’

     

  • STEP 4 : Deployment of method and manual creation of several jobs in DA which call the above dm_method.
     
    o Exemple 1 : creation of a job HuO_MyData1AuditArchiving on globalR (yes!) – Archive & Purge dm_audittrail named “huo1_*” with time_stamp > 3 months:

    + Frequency   :  1/ Day at 01:00:00
    + Method Name   :  HuO_AuditArchiving  
    + Arguments   :  -docbase_name HUO_MYDOCBASE1_DEV, -user_name huouser, -table MYDATA1, -qualification "event_name like 'huo1\_%' ESCAPE '\' OR object_type IN (select name from dm_type where r_object_id in (select r_type_id from dmi_type_info where any r_supertype LIKE 'huo\_%' ESCAPE '\'))", -grace_period 3, -commit_size 2000  
    

     
    o Exemple 2 : creation of a job HuO_MyData2AuditArchiving on globalR (yes!) – Archive & Purge dm_audittrail named “huo2_*” with time_stamp > 3 months:

    + Frequency   :  1/ Day at 01:00:00
    + Method Name   :  HuO_AuditArchiving  
    + Arguments   :  -docbase_name HUO_MYDOCBASE2_DEV, -user_name huouser, -table MYDATA2, -qualification "event_name like 'huo2\_%' ESCAPE '\' OR object_type IN (select name from dm_type where r_object_id in (select r_type_id from dmi_type_info where any r_supertype LIKE 'huo\_%' ESCAPE '\'))", -grace_period 3  
    

     

    Here, some DQL requests in order to check the deployment of dmc_module, dm_jar, dm_method, dm_job:

    # Last versions of Module : Definition of java class
    select r_object_id, object_name, r_creation_date, r_modify_date, r_version_label from dmc_module (all) where LOWER(object_name)  like '%auditarchiving%' ORDER BY r_modify_date desc ;
    0bxxxxxxxx9af	com.huo.lu.ecm.audit.AuditArchivingMethod	16/01/2014 14:37:04	31/10/2017 08:20:48	CURRENT,1.0
    

     

    # Last versions of JARS (Java Method):
    select r_object_id, object_name, r_creation_date, r_modify_date, r_version_label from dmc_jar (all) where LOWER(object_name)  like '%auditarchiving%' ORDER BY r_modify_date desc ;
    090xxxxxxxx8bf	AuditArchiving-Impl	31/10/2017 08:20:46	31/10/2017 08:20:47	CURRENT,1.13
    

     

    # Last versions of DAR:
    select r_object_id, object_name, r_creation_date, r_modify_date, r_version_label from dmc_dar (all) where LOWER(object_name)  like '%logbook-archiving%' ORDER BY r_modify_date desc ;
    080xxxxxxx8c1	ECM-LogBook-Archiving	31/10/2017 08:20:47	31/10/2017 08:20:48	1.13,CURRENT
    

     

    # Last versions of JARS (Java Method):
    SELECT r_object_id, object_name, r_creation_date, r_modify_date, trace_launch,  method_type, use_method_server, method_verb, r_version_label from dm_method (all) where LOWER(object_name)  like '%auditarchiving%' ORDER BY r_modify_date;
    10xxxxxxx9b9	HuO_AuditArchiving	16/01/2014 14:37:05	01/02/2016 09:53:13	0	java	1	com.huo.lu.ecm.audit.AuditArchivingMethod	CURRENT,1.0
    

     

    # Last versions of Jobs:
    SELECT r_object_id, object_name, r_creation_date, r_modify_date, r_version_label from dm_job (all) where LOWER(object_name)  like '%auditarchiving%' ORDER BY r_modify_date;
    080xxxxxxxx39ce	HuO_MyData1AuditArchiving	16/01/2014 14:37:06	24/11/2017 00:08:07	1.0,CURRENT
    080xxxxxxxx39cf	HuO_MyData2AuditArchiving	16/01/2014 14:37:06	24/11/2017 00:06:33	CURRENT,1.0
    

     

 

Here, the source code of Custom method AuditArchivingMethod:

package com.huo.lu.ecm.audit;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Time;
import java.text.DateFormat;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

import org.apache.commons.lang.StringUtils;

import com.documentum.com.DfClientX;
import com.documentum.com.IDfClientX;
import com.documentum.fc.client.DfQuery;
import com.documentum.fc.client.IDfBusinessObject;
import com.documentum.fc.client.IDfClient;
import com.documentum.fc.client.IDfCollection;
import com.documentum.fc.client.IDfModule;
import com.documentum.fc.client.IDfPersistentObject;
import com.documentum.fc.client.IDfQuery;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSessionManager;
import com.documentum.fc.commands.admin.DfAdminCommand;
import com.documentum.fc.commands.admin.IDfApplyPurgeAudit;
import com.documentum.fc.common.DfException;
import com.documentum.fc.common.DfLoginInfo;
import com.documentum.fc.common.IDfId;
import com.documentum.fc.common.impl.MessageHelper;
import com.documentum.fc.methodserver.IDfMethod;

public class AuditArchivingMethod implements IDfMethod, IDfModule, IDfBusinessObject {

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

	private static int copy(InputStream input, Blob output) throws SQLException, IOException {
		byte buffer[] = new byte[4096];
		int count = 0;
		for (int n = 0; -1 != (n = input.read(buffer));) {
			output.setBytes(count + 1, buffer, 0, n);
			count += n;
		}

		return count;
	}

	private PrintWriter printWriter;

	private boolean loadParameters = true;
	private String userName;
	private String repositoryName;
	private String tableName;
	private String qualification;
	private int gracePeriod;
	private int commitSize;
	private Properties properties;
	private DataSource dataSource;

	private String getProperty(String key, String defaultValue) {
		if (properties == null) {
			synchronized (this) {
				if (properties == null) {
					properties = new Properties();
					String propertyFile = getClass().getSimpleName() + ".properties";
					InputStream inputStream = getClass().getResourceAsStream(propertyFile);
					if (inputStream != null) {
						try {
							properties.load(inputStream);
						} catch (IOException e) {
							println("Unable to load " + propertyFile, e);
						} finally {
							try {
								inputStream.close();
							} catch (IOException e) {

							}
						}
					}
				}
			}
		}
		String result = properties.getProperty(key);
		if (result == null) {
			return defaultValue;
		}
		return result;
	}

	protected void execute() throws Exception {
		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);
		}

		final String globalRegistryRepository = "GLOBALR";
		IDfClientX clientx = new DfClientX();
		IDfClient client = clientx.getLocalClient();
		final IDfSessionManager sessionManager = client.newSessionManager();
		for (String repository : new String[] { globalRegistryRepository, getRepositoryName() }) {
			if (sessionManager.hasIdentity(repository)) {
				sessionManager.clearIdentity(repository);
			}
			sessionManager.setIdentity(repository, new DfLoginInfo(getUserName(), null));
		}

		Calendar timeOut = Calendar.getInstance();
		IDfSession globalRSession = sessionManager.getSession(globalRegistryRepository);
		try {
			IDfPersistentObject dfMethod = globalRSession.getObjectByQualification("dm_method WHERE method_verb = '" + this.getClass().getName() + "'");
			if (dfMethod == null) {
				timeOut.add(Calendar.SECOND, 3600);
			} else {
				timeOut.add(Calendar.SECOND, 95 * dfMethod.getInt("timeout_default") / 100);
			}
		} finally {
			sessionManager.release(globalRSession);
		}

		List<String> list = new ArrayList<String>(200);
		do {
			list.clear();
			IDfSession dfSession = sessionManager.newSession(getRepositoryName());
			try {
				if (dfSession.isTransactionActive()) {
					throw new DfException("IDfSession's transaction is already active !");
				}
				boolean commit = false;
				dfSession.beginTrans();
				println("IdfSession transaction has begun");
				try {
					Connection connection = dataSource.getConnection();
					try {
						connection.setAutoCommit(false);
						println("SqlConnection transaction has begun");
						try {
							StringBuilder dqlPredicate = new StringBuilder();
							dqlPredicate.append("dm_audittrail");
							boolean addWhere = true;
							println(MessageFormat.format("{0,choice,0#There is no grace period.|1#There is a grace period of one month.|1<There is a grace period of {0,number,integer} months}.", gracePeriod));
							if (gracePeriod >= 0) {
								dqlPredicate.append(" WHERE DATEDIFF(MONTH,TIME_STAMP,DATE(NOW)) >= ").append(gracePeriod);
								addWhere = false;
							}
							if (StringUtils.isNotBlank(qualification)) {
								if (addWhere) {
									dqlPredicate.append(" WHERE ");
									addWhere = false;
								} else {
									dqlPredicate.append(" AND ");
								}
								dqlPredicate.append("(").append(qualification).append(")");
							}

							StringBuilder sb = new StringBuilder();
							sb.append(" SELECT DISTINCT r_object_id, time_stamp, event_name, event_description, user_name ,user_id, owner_name, audited_obj_id, chronicle_id, object_name, version_label,");
							sb.append(" host_name, attribute_list, attribute_list_id, string_1, string_2, string_3, string_4, string_5, id_1, id_2, id_3, id_4, id_5, object_type, application_code");
							sb.append(" FROM ").append(dqlPredicate.toString());
							sb.append(" ORDER BY r_object_id ASC");
							sb.append(" ENABLE(RETURN_TOP ").append(getCommitSize()).append(")");

							IDfQuery dfQuery = new DfQuery(sb.toString());
							println(MessageFormat.format("Launching query: {0}", sb.toString()));

							IDfCollection coll = dfQuery.execute(dfSession, IDfQuery.DF_READ_QUERY);
							try {
								while (coll.next()) {
									if (!list.contains(coll.getId("r_object_id").getId())) {
										list.add(insertAuditTrails(connection, getTableName(), coll).getId());
									}
								}
							} finally {
								coll.close();
							}

							if (list.size() > 0) {
								println(MessageFormat.format("{0} dm_audittrail to purge", list.size()));
								IDfApplyPurgeAudit applyPurgeAudit = (IDfApplyPurgeAudit) DfAdminCommand.getCommand(DfAdminCommand.APPLY_PURGE_AUDIT);
								applyPurgeAudit.setDeletMode("PREDICATE");
								StringBuilder dql = new StringBuilder();
								dql.append("dm_audittrail");
								final int size = 200;
								int i = 0;
								while (i * size < list.size()) {
									if (i == 0) {
										dql.append(" WHERE r_object_id IN ('");
									} else {
										dql.append(" OR r_object_id IN ('");
									}
									dql.append(StringUtils.join(list.subList(i * size, ((i + 1) * size > list.size()) ? list.size() : (i + 1) * size), "','"));
									dql.append("')");
									i++;
								}

								applyPurgeAudit.setDQLPredicate(dql.toString());
								applyPurgeAudit.setPurgeNonArchived(true);
								println(MessageFormat.format("Launching purge_query with predicate : {0}", dql.toString()));
								IDfCollection dfCollection = applyPurgeAudit.execute(dfSession);
								try {
									if (dfCollection.next()) {
										boolean result = dfCollection.getBoolean("result");
										int deletedObjects = dfCollection.getInt("deleted_objects");
										if (result && deletedObjects == list.size()) {
											println(MessageFormat.format("Purge operation has succeed : {0} object(s) deleted", deletedObjects));
											commit = true;
										} else {
											if (!result) {
												println("Error : Purge operation failed !");
											} else {
												println(MessageFormat.format("Error : Expected to delete {0} object(s) but {1} object(s) were deleted", list.size(), deletedObjects));
											}
										}
									} else {
										println("Error : Unable to retrieve purge operation result");
									}
								} finally {
									dfCollection.close();
								}
							} else {
								println("Nothing to do !");
							}
						} finally {
							if (commit) {
								connection.commit();
								println("SqlConnection transaction commited !");
							} else {
								connection.rollback();
								println("SqlConnection transaction rollbacked !");
							}
						}
					} finally {
						connection.close();
					}
				} finally {
					if (commit) {
						dfSession.commitTrans();
						println("IdfSession transaction commited !");
					} else {
						dfSession.abortTrans();
						println("IdfSession transaction rollbacked !");
					}
				}
			} finally {
				sessionManager.release(dfSession);
			}
		} while (list.size() > 0 && timeOut.after(Calendar.getInstance()));
	}

	@SuppressWarnings("unchecked")
	public final void execute(Map arg0, OutputStream arg1) throws Exception {
		execute(arg0, new PrintWriter(arg1));
	}

	@SuppressWarnings("unchecked")
	public final int execute(Map arg0, PrintWriter arg1) throws Exception {
		try {
			this.printWriter = new PrintWriter(arg1, true);
			try {
				println(MessageFormat.format("Start time : {0,date,dd/MM/yyyy HH:mm:ss}", new Date()));
				println(MessageFormat.format("Method {0} launched with arguments {1}", this.getClass().getSimpleName(), arg0.keySet()));
				println("Vendor-name : " + getVendorString());
				println("Version : " + getVersion());
				if (loadParameters) {
					for (String parameter : requiredParameters()) {
						String[] values = (String[]) arg0.get(parameter);
						String value = (values == null || values.length == 0) ? null : values[0];
						validateParam(parameter, value);
					}
					for (Iterator iter = arg0.keySet().iterator(); iter.hasNext();) {
						String key = (String) iter.next();
						Method method = getSetterMethods().get(key);
						if (method == null) {
							println("Unknown argument " + key);
						} else {
							method.invoke(this, ((String[]) arg0.get(key))[0]);
						}
					}
				}
				execute();
				println(MessageFormat.format("End time : {0,date,dd/MM/yyyy HH:mm:ss}", new Date()));
			} catch (Throwable e) {
				println(MessageHelper.getStackTraceAsString(e));
				throw new Exception(e);
			}
		} finally {
			try {
				if (this.printWriter != null) {
					this.printWriter.close();
				}
			} catch (Exception e) {

			}
		}
		return 0;
	}

	public String getRepositoryName() {
		return repositoryName;
	}

	protected Map<String, Method> getSetterMethods() throws SecurityException, NoSuchMethodException {
		Map<String, Method> map = new HashMap<String, Method>();
		map.put("user_name", getClass().getMethod("setUserName", String.class));
		map.put("docbase_name", getClass().getMethod("setRepositoryName", String.class));
		map.put("table", getClass().getMethod("setTableName", String.class));
		map.put("grace_period", getClass().getMethod("setGracePeriod", String.class));
		map.put("qualification", getClass().getMethod("setQualification", String.class));
		map.put("commit_size", getClass().getMethod("setCommitSize", String.class));
		return map;
	}

	public String getTableName() {
		return tableName;
	}

	public String getUserName() {
		return userName;
	}

	public String getVendorString() {
		return getProperty("Vendor-Name", "PricewaterhouseCoopers (c) 2013");
	}

	public String getVersion() {
		return getProperty("Build-Version", "1.0");
	}

	private IDfId insertAuditTrails(Connection connection, String table, IDfCollection coll) throws SQLException, DfException, IOException {
		IDfId result;
		StringBuilder sql = new StringBuilder();
		sql.append(" INSERT INTO AUDIT_TRAIL.AUDIT_TRAILS_{0}_{1}");
		sql.append(" (ATTRIBUTE_LIST,AUDITED_OBJ_ID,CHRONICLE_ID,EVENT_DESCRIPTION,EVENT_NAME,HOST_NAME,ID_1,ID_2,ID_3,ID_4,ID_5,OBJECT_NAME,OWNER_NAME,STRING_1,STRING_2,STRING_3,STRING_4,STRING_5,TIME_STAMP,USER_ID,USER_NAME,VERSION_LABEL,OBJECT_TYPE,APPLICATION_CODE)");
		sql.append(" VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");

		DateFormat year = new SimpleDateFormat("yyyy");
		PreparedStatement statement = connection.prepareStatement(MessageFormat.format(sql.toString(), StringUtils.upperCase(StringUtils.trimToEmpty(table)), year.format(coll.getTime("time_stamp").getDate())));
		try {
			File file = new File(new File(System.getProperty("java.io.tmpdir")), "attribute_list_" + coll.getId("audited_obj_id").getId() + ".txt");
			try {
				PrintWriter printWriter = new PrintWriter(file);
				try {
					printWriter.print(coll.getString("attribute_list"));
					if (!coll.getId("attribute_list_id").isNull()) {
						IDfPersistentObject dmiAuditAttrs = coll.getObjectSession().getObject(coll.getId("attribute_list_id"));
						for (int i = 0; i < dmiAuditAttrs.getValueCount("attribute_list"); i++) {
							printWriter.print(dmiAuditAttrs.getRepeatingString("attribute_list", i));
						}
					}
				} finally {
					printWriter.close();
				}
				InputStream inputStream = (file.exists()) ? new FileInputStream(file) : new ByteArrayInputStream(new byte[] {});
				try {
					Blob blob = connection.createBlob();
					try {
						copy(inputStream, blob);
						statement.setBlob(1, blob);
						result = coll.getId("r_object_id");
						statement.setString(2, coll.getId("audited_obj_id").getId());
						statement.setString(3, coll.getId("chronicle_id").getId());
						statement.setString(4, coll.getString("event_description"));
						statement.setString(5, coll.getString("event_name"));
						statement.setString(6, coll.getString("host_name"));
						statement.setString(7, coll.getId("id_1").getId());
						statement.setString(8, coll.getId("id_2").getId());
						statement.setString(9, coll.getId("id_3").getId());
						statement.setString(10, coll.getId("id_4").getId());
						statement.setString(11, coll.getId("id_5").getId());
						statement.setString(12, coll.getString("object_name"));
						statement.setString(13, coll.getString("owner_name"));
						statement.setString(14, coll.getString("string_1"));
						statement.setString(15, coll.getString("string_2"));
						statement.setString(16, coll.getString("string_3"));
						statement.setString(17, coll.getString("string_4"));
						statement.setString(18, coll.getString("string_5"));
						statement.setTime(19, new Time(coll.getTime("time_stamp").getDate().getTime()));
						statement.setString(20, coll.getId("user_id").getId());
						statement.setString(21, coll.getString("user_name"));
						statement.setString(22, coll.getString("version_label"));
						statement.setString(23, coll.getString("object_type"));
						statement.setString(24, coll.getString("application_code"));
						statement.executeUpdate();
					} finally {
						blob.free();
					}
				} finally {
					inputStream.close();
				}
			} finally {
				file.delete();
			}
		} finally {
			statement.close();
		}
		return result;
	}

	public boolean isCompatible(String arg0) {
		return true;
	}

	final public boolean isLoadParameters() {
		return loadParameters;
	}

	protected void print(Object... obj) {
		String message = StringUtils.join(obj, "");
		if (printWriter == null) {
			System.out.print(message);
		} else {
			printWriter.print(message);
			printWriter.flush();
		}
	}

	protected void println(Object... obj) {
		String message = StringUtils.join(obj, "");
		if (printWriter == null) {
			System.out.println(message);
		} else {
			printWriter.println(message);
			printWriter.flush();
		}
	}

	protected String[] requiredParameters() {
		return new String[] { "docbase_name", "user_name", "table", "grace_period" };
	}

	public void setGracePeriod(String gracePeriod) {
		try {
			this.gracePeriod = Integer.parseInt(gracePeriod);
		} catch (Throwable e) {
			if (printWriter != null) {
				e.printStackTrace(printWriter);
			} else {
				e.printStackTrace();
			}
		}
		if (this.gracePeriod < 0) {
			this.gracePeriod = 0;
		}
	}

	public void setCommitSize(String commitSize) {
		try {
			this.commitSize = Integer.parseInt(commitSize);
		} catch (Throwable e) {
			if (printWriter != null) {
				e.printStackTrace(printWriter);
			} else {
				e.printStackTrace();
			}
		}
	}

	public int getCommitSize() {
		return (commitSize <= 0) ? 200 : commitSize;
	}

	final public void setLoadParameters(boolean loadParameters) {
		this.loadParameters = loadParameters;
	}

	public void setQualification(String qualification) {
		this.qualification = qualification;
	}

	public void setRepositoryName(String repositoryName) {
		this.repositoryName = repositoryName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	@Override
	public boolean supportsFeature(String arg0) {
		return true;
	}

	private void validateParam(String parameter, String value) throws Exception {
		if (StringUtils.isBlank(value)) {
			throw new Exception(MessageFormat.format("Non-null value is required for parameter {0}", parameter));
		}
	}

}

Best regards,

Huseyin OZVEREN

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 pwc_client_document where r_object_id ='090xxxxxxxxbbe';
090xxxxxxxxbbe	1	7759	html	060xxxxxxxxx0ca

 

Best regards,

Huseyin OZVEREN

Page 2 of 53:« 1 2 3 4 5 »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.