It's all about the answers!

Ask a question

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


nanda S (201419) | asked Jul 03 '14, 7:06 a.m.

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 )

_______________________________________________

One answer



permanent link
Ralph Schoon (55.2k23642) | answered Jul 03 '14, 7:54 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Start here: http://rsjazz.wordpress.com/2013/09/24/managing-workspaces-streams-and-components-using-the-plain-java-client-libraries/

Comments
nanda S commented Jul 03 '14, 8:30 a.m. | edited Jul 03 '14, 1:25 p.m.

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


Ralph Schoon commented Jul 03 '14, 11:37 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


Tim Mok commented Jul 03 '14, 1:27 p.m.
JAZZ DEVELOPER

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.


nanda S commented Jul 04 '14, 7:04 a.m.

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


nanda S commented Jul 04 '14, 10:04 a.m.

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


sam detweiler commented Jul 04 '14, 10:49 a.m. | edited Jul 04 '14, 10:53 a.m.

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.


Tim Mok commented Jul 04 '14, 10:52 a.m.
JAZZ DEVELOPER

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.


Ralph Schoon commented Jul 04 '14, 11:00 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


sam detweiler commented Jul 04 '14, 12:07 p.m. | edited Jul 04 '14, 12:08 p.m.

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 to post your answer.