]>
git.argeo.org Git - gpl/argeo-slc.git/blob - plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/WorkspaceElem.java
1 package org
.argeo
.slc
.client
.ui
.dist
.model
;
3 import javax
.jcr
.NodeIterator
;
4 import javax
.jcr
.RepositoryException
;
5 import javax
.jcr
.Session
;
6 import javax
.jcr
.query
.Query
;
8 import org
.argeo
.ArgeoException
;
9 import org
.argeo
.jcr
.JcrUtils
;
10 import org
.argeo
.slc
.jcr
.SlcNames
;
11 import org
.argeo
.slc
.jcr
.SlcTypes
;
13 /** Abstract a workspace that contains a software distribution */
14 public class WorkspaceElem
extends DistParentElem
{
15 private final RepoElem repoElem
;
16 private String workspaceName
;
17 private Session defaultSession
;
19 public WorkspaceElem(WkspGroupElem parent
, RepoElem repoElem
,
20 String workspaceName
) {
21 super(workspaceName
, repoElem
.inHome(), repoElem
.isReadOnly());
22 this.repoElem
= repoElem
;
23 this.workspaceName
= workspaceName
;
27 public String
getWorkspaceName() {
31 public RepoElem
getRepoElem() {
35 public Boolean
isConnected() {
36 if (defaultSession
!= null && defaultSession
.isLive())
43 defaultSession
= repoElem
.repositoryLogin(getName());
46 public boolean hasChildren() {
49 return defaultSession
.getRootNode().hasNodes();
52 } catch (RepositoryException re
) {
53 throw new ArgeoException(
54 "Unexpected error while checking children node existence",
59 /** Override normal behaviour to initialize display of the workspace */
61 public synchronized Object
[] getChildren() {
63 return super.getChildren();
65 // initialize current object
67 if (defaultSession
== null)
70 Query groupQuery
= defaultSession
74 "select * from [" + SlcTypes
.SLC_GROUP_BASE
75 + "] as group order by group.["
76 + SlcNames
.SLC_GROUP_BASE_ID
+ "]",
78 NodeIterator groups
= groupQuery
.execute().getNodes();
79 while (groups
.hasNext()) {
80 addChild(new GroupBaseElem(WorkspaceElem
.this, groups
82 .getProperty(SlcNames
.SLC_GROUP_BASE_ID
)
86 return super.getChildren();
87 } catch (RepositoryException e
) {
88 throw new ArgeoException(
89 "Cannot initialize WorkspaceNode UI object."
96 public synchronized void dispose() {
97 JcrUtils
.logoutQuietly(defaultSession
);