How can I create a project area programmatically?
I'd like to know if it's possible to be done programmatically? maybe some REST API for project area(we have some previous experience on manipulating RQM artifacts with REST API)?
Thanks in advance.
6 answers
Hi,
yes, project areas can be created programmatically thanks to the Team Process REST API: have a look at https://jazz.net/wiki/bin/view/Main/DraftTeamProcessRestApi#POST_project_areas_collection
I hope this helps.
Best regards,
-Nicolas
Hi Nicolas,
Thanks for your quick response. I try to issue PUT request with Firefox plugin Poster.
The project area XML file I use is like below. I read the project area collections URL(https://rqmdev.rtp.raleigh.ibm.com:9443/qm/process/project-areas) from rootservice, and also get template id from template collection resource(https://rqmdev.rtp.raleigh.ibm.com:9443/qm/process/templates).
<xml>
<jp06>
<jp06>
</jp06>
But I keeps getting 403 response like below.
</head><body><h1>HTTP Status 403 - </h1><HR><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>Access to the specified resource () has been forbidden.</u></p><HR><h3>Apache Tomcat/5.5.30</h3></body>
Do you know what might be the problem?
Hi,
yes, project areas can be created programmatically thanks to the Team Process REST API: have a look at https://jazz.net/wiki/bin/view/Main/DraftTeamProcessRestApi#POST_project_areas_collection
I hope this helps.
Best regards,
-Nicolas
Hi Nicolas,
Thanks for your quick response. I try to issue PUT request with Firefox plugin Poster.
The project area XML file I use is like below. I read the project area collections URL(https://rqmdev.rtp.raleigh.ibm.com:9443/qm/process/project-areas) from rootservice, and also get template id from template collection resource(https://rqmdev.rtp.raleigh.ibm.com:9443/qm/process/templates).
<xml>
<jp06>
<jp06>
</jp06>
But I keeps getting 403 response like below.
</head><body><h1>HTTP Status 403 - </h1><HR><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>Access to the specified resource () has been forbidden.</u></p><HR><h3>Apache Tomcat/5.5.30</h3></body>
Do you know what might be the problem?
Hi,
yes, project areas can be created programmatically thanks to the Team Process REST API: have a look at https://jazz.net/wiki/bin/view/Main/DraftTeamProcessRestApi#POST_project_areas_collection
I hope this helps.
Best regards,
-Nicolas
Hi Nicolas,
Thanks for your quick response. I try to issue PUT request with Firefox plugin Poster.
The project area XML file I use is like below. I read the project area collections URL(https://rqmdev.rtp.raleigh.ibm.com:9443/qm/process/project-areas) from rootservice, and also get template id from template collection resource(https://rqmdev.rtp.raleigh.ibm.com:9443/qm/process/templates).
<xml>
<jp06>
<jp06>
</jp06>
But I keeps getting 403 response like below.
</head><body><h1>HTTP Status 403 - </h1><*><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>Access to the specified resource () has been forbidden.</u></p><*><h3>Apache Tomcat/5.5.30</h3></body>
Do you know what might be the problem?
This will get the job done.
public class PAProperTemplate {
public static void main(String[] args) {
try {
if (!TeamPlatform.isStarted()) {
TeamPlatform.startup();
}
String rtcURL = "https://***"" " ;
String user = "***";
String pass = "**";
ITeamRepository repo = TeamPlatform.getTeamRepositoryService().getTeamRepository(rtcURL);
IProgressMonitor MONITOR = new NullProgressMonitor();
repo.registerLoginHandler(new LoginHandler(user, pass));
repo.login(MONITOR);
SampleOSLCJavaTest javaTest = new SampleOSLCJavaTest();
String result = javaTest.createProject("TestProjectFromOSLCCode", "****);
TeamPlatform.shutdown();
}
catch (TeamRepositoryException ex) {
ex.printStackTrace();
System.out.println(ex);
}
catch (Exception ex) {
ex.printStackTrace();
System.out.println(ex);
}
}
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;
}
}
// --------------------- Might -----------------------------------
public String createProject(String name, String processId, ITeamRepository repo) throws TeamRepositoryException {
try {
String msg = "Created project " + name + " with process id Name " + processId;
IProgressMonitor MONITOR = new NullProgressMonitor();
IProcessItemService service = (IProcessItemService) repo.getClientLibrary(IProcessItemService.class);
IProcessDefinition[] definitions = null;
IProcessDefinition processDefinition = service.findProcessDefinition(processId,
IProcessItemService.ALL_PROPERTIES, MONITOR);
if (processDefinition == null) {
// Create the definition if it does not exist.
definitions = service.deployPredefinedProcessDefinitions(new String[] { processId }, MONITOR);
if (definitions.length != 0) {
processDefinition = definitions[0];
} else {
throw new TeamRepositoryException("Process template " + processId + " does not exist.");
}
}
if (processDefinition == null) {
throw new TeamRepositoryException("Could not find Predefined Process " + processId);
}
// ---- creation of project area code
IProjectArea project = service.createProjectArea();
project.setName(name);
project.setProcessDefinition(processDefinition);
project.getDescription().setSummary("Test Process Summary");
// Save project area that uses the provided process
service.save(project, MONITOR);
// --------------- Set project access ------------------
service.initialize(project, MONITOR);
return msg;
}
catch (TeamRepositoryException ex) {
ex.printStackTrace();
// System.out.println(ex);
}
catch (Exception ex) {
ex.printStackTrace();
// System.out.println(ex);
}
return processId;
}
Thanks
Vaibhav