cancel
Showing results for 
Search instead for 
Did you mean: 

User Session

former_member343107
Participant
0 Kudos

Dear all,

Can you give a sample program to show how to get a user session? I used the following code but get an exception.

The code is:

final CreateUserSessionCommand userCommand = new CreateUserSessionCommand(pool);

RepositoryIdentifier rep_id = new RepositoryIdentifier("DataCleansing", "PVGN50061742A", DBMSType.MS_SQL);

userCommand.setRepositoryIdentifier(rep_id);

RegionProperties reg_prop = new RegionProperties();

reg_prop.setLocale(Locale.US);

userCommand.setDataRegion(reg_prop);

try {

userCommand.execute();

} catch (CommandException e) {

e.printStackTrace();

}

final String sessionId = userCommand.getUserSession();

The exception is:

java.lang.NullPointerException

at com.sap.mdm.data.RegionalString.<init>(RegionalString.java:50)

at com.sap.mdm.data.RegionalString.<init>(RegionalString.java:40)

at com.sap.mdm.internal.RegionDefinitionHelper.convertFrom(RegionDefinitionHelper.java:42)

at com.sap.mdm.commands.CreateUserSessionCommand.execute(CreateUserSessionCommand.java:77)

at com.sap.bpr.mdm.DataCleansingTest.main(DataCleansingTest.java:69)

Exception in thread "main"

Thanks + Best Regards

Jerome

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Please find the three methods, I used to get the User Session using the new MDM Java API.

<b>public static String getAuthenticatedUserSession(ConnectionAccessor connection) throws CommandException, ConnectionException</b>{

if (userSessionTag == null){

CreateUserSessionCommand cmd = new CreateUserSessionCommand(connection);

RepositoryIdentifier repId = getRepositoryIdentifier();

cmd.setRepositoryIdentifier(repId);

cmd.setDataRegion(getRegion(connection,repId));

cmd.execute();

userSessionTag = cmd.getUserSession();

authenticateUserSession(connection, userSessionTag);

}

return userSessionTag;

}

<b>public static RegionProperties getRegion(ConnectionAccessor connection, RepositoryIdentifier repId) throws CommandException</b>{

RegionProperties region = null;

GetRepositoryRegionListCommand cmd = new GetRepositoryRegionListCommand(connection);

cmd.setRepositoryIdentifier(repId);

cmd.execute();

region = cmd.getRegions()[0];

return region;

}

<b>public static void authenticateUserSession(ConnectionAccessor connection, String userSessionTag) throws CommandException</b>{

AuthenticateUserSessionCommand cmd = new AuthenticateUserSessionCommand(connection);

cmd.setUserName("Admin");

cmd.setUserPassword("");

cmd.setSession(userSessionTag);

cmd.execute();

}

former_member343107
Participant
0 Kudos

Thanks for your help. I can now use the user session to search for data records.

Best Regards

Jerome

Answers (0)