[dna-commits] DNA SVN: r657 - in trunk: extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem and 1 other directory.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Thu Dec 4 18:03:08 EST 2008


Author: rhauch
Date: 2008-12-04 18:03:08 -0500 (Thu, 04 Dec 2008)
New Revision: 657

Added:
   trunk/dna-graph/src/main/java/org/jboss/dna/graph/JcrMixLexicon.java
Modified:
   trunk/dna-graph/src/main/java/org/jboss/dna/graph/JcrLexicon.java
   trunk/dna-graph/src/main/java/org/jboss/dna/graph/JcrNtLexicon.java
   trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRequestProcessor.java
Log:
DNA-34  - Federate content stored on file system

Added a few more pieces of the implementation.  Still need to address determining mime types, binary values (see DNA-260), and unit tests.

Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/JcrLexicon.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/JcrLexicon.java	2008-12-04 21:36:58 UTC (rev 656)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/JcrLexicon.java	2008-12-04 23:03:08 UTC (rev 657)
@@ -37,5 +37,11 @@
     public static final Name UUID = new BasicName(Namespace.URI, "uuid");
     public static final Name NAME = new BasicName(Namespace.URI, "name");
     public static final Name PRIMARY_TYPE = new BasicName(Namespace.URI, "primaryType");
+    public static final Name MIXIN_TYPES = new BasicName(Namespace.URI, "mixinTypes");
     public static final Name CONTENT = new BasicName(Namespace.URI, "content");
+    public static final Name CREATED = new BasicName(Namespace.URI, "created");
+    public static final Name ENCODED = new BasicName(Namespace.URI, "encoded");
+    public static final Name MIMETYPE = new BasicName(Namespace.URI, "mimeType");
+    public static final Name DATA = new BasicName(Namespace.URI, "data");
+    public static final Name LAST_MODIFIED = new BasicName(Namespace.URI, "lastModified");
 }

Added: trunk/dna-graph/src/main/java/org/jboss/dna/graph/JcrMixLexicon.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/JcrMixLexicon.java	                        (rev 0)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/JcrMixLexicon.java	2008-12-04 23:03:08 UTC (rev 657)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.graph;
+
+import org.jboss.dna.graph.properties.Name;
+import org.jboss.dna.graph.properties.basic.BasicName;
+
+/**
+ * @author Randall Hauch
+ */
+public class JcrMixLexicon {
+
+    public static class Namespace {
+        public static final String URI = "http://www.jcp.org/jcr/mix/1.0";
+        public static final String PREFIX = "mix";
+    }
+
+    public static final Name REFERENCEABLE = new BasicName(Namespace.URI, "referenceable");
+    public static final Name VERSIONABLE = new BasicName(Namespace.URI, "versionable");
+    public static final Name LOCKABLE = new BasicName(Namespace.URI, "lockable");
+}


Property changes on: trunk/dna-graph/src/main/java/org/jboss/dna/graph/JcrMixLexicon.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/JcrNtLexicon.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/JcrNtLexicon.java	2008-12-04 21:36:58 UTC (rev 656)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/JcrNtLexicon.java	2008-12-04 23:03:08 UTC (rev 657)
@@ -38,4 +38,5 @@
     public static final Name FILE = new BasicName(Namespace.URI, "file");
     public static final Name FOLDER = new BasicName(Namespace.URI, "folder");
     public static final Name RESOURCE = new BasicName(Namespace.URI, "resource");
+    public static final Name BASE = new BasicName(Namespace.URI, "base");
 }

Modified: trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRequestProcessor.java
===================================================================
--- trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRequestProcessor.java	2008-12-04 21:36:58 UTC (rev 656)
+++ trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRequestProcessor.java	2008-12-04 23:03:08 UTC (rev 657)
@@ -27,13 +27,16 @@
 import org.jboss.dna.common.i18n.I18n;
 import org.jboss.dna.graph.ExecutionContext;
 import org.jboss.dna.graph.JcrLexicon;
+import org.jboss.dna.graph.JcrNtLexicon;
 import org.jboss.dna.graph.Location;
 import org.jboss.dna.graph.connectors.RepositorySourceException;
+import org.jboss.dna.graph.properties.DateTimeFactory;
 import org.jboss.dna.graph.properties.Name;
 import org.jboss.dna.graph.properties.NameFactory;
 import org.jboss.dna.graph.properties.Path;
 import org.jboss.dna.graph.properties.PathFactory;
 import org.jboss.dna.graph.properties.PathNotFoundException;
+import org.jboss.dna.graph.properties.PropertyFactory;
 import org.jboss.dna.graph.requests.CopyBranchRequest;
 import org.jboss.dna.graph.requests.CreateNodeRequest;
 import org.jboss.dna.graph.requests.DeleteBranchRequest;
@@ -139,17 +142,36 @@
         }
 
         // Get the java.io.File object that represents the location ...
-        File parent = getExistingFileFor(path, location, request);
-        if (parent.isDirectory()) {
+        File file = getExistingFileFor(path, location, request);
+        PropertyFactory factory = getExecutionContext().getPropertyFactory();
+        DateTimeFactory dateFactory = getExecutionContext().getValueFactories().getDateFactory();
+        // Note that we don't have 'created' timestamps, just last modified, so we'll have to use them
+        if (file.isDirectory()) {
             // Add properties for the directory ...
+            request.addProperty(factory.create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.FOLDER));
+            request.addProperty(factory.create(JcrLexicon.CREATED, dateFactory.create(file.lastModified())));
 
         } else {
             // It is a file, but ...
             if (path.getLastSegment().getName().equals(JcrLexicon.CONTENT)) {
                 // The request is to get properties of the "jcr:content" child node ...
+                request.addProperty(factory.create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.RESOURCE));
+                request.addProperty(factory.create(JcrLexicon.LAST_MODIFIED, dateFactory.create(file.lastModified())));
+                // Don't really know the encoding, either ...
+                // request.addProperty(factory.create(JcrLexicon.ENCODED, stringFactory.create("UTF-8")));
 
+                // Discover the mime type ...
+                // String mimeType = ...
+                // request.addProperty(factory.create(JcrLexicon.MIMETYPE, mimeType));
+
+                // Now put the file's content into the "jcr:data" property ...
+                // BinaryFactory binaryFactory = getExecutionContext().getValueFactories().getBinaryFactory();
+                // request.addProperty(factory.create(JcrLexicon.DATA, binaryFactory.create(file)));
+
             } else {
                 // The request is to get properties for the node representing the file
+                request.addProperty(factory.create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.FILE));
+                request.addProperty(factory.create(JcrLexicon.CREATED, dateFactory.create(file.lastModified())));
             }
 
         }




More information about the dna-commits mailing list