1 package org
.argeo
.slc
.client
.ui
.dist
.commands
;
4 import javax
.jcr
.NodeIterator
;
5 import javax
.jcr
.Repository
;
6 import javax
.jcr
.RepositoryException
;
7 import javax
.jcr
.Session
;
8 import javax
.jcr
.nodetype
.NodeType
;
10 import org
.apache
.commons
.logging
.Log
;
11 import org
.apache
.commons
.logging
.LogFactory
;
12 import org
.argeo
.ArgeoException
;
13 import org
.argeo
.slc
.client
.ui
.dist
.DistPlugin
;
14 import org
.argeo
.slc
.client
.ui
.dist
.utils
.CommandHelpers
;
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
;
21 * Delete chosen workspace in the current repository.
24 public class DeleteWorkspace
extends AbstractHandler
{
25 private static final Log log
= LogFactory
.getLog(DeleteWorkspace
.class);
27 public final static String ID
= DistPlugin
.ID
+ ".deleteWorkspace";
28 public final static String PARAM_WORKSPACE_NAME
= DistPlugin
.ID
30 public final static String DEFAULT_LABEL
= "Delete";
31 public final static String DEFAULT_ICON_PATH
= "icons/removeItem.gif";
33 /* DEPENDENCY INJECTION */
34 private Repository repository
;
36 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
38 // MessageDialog.openWarning(DistPlugin.getDefault()
39 // .getWorkbench().getDisplay().getActiveShell(),
40 // "WARNING", "Not yet implemented");
43 String workspaceName
= event
.getParameter(PARAM_WORKSPACE_NAME
);
44 String msg
= "Your are about to clear workspace [" + workspaceName
45 + "].\n Do you really want to proceed ?";
47 boolean result
= MessageDialog
.openConfirm(DistPlugin
.getDefault()
48 .getWorkbench().getDisplay().getActiveShell(),
49 "Confirm workspace clear", msg
);
51 Session session
= null;
53 session
= repository
.login(workspaceName
);
54 NodeIterator nit
= session
.getRootNode().getNodes();
55 while (nit
.hasNext()) {
56 Node node
= nit
.nextNode();
57 if (node
.isNodeType(NodeType
.NT_FOLDER
)
58 || node
.isNodeType(NodeType
.NT_UNSTRUCTURED
)) {
59 String path
= node
.getPath();
62 if (log
.isDebugEnabled())
63 log
.debug("Cleared " + path
+ " in "
67 CommandHelpers
.callCommand(RefreshDistributionsView
.ID
);
68 } catch (RepositoryException re
) {
69 throw new ArgeoException(
70 "Unexpected error while deleting workspace ["
71 + workspaceName
+ "].", re
);
80 /* DEPENDENCY INJECTION */
81 public void setRepository(Repository repository
) {
82 this.repository
= repository
;