Fix delete
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 26 Jun 2012 10:42:06 +0000 (10:42 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 26 Jun 2012 10:42:06 +0000 (10:42 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@5349 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

eclipse/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/commands.xml
eclipse/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/DeleteArtifacts.java

index 63d63517e7a7a736f4c33616efcac0a06d3251ac..3cd4942cedd47851cfdcbf5da85dd38e668676bd 100644 (file)
@@ -50,7 +50,6 @@
        <bean id="org.argeo.slc.client.ui.dist.deleteArtifacts"
                class="org.argeo.slc.client.ui.dist.commands.DeleteArtifacts"
                scope="prototype">
-               <property name="repository" ref="javaRepository" />
        </bean>
        <bean id="refreshDistributionOverviewPage"
                class="org.argeo.slc.client.ui.dist.commands.RefreshDistributionOverviewPage"
index 5ced1609ecd175f68b0a0d34c1cb1a0986125b96..5e67975fc7e830222d5bbf3f9442b549837a9fed 100644 (file)
@@ -3,9 +3,7 @@ package org.argeo.slc.client.ui.dist.commands;
 import java.util.Iterator;
 
 import javax.jcr.Node;
-import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
-import javax.jcr.Session;
 
 import org.argeo.ArgeoException;
 import org.argeo.slc.client.ui.dist.DistPlugin;
@@ -29,9 +27,6 @@ public class DeleteArtifacts extends AbstractHandler {
        public final static String DEFAULT_LABEL = "Delete selected items";
        public final static String DEFAULT_ICON_PATH = "icons/removeItem.gif";
 
-       /* DEPENDENCY INJECTION */
-       private Repository repository;
-
        public Object execute(ExecutionEvent event) throws ExecutionException {
                String msg = "Your are about to definitively remove these artifacts.\n"
                                + "Do you really want to proceed ?";
@@ -40,9 +35,9 @@ public class DeleteArtifacts extends AbstractHandler {
                                .getWorkbench().getDisplay().getActiveShell(),
                                "Confirm deletion", msg);
                if (result) {
-                       Session session = null;
+                       // Session session = null;
                        try {
-                               session = repository.login();
+                               // session = repository.login();
                                IWorkbenchPart activePart = DistPlugin.getDefault()
                                                .getWorkbench().getActiveWorkbenchWindow()
                                                .getActivePage().getActivePart();
@@ -57,25 +52,22 @@ public class DeleteArtifacts extends AbstractHandler {
                                                                .iterator();
                                                while (it.hasNext()) {
                                                        Node node = (Node) it.next();
-                                                       node.remove();
+                                                       // we remove the artifactVersion, that is the parent
+                                                       node.getParent().remove();
+                                                       node.getSession().save();
                                                }
                                        }
-                                       session.save();
+                                       // session.save();
                                }
                                CommandHelpers.callCommand(RefreshDistributionOverviewPage.ID);
                        } catch (RepositoryException re) {
                                throw new ArgeoException(
                                                "Unexpected error while deleting artifacts.", re);
                        } finally {
-                               if (session != null)
-                                       session.logout();
+                               // if (session != null)
+                               // session.logout();
                        }
                }
                return null;
        }
-
-       /* DEPENDENCY INJECTION */
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
 }