on ‎2008 May 06 5:08 PM
Hello
Is there a basic set of How To Guides available for using MDM Java API ?
If so can you please provide me with the link or information as to where i can download these from.
thanks
Request clarification before answering.
Hello.
As far as I know there is no HowTo guide by now.
But here some helpful links to begin with:
[SAP Help|http://help.sap.com/saphelp_mdm550/helpdata/en/46/28da41b8bc14dbe10000000a155369/frameset.htm]
[Javadoc|http://help.sap.com/javadocs/MDM/current]
But you can always use Google or the forum search to get more sample code.
Or blogs like these:
[https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2612] [original link is broken];
[https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2924] [original link is broken];
Here a brief description and some sample code, how to work with the Java API:
Build a connection accessor. If needed, create the session of your choice, user, repository or server, depending on what you want to do.
Then take a look in the Javadoc for the right command of your needs. The schema of using a command is like this:
Every command has a constructor. Most (all? I have not needed nor looked at all commands by now) take a connection accessor as parameter.
After creating the object you have to set at least the required attributes (see the Javadoc of the command for this). Then you can execute.
Using the getters of the object you can get back whatever the command is designed for. A session command has no getters which really get back something you need, but it is like opening the Console and then connecting to a repository with your user/password.
On to some sample code
The connection accessor is somewhat the heart of everything I did with the Java API:
// Create a new object of a connection accessor
ConnectionAccessor connectionAccessor = ConnectionPoolFactory.getInstance(MDM_SERVER);An example how to use a session command:
// An authenticate repository session as example
AuthenticateRepositorySessionCommand authRepSessionCommand = new AuthenticateRepositorySessionCommand(connectionAccessor);
authRepSessionCommand.setSession(repositorySession);
authRepSessionCommand.setUserName(USERNAME);
authRepSessionCommand.setUserPassword(PASSWD);
authRepSessionCommand.execute();For example this small piece of code will get you all repositories mounted on a server
GetMountedRepositoryListCommand getMountedRepositoryListCommand = new GetMountedRepositoryListCommand(connectionAccessor);
// Execute the command
getMountedRepositoryListCommand.execute();
// Get the list with all mounted repositories
MountedRepository[] mountedRepositories = getMountedRepositoryListCommand.getRepositories();In this case nothing has to be set anymore, but the connection accessor has to be set up before.
Then you can get an array of MountedRepository objects back.
Another example:
GetUserListCommand getUserListCommand = new GetUserListCommand(connectionAccessor);
getUserListCommand.setSession(sessionId);
getUserListCommand.execute();
// Get all the user properties in an array
userProperties = getUserListCommand.getUsers();With this you can retrieve all users. As before you create the object, set the attributes, execute and use a getter.
The rest is normal Java programming, depending what to do with the retrieved information
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.