top-image

OLDER ARTICLES

Hi,

Here, a very useful class exposing a lot of functionalities of Documentum (found on the Internet https://worldofchaitu.wordpress.com/2012/11/08/documentum-dfc-standalone-sample-program/):

  • To get a list of available docbase
  • To create a cabinet (dm_cabinet) in docbase
  • To create a folder (dm_folder object) in docbase
  • To create a document (dm_document object) in docbase
  • To check out a document from docbase using IDfOperations
  • To check in a document to docbase using IDfOperations making use of IAPI methods
  • To import a document into docbase
  • To cancelcheckout a document into docbase
  • To check out a document from docbase
  • To check in a document to docbase
  • To delete a document from docbase
  • To update document’s in docbase
  • To retrieve document’s attributes from docbase
  • To create a virtual document in docbase
  • To export a virtual document from docbase
  • To view virtual document from docbase
  • To retrieve document from document using IDQL
  • To create and start workflow
  • To view task in inbox
  • To attach a lifeCycle to a document in docbase
  • To promote a lifeCycle state of a document
  • To demote a lifeCycle state of a document
  • To expire a lifeCycle state of a document
  • To resume a lifeCycle state of a document
  • To assign a ACL to a document
package com.huo.test.ecm.test1;

import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.StringTokenizer;

import com.documentum.com.DfClientX;
import com.documentum.com.IDfClientX;
import com.documentum.fc.client.DfClient;
import com.documentum.fc.client.DfQuery;
import com.documentum.fc.client.IDfACL;
import com.documentum.fc.client.IDfActivity;
import com.documentum.fc.client.IDfClient;
import com.documentum.fc.client.IDfCollection;
import com.documentum.fc.client.IDfDocbaseMap;
import com.documentum.fc.client.IDfDocument;
import com.documentum.fc.client.IDfFolder;
import com.documentum.fc.client.IDfProcess;
import com.documentum.fc.client.IDfQuery;
import com.documentum.fc.client.IDfQueueItem;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSessionManager;
import com.documentum.fc.client.IDfSysObject;
import com.documentum.fc.client.IDfType;
import com.documentum.fc.client.IDfTypedObject;
import com.documentum.fc.client.IDfVirtualDocument;
import com.documentum.fc.client.IDfVirtualDocumentNode;
import com.documentum.fc.client.IDfWorkflow;
import com.documentum.fc.client.IDfWorkflowBuilder;
import com.documentum.fc.client.IDfWorkitem;
import com.documentum.fc.common.DfList;
import com.documentum.fc.common.DfLoginInfo;
import com.documentum.fc.common.IDfAttr;
import com.documentum.fc.common.IDfId;
import com.documentum.fc.common.IDfList;
import com.documentum.fc.common.IDfLoginInfo;
import com.documentum.operations.IDfCancelCheckoutNode;
import com.documentum.operations.IDfCancelCheckoutOperation;
import com.documentum.operations.IDfCheckinNode;
import com.documentum.operations.IDfCheckinOperation;
import com.documentum.operations.IDfCheckoutNode;
import com.documentum.operations.IDfCheckoutOperation;
import com.documentum.operations.IDfExportNode;
import com.documentum.operations.IDfExportOperation;
import com.documentum.operations.IDfImportNode;
import com.documentum.operations.IDfImportOperation;
import com.documentum.operations.IDfOperation;
import com.documentum.operations.IDfOperationError;

/**
 See https://webcache.googleusercontent.com/search?q=cache:MW2FjC-Rg7YJ:https://worldofchaitu.wordpress.com/2012/11/08/documentum-dfc-standalone-sample-program/+&cd=3&hl=en&ct=clnk&gl=lu
 Documentum DFC Standalone Sample Program


 This blog contains sample DFC code snippet of all basic functionalities of Documentum

 To get a list of available docbase
 To create a cabinet (dm_cabinet) in docbase
 To create a folder (dm_folder object) in docbase
 To create a document (dm_document object) in docbase
 To check out a document from docbase using IDfOperations
 To check in a document to docbase using IDfOperations making use of IAPI methods
 To import a document into docbase
 To cancelcheckout a document into docbase
 To check out a document from docbase
 To check in a document to docbase
 To delete a document from docbase
 To update document's in docbase
 To retrieve document's attributes from docbase
 To create a virtual document in docbase
 To export a virtual document from docbase
 To view virtual document from docbase
 To retrieve document from document using IDQL
 To create and start workflow
 To view task in inbox
 To attach a lifeCycle to a document in docbase
 To promote a lifeCycle state of a document
 To demote a lifeCycle state of a document
 To expire a lifeCycle state of a document
 To resume a lifeCycle state of a document
 To assign a ACL to a document
**/

public class DFCWorkShop {

	IDfSysObject sysObject = null;
	IDfSession idfSession = null;
	IDfSessionManager sessMgr = null;

	public DFCWorkShop(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 void getAllDocbases() throws Exception {

		IDfClient client = DfClient.getLocalClient();
		IDfDocbaseMap docbaseMap = client.getDocbaseMap();
		for (int i = 0; i < docbaseMap.getDocbaseCount(); i++) {
			System.out.println("Docbase Name : " + docbaseMap.getDocbaseName(i));
			System.out.println("Docbase Desc : " + docbaseMap.getDocbaseDescription(i));
		}
	}

	public void createCabinet() throws Exception {

		IDfFolder cabinet = (IDfFolder) idfSession.newObject("dm_cabinet");
		if (cabinet != null) {
			cabinet.setObjectName("Training Cabinet XXX");
			cabinet.save();
		}
	}

	public void createFolder() throws Exception {

		IDfFolder folder = (IDfFolder) idfSession.newObject("dm_folder");
		if (folder != null) {
			folder.setObjectName("Folder Level 2");
			folder.link("/Training Cabinet XXX");
			folder.save();
		}
	}

	public IDfDocument createDocument() throws Exception {

		IDfDocument document = (IDfDocument) idfSession
				.newObject("dm_document");
		if (document != null) {
			document.setObjectName("Test-Document");
			document.setContentType("crtext");
			document.setFile("C:\\Documentum\\config\\dfc.properties");
			document.link("/Training Cabinet XXX/Folder Level 1");
			document.save();
		}
		return document;
	}

	public void updateAttributes() throws Exception {

		sysObject = (IDfSysObject) idfSession
				.getObjectByPath("/Training Cabinet XXX/Folder Level 1/New Document");
		sysObject.setString("object_name", "New Document");
		sysObject.setString("authors", "Prasad");
		sysObject.setRepeatingString("authors", 1, "RamKumar");
		sysObject.save();
	}

	public void getAttributes() throws Exception {

		sysObject = (IDfSysObject) idfSession
				.getObjectByPath("/Training Cabinet XXX/Folder Level 1/New Document");
		if (sysObject != null) {
			System.out.println("objectName "
					+ sysObject.getString("object_name"));
			// System.out.println("authors " + sysObject.getString("authors"));
			String authors = sysObject.getAllRepeatingStrings("authors", ",");

			List list = new ArrayList();
			StringTokenizer st = new StringTokenizer(authors, ",");
			System.out.println("length of st " + st.countTokens());
			while (st.hasMoreTokens()) {
				list.add(st.nextElement());
			}
			System.out.println("length " + list.size());

			for (int i = 0; i < list.size(); i++) {
				System.out.println("Author[" + i + "] " + list.get(i));
			}
		}
	}

	public void getTypeAttributes() throws Exception {

		IDfType type = (IDfType) idfSession.newObject("dm_document");
		for (int i = 0; i < type.getAttrCount(); i++) {
			IDfAttr attr = type.getAttr(i);
			System.out.println("Name " + attr.getName());
			System.out.println("Datatype " + attr.getDataType());
			System.out.println("Length " + attr.getLength());
			System.out.println("IS Repeating Attr " + attr.isRepeating());
		}
	}

	public void checkoutDoc() throws Exception {

		sysObject = (IDfSysObject) idfSession
				.getObjectByPath("/Training Cabinet XXX/Folder Level 1/");
		if (!sysObject.isCheckedOut()) // if it is not checked out
			sysObject.checkout();

		System.out.println("is Check out " + sysObject.isCheckedOut());
	}

	public void checkinDoc() throws Exception {

		sysObject = (IDfSysObject) idfSession
				.getObjectByPath("/Training Cabinet XXX/Folder Level 1/Test-Document");

		if (sysObject.isCheckedOut()) { // if it is checked out
			sysObject.checkin(false, "CURRENT");
		}
	}

	public void deleteDoc() throws Exception {

		sysObject = (IDfSysObject) idfSession
				.getObjectByPath("/Training Cabinet XXX/Folder Level 1/Test-Document");
		if (sysObject != null) {
			sysObject.destroyAllVersions(); // delete all versions
			System.out.println("object destroyed…..");
		}
	}

	public void createVirtualDocument() throws Exception {

		IDfSysObject pSys = (IDfSysObject) idfSession
				.getObjectByPath("/Training Cabinet XXX/Folder Level 2/log4j.properties");
		IDfSysObject cSys = (IDfSysObject) idfSession
				.getObjectByPath("/Training Cabinet XXX/Folder Level 1/trace.log");

		pSys.setIsVirtualDocument(true);
		pSys.save();
		IDfVirtualDocument vDoc = pSys.asVirtualDocument("CURRENT", false);
		IDfVirtualDocumentNode pNode = vDoc.getRootNode();
		pSys.checkout();

		IDfVirtualDocumentNode nodeChild1 = vDoc.addNode(pNode, null, cSys
				.getChronicleId(), "CURRENT", false, false);

		pSys.checkin(false, "CURRENT");
	}

	public void viewVirtualDocument() throws Exception {

		IDfSysObject pSys = (IDfSysObject) idfSession
				.getObjectByPath("/Training Cabinet XXX/Folder Level 2/log4j.properties");
		if (pSys.isVirtualDocument()) {
			System.out.println("virtual document –> true");
			IDfVirtualDocument vDoc = pSys.asVirtualDocument("CURRENT", false);
			IDfVirtualDocumentNode pNode = vDoc.getRootNode();

			System.out.println("Iterating thru the lis to get the child nodes");
			for (int i = 0; i < pNode.getChildCount(); i++) {
				IDfVirtualDocumentNode cNode = pNode.getChild(i);
				System.out.println("Child Name "
						+ cNode.getSelectedObject().getObjectName());
			}
		}
	}

	public void exportVirtualDocument() throws Exception {

		System.out.println("exporting virtual document");

		IDfClientX clientx = new DfClientX();
		IDfExportOperation expOperation = clientx.getExportOperation();

		IDfSysObject sysObject = (IDfSysObject) idfSession
				.getObjectByPath("/Training Cabinet XXX/Folder Level 2/log4j.properties");
		if (sysObject.isVirtualDocument()) {
			IDfVirtualDocument Vdoc = sysObject.asVirtualDocument("CURRENT",
					false);
			IDfExportNode expNode = (IDfExportNode) expOperation.add(sysObject);
			expOperation.setDestinationDirectory(expOperation
					.getDefaultDestinationDirectory());
			boolean flag = expOperation.execute();
			displayError(expOperation, flag);
		}
	}

	public void cancelCheckoutDocument() throws Exception {

		IDfClientX clientx = new DfClientX();
		IDfCancelCheckoutOperation cancelcheckoutOper = clientx
				.getCancelCheckoutOperation();
		sysObject = (IDfSysObject) idfSession
				.getObjectByPath("/Training Cabinet XXX/Folder Level 2/log4j.properties");

		IDfCancelCheckoutNode node = (IDfCancelCheckoutNode) cancelcheckoutOper
				.add(sysObject);
		boolean flag = cancelcheckoutOper.execute();
		displayError(cancelcheckoutOper, flag);
	}

	public void checkoutDocument() throws Exception {

		IDfClientX clientx = new DfClientX();
		IDfCheckoutOperation checkoutOper = clientx.getCheckoutOperation();

		System.out.println("Checkout Dir "
				+ checkoutOper.getDefaultDestinationDirectory());
		checkoutOper.setDestinationDirectory(checkoutOper
				.getDefaultDestinationDirectory());

		sysObject = (IDfSysObject) idfSession
				.getObjectByPath("/Training Cabinet XXX/Folder Level 2/log4j.properties");

		IDfCheckoutNode node = (IDfCheckoutNode) checkoutOper.add(sysObject);
		boolean flag = checkoutOper.execute();
		displayError(checkoutOper, flag);

	}

	public void checkinDocument() throws Exception {

		IDfClientX clientx = new DfClientX();
		IDfCheckinOperation checkinOper = clientx.getCheckinOperation();

		IDfCheckinNode node = (IDfCheckinNode) checkinOper.add(sysObject);
		System.out.println("Flag —->" + checkinOper.execute());
	}

	public void importDocument() throws Exception {

		IDfSysObject sysObject = (IDfFolder) idfSession
				.getObjectByPath("/Training Cabinet XXX/Folder Level 2");
		System.out.println("Object ID " + sysObject.getObjectId());

		IDfClientX clientx = new DfClientX();
		IDfImportOperation importOper = clientx.getImportOperation();
		importOper.setSession(idfSession);

		if (importOper == null)
			System.out.println("operation object is null");

		importOper.setDestinationFolderId(sysObject.getObjectId());
		importOper.setVersionLabels("imported using operation");

		IDfImportNode node = (IDfImportNode) importOper
				.add("C:\\Documentum\\config\\log4j.properties");
		node.setFormat("pdf");

		boolean flag = importOper.execute();
		displayError(importOper, flag);
	}

	public void displayError(IDfOperation operation, boolean flag)
			throws Exception {

		if (!flag) {

			IDfList errlist = operation.getErrors();

			for (int i = 0; i < errlist.getCount(); i++) {
				IDfOperationError errOperation = (IDfOperationError) errlist
						.get(i);
				System.out.println("Error MSG " + errOperation.getMessage());
			}
		}
	}

	public void dmclAPI() throws Exception {

		System.out.println("Starting...");
		IDfSysObject sysObj = (IDfSysObject) idfSession
				.getObjectByQualification("dm_document where object_name='Test-Document'");
		String rObjectId = sysObj.getObjectId().getId();

		String name = (String) idfSession.apiGet("get", rObjectId+ ",object_name");
		System.out.println("Name : " + name);
		// idfSession.apiSet("set",rObjectId+",title","sample-doc");
		idfSession.apiExec("link",rObjectId+",/Training Cabinet XXX/Folder Level 2");
		System.out.println("Linked " + idfSession.apiExec("save", rObjectId));
	}

	public void collection() throws Exception {

		IDfQuery query = new DfQuery();
		query
				.setDQL("select * from dm_document where object_name='New Document' and any r_version_label like 'CURRENT%'");
		IDfCollection coll = query.execute(idfSession, 0);

		while (coll.next()) {
			IDfTypedObject typeObject = (IDfTypedObject) coll.getTypedObject();
			System.out.println("Object Name "
					+ typeObject.getString("r_object_id"));
			System.out.println("creation date "
					+ typeObject.getString("r_creation_date"));
		}

		if (coll != null)
			coll.close();
	}

	public void startWorkflow() throws Exception {

		// to get the attachment document
		IDfSysObject sysObj = (IDfSysObject) idfSession
				.getObjectByQualification("dm_document where object_name='DFCtest'");

		// to get the Workflow Template
		IDfProcess process = (IDfProcess) idfSession
				.getObjectByQualification("dm_process where object_name like '%INDIA_TIMES%'");

		// to create a Workflo Builder to start a workflow
		IDfWorkflowBuilder builder = idfSession.newWorkflowBuilder(process
				.getObjectId());
		IDfId wfId = builder.initWorkflow();

		// get the First Activity
		IDfList startActivityNames = builder.getStartActivityNames();
		IDfList startActivities = builder.getStartActivityIds();
		String activityName = startActivityNames.getString(0);
		IDfId activityID = (IDfId) startActivities.get(0);
		IDfActivity activity = (IDfActivity) idfSession.getObject(activityID);

		// to get the Package Name , Port and Package DocType
		int nPorts = activity.getPortCount();
		String InputPortName = null;
		String PkgType = null;
		String PkgName = null;

		for (int j = 0; j < nPorts; j++) {
			System.out.println("Port Name: " + activity.getPortName(j) + ", "
					+ "Port Type = " + activity.getPortType(j));

			if (activity.getPortType(j).equals("INPUT")) {
				InputPortName = activity.getPortName(j);
				PkgType = activity.getPackageType(j);
				PkgName = activity.getPackageName(j);
			}
		}

		// to Add the attachment document to List
		IDfList dfList = new DfList();
		dfList.append(sysObj.getObjectId());

		IDfId wfId2 = builder.runWorkflow();
		// Add a Package to Workflow Builder
		builder.addPackage(activityName, InputPortName, PkgName, PkgType, null,
				false, dfList);
		System.out.println("package added");

	}

	public void getInbox() throws Exception {
		// IDfCollection getTasks(String userName, int filter, String additionalAttributes, String orderBy)
		IDfCollection tasks = idfSession.getTasks("huoadm", IDfSession.DF_TASKS, "name, date_sent, message ", "task_name");

		try {
			while (tasks.next()) {
				IDfWorkitem wi = (IDfWorkitem) idfSession.getObject(tasks.getId("item_id"));
				IDfId queueItemId = wi.getQueueItemId();
				IDfQueueItem qi = (IDfQueueItem) idfSession.getObject(queueItemId);
				System.out.println(tasks.getString("sent_by") + "   "
								+ tasks.getString("task_name") + "   "
								+ tasks.getString("date_sent") + "   "
								+ tasks.getString("message") + "   "
								+ qi.getItemName());
				IDfActivity dfActivity = wi.getActivity();
				System.out.println("\tActivity Information : " + dfActivity.getString("object_name"));
				IDfCollection packColl = null;
				try {
					packColl = wi.getPackages("");
					while (packColl.next()) {
						IDfSysObject sysObj = (IDfSysObject) idfSession.getObject(packColl.getId("r_component_id"));
						System.out.println("\t Package Information: " + sysObj.getString("object_name"));
					}
					
				} finally {
					if (packColl != null)
						packColl.close();
				}
				// to finish a Task or Workitem
				// finishTask(wi);
			}
		} finally {
			if (tasks != null)
				tasks.close();
		}
	}

	public void finishTask(IDfWorkitem wi) throws Exception {

		if (wi.getRuntimeState() == IDfWorkflow.DF_WF_STATE_DORMANT) {
			wi.acquire();
		}
		wi.complete();
	}

	public void attachLC() throws Exception {

		IDfSysObject mDocs = (IDfSysObject) idfSession
				.getObjectByQualification("dm_document where object_name='UniqueDoc' ");

		IDfSysObject procObj = (IDfSysObject) idfSession
				.getObjectByQualification("dm_policy where object_name='Training_LC' ");
		mDocs.attachPolicy(procObj.getObjectId(), "Author", "");

	}

	public void promoteLC(String State) throws Exception {
		IDfSysObject mDocs = (IDfSysObject) idfSession
				.getObjectByQualification("dm_document where object_name='UniqueDoc' ");
		mDocs.promote(State, false, false);
	}

	public void demoteLC(String State) throws Exception {
		IDfSysObject mDocs = (IDfSysObject) idfSession
				.getObjectByQualification("dm_document where object_name='UniqueDoc' ");
		mDocs.demote(State, false);
	}

	public void expireLC(String State) throws Exception {
		IDfSysObject mDocs = (IDfSysObject) idfSession
				.getObjectByQualification("dm_document where object_name='UniqueDoc' ");
		mDocs.suspend(State, false, false);
	}

	public void resumeLC(String State) throws Exception {
		IDfSysObject mDocs = (IDfSysObject) idfSession
				.getObjectByQualification("dm_document where object_name='UniqueDoc' ");
		mDocs.resume(State, false, false, false);
	}


	public void assignACL() throws Exception {

		IDfSysObject mDocs = (IDfSysObject) idfSession
				.getObjectByQualification("dm_document where object_name='UniqueDoc' ");
		IDfACL dfACL = (IDfACL) idfSession
				.getObjectByQualification("dm_acl where object_name='TrainingACL' ");
		mDocs.setACL(dfACL);
		mDocs.save();
	}

	
	public static void main(String[] args) throws Exception {

		String user = "huoadm";
		String passwd = "pass_4_huoadm";
		String docbase = "MY_DOCBASE_DEV";
		DFCWorkShop object = new DFCWorkShop(user, passwd, docbase);

		try {

			// To get a list of available docbase
			/*
				Session created successfully
				Docbase Name : MY_DOCBASE2_DEV
				Docbase Desc : Company Repository 2
				Docbase Name : MY_DOCBASE_DEV
				Docbase Desc : Company Repository
				Docbase Name : GLOBALR
				Docbase Desc : Global Registry Repository
				Docbase Name : MY_DOCBASE3_DEV
				Docbase Desc : Company Repository 3
				Docbase Name : MY_DOCBASE4_DEV
				Docbase Desc : Company Repository 4 
			 */
//			object.getAllDocbases();

			// To create a cabinet (dm_cabinet) in docbase
			// object.createCabinet();

			// To create a folder (dm_folder object) in docbase
			// object.createFolder();

			// To create a document (dm_document object) in docbase
			// object.createDocument();

			// To check out a document from docbase using IDfOperations
			// object.checkoutDocument();

			// To check in a document to docbase using IDfOperations
			// object.checkinDocument();

			// making use of IAPI methods
			// object.dmclAPI();

			// To import a document into docbase
			// object.importDocument();

			// To cancelcheckout a document into docbase
			// object.cancelCheckoutDocument();

			// To check out a document from docbase
			// object.checkoutDoc();

			// To check in a document to docbase
			// object.checkinDoc();

			// To delete a document from docbase
			// object.deleteDoc();

			// To update document's in docbase
			// object.updateAttributes();

			// To retrieve document's attributes from docbase
			// object.getAttributes();

			// To create a virtual document in docbase
			// object.createVirtualDocument();

			// To export a virtual document from docbase
			// object.exportVirtualDocument();

			// To view virtual document from docbase
			// object.viewVirtualDocument();

			// To retrieve document from document using IDQL
			// object.collection();

			// To create and start workflow
			// object.startWorkflow();

			// to view task in inbox
			 object.getInbox();

			// To attach a lifeCycle to a document in docbase
			// object.attachLC();

			// To promote a lifeCycle state of a document
			// object.promoteLC("Review");

			// To demote a lifeCycle state of a document
			// object.demoteLC("Author");

			// To expire a lifeCycle state of a document
			// object.expireLC("Author");

			// To resume a lifeCycle state of a document
			// object.resumeLC("Author");

			// To assign a ACL to a document
			// object.assignACL();

		} finally {
			// to release a docbase session
			object.releaseSession();
		}
	}
}

Kind regards,

Huseyin

Hello,
 
In this post, I would like to present the definition of a custom Uniform Resource Identifier (URI) in order to execute a program in Windows on client side.
 
In a URL the portion with the HTTP://,FTP://, …etc are called URI Schemes. So, in some cases, it may be desirable to invoke another application to handle a custom Uniform Resource Identifier (URI) scheme. To register the existing application as an URI pluggable protocol handler and associate it with the custom URI scheme. Once the application has successfully launched, it can use command-line parameters to retrieve the URI that launched it. These settings apply to pluggable protocol handlers launched from within Windows Internet Explorer and from Windows Explorer using the Run… command (Windows logo key+R).
 
So, it is possible to register your own through the registry via the adding of a new key, along with the appropriate subkeys and values, to HKEY_CLASSES_ROOT. The root key must match the URI scheme that is being added.

HKEY_CLASSES_ROOT/
your-protocol-name/
your-protocol-name/(Default) = URL:your-protocol-name Protocol
your-protocol-name/URL Protocol = 
your-protocol-name/DefaultIcon/
your-protocol-name/DefaultIcon/(Default) = Executable.exe,1
your-protocol-name/shell/
your-protocol-name/shell/(Default) = 
your-protocol-name/shell/open/
your-protocol-name/shell/open/(Default) = 
your-protocol-name/shell/open/command/
your-protocol-name/shell/open/command/(Default) = "%ENV_VARIABLE%PathToExecutable/Executable.exe" "%1"

The URL Protocol string value indicates that this key declares a custom pluggable protocol handler. Without this key, the handler application will not launch. The value should be an empty string.
When a user clicks a link containing your custom URI scheme, Windows Internet Explorer launches the pluggable protocol handler registered for that URI scheme. If the specified open command specified in the registry contains a %1 parameter, Internet Explorer passes the URI to the registered pluggable protocol handler application
Importante Note IE must be the default browser on CLIENT side.

 
 

Example : Step by step

  • Go to Start then in Find type regedit -> it should open Registry editor:
  • Click Right Mouse on HKEY_CLASSES_ROOT then New -> Key:
  • In the Key give the lowercase name (testhuseyin) corresponding and matching with the URI Scheme (in my case it will be testhuseyin://mydata)
  • Click Right Mouse on testhuseyin -> then New -> String Value and add URL protocol without value.

  • Create hierarchy like testhuseyin -> shell -> open -> command via (Right Mouse New -> Key)
  • Create a new key DefaultIcon under testhuseyin via (Right Mouse New -> Key)
  • Inside the root key testhuseyin modify the value of entry (Default) to the protocol URL:Testhuseyin Protocol

  • Inside the key testhuseyin/DefaultIcon/, modify the value of (Default) to the name of .exe which to be launched: testhuseyin.exe,1 The “,1” corresponds to the parameter’s data.
  • Inside the key testhuseyin/shell/open/command/, modify the value of (Default) to the path of .exe which to be launched “c:\testing\testhuseyin.exe” “%1”. The “%1” corresponds to the parameter’s data.
  • Result should be:
    testhuseyin/
    testhuseyin/(Default) = URL:Testhuseyin Protocol
    testhuseyin/URL Protocol = 
    testhuseyin/DefaultIcon/
    testhuseyin/DefaultIcon/(Default) = testhuseyin.exe,1
    testhuseyin/shell/
    testhuseyin/shell/(Default) = 
    testhuseyin/shell/open/
    testhuseyin/shell/open/(Default) = 
    testhuseyin/shell/open/command/
    testhuseyin/shell/open/command/(Default) = "c:\testing\testhuseyin.exe" "%1"
    
  • To test if it works go to Internet Explorer (not Chrome or Firefox) and enter testhuseyin:test_1_test_2_hello_everybody:

    Without application helper, the below message will be displayed:

    If, you test with an unconfigured protocol, for example testhuseyin123, you will not obtain the same behaviour : testhuseyin123:test_1_test_2_hello_everybody.

  • So, create a new console application Testhuseyin:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace Testhuseyin
    {
        class Program
        {
            static void Main(string[] args)
            {
            }
        }
    }
    

    Modify the Main method simply to write into output the passed parameter:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace Testhuseyin
    {
        class Program
        {
            static void Main(string[] args)
            {
                //TEST HUSEYIN
                if (args != null && args.Length > 0)
                    Console.WriteLine(args[0]);
                Console.ReadKey();
    
            }
        }
    }
    

    Build the solution:

    1>------ Build started: Project: Testhuseyin, Configuration: Debug Any CPU ------
    1>  Testhuseyin -> C:\Workspaces\MS_Visual_Studio_Projects\Testhuseyin\Testhuseyin\bin\Debug\Testhuseyin.exe
    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
    

    Copy/paste the executable into the protocol’s configured folder:

  • Try again to test if it works go to Internet Explorer (not Chrome or Firefox) and enter testhuseyin:test_1_test_2_hello_everybody:

  • Try again to test if it works via Start Menu/Run and enter testhuseyin:JAVABLOG.LU_huseyin:

 

Advanced : Use environment variable

  • Create user environment variable in order to store the path of executable of application helper : my_huo_user_variable = C:\testing\
    For example, this variable could be modified every time the boot of standalone application.

    Check the value of this variable:

  • Inside the key testhuseyin/shell/open/command/, modify the value of (Default) in order to use this environment variable: “%my_huo_user_variable%testhuseyin.exe” “%1”.
  • In order to use environment variable, you need to change the type of testhuseyin/shell/open/command/(Default) from default type REG_SZ to REG_EXPAND_SZ. However, it is possible to do via regedit GUI. You can use command line reg.exe to do this.

    Example 1 : C:\WINDOWS\system32>reg.exe add “HKCR\testhuseyin\shell\open\command” /ve /t REG_EXPAND_SZ /d “\”%my_huo_user_variable%testhuseyin.exe\” \”%1\”” /f
    The operation completed successfully.

    Example 2 : C:\WINDOWS\system32>reg.exe add “HKCR\testhuseyin\shell\open\command” /ve /t REG_EXPAND_SZ /d “\”^%my_huo_user_variable^%testhuseyin.exe\” \”%1\”” /f
    The operation completed successfully.

  • Final result should be:
    testhuseyin/
    testhuseyin/(Default) = URL:Testhuseyin Protocol
    testhuseyin/URL Protocol = 
    testhuseyin/DefaultIcon/
    testhuseyin/DefaultIcon/(Default) = testhuseyin.exe,1
    testhuseyin/shell/
    testhuseyin/shell/(Default) = 
    testhuseyin/shell/open/
    testhuseyin/shell/open/(Default) = 
    testhuseyin/shell/open/command/
    testhuseyin/shell/open/command/(Default) = "%my_huo_user_variable%testhuseyin.exe" "%1"
    
  • Test again:

 

Advanced : Use creation script

  • Open notepad and save the below script to testhuseyin2.reg and execute it by clicking on it in explorer.
    REGEDIT4
    
    [HKEY_CLASSES_ROOT\testhuseyin2]
    @="URL:Testhuseyin2 Protocol"
    "URL Protocol"=""
    
    [HKEY_CLASSES_ROOT\testhuseyin2\DefaultIcon]
    @="testhuseyin.exe,1"
    
    [HKEY_CLASSES_ROOT\testhuseyin2\shell]
    
    [HKEY_CLASSES_ROOT\testhuseyin2\shell\open]
    
    [HKEY_CLASSES_ROOT\testhuseyin2\shell\open\command]
    @="\"C:\\testing\\testhuseyin.exe\" \"%1\""
    

  • Final result should be:
    testhuseyin2/
    testhuseyin2/(Default) = URL:Testhuseyin2 Protocol
    testhuseyin2/URL Protocol = 
    testhuseyin2/DefaultIcon/
    testhuseyin2/DefaultIcon/(Default) = testhuseyin.exe,1
    testhuseyin2/shell/
    testhuseyin2/shell/(Default) = 
    testhuseyin2/shell/open/
    testhuseyin2/shell/open/(Default) = 
    testhuseyin2/shell/open/command/
    testhuseyin2/shell/open/command/(Default) = "C:\\testing\\testhuseyin.exe" "%1"
    
  • Test again:

That’s all!!!

Huseyin OZVEREN

Hello,

Juste a post concerning the generation of proxies client for DFS web service project due to ANT script and utilities classes.
Several steps:

  • Create a project TESTWsClientGenerator
  • Add the JAR emc-dfs-rt-remote.jar and emc-dfs-rt.jar (from DocumentumCoreProject\dfs6.7\emc-dfs-sdk-6.7\lib\java) in the BuildPath of your project
  • Get in your workplace the CXF librairies : C:\Workspaces\HUO\ECMExternalLibraries\org\apache\cfx-3.0.3 http://cxf.apache.org/cxf-303-release-notes.html
  • Create a source folder wsgenerator
  • Create the package com.emc.documentum.fs.datamodel.core.content
  • Create the below utilities classes BinaryContent and DataHandlerContent in this com.emc.documentum.fs.datamodel.core.content:
    package com.emc.documentum.fs.datamodel.core.content;
    
    import java.io.Serializable;
    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlType;
    
    
    /**
     * <p>Java class for BinaryContent complex type.
     * 
     * <p>The following schema fragment specifies the expected content contained within this class.
     * 
     * <pre>
     * &lt;complexType name="BinaryContent">
     *   &lt;complexContent>
     *     &lt;extension base="{http://content.core.datamodel.fs.documentum.emc.com/}Content">
     *       &lt;sequence>
     *         &lt;element name="Value" type="{http://www.w3.org/2001/XMLSchema}base64Binary"/>
     *       &lt;/sequence>
     *     &lt;/extension>
     *   &lt;/complexContent>
     * &lt;/complexType>
     * </pre>
     * 
     * 
     */
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "BinaryContent", propOrder = {
        "value"
    })
    public class BinaryContent
        extends Content
        implements Serializable
    {
    
        private final static long serialVersionUID = 1397139757393L;
        @XmlElement(name = "Value", required = true)
        protected byte[] value;
    
        /**
         * Gets the value of the value property.
         * 
         * @return
         *     possible object is
         *     byte[]
         */
        public byte[] getValue() {
            return value;
        }
    
        /**
         * Sets the value of the value property.
         * 
         * @param value
         *     allowed object is
         *     byte[]
         */
        public void setValue(byte[] value) {
            this.value = value;
        }
    
    }
    

     

    package com.emc.documentum.fs.datamodel.core.content;
    
    import java.io.Serializable;
    import javax.activation.DataHandler;
    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlMimeType;
    import javax.xml.bind.annotation.XmlType;
    
    
    /**
     * <p>Java class for DataHandlerContent complex type.
     * 
     * <p>The following schema fragment specifies the expected content contained within this class.
     * 
     * <pre>
     * &lt;complexType name="DataHandlerContent">
     *   &lt;complexContent>
     *     &lt;extension base="{http://content.core.datamodel.fs.documentum.emc.com/}Content">
     *       &lt;sequence>
     *         &lt;element name="Value" type="{http://www.w3.org/2001/XMLSchema}base64Binary"/>
     *       &lt;/sequence>
     *     &lt;/extension>
     *   &lt;/complexContent>
     * &lt;/complexType>
     * </pre>
     * 
     * 
     */
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "DataHandlerContent", propOrder = {
        "value"
    })
    public class DataHandlerContent
        extends Content
        implements Serializable
    {
    
        private final static long serialVersionUID = 1397139757393L;
        @XmlElement(name = "Value", required = true)
        @XmlMimeType("*/*")
        protected DataHandler value;
    
        /**
         * Gets the value of the value property.
         * 
         * @return
         *     possible object is
         *     {@link DataHandler }
         *     
         */
        public DataHandler getValue() {
            return value;
        }
    
        /**
         * Sets the value of the value property.
         * 
         * @param value
         *     allowed object is
         *     {@link DataHandler }
         *     
         */
        public void setValue(DataHandler value) {
            this.value = value;
        }
    
    }
    
  • Create the package com.emc.documentum.fs.utils
  • Create the below utilities classes ContentUtil and ServiceProxyUtils in this com.emc.documentum.fs.utils:
    package com.emc.documentum.fs.utils;
    
    import java.io.BufferedInputStream;
    import java.io.ByteArrayInputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.net.MalformedURLException;
    import java.net.Proxy;
    import java.net.URL;
    import java.net.URLConnection;
    import java.text.MessageFormat;
    
    import javax.activation.DataHandler;
    import javax.activation.DataSource;
    
    import com.emc.documentum.fs.datamodel.core.content.BinaryContent;
    import com.emc.documentum.fs.datamodel.core.content.Content;
    import com.emc.documentum.fs.datamodel.core.content.DataHandlerContent;
    import com.emc.documentum.fs.datamodel.core.content.UrlContent;
    
    public class ContentUtil {
    
    	private static class InputStreamDataSource implements DataSource {
    		private final InputStream inputStream;
    		private final String type;
    
    		public InputStreamDataSource(InputStream inputStream) throws IOException {
    			this(inputStream, URLConnection.guessContentTypeFromStream(inputStream));
    		}
    
    		public InputStreamDataSource(InputStream inputStream, String type) {
    			this.inputStream = inputStream;
    			this.type = type;
    		}
    
    		@Override
    		public String getContentType() {
    			if (this.type == null) {
    				return "application/octet-stream";
    			}
    			return this.type;
    		}
    
    		@Override
    		public InputStream getInputStream() throws IOException {
    			return inputStream;
    		}
    
    		@Override
    		public String getName() {
    			return InputStreamDataSource.class.getSimpleName();
    		}
    
    		@Override
    		public OutputStream getOutputStream() throws IOException {
    			throw new IOException("Not Supported");
    		}
    	}
    
    	private static DataHandlerContent getDataHandlerContent(DataSource dataSource, String format) {
    		DataHandlerContent dataHandlerContent = new DataHandlerContent();
    		dataHandlerContent.setFormat(format);
    		dataHandlerContent.setValue(new DataHandler(dataSource));
    		return dataHandlerContent;
    	}
    
    	public static DataHandlerContent getDataHandlerContent(File file, String format) throws FileNotFoundException, IOException {
    		return getDataHandlerContent(new InputStreamDataSource(new FileInputStream(file), URLConnection.guessContentTypeFromName(file.getAbsolutePath())), format);
    	}
    
    	public static DataHandlerContent getDataHandlerContent(InputStream inputStream, String format) throws IOException {
    		return getDataHandlerContent(new InputStreamDataSource(inputStream), format);
    	}
    
    	public static InputStream getInputStream(Content content) throws MalformedURLException, IOException {
    		if (content == null) {
    			throw new IllegalArgumentException("content cannot be null");
    		}
    		if (content instanceof UrlContent) {
    			UrlContent urlContent = (UrlContent) content;
    			URL url = new URL(urlContent.getUrl());
    			URLConnection urlConnection = url.openConnection(Proxy.NO_PROXY);
    			InputStream inputStream = urlConnection.getInputStream();
    			BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
    			return bufferedInputStream;
    		} else if (content instanceof BinaryContent) {
    			BinaryContent binaryContent = (BinaryContent) content;
    			byte[] data = binaryContent.getValue();
    			ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(data);
    			return byteArrayInputStream;
    		} else if (content instanceof DataHandlerContent) {
    			DataHandlerContent dataHandlerContent = (DataHandlerContent) content;
    			DataHandler dataHandler = dataHandlerContent.getValue();
    			InputStream inputStream = dataHandler.getInputStream();
    			return inputStream;
    		}
    		throw new RuntimeException(MessageFormat.format("{0} content is not supported", content));
    	}
    }
    

     

    package com.emc.documentum.fs.utils;
    
    import java.lang.reflect.Constructor;
    import java.lang.reflect.InvocationTargetException;
    import java.text.MessageFormat;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    
    import javax.xml.bind.JAXBException;
    import javax.xml.namespace.QName;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.soap.SOAPElement;
    import javax.xml.soap.SOAPException;
    
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    
    public class ServiceProxyUtils {
    
    	private static final Logger logger = Logger.getLogger(ServiceProxyUtils.class.getName());
    
    	public static Element getSecurityHeaderForRegisteredToken(String token) throws ParserConfigurationException {
    		Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    		Element wsseSecurity = document.createElementNS("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "wsse:Security");
    		Element wsseToken = (Element) wsseSecurity.appendChild(document.createElementNS("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "wsse:BinarySecurityToken"));
    		wsseToken.setAttribute("QualificationValueType", "http://schemas.emc.com/documentum#ResourceAccessToken");
    		wsseToken.setAttributeNS("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", "wsu:Id", "RAD");
    		wsseToken.setTextContent(token);
    		return wsseSecurity;
    	}
    
    	public static Element getSecurityHeaderForKerberosToken(String token) throws ParserConfigurationException {
    		Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    		Element securityElement = (Element) document.createElementNS("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "ns3:Security");
    		securityElement.setAttribute("xmlns:ns1", "http://www.w3.org/2003/05/soap-envelope");
    		securityElement.setAttribute("xmlns:ns2", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
    		Element wsseToken = (Element) securityElement.appendChild(document.createElement("ns3:BinarySecurityToken"));
    		wsseToken.setAttribute("ValueType", "http://docs.oasis-open.org/wss/oasis-wss-kerberos-token-profile-1.1#Kerberosv5_AP_REQ");
    		wsseToken.setAttribute("EncodingType", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary");
    		wsseToken.setTextContent(token);
    		return securityElement;
    	}
    
    	public static Element getSecurityHeaderForJAXBObject(Object object) throws JAXBException, ParserConfigurationException {
    		javax.xml.bind.JAXBContext j = javax.xml.bind.JAXBContext.newInstance(object.getClass());
    		org.w3c.dom.Document document = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    		j.createMarshaller().marshal(object, document);
    		return document.getDocumentElement();
    	}
    
    	public static void addBasicSecurity(javax.xml.ws.Service service, final String userName, final String password) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
    		service.setHandlerResolver(new javax.xml.ws.handler.HandlerResolver() {
    			@SuppressWarnings("rawtypes")
    			@Override
    			public java.util.List<javax.xml.ws.handler.Handler> getHandlerChain(javax.xml.ws.handler.PortInfo portInfo) {
    				java.util.List<javax.xml.ws.handler.Handler> handlerList = new java.util.ArrayList<javax.xml.ws.handler.Handler>();
    				handlerList.add(new javax.xml.ws.handler.soap.SOAPHandler<javax.xml.ws.handler.soap.SOAPMessageContext>() {
    					public void close(javax.xml.ws.handler.MessageContext context) {
    					}
    
    					public java.util.Set<javax.xml.namespace.QName> getHeaders() {
    						return new java.util.TreeSet<javax.xml.namespace.QName>();
    					}
    
    					public boolean handleFault(javax.xml.ws.handler.soap.SOAPMessageContext context) {
    						return true;
    					}
    
    					public boolean handleMessage(javax.xml.ws.handler.soap.SOAPMessageContext context) {
    						Boolean outboundProperty = (Boolean) context.get(javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    						if (outboundProperty.booleanValue()) {
    							try {
    								javax.xml.soap.SOAPEnvelope envelope = context.getMessage().getSOAPPart().getEnvelope();
    								javax.xml.soap.SOAPHeader header = envelope.addHeader();
    								SOAPElement serviceContextElement = javax.xml.soap.SOAPFactory.newInstance().createElement(new QName("http://context.core.datamodel.fs.documentum.emc.com/", "ServiceContext"));
    								SOAPElement basicIdentityElement = serviceContextElement.addChildElement(javax.xml.soap.SOAPFactory.newInstance().createElement("Identities"));
    								basicIdentityElement.setAttribute("xsi:type", "BasicIdentity");
    								basicIdentityElement.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
    								basicIdentityElement.setAttribute("userName", userName);
    								basicIdentityElement.setAttribute("password", password);
    								header.addChildElement(serviceContextElement);
    							} catch (Exception e) {
    								throw new RuntimeException("SOAPException in handler => unable to add security layer in header", e);
    							}
    						} else {
    							// inbound => Nothing to do
    						}
    						return true;
    					}
    				});
    				return handlerList;
    			}
    		});
    	}
    
    	public static <T extends javax.xml.ws.Service> T getService(Class<T> clazz, java.net.URL wsdlLocation) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    		return getService(clazz, wsdlLocation, null);
    	}
    
    	public static <T extends javax.xml.ws.Service> T getService(Class<T> clazz, java.net.URL wsdlLocation, final org.w3c.dom.Element wsseSecurity) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    		javax.xml.ws.WebServiceClient webServiceClient = clazz.getAnnotation(javax.xml.ws.WebServiceClient.class);
    		return getService(clazz, wsdlLocation, new javax.xml.namespace.QName(webServiceClient.targetNamespace(), webServiceClient.name()), wsseSecurity);
    	}
    
    	public static <T extends javax.xml.ws.Service> T getService(Class<T> clazz, java.net.URL wsdlLocation, javax.xml.namespace.QName serviceName, final org.w3c.dom.Element wsseSecurity) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    		Constructor<T> constructor = clazz.getConstructor(java.net.URL.class, javax.xml.namespace.QName.class);
    		T result = constructor.newInstance(wsdlLocation, serviceName);
    		if (wsseSecurity != null) {
    			result.setHandlerResolver(new javax.xml.ws.handler.HandlerResolver() {
    				@SuppressWarnings("rawtypes")
    				@Override
    				public java.util.List<javax.xml.ws.handler.Handler> getHandlerChain(javax.xml.ws.handler.PortInfo portInfo) {
    					java.util.List<javax.xml.ws.handler.Handler> handlerList = new java.util.ArrayList<javax.xml.ws.handler.Handler>();
    					handlerList.add(new javax.xml.ws.handler.soap.SOAPHandler<javax.xml.ws.handler.soap.SOAPMessageContext>() {
    						public void close(javax.xml.ws.handler.MessageContext context) {
    						}
    
    						public java.util.Set<javax.xml.namespace.QName> getHeaders() {
    							return new java.util.TreeSet<javax.xml.namespace.QName>();
    						}
    
    						public boolean handleFault(javax.xml.ws.handler.soap.SOAPMessageContext context) {
    							return true;
    						}
    
    						public boolean handleMessage(javax.xml.ws.handler.soap.SOAPMessageContext context) {
    							Boolean outboundProperty = (Boolean) context.get(javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    							if (outboundProperty.booleanValue()) {
    								try {
    									javax.xml.soap.SOAPEnvelope envelope = context.getMessage().getSOAPPart().getEnvelope();
    									javax.xml.soap.SOAPHeader header = envelope.addHeader();
    									header.addChildElement(javax.xml.soap.SOAPFactory.newInstance().createElement(wsseSecurity));
    								} catch (SOAPException e) {
    									logger.log(Level.SEVERE, MessageFormat.format("SOAPException in handler => unable to add security layer {0} in header", wsseSecurity), e);
    								}
    							} else {
    								// inbound => Nothing to do
    							}
    							return true;
    						}
    					});
    					return handlerList;
    				}
    			});
    		}
    		return result;
    	}
    
    	private ServiceProxyUtils() {
    		super();
    	}
    }
    
  • Create a file build.properties:
    application.version=1
    build.vendor=JavaBlog.fr - Java.lu
    
  • Create a file 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 a file wsdllist.txt:
    https://ws.java.lu/services/mycontext/MyWebServiceForECMService?wsdl
    https://ws.java.lu/services/mycontext/runtime/ContextRegistryService?wsdl
    
  • Create an ANT script build.xml. Modify the folder of CXF home in script cxf.home:
    	<property name="cxf.home" location="C:\Workspaces\HUO\ECMExternalLibraries\org\apache\cfx-3.0.3" />
    
    <?xml version="1.0" encoding="UTF-8"?>
    <project name="TESTWsClientGenerator" default="dist" basedir=".">
    	<property file="build.properties" />
    	<property name="build" value="build" />
    	<property name="src" value="src" />
    	<property name="build.src" value="${build}\${src}" />
    	<property name="build.classes" value="${build}\classes" />
    	<property name="build.lib" value="lib" />
    	<property name="build.dist" location="${build}/dist" />
    	<property name="build.ClientAcceptanceProxy.jar" location="${build.dist}/${ant.project.name}.jar" />
    
    	<property name="cxf.home" location="C:\Workspaces\HUO\ECMExternalLibraries\org\apache\cfx-3.0.3" />
    
    	<target name="dist" depends="create_proxy, build">
    		<jar basedir="${build.classes}" destfile="${build.ClientAcceptanceProxy.jar}" manifest="${build}/MANIFEST.MF" />
    	</target>
    
    	<target name="build" depends="javac" />
    
    	<target name="init">
    		<delete dir="${build}" failonerror="false" />
    		<mkdir dir="${build}" />
    		<mkdir dir="${build.lib}" />
    		<mkdir dir="${build.src}" />
    	</target>
    
    	<target name="javac" depends="javaclasspath" description="compile the source">
    		<delete dir="${build.classes}" />
    		<mkdir dir="${build.classes}" />
    
    		<!-- compile -->
    		<javac destdir="${build.classes}" debug="true" srcdir="${build.src}" source="1.5" target="1.5" encoding="8859_1">
    			<classpath refid="classpath.compile" />
    		</javac>
    
    		<!-- copy all resources to the classes directory -->
    		<copy todir="${build.classes}">
    			<fileset dir="${build.src}">
    				<include name="**/*" />
    				<exclude name="**/*.java" />
    			</fileset>
    		</copy>
    
    		<tstamp>
    			<format property="build.time" pattern="dd/MM/yyyy HH:mm:ss" />
    		</tstamp>
    
    		<buildnumber file="${ant.project.name}.buildnumber" />
    		<property name="build.version" value="${application.version}.${build.number}" />
    
    		<manifest file="${build}/MANIFEST.MF">
    			<attribute name="Created-By" value="${user.name}" />
    			<attribute name="Product-Name" value="${ant.project.name}" />
    			<attribute name="Product-Version" value="${application.version}" />
    			<attribute name="Build-Version" value="${build.version}" />
    			<attribute name="Build-Date" value="${build.time}" />
    			<attribute name="Vendor-Name" value="${build.vendor}" />
    		</manifest>
    
    	</target>
    
    	<target name="javaclasspath" description="Configure classpath">
    		<!-- define classpath -->
    		<path id="classpath.compile">
    			<fileset dir="${build.lib}">
    				<include name="**/*.jar" />
    			</fileset>
    		</path>
    	</target>
    
    	<path id="cxf.classpath">
    		<fileset dir="${cxf.home}/lib">
    			<include name="*.jar" />
    		</fileset>
    	</path>
    
    	<target name="prepare">
    		<mkdir dir="${build}" />
    		<mkdir dir="${build.src}" />
    		<mkdir dir="${build.classes}" />
    		<mkdir dir="${build.dist}" />
    	</target>
    
    	<target name="clean">
    		<delete dir="${build}" includeemptydirs="true" />
    	</target>
    
    	<target name="create_proxy" depends="init,prepare">
    		<java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true">
    			<arg value="-autoNameResolution" />
    			<arg value="-verbose" />
    			<arg value="-fe" />
    			<arg value="jaxws21" />
    			<arg value="-d" />
    			<arg value="${build.src}" />
    			<arg value="-b" />
    			<arg value="simple-binding.xjb" />
    			<arg value="-wsdlList" />
    			<arg value="wsdllist.txt" />
    
    			<classpath>
    				<path refid="cxf.classpath" />
    			</classpath>
    		</java>
    
    		<mkdir dir="${build.src}/com/emc/documentum/fs/utils" />
    		<copy todir="${build.src}/com/emc/documentum/fs/utils">
    			<fileset dir="${basedir}">
    				<include name="*.java" />
    			</fileset>
    		</copy>
    
    		<delete dir="${basedir}/src" includeemptydirs="true" />
    		<copy todir="${basedir}/src">
    			<fileset dir="${build}/src">
    				<include name="**/*.java" />
    			</fileset>
    		</copy>
    	</target>
    </project>
    
  • Execute the ANT script – Warning: Use the JDK version JavaSE-1.7 – :
    
    Buildfile: C:\Workspaces\HUO\TESTWsClientGenerator\build.xml
    init:
       [delete] Deleting directory C:\Workspaces\HUO\TESTWsClientGenerator\build
        [mkdir] Created dir: C:\Workspaces\HUO\TESTWsClientGenerator\build
        [mkdir] Created dir: C:\Workspaces\HUO\TESTWsClientGenerator\build\src
    prepare:
        [mkdir] Created dir: C:\Workspaces\HUO\TESTWsClientGenerator\build\classes
        [mkdir] Created dir: C:\Workspaces\HUO\TESTWsClientGenerator\build\dist
    create_proxy:
          Loading FrontEnd jaxws21 ...
          Loading DataBinding jaxb ...
          wsdl2java -autoNameResolution -verbose -fe jaxws21 -d build\src -b simple-binding.xjb -wsdlList wsdllist.txt
          wsdl2java - Apache CXF 3.0.3
        [mkdir] Created dir: C:\Workspaces\HUO\TESTWsClientGenerator\build\src\com\emc\documentum\fs\utils
       [delete] Deleting directory C:\Workspaces\HUO\TESTWsClientGenerator\src
         [copy] Copying 139 files to C:\Workspaces\HUO\TESTWsClientGenerator\src
    javaclasspath:
    javac:
       [delete] Deleting directory C:\Workspaces\HUO\TESTWsClientGenerator\build\classes
        [mkdir] Created dir: C:\Workspaces\HUO\TESTWsClientGenerator\build\classes
        [javac] Compiling 139 source files to C:\Workspaces\HUO\TESTWsClientGenerator\build\classes
        [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.5
        [javac] 1 warning
         [copy] Copied 1 empty directory to 1 empty directory under C:\Workspaces\HUO\TESTWsClientGenerator\build\classes
    build:
    dist:
          [jar] Building jar: C:\Workspaces\HUO\TESTWsClientGenerator\build\dist\TESTWsClientGenerator.jar
    BUILD SUCCESSFUL
    Total time: 12 seconds
    
  • Result : The folder src contains the proxies classes in order to request the DFS web services. A file TESTWsClientGenerator.buildnumber is generated with the build number:
    #Build Number for ANT. Do not edit!
    #Thu Oct 05 11:55:44 CEST 2017
    build.number=2
    

    Warning : The BinaryContent and DataHandlerContent classes are double. so, it is possible to remove the package wsgenerator\com\emc\documentum\fs\datamodel\core\content. You could execute again the ANT script.

That’s all!

Huseyin OZVEREN

Page 6 of 55:« First« 3 4 5 6 7 8 9 »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.