+/*
+ * Copyright (C) 2007-2012 Mathieu Baudier
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.argeo.jcr.ui.explorer.model;
import java.util.Hashtable;
import org.argeo.eclipse.ui.TreeParent;
import org.argeo.jcr.ArgeoJcrConstants;
import org.argeo.jcr.ArgeoNames;
-import org.argeo.jcr.JcrUtils;
import org.argeo.jcr.RepositoryRegister;
-import org.argeo.jcr.security.JcrKeyring;
+import org.argeo.jcr.UserJcrUtils;
+import org.argeo.util.security.Keyring;
/**
* UI Tree component. Implements the Argeo abstraction of a
public class RepositoriesNode extends TreeParent implements ArgeoNames {
private final RepositoryRegister repositoryRegister;
+ private final RepositoryFactory repositoryFactory;
- private final JcrKeyring jcrKeyring;
+ /**
+ * A session of the logged in user on the default workspace of the node
+ * repository.
+ */
+ private final Session userSession;
+ private final Keyring keyring;
public RepositoriesNode(String name, RepositoryRegister repositoryRegister,
- TreeParent parent, JcrKeyring jcrKeyring) {
+ RepositoryFactory repositoryFactory, TreeParent parent,
+ Session userSession, Keyring keyring) {
super(name);
this.repositoryRegister = repositoryRegister;
- this.jcrKeyring = jcrKeyring;
+ this.repositoryFactory = repositoryFactory;
+ this.userSession = userSession;
+ this.keyring = keyring;
}
/**
}
// remote
- if (jcrKeyring != null) {
+ if (keyring != null) {
try {
- addRemoteRepositories(jcrKeyring);
+ addRemoteRepositories(keyring);
} catch (RepositoryException e) {
throw new ArgeoException(
"Cannot browse remote repositories", e);
}
}
- protected void addRemoteRepositories(JcrKeyring jcrKeyring)
+ protected void addRemoteRepositories(Keyring jcrKeyring)
throws RepositoryException {
- Session userSession = jcrKeyring.getSession();
- Node userHome = JcrUtils.getUserHome(userSession);
- if (userHome.hasNode(ARGEO_REMOTE)) {
+ Node userHome = UserJcrUtils.getUserHome(userSession);
+ if (userHome != null && userHome.hasNode(ARGEO_REMOTE)) {
NodeIterator it = userHome.getNode(ARGEO_REMOTE).getNodes();
while (it.hasNext()) {
Node remoteNode = it.nextNode();
String uri = remoteNode.getProperty(ARGEO_URI).getString();
try {
- Hashtable<String, String> params = new Hashtable<String, String>();
- params.put(ArgeoJcrConstants.JCR_REPOSITORY_URI, uri);
- params.put(ArgeoJcrConstants.JCR_REPOSITORY_ALIAS,
- remoteNode.getName());
- Repository repository = repositoryRegister
- .getRepository(params);
RemoteRepositoryNode remoteRepositoryNode = new RemoteRepositoryNode(
- remoteNode.getName(), repository, this, jcrKeyring,
- remoteNode.getPath());
+ remoteNode.getName(), repositoryFactory, uri, this,
+ userSession, jcrKeyring, remoteNode.getPath());
super.addChild(remoteRepositoryNode);
} catch (Exception e) {
ErrorFeedback.show("Cannot add remote repository "
// super.addChild(new RepositoriesNode(...));
}
- /** Returns the {@link RepositoryRegister} wrapped by thgis object. */
+ /** Returns the {@link RepositoryRegister} wrapped by this object. */
public RepositoryRegister getRepositoryRegister() {
return repositoryRegister;
}