SLING-6176 persist error text in case of installation failures
authorKonrad Windszus <kwin@apache.org>
Fri, 21 Oct 2016 09:03:23 +0000 (09:03 +0000)
committerKonrad Windszus <kwin@apache.org>
Fri, 21 Oct 2016 09:03:23 +0000 (09:03 +0000)
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1765962 13f79535-47bb-0310-9956-ffa450edef68

pom.xml
src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformer.java

diff --git a/pom.xml b/pom.xml
index 5fb25fd..68139ae 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -73,7 +73,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.installer.core</artifactId>
-            <version>3.5.0</version>
+            <version>3.7.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
index 1f9ff7e..550ce20 100644 (file)
@@ -20,6 +20,7 @@ package org.apache.sling.installer.factory.packages.impl;
 
 import java.io.BufferedInputStream;
 import java.io.IOException;
+import java.text.MessageFormat;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.regex.Matcher;
@@ -208,15 +209,17 @@ public class PackageTransformer implements ResourceTransformer, InstallTaskFacto
                 // open package
                 pkg = pkgMgr.open(pkgId);
                 if (pkg == null) {
-                    logger.error("Error during installation of {}: Package {} missing.", resource, pkgId);
-                    this.setFinishedState(ResourceState.IGNORED);
+                    String message = MessageFormat.format("Error during installation of {0}: Package {1} missing.", resource, pkgId);
+                    logger.error(message);
+                    this.setFinishedState(ResourceState.IGNORED, null, message);
                     return;
                 }
 
                 // check if package was installed in the meantime
                 if (pkg.isInstalled()) {
-                    logger.info("Package {} was installed externally. Marking as installed.", pkgId);
-                    this.setFinishedState(ResourceState.INSTALLED);
+                    String message = MessageFormat.format("Package {0} was installed externally. Marking as installed.", pkgId);
+                    logger.info(message);
+                    this.setFinishedState(ResourceState.INSTALLED, null, message);
                     return;
                 }
 
@@ -245,8 +248,9 @@ public class PackageTransformer implements ResourceTransformer, InstallTaskFacto
                 retryHandler.scheduleRetry();
 
             } catch (final Exception e) {
-                logger.error("Error while processing install task of {}.", resource, e);
-                this.setFinishedState(ResourceState.IGNORED);
+                String message = MessageFormat.format("Error while processing install task of {0} due to {1}, no retry.", resource, e.getLocalizedMessage());
+                logger.error(message, e);
+                this.setFinishedState(ResourceState.IGNORED, null, message);
             } finally {
                 if (pkg != null) {
                     pkg.close();