It's all about the answers!

Ask a question

How do you create a snapshot using the java api?


K M (38325251) | asked Apr 21 '10, 2:24 p.m.
How do you create a snapshot using the java api?

8 answers



permanent link
Nick Edgar (6.5k711) | answered Apr 22 '10, 2:13 p.m.
JAZZ DEVELOPER
Try:

import com.ibm.team.repository.client.ITeamRepository;
import com.ibm.team.scm.client.IWorkspaceManager;
import com.ibm.team.scm.client.SCMPlatform;
...

ITeamRepository repo = ...
IWorkspaceHandle ws = ...
IWorkspaceManager manager = SCMPlatform.getWorkspaceManager(repo);
IWorkspaceConnection connection = manager.getWorkspaceConnection(ws);
IBaselineSet snapshot = connection.createBaselineSet(null, "snapshot name", "snapshot comment", true, progressMonitor);

permanent link
K M (38325251) | answered Apr 22 '10, 3:03 p.m.
compile error:

incompatible types
found : com.ibm.team.scm.common.IBaselineSetHandle
required: com.ibm.team.scm.common.IBaselineSet
IBaselineSet snapshot = stream.createBaselineSet(null, "snapshot name", "snapshot comment", true, MONITOR);

my code snippit:

// Create Stream
IWorkspaceConnection stream = wm.createStream(processarea, streamName, msg, MONITOR);

// Add new components
stream.addComponent(component,baseConnection,false,MONITOR);

// Create snapshot
IBaselineSet snapshot = stream.createBaselineSet(null, "snapshot name", "snapshot comment", true, MONITOR);

permanent link
K M (38325251) | answered Apr 22 '10, 3:14 p.m.
change to

IBaselineSetHandle snapshot = stream.createBaselineSet(null, "snapshot name", "snapshot comment", true, MONITOR);

compiles but blows up:

Exception in thread "main" java.lang.NullPointerException
at com.ibm.team.scm.client.internal.WorkspaceConnection.createBaselineSet(WorkspaceConnection.java:3264)
at branch.Repository.createStream(Repository.java:464)
at branch.CmdRequest.processRequest(CmdRequest.java:66)
at branch.CmdRequest.main(CmdRequest.java:26)

permanent link
Nick Edgar (6.5k711) | answered Apr 22 '10, 4:01 p.m.
JAZZ DEVELOPER
My mistake -- createBaselineSet returns a handle, not an item.

The NPE is due to the null first argument (though the spec says this is allowed). Try passing Collections.emptyList() instead.

I've opened 112903: IWorkspaceConnection.createBaselineSet fails with null excludedComponents.

permanent link
K M (38325251) | answered Apr 22 '10, 4:01 p.m.
excludedComponents can not be null.

IBaselineSetHandle snapshot = stream.createBaselineSet(excludedComponents, "snapshot name", "snapshot comment", false, MONITOR);

permanent link
Nick Edgar (6.5k711) | answered Apr 23 '10, 2:17 p.m.
JAZZ DEVELOPER
Yes. Does it work if you pass Collections.emptyList() instead?

permanent link
Carlos Maciel (3112) | answered Nov 12 '15, 1:38 p.m.
For future use: It does work with Collections.emptyList()

permanent link
Guilherme Argentino (6) | answered Jan 20 '16, 2:27 p.m.
Now it´s deprecated. How do I use the new one?

Your answer


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