cancel
Showing results for 
Search instead for 
Did you mean: 

MDMJavaAPI: Execute() method is not running.

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

namrata_d
Active Participant
0 Kudos

Hi Tarun,

For deleting a repository from MDM Server you need to create a Server Session instead of Repository Session.

If you see the Javadocs for the class - DeleteRepsotioryCommand it is mentioned that

"NOTE: This command used to take in a repository session. This command had be changed to take in a server session. The setRepositoryIdentifier is also required."

I think this is the problem in you code.

Thanks

Namrata

Former Member
0 Kudos

Hi Namrata,

If we are deleting an repository, it means we are making connection with repository that's why we have to createRepositorySession rather than serverSession.

According to this JavaDoc note:

"NOTE: This command used to take in a repository session. This command had be changed to take in a server session. The setRepositoryIdentifier is also required."

the method setRepositoryIdentifier is defined in CreateRepositorySessionCommand not in ServerSessionCommand. That's why we have to use RepositorySessionCmd.

According to your advice I changed CreateRepositorySessionCommand and AuthenticateRepositorySessionCommand with ServerSessionCommand and AuthenticateServerSessionCommand but getting Same Error "The current Protocol operation is not supported for the session specified."

Thanks

Tarun

Edited by: Tarun Sharma on Jan 3, 2008 10:44 AM

Former Member
0 Kudos

Hi Tarun,

You have to use ServerSessionCommand only for deleting the repository you get the error session not supported for checking the repository status not for delete repository. if you have to check repository status you have to use repository session only.

to run the program you given change the CreateRepositorySessionCommand and AuthenticateRepositorySessionCommand with ServerSessionCommand and AuthenticateServerSessionCommand

and also comment GetRepositoryStatusCommand

then your program will work.

Note: please award points if found useful.

Thakns

Former Member
0 Kudos

Hi ninad,

Thanks for your advice.

It was too much helpful answer.

Many Thanks

Tarun

Answers (0)