From: Mathieu Baudier Date: Mon, 20 Aug 2012 17:13:25 +0000 (+0000) Subject: Implement remote browsing X-Git-Tag: argeo-slc-2.1.7~642 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=43e9e4e45dedbe68a1b3b427c2ee75d698b5ee9c;p=gpl%2Fargeo-slc.git Implement remote browsing git-svn-id: https://svn.argeo.org/slc/trunk@5521 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml b/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml index 04e4e225f..c938de8de 100644 --- a/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml +++ b/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml @@ -10,4 +10,6 @@ + + \ No newline at end of file diff --git a/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/views.xml b/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/views.xml index 7540fe21a..cfbbf2443 100644 --- a/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/views.xml +++ b/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/views.xml @@ -46,5 +46,6 @@ + diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/DistributionsView.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/DistributionsView.java index c401bb111..c143fb2e0 100644 --- a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/DistributionsView.java +++ b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/DistributionsView.java @@ -22,7 +22,9 @@ import java.util.Map; import javax.jcr.Repository; import javax.jcr.RepositoryException; +import javax.jcr.RepositoryFactory; import javax.jcr.Session; +import javax.jcr.SimpleCredentials; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -67,6 +69,7 @@ public class DistributionsView extends ViewPart implements SlcNames { public final static String ID = DistPlugin.ID + ".distributionsView"; private Repository repository; + private RepositoryFactory repositoryFactory; private TreeViewer viewer; @@ -107,7 +110,17 @@ public class DistributionsView extends ViewPart implements SlcNames { // Initializes repositories // TODO make it more generic, with remote repositories etc. - repositories.add(new RepositoryElem("java", repository)); + repositories.add(new RepositoryElem("java", repository, false)); + + // Remote + /* + String uri = "http://localhost:7070/org.argeo.jcr.webapp/remoting/java"; + //String uri = "http://dev.argeo.org/org.argeo.jcr.webapp/pub/java"; + Repository remoteRepository = JcrUtils.getRepositoryByUri( + repositoryFactory, uri); + repositories.add(new RepositoryElem("java@dev.argeo.org", + remoteRepository, true)); + */ viewer.setInput(getSite()); @@ -129,6 +142,10 @@ public class DistributionsView extends ViewPart implements SlcNames { this.repository = repository; } + public void setRepositoryFactory(RepositoryFactory repositoryFactory) { + this.repositoryFactory = repositoryFactory; + } + /** Programatically configure the context menu */ protected void contextMenuAboutToShow(IMenuManager menuManager) { IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench() @@ -200,15 +217,25 @@ public class DistributionsView extends ViewPart implements SlcNames { } + /** Wraps a repository **/ private static class RepositoryElem extends TreeParent { // private final Repository repository; private Session defaultSession; + private final Boolean isRemote; - public RepositoryElem(String name, Repository repository) { + public RepositoryElem(String name, Repository repository, + Boolean isRemote) { super(name); // this.repository = repository; + this.isRemote = isRemote; try { - defaultSession = repository.login(); + if (isRemote) { + SimpleCredentials sc = new SimpleCredentials("root", + "demo".toCharArray()); + defaultSession = repository.login(sc); + } else { + defaultSession = repository.login(); + } String[] workspaceNames = defaultSession.getWorkspace() .getAccessibleWorkspaceNames(); for (String workspace : workspaceNames)