X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=plugins%2Forg.argeo.slc.client.ui.dist%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fdist%2Fcommands%2FDeleteWorkspace.java;h=676a921c02bc503ea980c9ab68d87269f1d82074;hb=5187ffaff5610275cf3dbc5fb913f59126576da8;hp=4c77c806eef5b873dfcce638fba272bf5f12fcb9;hpb=651d33e13bfa9a7b46464be412023ee747e612e8;p=gpl%2Fargeo-slc.git diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/DeleteWorkspace.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/DeleteWorkspace.java index 4c77c806e..676a921c0 100644 --- a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/DeleteWorkspace.java +++ b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/DeleteWorkspace.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2007-2012 Argeo GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.argeo.slc.client.ui.dist.commands; import javax.jcr.Node; @@ -7,9 +22,8 @@ import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.jcr.nodetype.NodeType; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.ArgeoException; +import org.argeo.jcr.JcrUtils; +import org.argeo.slc.SlcException; import org.argeo.slc.client.ui.dist.DistPlugin; import org.argeo.slc.client.ui.dist.utils.CommandHelpers; import org.eclipse.core.commands.AbstractHandler; @@ -22,7 +36,7 @@ import org.eclipse.jface.dialogs.MessageDialog; */ public class DeleteWorkspace extends AbstractHandler { - private static final Log log = LogFactory.getLog(DeleteWorkspace.class); + // private static final Log log = LogFactory.getLog(DeleteWorkspace.class); public final static String ID = DistPlugin.ID + ".deleteWorkspace"; public final static String PARAM_WORKSPACE_NAME = DistPlugin.ID @@ -35,43 +49,53 @@ public class DeleteWorkspace extends AbstractHandler { public Object execute(ExecutionEvent event) throws ExecutionException { - // MessageDialog.openWarning(DistPlugin.getDefault() - // .getWorkbench().getDisplay().getActiveShell(), - // "WARNING", "Not yet implemented"); - // return null; - String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME); - String msg = "Your are about to clear workspace [" + workspaceName - + "].\n Do you really want to proceed ?"; + + String msg = "Your are about to completely delete workspace [" + + workspaceName + "].\n Do you really want to proceed ?"; boolean result = MessageDialog.openConfirm(DistPlugin.getDefault() .getWorkbench().getDisplay().getActiveShell(), - "Confirm workspace clear", msg); + "Confirm workspace deletion", msg); + + if (result) { + // msg = + // "There is no possible turning back, are your REALLY sure you want to proceed ?"; + msg = "WARNING: \nCurrent Jackrabbit version used does " + + "not support workspace management.\n" + + "Thus, the workspace will only be cleaned so " + + "that you can launch fetch process again.\n\n" + + "Do you still want to proceed ?"; + result = MessageDialog.openConfirm(DistPlugin.getDefault() + .getWorkbench().getDisplay().getActiveShell(), + "Confirm workspace deletion", msg); + } + if (result) { Session session = null; try { session = repository.login(workspaceName); + // TODO use this with a newer version of Jackrabbit + // Workspace wsp = session.getWorkspace(); + // wsp.deleteWorkspace(workspaceName); + NodeIterator nit = session.getRootNode().getNodes(); while (nit.hasNext()) { Node node = nit.nextNode(); if (node.isNodeType(NodeType.NT_FOLDER) || node.isNodeType(NodeType.NT_UNSTRUCTURED)) { - String path = node.getPath(); + // String path = node.getPath(); node.remove(); session.save(); - if (log.isDebugEnabled()) - log.debug("Cleared " + path + " in " - + workspaceName); } } CommandHelpers.callCommand(RefreshDistributionsView.ID); } catch (RepositoryException re) { - throw new ArgeoException( + throw new SlcException( "Unexpected error while deleting workspace [" + workspaceName + "].", re); } finally { - if (session != null) - session.logout(); + JcrUtils.logoutQuietly(session); } } return null;