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;
return 2;
else
return 5;
- else if (element instanceof GroupElem)
+ else if (element instanceof WkspGroupElem)
return 10;
else if (element instanceof WorkspaceElem)
return 15;
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;
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())
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 = '-';
--- /dev/null
+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
+++ /dev/null
-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;
- }
-
-}
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 {
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
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));
}
}
--- /dev/null
+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
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;
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();