incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1061701 - in /sling/trunk/installer/core/src/main/java/org/apache/sling/installer: api/tasks/TransformationResult.java core/impl/DefaultTransformer.java core/impl/PersistentResourceList.java
Date Fri, 21 Jan 2011 09:21:23 GMT
Author: cziegeler
Date: Fri Jan 21 09:21:22 2011
New Revision: 1061701

URL: http://svn.apache.org/viewvc?rev=1061701&view=rev
Log:
SLING-1944 : Check result from resource transformer

Modified:
    sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/tasks/TransformationResult.java
    sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/DefaultTransformer.java
    sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java

Modified: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/tasks/TransformationResult.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/tasks/TransformationResult.java?rev=1061701&r1=1061700&r2=1061701&view=diff
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/tasks/TransformationResult.java
(original)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/api/tasks/TransformationResult.java
Fri Jan 21 09:21:22 2011
@@ -23,6 +23,13 @@ import java.util.Map;
 
 /**
  * A result of a {@link ResourceTransformer}.
+ *
+ * In most cases the new transformation result just contains new
+ * content (provided through {@link #getInputStream()}.
+ *
+ * However, if the transformer is able to detect the new resource
+ * type and sets it, it must also provide a unique id (
+ * {@link #getResourceType()} and {@link #getId()}.
  */
 public class TransformationResult {
 

Modified: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/DefaultTransformer.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/DefaultTransformer.java?rev=1061701&r1=1061700&r2=1061701&view=diff
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/DefaultTransformer.java
(original)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/DefaultTransformer.java
Fri Jan 21 09:21:22 2011
@@ -44,7 +44,7 @@ public class DefaultTransformer
     /**
      * @see org.apache.sling.installer.core.impl.InternalService#init(org.osgi.framework.BundleContext)
      */
-    public void init(BundleContext bctx) {
+    public void init(final BundleContext bctx) {
         // nothing to do
     }
 

Modified: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java?rev=1061701&r1=1061700&r2=1061701&view=diff
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java
(original)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java
Fri Jan 21 09:21:22 2011
@@ -256,6 +256,17 @@ public class PersistentResourceList {
         this.untransformedResources.remove(resource);
         try {
             for(int i=0; i<result.length; i++) {
+                // check the result
+                final TransformationResult tr = result[i];
+                if ( tr == null ) {
+                    logger.warn("Ignoring null result for {}", resource);
+                    continue;
+                }
+                if ( tr.getResourceType() != null && tr.getId() == null) {
+                    logger.error("Result for {} contains new resource type {} but no unique
id!",
+                            resource, tr.getResourceType());
+                    continue;
+                }
                 final TaskResource clone =  ((RegisteredResourceImpl)resource).clone(result[i]);
                 this.checkInstallable(clone);
             }



Mime
View raw message