It's all about the answers!

Ask a question

Investigate file locking in server API


erling jorgensen (40911) | asked Jul 27 '12, 5:19 a.m.
edited Oct 10 '17, 2:40 p.m. by David Lafreniere (4.1k7)

 Hi


I have a need for investigating if files in a changeset are locked on delivery. In an operation advisor, that is triggered on delivery, i shall find out, if any of the files in the delivering changeset are locked on the receiving stream. 

My next need is to be able to lock files, that are delivered. I figure it done in an operation participant also triggered on delivery.

It's not easy to find anything about how to lock/unlock files by the serverside API.

Regards 

Erling

Accepted answer


permanent link
Andrew Niefer (6385) | answered Jul 30 '12, 5:14 p.m.
JAZZ DEVELOPER
The client side API is outlined in another forum post: SCM Locking API.

It would probably be useful to look at that, <tt>IWorkspaceManager.applyLockOperations</tt> will call the server side <tt>IScmService.updateLocks</tt> and <tt>IWorkspaceManager.findLocks</tt> calls the server side <tt>IScmQueryService.findLocks</tt>
David Lafreniere selected this answer as the correct answer

Comments
erling jorgensen commented Jul 31 '12, 8:20 a.m.

Thanks. This answer, and the referred forum post has really been helpfull!


erling jorgensen commented Sep 21 '12, 3:14 a.m.

I'm still having trouble making this work. My code is:

IScmService scmService = getService(IScmService.class);

    LockParameter lockParameter = ScmDtoFactory.eINSTANCE.createLockParameter();

    WorkspaceLocks wLocks = ScmDtoFactory.eINSTANCE.createWorkspaceLocks();
    wLocks.setWorkspace((IWorkspaceHandle) deliverData.getDestWorkspace().getItemHandle());

    ComponentLocks cLocks = ScmDtoFactory.eINSTANCE.createComponentLocks();
    cLocks.setComponent(changeSet.getComponent());

    ContributorLocks contLocks = ScmDtoFactory.eINSTANCE.createContributorLocks();
    contLocks.setContributor(changeSet.getAuthor());
    List<IChange> changes =  changeSet.changes();
    for (IChange iChange : changes) {
        IVersionableHandle versionableHandle = iChange.afterState(); //tried getting afterstate(), no difference
        if (versionableHandle.getItemType().getName().equals("FileItem")){
            contLocks.getVersionables().add(iChange.afterState());
        }
    }

    cLocks.getContributorLocks().add(contLocks);
    wLocks.getComponentLocks().add(cLocks);     
    lockParameter.getToAcquire().add(wLocks);

    scmService.updateLocks(lockParameter, null);

I don't get stacktraces, just an error.

Erling


Francisco Rodriguez commented Oct 30 '15, 11:36 a.m. | edited Oct 30 '15, 11:54 p.m.

 Hello Erling, did you find a solution for this?


David Lafreniere commented Oct 10 '17, 2:43 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

Note: Andrew answered the original question, so I am marking this as the accepted answer. It was mentioned that there was "an error". If there are still issues, please provide more details here or in a separate forum question.

Your answer


Register or to post your answer.