sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1617276 - in /sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication: agent/impl/SimpleReplicationAgent.java serialization/impl/vlt/FileVaultReplicationPackageBuilder.java
Date Mon, 11 Aug 2014 13:30:46 GMT
Author: tommaso
Date: Mon Aug 11 13:30:46 2014
New Revision: 1617276

URL: http://svn.apache.org/r1617276
Log:
SLING-3833 - applied Marius Petria's patch for cleaning up ReplicationAgent interface

Modified:
    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/serialization/impl/vlt/FileVaultReplicationPackageBuilder.java

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=1617276&r1=1617275&r2=1617276&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
Mon Aug 11 13:30:46 2014
@@ -190,7 +190,9 @@ public class SimpleReplicationAgent impl
 
 
     public void enable() {
-        log.info("enabling agent");
+        if (log.isInfoEnabled()) {
+            log.info("enabling agent");
+        }
         // apply rules if any
         if (rules.length > 0) {
             ruleEngine.applyRules(this, rules);
@@ -202,7 +204,9 @@ public class SimpleReplicationAgent impl
     }
 
     public void disable() {
-        log.info("disabling agent");
+        if (log.isInfoEnabled()) {
+            log.info("disabling agent");
+        }
         if (rules != null) {
             ruleEngine.unapplyRules(this, rules);
         }
@@ -213,21 +217,30 @@ public class SimpleReplicationAgent impl
     }
 
     private boolean processTransportQueue(ReplicationQueueItem queueItem) {
-        log.debug("reading package from id {}", queueItem.getId());
+        boolean success = false;
+        if (log.isDebugEnabled()) {
+            log.debug("reading package with id {}", queueItem.getId());
+        }
         try {
             ReplicationPackage replicationPackage = replicationPackageExporter.exportPackageById(queueItem.getId());
-            replicationPackageImporter.importPackage(replicationPackage);
-            replicationPackage.delete();
-            return true;
+            if (replicationPackage != null) {
+                replicationPackageImporter.importPackage(replicationPackage);
+                replicationPackage.delete();
+                success = true;
+            }
         } catch (ReplicationPackageReadingException e) {
-            return false;
+            if (log.isErrorEnabled()) {
+                log.error("could not process transport queue", e);
+            }
         }
+        return success;
     }
 
     class PackageQueueProcessor implements ReplicationQueueProcessor {
         public boolean process(String queueName, ReplicationQueueItem packageInfo) {
-            log.info("running package queue processor");
-
+            if (log.isInfoEnabled()) {
+                log.info("running package queue processor");
+            }
             return processTransportQueue(packageInfo);
         }
     }

Modified: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/vlt/FileVaultReplicationPackageBuilder.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/vlt/FileVaultReplicationPackageBuilder.java?rev=1617276&r1=1617275&r2=1617276&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/vlt/FileVaultReplicationPackageBuilder.java
(original)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/serialization/impl/vlt/FileVaultReplicationPackageBuilder.java
Mon Aug 11 13:30:46 2014
@@ -174,10 +174,11 @@ public class FileVaultReplicationPackage
             if (file.exists()) {
                 VaultPackage pkg = packaging.getPackageManager().open(file);
                 replicationPackage = new FileVaultReplicationPackage(pkg);
-            } else {
-                VaultPackage pkg = packaging.getPackageManager(getSession()).open(PackageId.fromString(id)).getPackage();
-                replicationPackage = new FileVaultReplicationPackage(pkg);
             }
+//            else {
+//                VaultPackage pkg = packaging.getPackageManager(getSession()).open(PackageId.fromString(id)).getPackage();
+//                replicationPackage = new FileVaultReplicationPackage(pkg);
+//            }
         } catch (Exception e) {
             if (log.isWarnEnabled()) {
                 log.warn("could not find a package with id : {}", id);
@@ -203,17 +204,17 @@ public class FileVaultReplicationPackage
         Session session = null;
         try {
             session = getSession();
-            if (session != null) {
-                final JcrPackage jcrPackage = packaging.getPackageManager(getSession())
-                        .open(PackageId.fromString(replicationPackage.getId()));
-                jcrPackage.install(new ImportOptions());
-            }
-//            File file = new File(replicationPackage.getId());
-//            if (file.exists()) {
-//                VaultPackage pkg = packaging.getPackageManager().open(file);
-//                pkg.extract(session, new ImportOptions());
-//                return true;
+//            if (session != null) {
+//                final JcrPackage jcrPackage = packaging.getPackageManager(getSession())
+//                        .open(PackageId.fromString(replicationPackage.getId()));
+//                jcrPackage.install(new ImportOptions());
 //            }
+            File file = new File(replicationPackage.getId());
+            if (file.exists()) {
+                VaultPackage pkg = packaging.getPackageManager().open(file);
+                pkg.extract(session, new ImportOptions());
+                return true;
+            }
         } catch (Exception e) {
             if (log.isErrorEnabled()) {
                 log.error("could not read / install the package", e);



Mime
View raw message