]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/WkspGroupElem.java
1 package org
.argeo
.slc
.client
.ui
.dist
.model
;
3 import javax
.jcr
.RepositoryException
;
4 import javax
.jcr
.Session
;
6 import org
.argeo
.ArgeoException
;
7 import org
.argeo
.jcr
.JcrUtils
;
10 * Abstract set of similar workspaces, that is a bunch of workspaces with same
13 public class WkspGroupElem
extends DistParentElem
{
15 private Session defaultSession
;
17 public WkspGroupElem(RepoElem repoElem
, String prefix
) {
18 super(prefix
, repoElem
.inHome(), repoElem
.isReadOnly());
20 // Directly adds children upon creation
22 defaultSession
= repoElem
.repositoryLogin(null);
23 String
[] wkpNames
= defaultSession
.getWorkspace()
24 .getAccessibleWorkspaceNames();
25 for (String wkpName
: wkpNames
) {
26 if (prefix
.equals(getPrefix(wkpName
))
27 // if (wkpName.startsWith(prefix)
28 && repoElem
.isWorkspaceVisible(wkpName
))
29 addChild(new WorkspaceElem(WkspGroupElem
.this, repoElem
,
32 } catch (RepositoryException e
) {
33 throw new ArgeoException("Cannot retrieve workspace names", e
);
37 // FIXME - we rely on a "hard coded" convention : Workspace name must have
38 // this format: name-major.minor
39 // We might expose this method as static public, to be used among others by
40 // the RepoElem parent objects when building its children
41 private String
getPrefix(String workspaceName
) {
42 if (workspaceName
.lastIndexOf(VERSION_SEP
) > 0)
43 return workspaceName
.substring(0,
44 workspaceName
.lastIndexOf(VERSION_SEP
));
49 public void dispose() {
50 JcrUtils
.logoutQuietly(defaultSession
);