cancel
Showing results for 
Search instead for 
Did you mean: 

unable to fetch roles using GetRoleListCommand

Former Member
0 Kudos

I am trying to fetch all the roles from a particular repository. But getting below error:

runningRepository...........PG_PRODUCT

Exception in thread "main" java.lang.NullPointerException

  at com.sap.mdm.internal.SessionConvertHelper.convertToLong(SessionConvertHelper.java:11)

  at com.sap.mdm.internal.protocol.manual.AbstractProtocolCommand.setSession(AbstractProtocolCommand.java:236)

  at com.sap.mdm.schema.commands.GetRemoteSystemListCommand.executeImpl(GetRemoteSystemListCommand.java:68)

  at com.sap.mdm.commands.AbstractCommandBase.execute(AbstractCommandBase.java:129)

  at com.sap.mdm.security.commands.GetRoleListCommand.executeImpl(GetRoleListCommand.java:76)

  at com.sap.mdm.commands.AbstractCommandBase.execute(AbstractCommandBase.java:129)

  at com.jnj.mdm.connection.MDMConnection.<init>(MDMConnection.java:63)

  at com.jnj.mdm.audit.MainMethod.main(MainMethod.java:23)

Could anybody help in this? Just let me know how to use the GetRoleListCommand class?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Can anybody suggest here what could be the answer?

Former Member
0 Kudos

If u could share sample code, it would be helpful.

Former Member
0 Kudos

try {

  /** Create connection**/

  conAccessor = SimpleConnectionFactory.getInstance(servername);

  /***Get Running Repository Details ***/

  GetRunningRepositoryListCommand runningRepository = new GetRunningRepositoryListCommand(conAccessor);

  runningRepository.execute();

  RepositoryIdentifier[] repositoriesIdentifier = runningRepository.getRepositories();

  for (int i = 0; i < repositoriesIdentifier.length; i++) {

  /***Create Repository Session Command ***/

  System.out.println("runningRepository..........."+repositoriesIdentifier[i].toString());

  CreateRepositorySessionCommand createRepositorySessionCommand = new CreateRepositorySessionCommand(conAccessor);

  // Create a user session

  sessionManager.createSession(userSessionContext, SessionTypes.USER_SESSION_TYPE,

  pwd);

  createRepositorySessionCommand.setRepositoryIdentifier(repositoriesIdentifier[i]);

  createRepositorySessionCommand.execute();

  if(repositoriesIdentifier[i].toString().equals("_SLAVE")){

  }

  if(repositoriesIdentifier[i].toString().equals("PG_PRODUCT")){

  GetRoleListCommand roleListCommand = new GetRoleListCommand(conAccessor);

  roleListCommand.execute();

  RoleProperties[] roleProperties = roleListCommand.getRoles();

  for(int ak=0;ak<roleProperties.length;ak++){

  System.out.println("roles...."+roleProperties[ak].getName());

  }

  }

  }

At roleListCommand.execute(); I am getting this error...

Former Member
0 Kudos

Its seems like, at line


conAccessor = SimpleConnectionFactory.getInstance(servername);


nothing is assigned to "conAccessor" Variable i.e you can check the server name again.


Because when you create object of GetRoleListCommand class i.e (roleListCommand) seems to be null, hence you are getting error at execute().



Regards,

Former Member
0 Kudos

no "conAccessor" is not null, as before this step I have fetched the list of repository; there execute is working and I am able to fetch all the repository which are running.

Former Member
0 Kudos

To create object of GetRoleListCommand class, i think object need to be passed of type ConnectionAccessor or RepositorySessionContext. Where as "conAccessor" is of type SimpleConnection.

Can u check on this...

GetRoleListCommand(ConnectionAccessor connection)

          Creates a new instance of this command.

GetRoleListCommand(RepositorySessionContext ctx)
          Creates a new instance of this command by context.

Regards,

Former Member
0 Kudos

thanks Ankit for the help!

I am able to fix the issue...

I was passing "conAccessor"; which had only servername. Then I passed UserSessionContext with servername, repositoryname, username and password. So its resolved!

Former Member
0 Kudos

Nice to hear ur problem is resolved.

Cheers !!!

Answers (1)

Answers (1)

Vlado
Advisor
Advisor
0 Kudos

Hi, I moved your question to SAP MDM space where you should have more chance of getting it answered.