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.

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

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!


4 answers

permanent link
Jorge Diaz (8664234) | answered Jul 14 '11, 7:07 a.m.

have you tried REST API for this assignment operation?

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.



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

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
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 org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;


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) {

boolean result;
try {
result= run(args);
} catch (TeamRepositoryException x) {
result= false;
} finally {
if (!result)

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();
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;

return true;

permanent link
Jorge Diaz (8664234) | answered Jul 14 '11, 1:36 p.m.
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?



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

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);


Your answer

Register or to post your answer.