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
.resource
.ImageDescriptor
;
21 import org
.eclipse
.jface
.wizard
.WizardDialog
;
22 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
25 * Wrap a {@link RepoSync} as an Eclipse command. Open a wizard that enable
26 * definition of the fetch process parameters
28 public class Fetch
extends AbstractHandler
{
29 // private final static Log log = LogFactory.getLog(Fetch.class);
31 public final static String ID
= DistPlugin
.ID
+ ".fetch";
32 public final static String DEFAULT_LABEL
= "Fetch...";
33 public final static ImageDescriptor DEFAULT_ICON
= DistPlugin
34 .getImageDescriptor("icons/fetchRepo.png");
36 public final static String PARAM_TARGET_REPO_PATH
= "targetRepoPath";
38 // DEPENDENCY INJECTION
39 private Keyring keyring
;
40 private RepositoryFactory repositoryFactory
;
41 private Repository nodeRepository
;
43 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
45 Session currSession
= null;
48 String targetRepoPath
= event
.getParameter(PARAM_TARGET_REPO_PATH
);
49 currSession
= nodeRepository
.login();
50 Node targetRepoNode
= currSession
.getNode(targetRepoPath
);
52 FetchWizard wizard
= new FetchWizard(keyring
, repositoryFactory
,
54 wizard
.setTargetRepoNode(targetRepoNode
);
55 WizardDialog dialog
= new WizardDialog(
56 HandlerUtil
.getActiveShell(event
), wizard
);
58 int result
= dialog
.open();
59 if (result
== Dialog
.OK
)
60 CommandHelpers
.callCommand(RefreshDistributionsView
.ID
);
62 } catch (RepositoryException e
) {
63 throw new SlcException("Unable te retrieve repo node from path", e
);
65 JcrUtils
.logoutQuietly(currSession
);
69 // DEPENDENCY INJECTION
70 public void setRepositoryFactory(RepositoryFactory repositoryFactory
) {
71 this.repositoryFactory
= repositoryFactory
;
74 public void setKeyring(Keyring keyring
) {
75 this.keyring
= keyring
;
78 public void setNodeRepository(Repository repository
) {
79 this.nodeRepository
= repository
;