It's all about the answers!

Ask a question

Local projects out of sync after workspaceConnection.deliver


Mohammed Ajmal (112) | asked Jan 26 '11, 12:59 p.m.
I have written an IOperationAdvisor which acts as a precondition to the Deliver operation. The advisor examines the file contents and if a certain chunk of text is missing, the advisor will modify the file and commit and deliver this to the repository workspace.

This is all working fine except for the fact that the local resources are out of sync when the deliver action completes. This, too, makes sense since I'm changing the file content "behind the scenes" when the user invokes the Deliver action.

So the question: is there a way for me to programatically resynchronize these files that my operation advisor has modified?

fileItem.setContent(...);
fileItem.setFileTimestamp(new Date());

IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(repo);
Collection<IShareable> shareables = FileSystemCore.getSharingManager().findShareables(fileItem, monitor);
IShareable shareable = shareables.iterator().next().getShare(monitor).getSharingDescriptor();

IWorkspaceHandle ws = (IWorkspaceHandle) sd.getConnectionHandle();
IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(ws, null);

workspaceConnection.commit(curHandle, Collections.singletonList(workspaceConnection.configurationOpFactory().save(fileItem)), monitor);

IChangeHistorySyncReport sync = workspaceConnection.compareTo(workspaceConnection, WorkspaceComparisonFlags.CHANGE_SET_COMPARISON_ONLY,
Collections.EMPTY_LIST, monitor);
workspaceConnection.deliver(workspaceConnection, sync, Collections.EMPTY_LIST, sync.outgoingChangeSets(changeSet.getComponent()), monitor);

2 answers



permanent link
Michael Valenta (3.7k3) | answered Jan 27 '11, 8:30 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
We have a similar advisor in RTC (copyright advisor) but it does not do automatic delivery because of the many possible complications. What the copyright advisor does is fail the deliver and provide a quick fix in the Team Advisor view that, when chosen by the user, updates the text accordingly. Then the user can check-in the changes either into an existing change set or a new one if all the existing change sets are complete.

The reason it is not done automatically is because of the change set handling. If the file in question is in an active change set, then the advisor would need to make the local change and check it in to that active change set. However, it is possible that the change set is complete, in which case, the advisor would need to either check the file into a different active change set or create a new change set. I think it would be fairly easy for the advisor to do the wrong thing in these cases so I think you would be better off using the same approach as the copyright advisor.

permanent link
Mohammed Ajmal (112) | answered Jan 27 '11, 11:16 a.m.
Michael,

That's exactly what I was looking for. Thanks for your reply.

Your answer


Register or to post your answer.