cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Performing a MKS Server checkout using the Java API

ptc-6124669
1-Newbie

Performing a MKS Server checkout using the Java API

Hi,

I'm trying to create a Java app that checks out my project to a local path. I have created a command runner and a command but I'm not really sure what arguments I need to pass when adding actual options to the command.

This is what I have so far:

import com.mks.api.CmdRunner;

import com.mks.api.Command;

import com.mks.api.IntegrationPoint;

import com.mks.api.IntegrationPointFactory;

import com.mks.api.Option;

import com.mks.api.Session;

import com.mks.api.response.APIException;

import com.mks.api.response.Response;

public class MksMain {

@SuppressWarnings("deprecation")

public static void main(String[] args) {

String host = "";

int port = 7001;

boolean secure = true;

String user = "";

String password = "";

try {

IntegrationPoint ipf = IntegrationPointFactory.getInstance().createIntegrationPoint(host, port, secure, 4, 11);

Session session = ipf.createSession(user, password);

CmdRunner cmd = session.createCmdRunner();

cmd.setDefaultHostname(host);

cmd.setDefaultPort(port);

cmd.setDefaultHostname(user);

cmd.setDefaultPassword(password);

Command connect = new Command(Command.SI, "connect");

connect.addOption(new Option("",""));

Command checkout = new Command(Command.SI, "co");

checkout.addOption(new Option("", ""));

Command disconnect = new Command(Command.SI, "disconnect");

connect.addOption(new Option("",""));

cmd.execute(connect);

cmd.execute(checkout);

cmd.execute(disconnect);

Response response = cmd.execute(checkout);

String resID = response.getResult().getMessage();

System.out.println("Established connection " + resID);

}

catch (APIException e){

System.out.println("oops");

e.printStackTrace();

}

}

}

Maybe someone has some sample code or can help me out with the exact commands I need to run through the command runner object. Not sure what arguments to pass in the Option constructor either. Any help would be greatly appreciated.

3 REPLIES 3

Hi,

you should read the API documentation which is normally available through the servers web-interface:

http://your-mks-server/documentation/javadocs/api/index.html

Veikko

Rahul Chandrashekar‌,

Please take another look at the URL.  Note that there is no top level domain where you would expect one to be provided.

I hope that helps,

-Kael


Kind Regards,
Kael Lizak

Senior Technical Support Engineer
PTC Integrity Lifecycle Manager
Top Tags