on 06-08-2007 12:07 PM
Hi, guys,
I'm accessing an MDM Server from a java application using MDMJavaAPI Version 5.5.36.23. I succeeded in reading schema, but each time I execute any command from com.sap.mdm.data.commands (the simplest - RecordCountCommand, see below), I get authorization exception. That's weird, because I'm authorized as an administrator and with this authorization I can do anything using standard SAP MDM Data Manager, and in the java application this authorization works, because schema reading also requires one. Can anyone tell me what's going on?
The source code (the last line raises the Exception):
//1. create connection pool
ConnectionPool pool = ConnectionPoolFactory.getInstance(HOST);
String repositorySessionId = null;
try {
//2. get Repository Identifier
RepositoryIdentifier repos = findRepositoryByName(pool,REPOSITORY_NAME);
//3. create session for this repository
CreateRepositorySessionCommand sessCmd = new CreateRepositorySessionCommand(pool);
sessCmd.setRepositoryIdentifier(repos);
sessCmd.setInterfaceRegion(SupportedLocales.getInterfaceLocales()[0]);
sessCmd.execute();
repositorySessionId = sessCmd.getRepositorySession();
//4. authenticate repository session:
AuthenticateRepositorySessionCommand authCmd = new AuthenticateRepositorySessionCommand(pool);
authCmd.setSession(repositorySessionId);
authCmd.setUserName(USERNAME);
authCmd.setUserPassword(PASSWORD);
authCmd.execute();
//5. get schema:
GetRepositorySchemaCommand cmd = new GetRepositorySchemaCommand(pool);
cmd.setSession(repositorySessionId);
cmd.execute();
RepositorySchema schema = cmd.getRepositorySchema();
//6. get table definition
TableProperties[] tables = schema.getTables();
TableProperties table = tables[0];
System.out.println(table.getName()); //to make sure that the schema is read properly
//7. try to count the number of records of the table
RecordCountCommand readCountCmd = new RecordCountCommand(pool);
readCountCmd.setSession(repositorySessionId);
readCountCmd.setTable(table.getId());
readCountCmd.execute(); //HERE is the Exception!!!
Output:
Articles Catalogue
com.sap.mdm.commands.CommandException: com.sap.mdm.internal.protocol.manual.ServerException: Die aktuelle Protokolloperation wird nicht unterstützt für die angegebene Sitzung
at com.sap.mdm.data.commands.RecordCountCommand.execute(Unknown Source)
By the way, in MDM_API_Tutorial these's no single word about data access...
{code}
Hmm . you are creating a repository Session , not a user session . as per Scotts Cairncrosss pdf available for download on sdn (sorry no link . 😞
Within the new JAVA API after performing an initial connection to the MDM server you can then perform your commands by simply passing the session string generated.
Whether you want to work with the server, repository or the datawithin the repository will determine the type of session which will need tobe created.
􀂄CreateUserSessionCommandData
􀂄CreateServerSessionCommandServer
􀂄CreateRepositorySessionCommandRepository
After a session is created it needs to be followed by an authentication command.
􀂄AuthenticateUserSessionCommand
􀂄AuthenticateServerSessionCommand
􀂄AuthenticateRepositorySessionCommand
this is a snip it from my code
repId = new RepositoryIdentifier(repName , dbName, dbType);
RegionProperties dataRegion ;
GetRepositoryRegionListCommand getRepositoryRegionListCommand = new GetRepositoryRegionListCommand(conn);
getRepositoryRegionListCommand.setRepositoryIdentifier(repId);
try {
getRepositoryRegionListCommand.execute();
} catch (CommandException e1) {
e1.printStackTrace();
}
RegionProperties regionProperties[] = getRepositoryRegionListCommand.getRegions();
dataRegion = regionProperties[0];
CreateUserSessionCommand createUserSessionCommand = new CreateUserSessionCommand(conn);
createUserSessionCommand.setRepositoryIdentifier(repId);
createUserSessionCommand.setDataRegion(dataRegion);
try {
createUserSessionCommand.execute();
} catch (CommandException e2) {
e2.printStackTrace();
}
session = createUserSessionCommand.getUserSession();
AuthenticateUserSessionCommand authenticateUserSessionCommand = new AuthenticateUserSessionCommand(conn);
authenticateUserSessionCommand.setSession(session);
authenticateUserSessionCommand.setUserName(settings.getUsername());
authenticateUserSessionCommand.setUserPassword(settings.getPassword());
//authenticateUserSessionCommand.setUserName("Admin");
//authenticateUserSessionCommand.setUserPassword("");
try {
authenticateUserSessionCommand.execute();
return session;
} catch (CommandException e3) {
e3.printStackTrace();
return null;
}
then you can go ahead and use the RetriveLimitedRecordsCommand passing the authenticated session .
let me know if this works for you .
cheers,
Guy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.