Jerry Jacob's Blog

Querying the ‘IBM Content Manager On Demand’ using ODWEK API

Posted in Java/ J2EE by jerlinworld on July 23, 2009

The IBM Content Manager OnDemand Web Enablement Kit (ODWEK) API’s provide a development environment for client access to Content Manager OnDemand (OD) servers. This API provide access to Servers, Folders, Criteria, and Hits, making it easy for Web application developers to logon, search and retrieve OD content. Here is the code that I used to query the CMOD folder with a specific criteria.

private int validateClaimInfo(final String ssnNumber, final String cDate) {
	final int port = 2345;
	final ODServer odServer = new ODServer(new ODConfig());
	try {
		................. 
		.................
		//Logon to specified server
		odServer.setConnectType(ODConstant.CONNECT_TYPE_TCPIP);
		odServer.setServerName(this.cmodProps.getString("cmod.server") .trim());
		odServer.setPort(port);
		odServer.setUserId(this.cmodProps.getString("cmod.userid").trim());
		odServer.setPassword(this.cmodProps.getString("cmod.password").trim());
		odServer.initialize("ClaimsValidationHelper");
		odServer.logon();
		//Search Folder
		return this.isExistingClaim(odServer, ssnNumber, cDate);
	} catch (final ODException e) {
		if (e.getErrorId() == 2107) {
			this.logger.error("OnDemand server " + odServer.getServerName()  + " is alive but: " + e.getErrorMsg());
		} else {
			this.logger.error(" Error code: " + e.getErrorId()+ "Encountered error: " + e.getErrorMsg());
   		}
  	} catch (final Exception e) {
   		e.printStackTrace();
	} finally {
		try {
    			odServer.logoff();
   		} catch (final Exception e) {
   		}
  		 odServer.terminate();
  	}
  	return 0;
 }
private int isExistingClaim(final ODServer odServer, final String ssnNumber, final String cDate) {
	int isExisting = 0;
	try {
		//Opening the folder specified in the property file...
		final ODFolder folder = odServer.openFolder(this.cmodProps.getString("claimings.folder").trim());
		//Getting specified criteria...
		final ODCriteria odCriteriaSsn = folder.getCriteria(this.cmodProps.getString("criteria.ssn").trim());
		//Setting operand...
		odCriteriaSsn.setOperator(ODConstant.OPEqual);
		odCriteriaSsn.setSearchValue(ssnNumber);
		final ODCriteria odCriteriaCDate = folder.getCriteria(this.cmodProps.getString("criteria.cdate").trim());
		odCriteriaCDate.setOperator(ODConstant.OPEqual);
		odCriteriaCDate.setSearchValue(cDate);
		folder.search();
		this.logger.debug("Search results size: "+ folder.searchCountHits());
		if (folder.searchCountHits() > 0) {
			isExisting = 1;
		}
	} catch (final ODException e) {
		this.logger.error("ODException: " + e.getMessage(), e);
	} catch (final Exception e) {
		this.logger.error("Exception: " + e.getMessage(), e);
	}
	return isExisting;
}
Advertisements

One Response

Subscribe to comments with RSS.

  1. Gehan said, on May 2, 2014 at 6:00 am

    is is possible to set search criteria as ascending to descending when retrieving documents


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: