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

How to Deliver Component using Java API after sharing folders with scm command?

Hi

How to Deliver Component using Java API  after sharing folders with scm command?

I have to do the following actions:

Login i am using -java api

Create stream using -java api

Create workspace using -java api

Create component using -java api

Share folders to component using -SCM command

How to deliver components  to stream using -java API

(I need the java code to deliver the components which has be shared with files using scm command )

_______________________________________________

0 votes



One answer

Permanent link
Start here: http://rsjazz.wordpress.com/2013/09/24/managing-workspaces-streams-and-components-using-the-plain-java-client-libraries/

1 vote

Comments

Hi Ralph Schoon,

Thank you for the reply

I have refered the link before and the deliver for the change sets is not working i.e. for list of components 

NOT WORKING example:

for(int=0;i<listofcomponents.size();i++)

{

synchr =workspace.compareTo(streamname, WorkspaceCompFlags.CHANGE_SET_COMPARISON_ONLY,Collections.EMPTY_LIST, monitor);

workspacename.deliver(streamname, synchr, Collections.EMPTY_LIST,synchr.outgoingChangeSets(listofcomponents), monitor);

}

-----------------NOT WORKING--------------------

Not working is a too general statement. What does not work?

The code I have created and that is included in the blog works for me. I however add the component to the workspace/stream, instead of delivering the components, they are already there. So maybe adding the components is a different matter.

That code is for delivering change sets. If you're going to add a component to a workspace/stream, you should refer to the section of the blog about adding a component.

I have tried to add a component to stream using

 stream.addComponent(listofcomponents.get(i), workspace, false, monitor); 

it says Unable to obtain components locks

Hi Ralph,

Thank you for the reply

The code which is not working is the code which i have mentioned as an example

All i need is the Java code equivalent of

scm deilver -r repoID -u userID -p password -s workspaceName -C componentstobedelivered

there is not ONE api.. multiple apis required..

to create a component
IWorkspaceManager destmgr = SCMPlatform.getWorkspaceManager(repo);
         destmgr.createComponent(name ,project_area_owner, null);

get the stream connection
IWorkspaceConnection desttream = destmgr.getWorkspaceConnection(workspace_handle, null);

use the ComponentOperations to add the component to the stream

deliver some changes to the stream
deststream.deliver(parms,,,);

see the javadoc. for the parms.

You cannot obtain the locks on the components for some reason. I see in your original post that you want to create the stream, workspace, and components. In your snippet, you're adding the components use the workspace as a source. Have you added the components to the workspace at that point? This may be your problem because it can't get component locks in the workspace when they don't exist in the workspace.

As Tim points out, I add the components to the stream/workspace using

private IComponentHandle renameOrCreateComponent(
        ITeamRepository teamRepository, IWorkspaceManager wm,
        IProjectArea area, IComponentHandle componentHandle,
        String componentName, IProgressMonitor monitor)
        throws TeamRepositoryException {
    if (componentHandle == null) {
        // Rename component
        componentHandle = wm.createComponent(componentName,
                teamRepository.loggedInContributor(), monitor);
        wm.setComponentOwner(componentHandle, area, monitor);
    } else {
        // Rename component
        wm.renameComponent(componentHandle, componentName, monitor);
        wm.setComponentOwner(componentHandle, area, monitor);
    }
    return componentHandle;
}

Once the component is part of the workspace, it can be used for checkin and delivery. I think I also add them to both the workspace and the stream. I am not sure if a deliver would add the components to the stream automatically.

but that should only create the component in this project area. the Workspace.addComponent() (deprecated), now use ComponentOp, is what is used to add the newly existent component TO the stream/workspace.

you don't have a stream or workspace handle/connection in your snippet.

I had the same code in my copy project area utility.. because the components were already added to the streams/workspaces on the remote system prior to my copying.

showing 5 of 9 show 4 more comments

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
× 10,934
× 1,700
× 383

Question asked: Jul 03 '14, 7:06 a.m.

Question was seen: 6,975 times

Last updated: Jul 04 '14, 12:08 p.m.

Confirmation Cancel Confirm