Skip to main content

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

Hi Alexander,

We have followed your instructions and sharing the project works. However, lately we are having trouble with the credentials.

On every start of our application, we are looking for a repository location that is usable for the project -- creating one if it does not exist -- and are setting the credentials on it. We even specify that the credentials should be saved. Then, if the project is not already shared, we share it using the repository location.

However, as soon as the first svn operation is executed, we are prompted for credentials. We have found out that different repository locations are involved, although we would expect only one to exist.

I tried implementing my own ISVNCredentialsPrompt and IOptionProvider, which solves the problem of the user being prompted, because I can provide the credentials without asking the user (he would not know what to enter). But that seems like a workaround to me.

Can you explain how credentials are stored and how we can specify credentials in such a way that we are not prompted? That would save us from having to provide an ISVNCredentialsPrompt and would thus reduce complexity.

Thanks,
Biörn


From: subversive-dev-bounces@xxxxxxxxxxx [subversive-dev-bounces@xxxxxxxxxxx] on behalf of Alexander Gurov [alexander.gurov@xxxxxxxxxxxx]
Sent: 26 September 2011 18:22
To: Developers mailing list
Subject: 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


Back to the top