You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2018/01/18 21:24:05 UTC

[sling-whiteboard] 01/02: Code signing: improve error reporting

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git

commit 52df805f6b584e81f826352278be70c4566cb5cc
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Wed Jan 17 00:11:04 2018 +0200

    Code signing: improve error reporting
---
 .../org/apache/tomcat/buildutil/SignCodeMojo.java  | 28 +++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/codesign/src/main/java/org/apache/tomcat/buildutil/SignCodeMojo.java b/codesign/src/main/java/org/apache/tomcat/buildutil/SignCodeMojo.java
index 4bbd62f..b5a1d27 100644
--- a/codesign/src/main/java/org/apache/tomcat/buildutil/SignCodeMojo.java
+++ b/codesign/src/main/java/org/apache/tomcat/buildutil/SignCodeMojo.java
@@ -273,6 +273,7 @@ public class SignCodeMojo extends AbstractMojo {
 
         String signingSetID = null;
         String signingSetStatus = null;
+        StringBuilder errors = new StringBuilder();
 
         for (int i = 0; i < returnNodes.getLength(); i++) {
             Node returnNode = returnNodes.item(i);
@@ -280,17 +281,42 @@ public class SignCodeMojo extends AbstractMojo {
                 signingSetID = returnNode.getTextContent();
             } else if (returnNode.getLocalName().equals("signingSetStatus")) {
                 signingSetStatus = returnNode.getTextContent();
+            } else if (returnNode.getLocalName().equals("result") ) {
+                final NodeList returnChildNodes = returnNode.getChildNodes();
+                for (int j = 0; j < returnChildNodes.getLength(); j++ ) {
+                    if ( returnChildNodes.item(j).getLocalName().equals("errors") ) {
+                        extractErrors(returnChildNodes.item(j), errors);
+                    }
+                }
             }
         }
 
         if (!signingService.contains("TEST") && !"SIGNED".equals(signingSetStatus) ||
                 signingService.contains("TEST") && !"INITIALIZED".equals(signingSetStatus) ) {
-            throw new BuildException("Signing failed. Status was: " + signingSetStatus);
+            throw new BuildException("Signing failed. Status was: " + signingSetStatus + " . Reported errors: " + errors + ".");
         }
 
         return signingSetID;
     }
 
+
+    private void extractErrors(Node errorsNode, StringBuilder errors) {
+        
+        for (int i = 0 ; i < errorsNode.getChildNodes().getLength(); i++) {
+            Node errorNode = errorsNode.getChildNodes().item(i);
+            final NodeList errorChildNodes = errorNode.getChildNodes();
+            for ( int j = 0; j < errorChildNodes.getLength(); j++) {
+                Node item = errorChildNodes.item(j);
+                if ( item.getLocalName().equals("errorMessage") ) {
+                    if ( errors.length() > 0 ) {
+                        errors.append(" ,");
+                    }
+                    errors.append(item.getTextContent());
+                }
+            }
+        }
+    }
+
     // pass-through method to make it easier to copy/paste code from tomcat's ant mojos
     private void log(String msg) {
 		getLog().info(msg);

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.