1 package org
.argeo
.slc
.client
.ui
.dist
.commands
;
4 import javax
.jcr
.Repository
;
5 import javax
.jcr
.RepositoryException
;
6 import javax
.jcr
.RepositoryFactory
;
7 import javax
.jcr
.Session
;
9 import org
.argeo
.api
.security
.Keyring
;
10 import org
.argeo
.jcr
.JcrUtils
;
11 import org
.argeo
.slc
.SlcException
;
12 import org
.argeo
.slc
.client
.ui
.dist
.DistPlugin
;
13 import org
.argeo
.slc
.client
.ui
.dist
.utils
.CommandHelpers
;
14 import org
.argeo
.slc
.client
.ui
.dist
.wizards
.FetchWizard
;
15 import org
.eclipse
.core
.commands
.AbstractHandler
;
16 import org
.eclipse
.core
.commands
.ExecutionEvent
;
17 import org
.eclipse
.core
.commands
.ExecutionException
;
18 import org
.eclipse
.jface
.dialogs
.Dialog
;
19 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
20 import org
.eclipse
.jface
.wizard
.WizardDialog
;
21 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
24 * Wrap a {@code RepoSync} as an Eclipse command. Open a wizard that enable
25 * definition of the fetch process parameters
27 public class Fetch
extends AbstractHandler
{
28 // private final static Log log = LogFactory.getLog(Fetch.class);
30 public final static String ID
= DistPlugin
.PLUGIN_ID
+ ".fetch";
31 public final static String DEFAULT_LABEL
= "Fetch...";
32 public final static ImageDescriptor DEFAULT_ICON
= DistPlugin
33 .getImageDescriptor("icons/fetchRepo.png");
35 public final static String PARAM_TARGET_REPO_PATH
= "targetRepoPath";
37 // DEPENDENCY INJECTION
38 private Keyring keyring
;
39 private RepositoryFactory repositoryFactory
;
40 private Repository nodeRepository
;
42 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
44 Session currSession
= null;
47 String targetRepoPath
= event
.getParameter(PARAM_TARGET_REPO_PATH
);
48 currSession
= nodeRepository
.login();
49 Node targetRepoNode
= currSession
.getNode(targetRepoPath
);
51 FetchWizard wizard
= new FetchWizard(keyring
, repositoryFactory
,
53 wizard
.setTargetRepoNode(targetRepoNode
);
54 WizardDialog dialog
= new WizardDialog(
55 HandlerUtil
.getActiveShell(event
), wizard
);
57 int result
= dialog
.open();
58 if (result
== Dialog
.OK
)
59 CommandHelpers
.callCommand(RefreshDistributionsView
.ID
);
61 } catch (RepositoryException e
) {
62 throw new SlcException("Unable te retrieve repo node from path", e
);
64 JcrUtils
.logoutQuietly(currSession
);
68 // DEPENDENCY INJECTION
69 public void setRepositoryFactory(RepositoryFactory repositoryFactory
) {
70 this.repositoryFactory
= repositoryFactory
;
73 public void setKeyring(Keyring keyring
) {
74 this.keyring
= keyring
;
77 public void setNodeRepository(Repository repository
) {
78 this.nodeRepository
= repository
;