]>
git.argeo.org Git - gpl/argeo-slc.git/blob - GroupElem.java
8e9cef36d70b868961c63647cd6e4f0daa08fc14
1 package org
.argeo
.slc
.client
.ui
.dist
.model
;
3 import java
.security
.AccessControlException
;
4 import java
.util
.ArrayList
;
7 import javax
.jcr
.Repository
;
8 import javax
.jcr
.RepositoryException
;
9 import javax
.jcr
.Session
;
11 import org
.argeo
.jcr
.JcrUtils
;
12 import org
.argeo
.slc
.SlcException
;
15 * Abstracts a group of distribution, that is a bunch of workspaces with same
18 public class GroupElem
extends DistParentElem
{
19 private RepoElem repoElem
;
22 public GroupElem(RepoElem repoElem
, String prefix
) {
23 super(repoElem
.inHome(), repoElem
.isReadOnly());
24 this.repoElem
= repoElem
;
28 public Object
[] getChildren() {
29 Session session
= null;
31 Repository repository
= repoElem
.getRepository();
32 session
= repository
.login(repoElem
.getCredentials());
34 String
[] workspaceNames
= session
.getWorkspace()
35 .getAccessibleWorkspaceNames();
36 List
<WorkspaceElem
> distributionElems
= new ArrayList
<WorkspaceElem
>();
37 buildWksp
: for (String workspaceName
: workspaceNames
) {
39 // Filter non-public workspaces for user anonymous.
40 if (repoElem
.getRepoNode() == null) {
41 Session tmpSession
= null;
43 tmpSession
= repository
.login(workspaceName
);
46 tmpSession
.checkPermission("/", "read");
47 } catch (AccessControlException e
) {
52 } catch (RepositoryException e
) {
53 throw new SlcException(
54 "Cannot list workspaces for anonymous user", e
);
56 JcrUtils
.logoutQuietly(tmpSession
);
60 // filter technical workspaces
61 if (workspaceName
.startsWith(name
)) {
62 distributionElems
.add(new WorkspaceElem(repoElem
,
66 return distributionElems
.toArray();
67 } catch (RepositoryException e
) {
68 throw new SlcException("Cannot list workspaces for prefix " + name
,
71 JcrUtils
.logoutQuietly(session
);
75 public String
getLabel() {
79 public String
toString() {
83 public void dispose() {
86 public RepoElem
getRepoElem() {