on 02-05-2007 1:58 AM
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
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();
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.