DRM sdk provides below artifacts
Figure 1
but we need only jar files belongs to dist/lib and thirdparty to create below libraries for our Jdeveloper Project. Jdeveloper 11.1.1.3 is the IDE I am using for developing the project.
Figure 2
where library “Thirdparty” contains below jar files.I prefer those jar files needs to be copied to project folder, I mean from DRM SDK zip file (from figure 1) to project folder.
DRMAPI library contains dist/lib/hdrm-proxy-api.jar and xerces library contains thirdparty/xerces/xerces.jar. After doing all setups we can move for development.
please follow below code block for adding a node in DRM.
public class AddDRMNode { //declare variables that needs to be initialized and //used through out the class Identify the DRM server //to which we are trying to make request String aUrl = "<Url of DRM server>"; //Initialize master data management IMasterDataManagement masterDataManagement = null ; //Initialize TRemSessionInfo TRemSessionInfo sessionInfo = null ; //Initialize Current Version String CurrentVersion = null ; //Initialize list of hierarchy Objects ArrayOfStringHolder hierobjects= null ; public AddDRMNode(){} public void addNode( String <DRM UserId>, String <DRM Password>, Sring node) { //get instance of mdm masterDataManagement = MasterDataManagementUtils . getMasterDataManagementFacade ( new URL (aUrl)); //get session try{ sessionInfo = masterDataManagement. getSessionMgr (). createSession (<DRM Server User ID>, <DRM Server Password>, "ProductVersion=11.1.1,CleartextPassword=True"); } catch ( Exception e) { logger. info ("unable to get session");} //get hold of current version currentversion = "Current"; //get list of all hierarchies under Current version. here listHierObjects //is a method which returns list of hierarchies.Defined later in my post try { hierobjects = listHierObjects(this.sessionInfo, currentversion); logger. info ("there are [" + hierobjects.value.length + "] hierarchy objects for version [" + currentversion + "]"); } catch ( Exception e) { logger. info ("Hierarchies are not found"); } //looping through the Current Hierarchy for ( int i = 0; i < hierobjects. value . length ; i++) { logger. info ("[" + i + "] hierarchy value is [" + hierobjects. value [i] + "]"); //Obtain a hierarchy locator using version and current hierarchy value hierlocator = getHierLocator(currentversion, hierobjects. value [i]); //get hold of hierarchy prefix using the hierarchy locator try { prefix = getHierarchyPrefix(hierlocator); //update passed argument node as a concat with prefix node = prefix+ node; logger. info ("Customer to be added :[" + node + "]"); } catch ( Exception e) { logger. info ("Problem retrieving Hierarchy Prefix"); e. printStackTrace (); } //get IHier_PortyType for node addition ihierpt = this .masterDataManagement. getHier (); //get hold of parent node try { parentnode = ihierpt. nodeByAbbrev (hierlocator, <Parrent node name>); logger. info ("ID of Unmapped node is" + parentnode. getID() ); } catch ( Exception e) { logger. info ("parent node does not exist"); e. printStackTrace() ; break ; } //get hold of nodelocator object for parent node TRemLocalNodeLocator nodelocator = getTremLocalNodeLocator(currentversion, hierobjects.value[i], localnode. getDisplayByString ()); try { //check whether passed node is existed, isnodeExist is //defined later. passed argument is //locator of parent node,Local node object,node to be added if (isnodeExist(nodelocator, this.masterDataManagement. getLocalNode (), node)) { logger. info ("Node Exists in UNMAPPED"); } else { logger. info ("Node does not exist, going to add"); //addNode passed arguments are hierarchy locator //node to be added,parent node ID,boolean value to decide //whether added node is leaf or limb ihierpt. addNode (hierlocator, node, parentnode.getID(), true); } } catch ( Exception e) { logger. info ("Exception odue to node handling, It may be mapped earlier in parent Node"); } } } private boolean isNodeExist( TRemLocalNodeLocator nodelocator, ILocalNode localnode, String node ) { //obtain list of descendent nodes for parent node TRemLocalNode [] descendentArray = localnode. fillChildrenSorted (nodelocator); boolean flagExist = false ; for ( int i=0;i<=descendentArray. length ;i++) { //if parent nodes display equals to passed node //then set flag equals to true if (descendentArray[i]. equals (). getDisplayByString (). equals (node)) { flagExist = true ; } } //return flag return flagExist; } //This method take session and version as input and returns list of hierarchies as output //private ArrayOfStringHolder listHierObjects(TRemSessionInfo sessionInfo, String versionId) throws Exception { //Get IVersion object to invoke methods for retriving list of hierarchies IVersion versionOfInterest = this.masterDataManagement. getVersion (); ArrayOfStringHolder hierarchies = new ArrayOfStringHolder() ; //obtain list of hierarchies versionOfInterest.listHiers(sessionInfo. getSession (), versionId, hierarchies); return hierarchies; } //This method takes version and hierarchy name as input and returns //TRemHierarchy locator as output public TRemHierLocator getHierLocator( String versionID, String hierarchyname) { TRemHierLocator tremhierlocator = new TRemHierLocator (); tremhierlocator. setSession ( this .sessionInfo. getSession ()); tremhierlocator. setVersion (versionID); tremhierlocator. setHier (hierarchyname); return tremhierlocator; } //This procedure takes hierarchy locator object as input and //returns valid prefix stringfor that hierarchy as output private String getHierarchyPrefix( TRemHierLocator hierLocator) throws Exception { logger . info ("Hierarchy prefix for " + hierLocator. getHier ()); String prefix = this .masterDataManagement. getHier (). fillStrPropValue (hierLocator, DRM_HIERARCHY_PREFIX_FINDER); return prefix; } }