Hi Gurus,
I am trying to delete the repository using MDMJavaAPI.
Here is the whole code for deleting repository.
=============================================import com.sap.mdm.commands.AuthenticateRepositorySessionCommand;
import com.sap.mdm.commands.CommandException;
import com.sap.mdm.commands.CreateRepositorySessionCommand;
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.RepositoryStatus;
import com.sap.mdm.repository.commands.DeleteRepositoryCommand;
import com.sap.mdm.repository.commands.GetRepositoryStatusCommand;
import com.sap.mdm.server.DBMSType;
import com.sap.mdm.server.RepositoryIdentifier;
/**
@author tarunsha
*
To change the template for this generated type comment go to
Window>Preferences>Java>Code Generation>Code and Comments
*/
public class TestDeleteRepository {
public static final int STATE_NOT_CONNECTED = 0;
public static final int STATE_CONNECTED = 1;
public static int state = STATE_NOT_CONNECTED;
public static ConnectionPool simpleConnection;
public static RepositoryIdentifier repIdentifier;
public static String session;
public static String connection = "ntbomsap14";
public static String repository = "Test_JavaMDMapi_Tarun";
public static DBMSType dbmsType = DBMSType.MS_SQL;
public static void main(String[] args)throws CommandException, ConnectionException {
//Creating Connection.
simpleConnection = ConnectionPoolFactory.getInstance(connection);
//Establishing connection with Repository.
repIdentifier = new RepositoryIdentifier("Test_JavaMDMapi_Tarun", connection, dbmsType);
//Creation Repository Session.
CreateRepositorySessionCommand createRepositorySessionCmd = new CreateRepositorySessionCommand(simpleConnection);
createRepositorySessionCmd.setRepositoryIdentifier(repIdentifier);
createRepositorySessionCmd.execute();
System.out.println("Create Repository Session Cmd is Executed.......");
session = createRepositorySessionCmd.getRepositorySession();
System.out.println("STATE_CONNECTION_ESTABLISHED.....");
AuthenticateRepositorySessionCommand authenticateRepositorySessionCmd = new AuthenticateRepositorySessionCommand(simpleConnection);
authenticateRepositorySessionCmd.setSession(session);
authenticateRepositorySessionCmd.setUserName("Admin");
authenticateRepositorySessionCmd.setUserPassword("");
authenticateRepositorySessionCmd.execute();
session = authenticateRepositorySessionCmd.getSession();
GetRepositoryStatusCommand getRepStatusCmd = new GetRepositoryStatusCommand(simpleConnection);
getRepStatusCmd.setSession(session);
getRepStatusCmd.execute();
RepositoryStatus repStatus = getRepStatusCmd.getStatus();
if(repStatus.getStatus() == RepositoryStatus.RUNNING) {
System.out.println("Cannot delete a repository with status running! Canceling deletion process...");
destroy(session);
}
DeleteRepositoryCommand deleteRepCmd = new DeleteRepositoryCommand(simpleConnection); deleteRepCmd.setRepositoryIdentifier(repIdentifier);
deleteRepCmd.setSession(session);
// Excute the command...
System.out.println("Running");//Just for checking wheather control is reaching here or not.
deleteRepCmd.execute();
System.out.println("Execution of DeleteRepositoryCommand successful.");
destroy(session);
}
public static void destroy(String session) throws CommandException{
DestroySessionCommand destroySessionCmd = new DestroySessionCommand(simpleConnection);
destroySessionCmd.setSession(session);
destroySessionCmd.execute();
session = null;
System.out.println("STATE CONNECTION is DESTROYED......");
}
}
=============================================
When control reaches at execute method of DeleteRepositoryCommand class, it displays the following error msg.
-
com.sap.mdm.commands.CommandException: com.sap.mdm.internal.protocol.manual.ServerException: The current Protocol operation is not supported for the session specified.
* at com.sap.mdm.repository.commands.DeleteRepositoryCommand.execute(DeleteRepositoryCommand.java:69)*
* at Test_Package.TestDeleteRepository.main(TestDeleteRepository.java:85)*
Caused by: com.sap.mdm.internal.protocol.manual.ServerException: The current Protocol operation is not supported for the session specified.
* at com.sap.mdm.internal.protocol.manual.AbstractProtocolCommand.execute(AbstractProtocolCommand.java:112)*
* at com.sap.mdm.repository.commands.DeleteRepositoryCommand.execute(DeleteRepositoryCommand.java:64)*
* ... 1 more*
Exception in thread "main"
-
Could you suggest me, what i have to do in this situation.
I need your help.
Edited by: Tarun Sharma on Jan 2, 2008 5:46 PM
Edited by: Tarun Sharma on Jan 2, 2008 5:50 PM
Edited by: Tarun Sharma on Jan 3, 2008 11:32 AM