It's all about the answers!

Ask a question

How to programmatically(Plain Java) create repository workspace for the specified changeset?


DAVID GUO (35413) | asked Mar 15 '16, 6:06 a.m.
I want to create a repository workspace programmatically in order to get the file of  the specified changeset.

So, How I get the new workspace's IWorkspaceConnection?

I use the follow code,could create workspace.

But the baseline of workspace's component is initial baseline, so the content is empty.


 String StrChangeSetUUID    = "_r7455343xMsxIDwg";

UUID uuid = UUID.valueOf(StrChangeSetUUID); 

IChangeSetHandle csHandle = (IChangeSetHandle) IChangeSet.ITEM_TYPE.createItemHandle(uuid, null);
        
IChangeSet changeSet =  (IChangeSet) repo.itemManager().fetchCompleteItem(csHandle, IItemManager.DEFAULT, null);

IComponentHandle componentHandle = changeSet.getComponent();

IWorkspaceConnection workspaceConnection = null;
try
{
    // How to programmatically create repository workspace for the specified changeset?
    workspaceConnection = wm.createWorkspace(repo.loggedInContributor(), "Automatic created WM",                                                                                               "Description", monitor);
    workspaceConnection.addComponent(componentHandle, false, monitor);
}
catch (TeamRepositoryException e)
{
    e.printStackTrace();
}

Be the first one to answer this question!


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.