*/
package org.argeo.cms.ui.workbench;
-import org.argeo.cms.ui.workbench.useradmin.LogView;
+import org.argeo.cms.ui.workbench.jcr.NodeFsBrowserView;
import org.argeo.cms.ui.workbench.useradmin.UserProfile;
import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
layout.setEditorAreaVisible(true);
layout.setFixed(false);
- IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, 0.30f, editorArea);
+ IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, 0.40f, editorArea);
+ left.addView(NodeFsBrowserView.ID);
left.addView(UserProfile.ID);
- left.addView(LogView.ID);
+ // left.addView(LogView.ID);
}
}
import java.nio.file.spi.FileSystemProvider;
import org.argeo.cms.CmsException;
-import org.argeo.cms.auth.CurrentUser;
import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
import org.argeo.eclipse.ui.fs.SimpleFsBrowser;
-import org.argeo.node.NodeConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;
@Override
public void createPartControl(Composite parent) {
- if (CurrentUser.isInRole(NodeConstants.ROLE_ADMIN))
- try {
- URI uri = new URI("node:///home");
- FileSystem fileSystem = nodeFileSystemProvider.getFileSystem(uri);
- if (fileSystem == null)
- fileSystem = nodeFileSystemProvider.newFileSystem(uri, null);
- Path nodePath = fileSystem.getPath("/home");
- SimpleFsBrowser browser = new SimpleFsBrowser(parent, SWT.NO_FOCUS);
- browser.setInput(nodePath);
- } catch (Exception e) {
- throw new CmsException("Cannot open file system browser", e);
- }
+ try {
+ URI uri = new URI("node:///");
+ FileSystem fileSystem = nodeFileSystemProvider.getFileSystem(uri);
+ if (fileSystem == null)
+ fileSystem = nodeFileSystemProvider.newFileSystem(uri, null);
+ Path nodePath = fileSystem.getPath("~");
+ SimpleFsBrowser browser = new SimpleFsBrowser(parent, SWT.NO_FOCUS);
+ browser.setInput(nodePath);
+ } catch (Exception e) {
+ throw new CmsException("Cannot open file system browser", e);
+ }
}
@Override
import java.util.HashMap;
import java.util.Map;
+import javax.jcr.Node;
import javax.jcr.Repository;
import javax.jcr.Session;
import org.argeo.jcr.fs.JcrFileSystem;
import org.argeo.jcr.fs.JcrFsException;
import org.argeo.node.NodeConstants;
+import org.argeo.node.NodeUtils;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
String username = CurrentUser.getUsername();
return fileSystems.get(username);
}
+
+ public Node getUserHome(Session session) {
+ return NodeUtils.getUserHome(session);
+ }
}
}
try {
// TODO enhance transformation of cn to a valid node name
- String relPath = cn.replaceAll("[^a-zA-Z0-9]", "_");
+ // String relPath = cn.replaceAll("[^a-zA-Z0-9]", "_");
+ String relPath = JcrUtils.replaceInvalidChars(cn);
newWorkgroup = JcrUtils.mkdirs(adminSession.getNode(groupsBasePath), relPath, NodeType.NT_UNSTRUCTURED);
newWorkgroup.addMixin(NodeTypes.NODE_GROUP_HOME);
newWorkgroup.setProperty(NodeNames.LDAP_CN, cn);
adminSession.save();
- JcrUtils.addPrivilege(adminSession, newWorkgroup.getPath(), dn.toString(), Privilege.JCR_ALL);
+ JcrUtils.addPrivilege(adminSession, newWorkgroup.getPath(), dn.toString(), Privilege.JCR_READ);
adminSession.save();
} catch (RepositoryException e) {
throw new CmsException("Cannot create workgroup", e);
* http://www.day.com/specs/jcr/2.0/3_Repository_Model.html#3.2.2%20Local
* %20Names
*/
- public final static char[] INVALID_NAME_CHARACTERS = { '/', ':', '[', ']', '|', '*', /*
- * invalid XML chars :
- */
- '<', '>', '&' };
+ public final static char[] INVALID_NAME_CHARACTERS = { '/', ':', '[', ']', '|', '*', /* invalid for XML: */ '<',
+ '>', '&' };
/** Prevents instantiation */
private JcrUtils() {
return name;
}
- /**
- * Removes forbidden characters from a path, replacing them with '_'
- *
- * @deprecated use {@link #replaceInvalidChars(String)} instead
- */
- public static String removeForbiddenCharacters(String str) {
- return str.replace('[', '_').replace(']', '_').replace('/', '_').replace('*', '_');
-
- }
+// /**
+// * Removes forbidden characters from a path, replacing them with '_'
+// *
+// * @deprecated use {@link #replaceInvalidChars(String)} instead
+// */
+// public static String removeForbiddenCharacters(String str) {
+// return str.replace('[', '_').replace(']', '_').replace('/', '_').replace('*', '_');
+//
+// }
/** Cleanly disposes a {@link Binary} even if it is null. */
public static void closeQuietly(Binary binary) {
private FileTime EPOCH = FileTime.fromMillis(0);
public JcrBasicfileAttributes(Node node) {
+ if (node == null)
+ throw new JcrFsException("Node underlying the attributes cannot be null");
this.node = node;
}
import java.util.HashSet;
import java.util.Set;
+import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
public class JcrFileSystem extends FileSystem {
private final JcrFileSystemProvider provider;
private final Session session;
+ private String userHomePath = null;
public JcrFileSystem(JcrFileSystemProvider provider, Session session) {
super();
this.provider = provider;
this.session = session;
+ Node userHome = provider.getUserHome(session);
+ if (userHome != null)
+ try {
+ userHomePath = userHome.getPath();
+ } catch (RepositoryException e) {
+ throw new JcrFsException("Cannot retrieve user home path", e);
+ }
+ }
+
+ public String getUserHomePath() {
+ return userHomePath;
}
@Override
try {
// TODO check if assignable
Node node = toNode(path);
+ if(node==null) {
+ throw new JcrFsException("JCR node not found for "+path);
+ }
return (A) new JcrBasicfileAttributes(node);
} catch (RepositoryException e) {
throw new JcrFsException("Cannot read basic attributes of " + path, e);
return ((JcrPath) path).getNode();
}
+ /**
+ * To be overriden in order to support the ~ path, with an implementation
+ * specific concept of user home.
+ *
+ * @return null by default
+ */
+ public Node getUserHome(Session session) {
+ return null;
+ }
}
private final int hashCode;
public JcrPath(JcrFileSystem filesSystem, String path) {
- // this(filesSystem, path.equals("/") ? null : path.split("/"), path ==
- // null ? true : path.startsWith("/"));
this.fs = filesSystem;
if (path == null)
throw new JcrFsException("Path cannot be null");
this.hashCode = "".hashCode();
return;
}
+
+ if (path.equals("~")) {// home
+ path = filesSystem.getUserHomePath();
+ if (path == null)
+ throw new JcrFsException("No home directory available");
+ }
+
this.absolute = path.charAt(0) == delimChar ? true : false;
String trimmedPath = path.substring(absolute ? 1 : 0,
path.charAt(path.length() - 1) == delimChar ? path.length() - 1 : path.length());
nodes: while (nodeIterator.hasNext()) {
try {
Node node = nodeIterator.nextNode();
+ String nodeName = node.getName();
+ if (nodeName.startsWith("rep:") || nodeName.startsWith("jcr:"))
+ continue nodes;
next = new JcrPath(fs, node);
if (filter != null) {
if (filter.accept(next))