Skip to Content
0
Former Member
Apr 26, 2009 at 11:44 AM

Failed to connect to MDM via Java API

25 Views

Hi,

I wrote a very simple application in which there is a view which

calls the component contoller. The Component Controller

connects to MDM Repository.

I think I am wrong with the calling of Component from Web Dynpro view.

As, the code resulting in no error or success.

Please suggets something.

public void getRepositoryConnection( java.lang.String hostName, java.lang.String repositoryName, java.lang.String userId, java.lang.String passWord )
  {
    //@@begin getRepositoryConnection()
   
//		create connection pool to a MDM server
         String serverName = "kolapon.HCLT.CORP.HCL.IN";
         ConnectionPool connections = null;
         try{
         	connections=ConnectionPoolFactory.getInstance(serverName);
         }
         catch(ConnectionException e)
         { e.printStackTrace();
         	return;
         }
//		specify the repository to use
					  // alternatively, a repository identifier can be obtain from the GetMountedRepositoryListCommand
				   repositoryName = "KaushikRepo";
         String dbmsName ="MDM";
		RepositoryIdentifier reposId = new RepositoryIdentifier(repositoryName, dbmsName, DBMSType.ORACLE);
//		get list of available regions for the repository
		GetRepositoryRegionListCommand regionListCommand = new GetRepositoryRegionListCommand(connections);
		regionListCommand.setRepositoryIdentifier(reposId);
		try{
			regionListCommand.execute();
		}
		catch(CommandException e)
		{
			e.printStackTrace();
			return;
		}
     RegionProperties[] regions = regionListCommand.getRegions();
//	 create a user session
	 CreateUserSessionCommand sessionCommand = new CreateUserSessionCommand(connections);
	 sessionCommand.setRepositoryIdentifier(reposId);
	 sessionCommand.setDataRegion(regions[0]); // use the first region
	
	try {
						 sessionCommand.execute();
					 } catch (CommandException e) {
						 e.printStackTrace();
						 return;
					 }
     String sessionId = sessionCommand.getUserSession();
//	 authenticate the user session
	 String userName ="kaushikb";
	 String userPassword ="taton";
	 AuthenticateUserSessionCommand authCommand =
						  new AuthenticateUserSessionCommand(connections);
	 if(authCommand!=null)
	 {
	 	wdComponentAPI.getMessageManager().reportSuccess("Success");					  
	 }
	 else{
	 	wdComponentAPI.getMessageManager().reportWarning("Failure");
	 }
	 authCommand.setSession(sessionId);
	 authCommand.setUserName(userName);
	 authCommand.setUserPassword(userPassword);
	 try {
						  authCommand.execute();
					  } catch (CommandException e) {
						  e.printStackTrace();
						  return;
					  }
 
					  // the main table, hard-coded
	  try{
		GetRepositorySchemaCommand getRepositorySchemaCommand = new GetRepositorySchemaCommand(connections);
		getRepositorySchemaCommand.setSession(sessionId);
		getRepositorySchemaCommand.execute();
		RepositorySchema repositorySchema;
		repositorySchema = getRepositorySchemaCommand.getRepositorySchema();
		TableId tableId= repositorySchema.getTable("MDM_BUSINESS_PARTNERS").getId();
	
	RecordFactory.createEmptyRecord(tableId);
	//RecordFactory.createEmptyRecord(mainTableId);
	if(tableId!=null)
	{
		wdComponentAPI.getMessageManager().reportSuccess("It is success");
	}
	else{
	wdComponentAPI.getMessageManager().reportWarning("Failure");	
	}
}
catch(Exception ce)
{				  
ce.printStackTrace();	
}
//  catch(SessionException se)
//{
//se.printStackTrace();
//}	
					  						  

    //@@end
  }

Regards

Kaushik Banerjee