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
.jcr
.JcrUtils
;
10 import org
.argeo
.slc
.SlcException
;
11 import org
.argeo
.slc
.client
.ui
.dist
.DistPlugin
;
12 import org
.argeo
.slc
.client
.ui
.dist
.utils
.CommandHelpers
;
13 import org
.argeo
.slc
.client
.ui
.dist
.wizards
.FetchWizard
;
14 import org
.argeo
.slc
.repo
.RepoSync
;
15 import org
.argeo
.util
.security
.Keyring
;
16 import org
.eclipse
.core
.commands
.AbstractHandler
;
17 import org
.eclipse
.core
.commands
.ExecutionEvent
;
18 import org
.eclipse
.core
.commands
.ExecutionException
;
19 import org
.eclipse
.jface
.dialogs
.Dialog
;
20 import org
.eclipse
.jface
.wizard
.WizardDialog
;
21 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
23 /** Wraps a {@link RepoSync} as an Eclipse command. */
24 public class Fetch
extends AbstractHandler
{
25 // private final static Log log = LogFactory.getLog(Fetch.class);
27 public final static String ID
= DistPlugin
.ID
+ ".fetch";
28 public final static String PARAM_TARGET_REPO_PATH
= "targetRepoPath";
29 public final static String DEFAULT_LABEL
= "Fetch...";
30 public final static String DEFAULT_ICON_PATH
= "icons/fetchRepo.png";
32 // DEPENDENCY INJECTION
33 private Keyring keyring
;
34 private RepositoryFactory repositoryFactory
;
35 private Repository nodeRepository
;
37 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
38 Session currSession
= null;
41 String targetRepoPath
= event
.getParameter(PARAM_TARGET_REPO_PATH
);
42 currSession
= nodeRepository
.login();
43 Node targetRepoNode
= currSession
.getNode(targetRepoPath
);
45 FetchWizard wizard
= new FetchWizard(keyring
, repositoryFactory
,
47 wizard
.setTargetRepoNode(targetRepoNode
);
48 WizardDialog dialog
= new WizardDialog(
49 HandlerUtil
.getActiveShell(event
), wizard
);
51 int result
= dialog
.open();
52 if (result
== Dialog
.OK
)
53 CommandHelpers
.callCommand(RefreshDistributionsView
.ID
);
55 } catch (RepositoryException e
) {
56 throw new SlcException("Unexpected error while fetching data", e
);
58 JcrUtils
.logoutQuietly(currSession
);
62 // DEPENDENCY INJECTION
63 public void setRepositoryFactory(RepositoryFactory repositoryFactory
) {
64 this.repositoryFactory
= repositoryFactory
;
67 public void setKeyring(Keyring keyring
) {
68 this.keyring
= keyring
;
71 public void setNodeRepository(Repository repository
) {
72 this.nodeRepository
= repository
;