X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2Forg.argeo.slc.client.ui.dist%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fdist%2Fwizards%2FRegisterRepoWizard.java;h=3f7f30c6588b7ebd5484c115be5007daa2b1f8f0;hb=48b6f7647f12f4b96d1914bcafc95efd7f43cc43;hp=fb80ac3cf5d7076821fd39178fb55eb6fff22962;hpb=7e3da04a2593e3949edce627bd945bbaacc3480b;p=gpl%2Fargeo-slc.git diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/wizards/RegisterRepoWizard.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/wizards/RegisterRepoWizard.java index fb80ac3cf..3f7f30c65 100644 --- a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/wizards/RegisterRepoWizard.java +++ b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/wizards/RegisterRepoWizard.java @@ -19,6 +19,7 @@ import java.net.URI; import java.util.Hashtable; import javax.jcr.Node; +import javax.jcr.NodeIterator; import javax.jcr.Property; import javax.jcr.Repository; import javax.jcr.RepositoryFactory; @@ -26,7 +27,6 @@ import javax.jcr.Session; import javax.jcr.SimpleCredentials; import javax.jcr.nodetype.NodeType; -import org.argeo.ArgeoException; import org.argeo.eclipse.ui.ErrorFeedback; import org.argeo.jcr.ArgeoJcrConstants; import org.argeo.jcr.ArgeoJcrUtils; @@ -113,9 +113,26 @@ public class RegisterRepoWizard extends Wizard { Node repos = nodeSession.getNode(reposPath); String repoNodeName = JcrUtils.replaceInvalidChars(name.getText()); if (repos.hasNode(repoNodeName)) - throw new ArgeoException( + throw new SlcException( "There is already a remote repository named " + repoNodeName); + + // check if the same URI has already been registered + NodeIterator ni = repos.getNodes(); + while (ni.hasNext()) { + Node node = ni.nextNode(); + if (node.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY) + && node.hasProperty(ArgeoNames.ARGEO_URI) + && node.getProperty(ArgeoNames.ARGEO_URI).getString() + .equals(uri.getText())) + throw new SlcException( + "This URI " + + uri.getText() + + " is already registered, " + + "for the time being, only one instance of a single " + + "repository at a time is implemented."); + } + Node repoNode = repos.addNode(repoNodeName, ArgeoTypes.ARGEO_REMOTE_REPOSITORY); repoNode.setProperty(ArgeoNames.ARGEO_URI, uri.getText()); @@ -160,7 +177,7 @@ public class RegisterRepoWizard extends Wizard { uri = createLT(composite, "URI", DEFAULT_URI); final Button anonymousLogin = createLC(composite, - "log as anonymous", true); + "Log as anonymous", true); anonymousLogin.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { if (anonymousLogin.getSelection()) { @@ -207,7 +224,7 @@ public class RegisterRepoWizard extends Wizard { /** Creates label and text. */ protected Text createLT(Composite parent, String label, String initial) { - new Label(parent, SWT.NONE).setText(label); + new Label(parent, SWT.RIGHT).setText(label); Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER); text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true)); text.setText(initial); @@ -217,7 +234,7 @@ public class RegisterRepoWizard extends Wizard { /** Creates label and check. */ protected Button createLC(Composite parent, String label, Boolean initial) { - new Label(parent, SWT.NONE).setText(label); + new Label(parent, SWT.RIGHT).setText(label); Button check = new Button(parent, SWT.CHECK); check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); check.setSelection(initial);