import javax.jcr.RepositoryFactory;
import javax.jcr.Session;
-import org.argeo.jcr.ArgeoJcrUtils;
-import org.argeo.jcr.ArgeoNames;
+import org.argeo.api.NodeUtils;
+import org.argeo.api.security.Keyring;
+import org.argeo.cms.ArgeoNames;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
import org.argeo.slc.repo.RepoConstants;
import org.argeo.slc.repo.RepoUtils;
-import org.argeo.util.security.Keyring;
/**
* Abstract a repository. It might be persisted by a node in the current user
* initialisation
*
*/
- public RepoElem(RepositoryFactory repoFactory, Keyring keyring,
- Node repoNode, String alias) {
+ public RepoElem(RepositoryFactory repoFactory, Keyring keyring, Node repoNode, String alias) {
super(alias);
this.label = alias;
// label = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
this.keyring = keyring;
try {
// Initialize this repo information
- setInHome(RepoConstants.DEFAULT_JAVA_REPOSITORY_ALIAS
- .equals(repoNode.getName()));
+ setInHome(RepoConstants.DEFAULT_JAVA_REPOSITORY_ALIAS.equals(repoNode.getName()));
if (inHome())
// Directly log and retrieve children for local repository
login();
if (repository == null)
if (repoNode == null)
// Anonymous
- repository = ArgeoJcrUtils.getRepositoryByUri(
- repositoryFactory, uri);
+ repository = NodeUtils.getRepositoryByUri(repositoryFactory, uri);
else {
- repository = RepoUtils.getRepository(repositoryFactory,
- keyring, repoNode);
- credentials = RepoUtils.getRepositoryCredentials(keyring,
- repoNode);
+ repository = RepoUtils.getRepository(repositoryFactory, keyring, repoNode);
+ credentials = RepoUtils.getRepositoryCredentials(keyring, repoNode);
}
try {
- defaultSession = repository.login(credentials);
+ // FIXME make it more generic
+ String defaultWorkspace = "main";
+ defaultSession = repository.login(credentials, defaultWorkspace);
refreshChildren();
} catch (RepositoryException e) {
- throw new SlcException("Cannot login repository " + label
- + " with credential " + credentials, e);
+ throw new SlcException("Cannot login repository " + label + " with credential " + credentials, e);
}
}
protected void refreshChildren() {
try {
// TODO also remove deleted children (only adds for the time being
- String[] workspaceNames = defaultSession.getWorkspace()
- .getAccessibleWorkspaceNames();
+ String[] workspaceNames = defaultSession.getWorkspace().getAccessibleWorkspaceNames();
buildWksp: for (String workspaceName : workspaceNames) {
if (!isWorkspaceVisible(workspaceName))
continue buildWksp;
String prefix = getPrefix(workspaceName);
if (getChildByName(prefix) == null) {
- WkspGroupElem wkspGpElem = new WkspGroupElem(RepoElem.this,
- prefix);
+ WkspGroupElem wkspGpElem = new WkspGroupElem(RepoElem.this, prefix);
addChild(wkspGpElem);
}
}
// Here is the tricks - we rely on a "hard coded" convention
// Workspace name should be like: name-major.minor
if (workspaceName.lastIndexOf(VERSION_SEP) > 0)
- return workspaceName.substring(0,
- workspaceName.lastIndexOf(VERSION_SEP));
+ return workspaceName.substring(0, workspaceName.lastIndexOf(VERSION_SEP));
else
return workspaceName;
}
result = false;
}
} catch (RepositoryException e) {
- throw new SlcException(
- "Cannot list workspaces for anonymous user", e);
+ throw new SlcException("Cannot list workspaces for anonymous user", e);
} finally {
JcrUtils.logoutQuietly(tmpSession);
}
*/
protected Session repositoryLogin(String workspaceName) {
try {
+ if (workspaceName == null)
+ workspaceName = "main";// FIXME make it more generic
return repository.login(credentials, workspaceName);
} catch (RepositoryException e) {
- throw new SlcException("Cannot login repository " + label
- + " with credential " + credentials, e);
+ throw new SlcException("Cannot login repository " + label + " with credential " + credentials, e);
}
}
try {
return repoNode.getPath();
} catch (RepositoryException e) {
- throw new SlcException("Cannot get node path for repository "
- + label, e);
+ throw new SlcException("Cannot get node path for repository " + label, e);
}
}