[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [subversive-dev] Programmatically sharing a project and specifying credentials

Hello Biörn,

First of all you should detect which repository location you could use in order to share the project (below is the part of AlreadyConnectedPage which is responsible for the doing):

String url = ""> for (int i = 0; i < projects.length; i++) {
    SVNChangeStatus info = SVNUtility.getSVNInfoForNotConnected(projects[i]);
    String tmp = SVNUtility.decodeURL(info.url);
    if (url == null) {
        url = "">     }
    else {
        IPath tPath = SVNUtility.createPathForSVNUrl(url);
        IPath tPath2 = SVNUtility.createPathForSVNUrl(tmp);
        if (tPath2.isPrefixOf(tPath)) {
            url = "">         }
        else {
            while (!tPath.isPrefixOf(tPath2)) {
                tPath = tPath.removeLastSegments(1);
            }
            url = "">         }
    }
}
IRepositoryRoot []repositoryRoots = SVNUtility.findRoots(url, true); // here you will get all the acceptable repository locations


IRepositoryLocation location = repositoryRoots[0].getRepositoryLocation(); // you can take the first acceptable one, for example

If there are no location then you should create it first. In order to do so you can use the url you got from the previous step:

AbstractActionOperation createOp =  null;
if (repositoryRoots.length == 0) {
    location = SVNRemoteStorage.instance().newRepositoryLocation();
......// fill the IRepositoryLocation instance here
   createOp =  new AddRepositoryLocationOperation(location);
}

And in the end this is how you could share the projects that already contains Subversion metadata:

IProject []projects = ....;
IRepositoryLocation location = ....;

ReconnectProjectOperation mainOp = new ReconnectProjectOperation(projects, location); // reconnect operation itself

CompositeOperation op = new CompositeOperation(mainOp.getId(), mainOp.getMessagesClass());

op.add(new NotifyProjectStatesChangedOperation(mainOp.getProjects(), ProjectStatesChangedEvent.ST_PRE_SHARED)); // send required notifications
if (createOp != null) {
    op.add(createOp);
    op.add(new SaveRepositoryLocationsOperation());
    op.add(mainOp, new IActionOperation[] {createOp});
}
else {
    op.add(mainOp);
}
op.add(new RefreshResourcesOperation(mainOp, IResource.DEPTH_INFINITE, RefreshResourcesOperation.REFRESH_ALL)); // initialize SVN metadata cache loading, redraw for the workspace resources tree etc.
op.add(new NotifyProjectStatesChangedOperation(mainOp.getProjects(), ProjectStatesChangedEvent.ST_POST_SHARED)); // send required notifications

UIMonitorUtility.doTaskScheduledDefault(op);


Best regards,
Alexander Gurov.

14.09.2011 18:45, Biörnstad, Biörn пишет:
Hello

We want to programmatically enable the sharing of a project that already contains Subversion meta data (.svn). I have found the ShareProjectOperation and the ShareProjectWizard with the AlreadyConnectedPage. However, they contain much code and I am getting slightly lost.

Can someone give me instructions on how to achieve this?

Additionally, we want to provide the credentials (username and password) that Subversive should use when contacting the Subversion repository. Is it possible to specify the information when sharing the project? Or do we need to use an ISVNCredentialsPrompt through an IOptionProvider?

The point is that both operations should be done programmatically without user interaction.

Thanks in advance,
Biörn
_______________________________________________
subversive-dev mailing list
subversive-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/subversive-dev