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