X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=org.argeo.cms.ui.workbench%2Fsrc%2Forg%2Fargeo%2Fcms%2Fui%2Fworkbench%2Finternal%2Fjcr%2Fmodel%2FRepositoryElem.java;fp=org.argeo.cms.ui.workbench%2Fsrc%2Forg%2Fargeo%2Fcms%2Fui%2Fworkbench%2Finternal%2Fjcr%2Fmodel%2FRepositoryElem.java;h=116aeeeb52bd4944224e0a6e5429a8ca417e5773;hb=95215042df996ee0658c04a38fa6099c1e03cc56;hp=118ab23febee05cbf0ddc3c03724eb71ae82400a;hpb=9a6babc07d80c6aa8c10adc12f40f84eef3619c5;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/model/RepositoryElem.java b/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/model/RepositoryElem.java index 118ab23fe..116aeeeb5 100644 --- a/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/model/RepositoryElem.java +++ b/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/model/RepositoryElem.java @@ -21,11 +21,13 @@ import javax.jcr.Session; import org.argeo.eclipse.ui.EclipseUiException; import org.argeo.eclipse.ui.TreeParent; +import org.argeo.jcr.JcrUtils; /** - * UI Tree component that wraps a JCR {@link Repository}. It also keeps a reference - * to its parent Tree Ui component; typically the unique {@link RepositoriesElem} - * object of the current view to enable bi-directionnal browsing in the tree. + * UI Tree component that wraps a JCR {@link Repository}. It also keeps a + * reference to its parent Tree Ui component; typically the unique + * {@link RepositoriesElem} object of the current view to enable bi-directionnal + * browsing in the tree. */ public class RepositoryElem extends TreeParent { @@ -44,8 +46,7 @@ public class RepositoryElem extends TreeParent { public void login() { try { defaultSession = repositoryLogin("main"); - String[] wkpNames = defaultSession.getWorkspace() - .getAccessibleWorkspaceNames(); + String[] wkpNames = defaultSession.getWorkspace().getAccessibleWorkspaceNames(); for (String wkpName : wkpNames) { if (wkpName.equals(defaultSession.getWorkspace().getName())) addChild(new WorkspaceElem(this, wkpName, defaultSession)); @@ -57,13 +58,21 @@ public class RepositoryElem extends TreeParent { } } + public synchronized void logout() { + for (Object child : getChildren()) { + if (child instanceof WorkspaceElem) + ((WorkspaceElem) child).logout(); + } + clearChildren(); + JcrUtils.logoutQuietly(defaultSession); + defaultSession = null; + } + /** - * Actual call to the - * {@link Repository#login(javax.jcr.Credentials, String)} method. To be - * overridden. + * Actual call to the {@link Repository#login(javax.jcr.Credentials, String)} + * method. To be overridden. */ - protected Session repositoryLogin(String workspaceName) - throws RepositoryException { + protected Session repositoryLogin(String workspaceName) throws RepositoryException { return repository.login(workspaceName); }