It's all about the answers!

Ask a question

Programatically create users, team areas and bind them


pere irazusta (2062120) | asked Jul 13 '11, 4:54 a.m.
Hi,

I'm quite new using RTC, and even newer trying to extend it :).

Scenario:
I have LOTS of users integrated with LDAP to a project area. What I need (i'm using the visibility category/team 3.0.1 featue ) is to bind them to several team areas programatically.

Optional: If there was a way to create by command-line/scripting the team-areas,categories and the bindings between them that would be great!

1st approach!
SDK: Using the SDK integrated with Eclipse, and creating a Java Client that acces to the PA and using the RTC API play the magic. I ' ve done some unsuccesful tries and this is becoming a quite a big headeach and I'm not sure if this is the way ( or the easiest way ) to do it.

2nd approach

Repotools: Trying to use the export option and modifing ( using some scripting ) the exported files and importing them again. The problem is that the format/sctructure of the .tar exported is quite confusing and can't find the users associated info and dont know if doing it that way will work.


Any idea/help/orientation on how to do it will be appreciated!

Thanks!!

4 answers



permanent link
Jorge Diaz (8664434) | answered Jul 14 '11, 7:07 a.m.
JAZZ DEVELOPER
Hello,

have you tried REST API for this assignment operation?

https://jazz.net/wiki/bin/view/Main/DraftTeamProcessRestApi

On the other hand, I wouldn't try the exported tar approach as, in case you were able to properly modify it, the import process will drop all your data before importing, which is a heavy process that can lead you to data loss for the logic you are trying to achieve.

I hope this helps.

Regards,

Jorge.

permanent link
pere irazusta (2062120) | answered Jul 14 '11, 1:21 p.m.
Hi,

Thanks for your response!

1st approach:

I've been looking for the REST API article that you mentioned but it doesn't cover what we need. The REST API looks like a way to consult differnt information and what we need is to create that information programmatically.

We are finally creating a plain-java client with the RTC SDK to do these tasks based on this explanation https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation
but we are experiencing some problems with the connection to the server as we get a time out error:
CRJAZ1371E The URL https://xxx:9443/ccm/versionCompatibility?clientVersion=3.0.1 cannot be reached. The server cannot be reached. The network could not connect to the server

Has anyone experienced something similar? We think it has to be something related with the certificate as we have any defined, and when we launch the client from the Eclipse-RTC Client we don't get any confirmation to trust the certificate (as it usually happens when we connect to the repository).


2nd approach:
Option dropped.

Thanks for your help!

I also attach the code we are using:
import java.net.URI;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;

import com.ibm.team.process.client.IProcessClientService;
import com.ibm.team.process.common.IProjectArea;
import com.ibm.team.repository.client.ITeamRepository;
import com.ibm.team.repository.client.TeamPlatform;
import com.ibm.team.repository.client.ITeamRepository.ILoginHandler;
import com.ibm.team.repository.client.ITeamRepository.ILoginHandler.ILoginInfo;
import com.ibm.team.repository.common.TeamRepositoryException;


public class Client {

private static class LoginHandler implements ILoginHandler, ILoginInfo {

private String fUserId;
private String fPassword;

private LoginHandler(String userId, String password) {
fUserId= userId;
fPassword= password;
}

public String getUserId() {
return fUserId;
}

public String getPassword() {
return fPassword;
}

public ILoginInfo challenge(ITeamRepository repository) {
return this;
}
}

public static void main(String[] args) {

System.out.println("1");
boolean result;
System.out.println("2");
TeamPlatform.startup();
System.out.println("3");
try {
result= run(args);
} catch (TeamRepositoryException x) {
x.printStackTrace();
result= false;
} finally {
TeamPlatform.shutdown();
}
if (!result)
System.exit(1);
}

private static boolean run(String[] args) throws TeamRepositoryException {

if (args.length != 7) {
System.out.println("Hi han aquests arguments:"+args.length);
System.out.println("Usage: CreateWorkItem <repositoryURI> <userId> <password> <projectArea> <workItemType> <summary> <category>");
return false;
}

String repositoryURI= args;
String userId= args;
String password= args;
String projectAreaName= args;
String typeIdentifier= args;
String summary= args;
String categoryName= args;

System.out.println("HelloWorldProhibitSave! 4");
ITeamRepository teamRepository= TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryURI);
teamRepository.registerLoginHandler(new LoginHandler(userId, password));
System.out.println("Preparant login! amb URI :"+repositoryURI);
IProgressMonitor monitor = new NullProgressMonitor();
teamRepository.login(monitor);
System.out.println("Login Ok! 6");

IProcessClientService processClient= (IProcessClientService) teamRepository.getClientLibrary(IProcessClientService.class);

//IAuditableClient auditableClient= (IAuditableClient) teamRepository.getClientLibrary(IAuditableClient.class);
//IWorkItemClient workItemClient= (IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class);

URI uri= URI.create(projectAreaName.replaceAll(" ", "%20"));
System.out.println(uri.toString()+"! 7");
IProjectArea projectArea= (IProjectArea) processClient.findProcessArea(uri, null, null);
if (projectArea == null) {
System.out.println("Project area not found.");
return false;
}

teamRepository.logout();
return true;
}
}


permanent link
Jorge Diaz (8664434) | answered Jul 14 '11, 1:36 p.m.
JAZZ DEVELOPER
Hello Pere,

actually the REST API helps you in the creation too. You have to perform a POST operation with the specified format to create the required data in the server (where a GET will be to retrieve the information).

On the other hand, the exception you are getting seems more related with networking issues, are you sure the code is receiving the correct connection URL?

Regards,

Jorge.

permanent link
pere irazusta (2062120) | answered Jul 18 '11, 5:44 a.m.
Hi,

Thanks Jorge for your replies!

First: Yes, with the REST API you can POST new users :), I noticied the the second time I overviewed it!

Second: I've finally managed to connect to my server, the problem was originated with the proxy configuration, althought it was configured on the RTC client I had to provide proxy attributes information to the ITeamRepository before logging in.

Sample code:

ITeamRepository teamRepository= TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryURI);
teamRepository.registerLoginHandler(new LoginHandler(userId, password));

IProgressMonitor monitor = new NullProgressMonitor();
teamRepository.setProxy("IP", port, null,null);
teamRepository.login(monitor);



Thanks!

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.