1 package org
.argeo
.jcr
.ui
.explorer
.commands
;
3 import java
.util
.Hashtable
;
5 import javax
.jcr
.Repository
;
6 import javax
.jcr
.RepositoryFactory
;
8 import org
.argeo
.eclipse
.ui
.ErrorFeedback
;
9 import org
.argeo
.eclipse
.ui
.dialogs
.SingleValue
;
10 import org
.argeo
.jcr
.ArgeoJcrConstants
;
11 import org
.argeo
.jcr
.ui
.explorer
.JcrExplorerConstants
;
12 import org
.eclipse
.core
.commands
.AbstractHandler
;
13 import org
.eclipse
.core
.commands
.ExecutionEvent
;
14 import org
.eclipse
.core
.commands
.ExecutionException
;
15 import org
.osgi
.framework
.BundleContext
;
18 * Connect to a remote repository and, if usccessful publish it as an OSGi
21 public class AddRemoteRepository
extends AbstractHandler
implements
22 JcrExplorerConstants
{
24 private RepositoryFactory repositoryFactory
;
25 private BundleContext bundleContext
;
27 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
29 if (event
.getParameters().containsKey(PARAM_REPOSITORY_URI
))
30 uri
= event
.getParameter(PARAM_REPOSITORY_URI
);
34 "Remote repository URI"
35 + " (e.g. http://localhost:7070/org.argeo.jcr.webapp/remoting/node)");
41 Hashtable
<String
, String
> params
= new Hashtable
<String
, String
>();
42 params
.put(ArgeoJcrConstants
.JCR_REPOSITORY_URI
, uri
);
43 // by default we use the URI as alias
44 params
.put(ArgeoJcrConstants
.JCR_REPOSITORY_ALIAS
, uri
);
45 Repository repository
= repositoryFactory
.getRepository(params
);
46 bundleContext
.registerService(Repository
.class.getName(),
48 } catch (Exception e
) {
49 ErrorFeedback
.show("Cannot add remote repository " + uri
, e
);
54 public void setRepositoryFactory(RepositoryFactory repositoryFactory
) {
55 this.repositoryFactory
= repositoryFactory
;
58 public void setBundleContext(BundleContext bundleContext
) {
59 this.bundleContext
= bundleContext
;