1 package org
.argeo
.slc
.client
.ui
.dist
.commands
;
4 import javax
.jcr
.Property
;
5 import javax
.jcr
.Repository
;
6 import javax
.jcr
.RepositoryException
;
7 import javax
.jcr
.Session
;
9 import org
.argeo
.api
.cms
.CmsConstants
;
10 import org
.argeo
.cms
.ArgeoTypes
;
11 import org
.argeo
.cms
.ui
.workbench
.util
.CommandUtils
;
12 import org
.argeo
.jcr
.JcrUtils
;
13 import org
.argeo
.slc
.SlcException
;
14 import org
.argeo
.slc
.client
.ui
.dist
.DistPlugin
;
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
.MessageDialog
;
19 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
22 * Un-register a remote repository by deleting the corresponding RepoNode from
23 * the node Repository. It does not affect the repository instance
25 public class UnregisterRemoteRepo
extends AbstractHandler
{
26 // private static final CmsLog log = CmsLog
27 // .getLog(UnregisterRemoteRepo.class);
29 public final static String ID
= DistPlugin
.PLUGIN_ID
+ ".unregisterRemoteRepo";
30 public final static String DEFAULT_LABEL
= "Unregister";
31 public final static ImageDescriptor DEFAULT_ICON
= DistPlugin
.getImageDescriptor("icons/removeItem.gif");
33 public final static String PARAM_REPO_PATH
= DistPlugin
.PLUGIN_ID
+ ".repoNodePath";
36 private Repository nodeRepository
;
38 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
39 Session session
= null;
40 String repoPath
= event
.getParameter(PARAM_REPO_PATH
);
45 session
= nodeRepository
.login(CmsConstants
.HOME_WORKSPACE
);
46 Node rNode
= session
.getNode(repoPath
);
47 if (rNode
.isNodeType(ArgeoTypes
.ARGEO_REMOTE_REPOSITORY
)) {
49 String alias
= rNode
.getProperty(Property
.JCR_TITLE
).getString();
50 String msg
= "Your are about to unregister remote repository: " + alias
+ "\n"
51 + "Are you sure you want to proceed ?";
53 boolean result
= MessageDialog
.openConfirm(
54 DistPlugin
.getDefault().getWorkbench().getDisplay().getActiveShell(), "Confirm Delete", msg
);
60 CommandUtils
.callCommand(RefreshDistributionsView
.ID
);
62 } catch (RepositoryException e
) {
63 throw new SlcException("Unexpected error while unregistering remote repository.", e
);
65 JcrUtils
.logoutQuietly(session
);
71 public void setNodeRepository(Repository nodeRepository
) {
72 this.nodeRepository
= nodeRepository
;