Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How can I create a project area programmatically?

We are creating a front end web application for RQM v3.0.1. When a user submit a request in our application, we would like to create a new project area in RQM and then assign the user as project area admin.
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.

0 votes



6 answers

Permanent link
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

0 votes


Permanent link
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.
&lt;/head&gt;&lt;body&gt;&lt;h1&gt;HTTP Status 403 - &lt;/h1&gt;&lt;HR&gt;&lt;p&gt;<b>type</b> Status report&lt;/p&gt;&lt;p&gt;<b>message</b> <u></u>&lt;/p&gt;&lt;p&gt;<b>description</b> <u>Access to the specified resource () has been forbidden.</u>&lt;/p&gt;&lt;HR&gt;&lt;h3&gt;Apache Tomcat/5.5.30&lt;/h3&gt;&lt;/body&gt;

Do you know what might be the problem?

0 votes


Permanent link
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).

&lt;xml&gt;
&lt;jp06&gt;
&lt;jp06&gt;
&lt;/jp06&gt;

But I keeps getting 403 response like below.
&lt;/head&gt;&lt;body&gt;&lt;h1&gt;HTTP Status 403 - &lt;/h1&gt;&lt;HR&gt;&lt;p&gt;<b>type</b> Status report&lt;/p&gt;&lt;p&gt;<b>message</b> <u></u>&lt;/p&gt;&lt;p&gt;<b>description</b> <u>Access to the specified resource () has been forbidden.</u>&lt;/p&gt;&lt;HR&gt;&lt;h3&gt;Apache Tomcat/5.5.30&lt;/h3&gt;&lt;/body&gt;

Do you know what might be the problem?

0 votes


Permanent link
Looks to me you don't have the privilege to create a new project area. You need to be a jazz admin in order to do so. So try use an user credential with jazz admin privilege to try it again. cheers.

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

&lt;xml&gt;
&lt;jp06&gt;
&lt;jp06&gt;
&lt;/jp06&gt;

But I keeps getting 403 response like below.
&lt;/head&gt;&lt;body&gt;&lt;h1&gt;HTTP Status 403 - &lt;/h1&gt;&lt;*&gt;&lt;p&gt;<b>type</b> Status report&lt;/p&gt;&lt;p&gt;<b>message</b> <u></u>&lt;/p&gt;&lt;p&gt;<b>description</b> <u>Access to the specified resource () has been forbidden.</u>&lt;/p&gt;&lt;*&gt;&lt;h3&gt;Apache Tomcat/5.5.30&lt;/h3&gt;&lt;/body&gt;

Do you know what might be the problem?

0 votes


Permanent link
After adding the &quot;Referer&quot; section into header like below, I'm able to create project area through REST API now.

Referer: https://rqmdev.rtp.raleigh.ibm.com:9443/qm

0 votes


Permanent link

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

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: Jul 06 '11, 4:41 a.m.

Question was seen: 5,730 times

Last updated: Apr 04 '17, 5:37 a.m.

Confirmation Cancel Confirm