]> git.argeo.org Git - gpl/argeo-slc.git/commitdiff
work on the modular distribution part.
authorBruno Sinou <bsinou@argeo.org>
Wed, 26 Feb 2014 16:49:31 +0000 (16:49 +0000)
committerBruno Sinou <bsinou@argeo.org>
Wed, 26 Feb 2014 16:49:31 +0000 (16:49 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@6860 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/controllers/DistTreeComparator.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/controllers/DistTreeLabelProvider.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/DistParentElem.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/GroupBaseElem.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/GroupElem.java [deleted file]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/RepoElem.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/WkspGroupElem.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/DistributionsView.java

index ca67024ffbbd6788ce330f0a328e0dc08b5bd464..26065428b58c3d18c98b5eab02755b82b21f77e8 100644 (file)
@@ -1,7 +1,7 @@
 package org.argeo.slc.client.ui.dist.controllers;
 
 import org.argeo.slc.client.ui.dist.model.DistParentElem;
-import org.argeo.slc.client.ui.dist.model.GroupElem;
+import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
 import org.argeo.slc.client.ui.dist.model.RepoElem;
 import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
 import org.eclipse.jface.viewers.Viewer;
@@ -17,7 +17,7 @@ public class DistTreeComparator extends ViewerComparator {
                                return 2;
                        else
                                return 5;
-               else if (element instanceof GroupElem)
+               else if (element instanceof WkspGroupElem)
                        return 10;
                else if (element instanceof WorkspaceElem)
                        return 15;
index fe45871f7c02ad123c1f1b41654155168bf5f72d..b504ae6f3bb022ecee61370b056ee9432e1c842f 100644 (file)
@@ -2,7 +2,7 @@ package org.argeo.slc.client.ui.dist.controllers;
 
 import org.argeo.slc.client.ui.dist.DistImages;
 import org.argeo.slc.client.ui.dist.model.DistParentElem;
-import org.argeo.slc.client.ui.dist.model.GroupElem;
+import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
 import org.argeo.slc.client.ui.dist.model.RepoElem;
 import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
 import org.eclipse.jface.viewers.ColumnLabelProvider;
@@ -31,7 +31,7 @@ public class DistTreeLabelProvider extends ColumnLabelProvider {
                                        return DistImages.IMG_REPO_READONLY;
                                else
                                        return DistImages.IMG_REPO;
-                       else if (bElement instanceof GroupElem)
+                       else if (bElement instanceof WkspGroupElem)
                                return DistImages.IMG_WKSP;
                        else if (element instanceof WorkspaceElem)
                                if (((WorkspaceElem) element).isReadOnly())
index 3d7cef270c7288c71d59c27a70353b3156cdb827..09dede9e820049ddc5a2df9dae85cb91636319cd 100644 (file)
@@ -1,6 +1,6 @@
 package org.argeo.slc.client.ui.dist.model;
 
-/** Common super class for all dist tree elements */
+/** Common super class for all tree elements of the Distributions View*/
 public abstract class DistParentElem {
        public final static Character VERSION_SEP = '-';
 
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/GroupBaseElem.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/GroupBaseElem.java
new file mode 100644 (file)
index 0000000..9b6b3ff
--- /dev/null
@@ -0,0 +1,35 @@
+package org.argeo.slc.client.ui.dist.model;
+
+/**
+ * Abstract a node of type slc:groupBase that gathers a set of artifacts that
+ * have the same group ID
+ */
+public class GroupBaseElem extends DistParentElem {
+       private WorkspaceElem wkspElem;
+       private String groupId;
+
+       public GroupBaseElem(WorkspaceElem wkspElem, String groupId) {
+               super(wkspElem.inHome(), wkspElem.isReadOnly());
+               this.wkspElem = wkspElem;
+               this.groupId = groupId;
+       }
+
+       public Object[] getChildren() {
+               return null;
+       }
+
+       public String getLabel() {
+               return groupId;
+       }
+
+       public String toString() {
+               return getLabel();
+       }
+
+       public void dispose() {
+       }
+
+       public WorkspaceElem getWorkspaceElem() {
+               return wkspElem;
+       }
+}
\ No newline at end of file
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/GroupElem.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/GroupElem.java
deleted file mode 100644 (file)
index bc5e94e..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-package org.argeo.slc.client.ui.dist.model;
-
-import java.security.AccessControlException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-
-/**
- * Abstracts a group of distribution, that is a bunch of workspaces with same
- * prefix.
- */
-public class GroupElem extends DistParentElem {
-       private RepoElem repoElem;
-       private String name;
-
-       public GroupElem(RepoElem repoElem, String prefix) {
-               super(repoElem.inHome(), repoElem.isReadOnly());
-               this.repoElem = repoElem;
-               this.name = prefix;
-       }
-
-       public Object[] getChildren() {
-               Session session = null;
-               try {
-                       Repository repository = repoElem.getRepository();
-                       session = repository.login(repoElem.getCredentials());
-
-                       String[] workspaceNames = session.getWorkspace()
-                                       .getAccessibleWorkspaceNames();
-                       List<WorkspaceElem> distributionElems = new ArrayList<WorkspaceElem>();
-                       buildWksp: for (String workspaceName : workspaceNames) {
-
-                               // Filter non-public workspaces for user anonymous.
-                               if (repoElem.getRepoNode() == null) {
-                                       Session tmpSession = null;
-                                       try {
-                                               tmpSession = repository.login(workspaceName);
-                                               Boolean res = true;
-                                               try {
-                                                       tmpSession.checkPermission("/", "read");
-                                               } catch (AccessControlException e) {
-                                                       res = false;
-                                               }
-                                               if (!res)
-                                                       continue buildWksp;
-                                       } catch (RepositoryException e) {
-                                               throw new SlcException(
-                                                               "Cannot list workspaces for anonymous user", e);
-                                       } finally {
-                                               JcrUtils.logoutQuietly(tmpSession);
-                                       }
-                               }
-
-                               // filter technical workspaces
-                               if (workspaceName.startsWith(name)
-                                               && workspaceName.substring(0,
-                                                               workspaceName.lastIndexOf(VERSION_SEP)).equals(name)) {
-                                       distributionElems.add(new WorkspaceElem(repoElem,
-                                                       workspaceName));
-                               }
-                       }
-                       return distributionElems.toArray();
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot list workspaces for prefix " + name,
-                                       e);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
-               }
-       }
-
-       public String getLabel() {
-               return name;
-       }
-
-       public String toString() {
-               return getLabel();
-       }
-
-       public void dispose() {
-       }
-
-       public RepoElem getRepoElem() {
-               return repoElem;
-       }
-
-}
index 7d584f7875d311927e90b2566e8e3eb4cab3a263..60916bec59d13d6601ca1a48e6124cc4f23662e3 100644 (file)
@@ -24,7 +24,7 @@ import org.argeo.slc.repo.RepoUtils;
 import org.argeo.util.security.Keyring;
 
 /**
- * Abstract a repository. Might be persisted by a node in the current user home
+ * Abstract a repository. It might be persisted by a node in the current user home
  * Node or just an URI and a label if user is anonymous
  */
 public class RepoElem extends DistParentElem {
@@ -116,7 +116,7 @@ public class RepoElem extends DistParentElem {
                        session = repository.login(credentials);
                        String[] workspaceNames = session.getWorkspace()
                                        .getAccessibleWorkspaceNames();
-                       Map<String, GroupElem> children = new HashMap<String, GroupElem>();
+                       Map<String, WkspGroupElem> children = new HashMap<String, WkspGroupElem>();
 
                        buildWksp: for (String workspaceName : workspaceNames) {
                                // Add a supplementary check to hide workspace that are not
@@ -148,7 +148,7 @@ public class RepoElem extends DistParentElem {
                                        String prefix = workspaceName.substring(0,
                                                        workspaceName.lastIndexOf(VERSION_SEP));
                                        if (!children.containsKey(prefix)) {
-                                               children.put(prefix, new GroupElem(RepoElem.this,
+                                               children.put(prefix, new WkspGroupElem(RepoElem.this,
                                                                prefix));
                                        }
                                }
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/WkspGroupElem.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/WkspGroupElem.java
new file mode 100644 (file)
index 0000000..685a8e0
--- /dev/null
@@ -0,0 +1,92 @@
+package org.argeo.slc.client.ui.dist.model;
+
+import java.security.AccessControlException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+
+/**
+ * Abstract set of similar workspaces, that is a bunch of workspaces with same
+ * prefix.
+ */
+public class WkspGroupElem extends DistParentElem {
+       private RepoElem repoElem;
+       private String name;
+
+       public WkspGroupElem(RepoElem repoElem, String prefix) {
+               super(repoElem.inHome(), repoElem.isReadOnly());
+               this.repoElem = repoElem;
+               this.name = prefix;
+       }
+
+       public Object[] getChildren() {
+               Session session = null;
+               try {
+                       Repository repository = repoElem.getRepository();
+                       session = repository.login(repoElem.getCredentials());
+
+                       String[] workspaceNames = session.getWorkspace()
+                                       .getAccessibleWorkspaceNames();
+                       List<WorkspaceElem> distributionElems = new ArrayList<WorkspaceElem>();
+                       buildWksp: for (String workspaceName : workspaceNames) {
+
+                               // Filter non-public workspaces for user anonymous.
+                               if (repoElem.getRepoNode() == null) {
+                                       Session tmpSession = null;
+                                       try {
+                                               tmpSession = repository.login(workspaceName);
+                                               Boolean res = true;
+                                               try {
+                                                       tmpSession.checkPermission("/", "read");
+                                               } catch (AccessControlException e) {
+                                                       res = false;
+                                               }
+                                               if (!res)
+                                                       continue buildWksp;
+                                       } catch (RepositoryException e) {
+                                               throw new SlcException(
+                                                               "Cannot list workspaces for anonymous user", e);
+                                       } finally {
+                                               JcrUtils.logoutQuietly(tmpSession);
+                                       }
+                               }
+
+                               // filter technical workspaces
+                               if (workspaceName.startsWith(name)
+                                               && workspaceName.substring(0,
+                                                               workspaceName.lastIndexOf(VERSION_SEP)).equals(
+                                                               name)) {
+                                       distributionElems.add(new WorkspaceElem(repoElem,
+                                                       workspaceName));
+                               }
+                       }
+                       return distributionElems.toArray();
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot list workspaces for prefix " + name,
+                                       e);
+               } finally {
+                       JcrUtils.logoutQuietly(session);
+               }
+       }
+
+       public String getLabel() {
+               return name;
+       }
+
+       public String toString() {
+               return getLabel();
+       }
+
+       public void dispose() {
+       }
+
+       public RepoElem getRepoElem() {
+               return repoElem;
+       }
+}
\ No newline at end of file
index 908aff571be7285c915bd833f9a09addec45e19c..29797590da0df61441370c91130e32961c9fd615 100644 (file)
@@ -43,7 +43,7 @@ import org.argeo.slc.client.ui.dist.controllers.DistTreeContentProvider;
 import org.argeo.slc.client.ui.dist.controllers.DistTreeDoubleClickListener;
 import org.argeo.slc.client.ui.dist.controllers.DistTreeLabelProvider;
 import org.argeo.slc.client.ui.dist.model.DistParentElem;
-import org.argeo.slc.client.ui.dist.model.GroupElem;
+import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
 import org.argeo.slc.client.ui.dist.model.RepoElem;
 import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
 import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
@@ -165,8 +165,8 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                                        isRepoElem = true;
                                        isHomeRepo = re.inHome();
                                        isReadOnly = re.isReadOnly();
-                               } else if (firstElement instanceof GroupElem) {
-                                       GroupElem dge = (GroupElem) firstElement;
+                               } else if (firstElement instanceof WkspGroupElem) {
+                                       WkspGroupElem dge = (WkspGroupElem) firstElement;
                                        isReadOnly = dge.isReadOnly();
                                        isDistribGroupElem = true;
                                        re = dge.getRepoElem();