incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r592325 - in /incubator/sling/trunk/content/src/main/java/org/apache/sling/content: ContentManager.java jcr/internal/mapping/ContentManagerImpl.java
Date Tue, 06 Nov 2007 08:13:42 GMT
Author: fmeschbe
Date: Tue Nov  6 00:13:41 2007
New Revision: 592325

URL: http://svn.apache.org/viewvc?rev=592325&view=rev
Log:
Better API for Content creation

Modified:
    incubator/sling/trunk/content/src/main/java/org/apache/sling/content/ContentManager.java
    incubator/sling/trunk/content/src/main/java/org/apache/sling/content/jcr/internal/mapping/ContentManagerImpl.java

Modified: incubator/sling/trunk/content/src/main/java/org/apache/sling/content/ContentManager.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/content/src/main/java/org/apache/sling/content/ContentManager.java?rev=592325&r1=592324&r2=592325&view=diff
==============================================================================
--- incubator/sling/trunk/content/src/main/java/org/apache/sling/content/ContentManager.java
(original)
+++ incubator/sling/trunk/content/src/main/java/org/apache/sling/content/ContentManager.java
Tue Nov  6 00:13:41 2007
@@ -18,8 +18,6 @@
  */
 package org.apache.sling.content;
 
-import java.util.Map;
-
 import org.apache.sling.component.Content;
 
 /**
@@ -46,7 +44,8 @@
 
     // Content related operations
 
-    Content create(String path, Class objectClass, Map properties);
+    // store the content object at the location set in the path field
+    void create(Content content);
 
     /**
      * Returns a <code>Content</code> object loaded from the repository node

Modified: incubator/sling/trunk/content/src/main/java/org/apache/sling/content/jcr/internal/mapping/ContentManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/content/src/main/java/org/apache/sling/content/jcr/internal/mapping/ContentManagerImpl.java?rev=592325&r1=592324&r2=592325&view=diff
==============================================================================
--- incubator/sling/trunk/content/src/main/java/org/apache/sling/content/jcr/internal/mapping/ContentManagerImpl.java
(original)
+++ incubator/sling/trunk/content/src/main/java/org/apache/sling/content/jcr/internal/mapping/ContentManagerImpl.java
Tue Nov  6 00:13:41 2007
@@ -18,9 +18,7 @@
  */
 package org.apache.sling.content.jcr.internal.mapping;
 
-import java.security.AccessControlException;
 import java.util.Iterator;
-import java.util.Map;
 import java.util.NoSuchElementException;
 
 import javax.jcr.Node;
@@ -159,38 +157,16 @@
     }
 
     /**
-     * @see org.apache.sling.core.content.ContentManager#create(java.lang.String, java.lang.Class,
java.util.Map)
+     * @see org.apache.sling.content.ContentManager#create(org.apache.sling.component.Content)
      */
-    public Content create(String path, Class objectClass, Map properties) {
-        this.checkPermission(path, ACTION_CREATE);
-
-        try {
-            // create content
-            Content content = (Content) objectClass.newInstance();
-
-            // set the path on the content object
-            this.setPath(content, path);
+    public void create(Content content) {
+        String path = content.getPath();
 
-            // set initial properties
-            if (properties != null) {
-                for (Iterator pi = properties.entrySet().iterator(); pi.hasNext();) {
-                    Map.Entry prop = (Map.Entry) pi.next();
-                    if (prop.getKey() instanceof String) {
-                        ReflectionUtils.setNestedProperty(content,
-                            (String) prop.getKey(), prop.getValue());
-                    }
-                }
-            }
+        this.checkPermission(path, ACTION_CREATE);
 
-            this.insert(content);
-            this.conditionalSave();
-            return content;
-        } catch (IllegalAccessException iae) {
-        } catch (InstantiationException ie) {
-        } catch (ExceptionInInitializerError eiie) {
-            // TODO: handle
-        }
-        return null;
+        // TODO handle exceptions correctly
+        this.insert(content);
+        this.conditionalSave();
     }
 
     /**



Mime
View raw message