on 08-12-2008 3:48 PM
Hi,
I am trying to archive the repository via java api and am getting null pointer exception when I execute. Any help appreciated.
While I can get a list of regions I get err while executing archiving...
/*
* Created on 12-Aug-2008
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package com.sap.brm.cf;
import com.sap.mdm.commands.CommandException;
import com.sap.mdm.commands.GetRepositoryRegionListCommand;
import com.sap.mdm.data.RegionProperties;
import com.sap.mdm.net.ConnectionException;
import com.sap.mdm.net.ConnectionPool;
import com.sap.mdm.net.ConnectionPoolFactory;
import com.sap.mdm.repository.commands.ArchiveRepositoryCommand;
import com.sap.mdm.server.DBMSType;
import com.sap.mdm.server.RepositoryIdentifier;
/**
* @author dbharti
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class RepositoryTest {
public static void main(String[] args) {
// create connection pool
String connectionTag = "<NAME>";
ConnectionPool connections = null;
try {
connections = ConnectionPoolFactory.getInstance(connectionTag);
} catch (ConnectionException e) {
e.printStackTrace();
return;
}
// // get a list of running repositories
// // this is one of the few commands that doesn't require a session
// GetRunningRepositoryListCommand cmd = new GetRunningRepositoryListCommand(connections);
// try {
// cmd.execute();
// } catch (CommandException e) {
// e.printStackTrace();
// return;
// }
//
// RepositoryIdentifier[] reposIds = cmd.getRepositories();
// for (int i = 0; i < reposIds.length; i++) {
// System.out.println(reposIds<i>.getName());
// }
RepositoryIdentifier rid = new RepositoryIdentifier("<NAME>", "<NAME>", DBMSType.ORACLE);
System.out.println("1");
GetRepositoryRegionListCommand cmd = new GetRepositoryRegionListCommand(connections);
cmd.setRepositoryIdentifier(rid);
try {
cmd.execute();
} catch (CommandException e) {
e.printStackTrace();
return;
}
RegionProperties[] regions = cmd.getRegions();
for (int i = 0; i < regions.length; i++) {
System.out.println(regions<i>.getName());
}
ArchiveRepositoryCommand arcmd = new ArchiveRepositoryCommand(connections);
arcmd.setRepositoryIdentifier(rid);
System.out.println("2");
arcmd.setArchiveFileName("55600_BUSINESS_PARTNER");
System.out.println("3");
try{
System.out.println("4"+arcmd.getArchiveFileName());
arcmd.execute();
}
catch (Exception e1) {
System.out.println(e1.getMessage());
e1.printStackTrace();
return;
}
System.out.println("5!!");
}
}
Edited by: Devashish Bharti on Aug 12, 2008 4:49 PM
Hi Devashish,
Verify your code from the code given below:
import com.sap.mdm.commands.AuthenticateServerSessionCommand;
import com.sap.mdm.commands.CommandException;
import com.sap.mdm.commands.CreateServerSessionCommand;
import com.sap.mdm.commands.DestroySessionCommand;
import com.sap.mdm.net.ConnectionException;
import com.sap.mdm.net.ConnectionPool;
import com.sap.mdm.net.ConnectionPoolFactory;
import com.sap.mdm.repository.commands.ArchiveRepositoryCommand;
import com.sap.mdm.server.DBMSType;
import com.sap.mdm.server.RepositoryIdentifier;
public class TestArchiveRepository
{
public static ConnectionPool simpleConnection;
public static RepositoryIdentifier repIdentifier;
public static String session;
public static String connection = "TEST_MDM";
public static String repository = "Test_REPO";
public static DBMSType dbmsType = DBMSType.MS_SQL;
public static void main(String[] args)throws CommandException, ConnectionException
{
simpleConnection = ConnectionPoolFactory.getInstance(connection);
repIdentifier = new RepositoryIdentifier(repository, connection, dbmsType);
CreateServerSessionCommand createServerSessionCmd = new CreateServerSessionCommand(simpleConnection);
createServerSessionCmd.execute();
session = createServerSessionCmd.getSession();
AuthenticateServerSessionCommand auth= new AuthenticateServerSessionCommand(simpleConnection);
auth.setSession(session);
auth.setUserName("Admin");
auth.setUserPassword("Pass123");
auth.execute();
session = auth.getSession();
ArchiveRepositoryCommand archiveRepCmd = new ArchiveRepositoryCommand(simpleConnection);
archiveRepCmd.setArchiveFileName("Test_ABC");
archiveRepCmd.setRepositoryIdentifier(repIdentifier);
archiveRepCmd.setSession(session);
archiveRepCmd.execute();
DestroySessionCommand destroySessionCmd = new DestroySessionCommand(simpleConnection);
destroySessionCmd.setSession(session);
destroySessionCmd.execute();
session = null;
}
}
Kindly update us....
Regards,
Jitesh Talreja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I have the code with me and thanks to you guys it works... though I am closing this thread as it is answered wanted to ask you one doubt...
In AuthenticateSession Command when I was passing the repository's userid and password as Admin and <password>, it was not working. (I was using the same password with which I used to login in console). Strangely this was not working and when I tried <blank> password which comes by default with MDM shipment it worked. Dont know why... can anyone shed some light on this?
Regards,
Dev.
Hello Devashish,
you have not set the session of the ArchiveRepositoryCommand. According to the [API|https://help.sap.com/javadocs/MDM/current/com/sap/mdm/repository/commands/ArchiveRepositoryCommand.html] the ArchiveRepositoryCommand needs a server session (SP6) or repository session (SP5) to work properly.
Best regards
Dominik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.