sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpet...@apache.org
Subject svn commit: r1637123 - in /sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication: agent/impl/ component/impl/ resources/impl/ serialization/impl/
Date Thu, 06 Nov 2014 14:40:49 GMT
Author: mpetria
Date: Thu Nov  6 14:40:49 2014
New Revision: 1637123

URL: http://svn.apache.org/r1637123
Log:
SLING-4106: adding some logging for config and agent creation

Modified:
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/CoordinatingReplicationAgentFactory.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgent.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentFactory.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/GenericReplicationComponentFactory.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/resources/impl/OsgiConfigurationResourceProvider.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/resources/impl/OsgiUtils.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/ResourceSharedReplicationPackage.java
    sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/ResourceSharedReplicationPackageBuilder.java

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/CoordinatingReplicationAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/CoordinatingReplicationAgentFactory.java?rev=1637123&r1=1637122&r2=1637123&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/CoordinatingReplicationAgentFactory.java
(original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/CoordinatingReplicationAgentFactory.java
Thu Nov  6 14:40:49 2014
@@ -44,6 +44,7 @@ import org.apache.sling.replication.queu
 import org.apache.sling.replication.queue.ReplicationQueueProvider;
 import org.apache.sling.replication.queue.impl.SingleQueueDistributionStrategy;
 import org.apache.sling.replication.queue.impl.jobhandling.JobHandlingReplicationQueueProvider;
+import org.apache.sling.replication.resources.impl.OsgiUtils;
 import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
 import org.apache.sling.settings.SlingSettingsService;
 import org.osgi.framework.BundleContext;
@@ -120,6 +121,8 @@ public class CoordinatingReplicationAgen
 
     @Activate
     protected void activate(BundleContext context, Map<String, Object> config) {
+        log.info("activating with config {}", OsgiUtils.osgiPropertyMapToString(config));
+
 
         savedContext = context;
         // inject configuration

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgent.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgent.java?rev=1637123&r1=1637122&r2=1637123&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgent.java
(original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgent.java
Thu Nov  6 14:40:49 2014
@@ -283,7 +283,8 @@ public class SimpleReplicationAgent impl
                 }
                 success = true;
             } else {
-                log.warn("replication package with id {} does not exist", queueItem.getId());
+                success = true; // return success if package does not exist in order to clear
the queue.
+                log.error("replication package with id {} does not exist", queueItem.getId());
             }
 
         } catch (ReplicationPackageImportException e) {

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentFactory.java?rev=1637123&r1=1637122&r2=1637123&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentFactory.java
(original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentFactory.java
Thu Nov  6 14:40:49 2014
@@ -43,6 +43,7 @@ import org.apache.sling.replication.queu
 import org.apache.sling.replication.queue.ReplicationQueueProvider;
 import org.apache.sling.replication.queue.impl.SingleQueueDistributionStrategy;
 import org.apache.sling.replication.queue.impl.jobhandling.JobHandlingReplicationQueueProvider;
+import org.apache.sling.replication.resources.impl.OsgiUtils;
 import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
 import org.apache.sling.settings.SlingSettingsService;
 import org.osgi.framework.BundleContext;
@@ -119,6 +120,8 @@ public class SimpleReplicationAgentFacto
 
     @Activate
     protected void activate(BundleContext context, Map<String, Object> config) {
+        log.info("activating with config {}", OsgiUtils.osgiPropertyMapToString(config));
+
 
         savedContext = context;
         savedConfig = config;

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/GenericReplicationComponentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/GenericReplicationComponentFactory.java?rev=1637123&r1=1637122&r2=1637123&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/GenericReplicationComponentFactory.java
(original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/component/impl/GenericReplicationComponentFactory.java
Thu Nov  6 14:40:49 2014
@@ -39,6 +39,7 @@ import org.apache.sling.replication.comp
 import org.apache.sling.replication.component.ReplicationComponent;
 import org.apache.sling.replication.component.ReplicationComponentFactory;
 import org.apache.sling.replication.component.ReplicationComponentProvider;
+import org.apache.sling.replication.resources.impl.OsgiUtils;
 import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
 import org.apache.sling.replication.trigger.ReplicationTrigger;
 import org.apache.sling.settings.SlingSettingsService;
@@ -91,7 +92,7 @@ public class GenericReplicationComponent
 
     @Activate
     protected void activate(BundleContext context, Map<String, Object> config) {
-        log.debug("activating component with config {}", config);
+        log.debug("activating with config {}", OsgiUtils.osgiPropertyMapToString(config));
 
         savedContext = context;
         savedConfig = config;

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/resources/impl/OsgiConfigurationResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/resources/impl/OsgiConfigurationResourceProvider.java?rev=1637123&r1=1637122&r2=1637123&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/resources/impl/OsgiConfigurationResourceProvider.java
(original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/resources/impl/OsgiConfigurationResourceProvider.java
Thu Nov  6 14:40:49 2014
@@ -41,6 +41,8 @@ import org.apache.sling.replication.reso
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * {@link ResourceProvider} for Osgi configurations for a specific configuration factory.
@@ -49,6 +51,8 @@ import org.osgi.service.cm.Configuration
  */
 public class OsgiConfigurationResourceProvider extends AbstractModifyingResourceProvider
implements ResourceProvider, ModifyingResourceProvider {
 
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
     private final ConfigurationAdmin configurationAdmin;
     private final String configFactory;
     private final String friendlyNameProperty;
@@ -83,6 +87,9 @@ public class OsgiConfigurationResourcePr
                 }
 
                 properties = filterBeforeSave(properties);
+
+                log.info("updating with config {}", OsgiUtils.osgiPropertyMapToString(properties));
+
                 configuration.update(toDictionary(properties));
             }
 
@@ -148,6 +155,9 @@ public class OsgiConfigurationResourcePr
         Configuration[] configurations = getConfigurations(configName);
 
         if (configurations == null || configurations.length != 1) {
+            if (configurations != null && configurations.length > 1) {
+                log.warn("found more than 1 ({}) configuration with name {}", configurations.length,
configName);
+            }
             return null;
         }
 
@@ -225,7 +235,6 @@ public class OsgiConfigurationResourcePr
         }
 
         return result;
-
     }
 
     private Map<String, Object> filterBeforeRead(Map<String, Object> properties)
{

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/resources/impl/OsgiUtils.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/resources/impl/OsgiUtils.java?rev=1637123&r1=1637122&r2=1637123&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/resources/impl/OsgiUtils.java
(original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/resources/impl/OsgiUtils.java
Thu Nov  6 14:40:49 2014
@@ -18,6 +18,8 @@
  */
 package org.apache.sling.replication.resources.impl;
 
+import java.util.Map;
+
 public class OsgiUtils {
     /**
      * Encode the value for the ldap filter: \, *, (, and ) should be escaped.
@@ -28,4 +30,36 @@ public class OsgiUtils {
                 .replace("(", "\\(")
                 .replace(")", "\\)");
     }
+
+    public static String osgiPropertyMapToString(Map<String, Object> map) {
+        String result = "";
+        if (map == null) {
+            return result;
+        }
+
+        for (Map.Entry<String, Object> entry : map.entrySet()) {
+            result += entry.getKey() + "=";
+
+            if (entry.getValue() == null) {
+                result += safeString(entry.getValue());
+            }
+            else if (entry.getValue().getClass().isArray()) {
+                Object[] array = (Object[]) entry.getValue();
+                for (Object obj : array) {
+                    result += safeString(obj) + ",";
+                }
+            }
+            else {
+                result += safeString(entry.getValue());
+            }
+
+            result += "\n";
+        }
+
+        return result;
+    }
+
+    private static String safeString(Object obj) {
+        return obj == null? "null" : obj.toString();
+    }
 }

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/ResourceSharedReplicationPackage.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/ResourceSharedReplicationPackage.java?rev=1637123&r1=1637122&r2=1637123&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/ResourceSharedReplicationPackage.java
(original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/ResourceSharedReplicationPackage.java
Thu Nov  6 14:40:49 2014
@@ -165,7 +165,7 @@ public class ResourceSharedReplicationPa
             return;
         }
 
-        resourceResolver.create(holderRoot, holderName, Collections.singletonMap(ResourceResolver.PROPERTY_RESOURCE_TYPE,
(Object) "nt:unstructured"));
+        resourceResolver.create(holderRoot, holderName, Collections.singletonMap(ResourceResolver.PROPERTY_RESOURCE_TYPE,
(Object) "sling:Folder"));
         resourceResolver.commit();
 
     }

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/ResourceSharedReplicationPackageBuilder.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/ResourceSharedReplicationPackageBuilder.java?rev=1637123&r1=1637122&r2=1637123&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/ResourceSharedReplicationPackageBuilder.java
(original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/ResourceSharedReplicationPackageBuilder.java
Thu Nov  6 14:40:49 2014
@@ -119,13 +119,13 @@ public class ResourceSharedReplicationPa
         properties.put(PN_ORIGINAL_ACTION, replicationPackage.getAction());
         properties.put(PN_ORIGINAL_PATHS, replicationPackage.getPaths());
 
-        Resource resource = ResourceUtil.getOrCreateResource(resourceResolver, packagePath,
"nt:unstructured", "sling:Folder", false);
+        Resource resource = ResourceUtil.getOrCreateResource(resourceResolver, packagePath,
"sling:Folder", "sling:Folder", false);
 
         ModifiableValueMap valueMap = resource.adaptTo(ModifiableValueMap.class);
         valueMap.putAll(properties);
 
         resourceResolver.create(resource, ResourceSharedReplicationPackage.REFERENCE_ROOT_NODE,
-                Collections.singletonMap(ResourceResolver.PROPERTY_RESOURCE_TYPE, (Object)"nt:unstructured"));
+                Collections.singletonMap(ResourceResolver.PROPERTY_RESOURCE_TYPE, (Object)"sling:Folder"));
 
         resourceResolver.commit();
         return packagePath;



Mime
View raw message