You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by md...@apache.org on 2013/07/19 15:32:28 UTC

svn commit: r1504872 - in /syncope/branches/1_1_X: common/src/main/java/org/apache/syncope/common/to/ console/src/main/java/org/apache/syncope/console/pages/ console/src/main/resources/org/apache/syncope/console/pages/ core/src/main/java/org/apache/syn...

Author: mdisabatino
Date: Fri Jul 19 13:32:27 2013
New Revision: 1504872

URL: http://svn.apache.org/r1504872
Log:
SYNCOPE-403 Added to the ResultStatusModalPage the possibility to see the error message if the propagation fails

Added:
    syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/FailureMessageModalPage.java
    syncope/branches/1_1_X/console/src/main/resources/org/apache/syncope/console/pages/FailureMessageModalPage.html
Modified:
    syncope/branches/1_1_X/common/src/main/java/org/apache/syncope/common/to/PropagationStatusTO.java
    syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/ResultStatusModalPage.java
    syncope/branches/1_1_X/console/src/main/resources/org/apache/syncope/console/pages/ResultStatusModalPage.html
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationHandler.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/AbstractPropagationTaskExecutor.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/DefaultPropagationHandler.java
    syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java

Modified: syncope/branches/1_1_X/common/src/main/java/org/apache/syncope/common/to/PropagationStatusTO.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/common/src/main/java/org/apache/syncope/common/to/PropagationStatusTO.java?rev=1504872&r1=1504871&r2=1504872&view=diff
==============================================================================
--- syncope/branches/1_1_X/common/src/main/java/org/apache/syncope/common/to/PropagationStatusTO.java (original)
+++ syncope/branches/1_1_X/common/src/main/java/org/apache/syncope/common/to/PropagationStatusTO.java Fri Jul 19 13:32:27 2013
@@ -57,9 +57,9 @@ public class PropagationStatusTO extends
     private PropagationTaskExecStatus status;
     
     /**
-     * Propagation task execution message.
+     * Propagation task execution failure message.
      */
-    private String executionMessage;
+    private String failureReason;
 
     /**
      * After object getter.
@@ -136,18 +136,18 @@ public class PropagationStatusTO extends
     /**
      * Propagation execution message getter.
      *
-     * @return executionMessage.
+     * @return failureReason.
      */
-    public String getExecutionMessage() {
-        return executionMessage;
+    public String getFailureReason() {
+        return failureReason;
     }
 
     /**
-     * Propagation execution message setter.
+     * Propagation execution failure message setter.
      *
-     * @param executionMessage
+     * @param failureReason
      */
-    public void setExecutionMessage(final String executionMessage) {
-        this.executionMessage = executionMessage;
+    public void setFailureReason(final String failureReason) {
+        this.failureReason = failureReason;
     }
 }

Added: syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/FailureMessageModalPage.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/FailureMessageModalPage.java?rev=1504872&view=auto
==============================================================================
--- syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/FailureMessageModalPage.java (added)
+++ syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/FailureMessageModalPage.java Fri Jul 19 13:32:27 2013
@@ -0,0 +1,37 @@
+    /*
+     * Licensed to the Apache Software Foundation (ASF) under one
+     * or more contributor license agreements.  See the NOTICE file
+     * distributed with this work for additional information
+     * regarding copyright ownership.  The ASF licenses this file
+     * to you under the Apache License, Version 2.0 (the
+     * "License"); you may not use this file except in compliance
+     * with the License.  You may obtain a copy of the License at
+     *
+     *   http://www.apache.org/licenses/LICENSE-2.0
+     *
+     * Unless required by applicable law or agreed to in writing,
+     * software distributed under the License is distributed on an
+     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+     * KIND, either express or implied.  See the License for the
+     * specific language governing permissions and limitations
+     * under the License.
+     */
+    package org.apache.syncope.console.pages;
+
+    import org.apache.wicket.markup.html.basic.Label;
+    import org.apache.wicket.model.Model;
+
+    public class FailureMessageModalPage extends BaseModalPage {
+
+        private static final long serialVersionUID = 9216117990503199258L;
+
+        public FailureMessageModalPage(final String message, final String failureMessage) {
+            final Label executionFailureMessage;
+            if (!failureMessage.isEmpty()) {
+                executionFailureMessage = new Label("failureMessage", new Model<String>(failureMessage));
+            } else {
+                executionFailureMessage = new Label("failureMessage");
+            }
+            add(executionFailureMessage.setOutputMarkupId(true));
+        }
+    }

Modified: syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/ResultStatusModalPage.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/ResultStatusModalPage.java?rev=1504872&r1=1504871&r2=1504872&view=diff
==============================================================================
--- syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/ResultStatusModalPage.java (original)
+++ syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/ResultStatusModalPage.java Fri Jul 19 13:32:27 2013
@@ -29,6 +29,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import org.apache.commons.lang.StringUtils;
 import org.apache.syncope.common.to.AbstractAttributableTO;
 import org.apache.syncope.common.to.AttributeTO;
 import org.apache.syncope.common.to.ConnObjectTO;
@@ -40,6 +41,7 @@ import org.apache.syncope.console.common
 import org.apache.syncope.console.commons.Constants;
 import org.apache.syncope.console.commons.StatusUtils;
 import org.apache.wicket.Component;
+import org.apache.wicket.Page;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.ajax.markup.html.AjaxLink;
 import org.apache.wicket.behavior.Behavior;
@@ -164,6 +166,17 @@ public class ResultStatusModalPage exten
 
                     final Image image;
                     final String alt, title;
+                    final ModalWindow failureWindow = new ModalWindow("failureWindow");
+                    final AjaxLink<?> failureWindowLink = new AjaxLink<Void>("showFailureWindow") {
+
+                        private static final long serialVersionUID = -7978723352517770644L;
+
+                        @Override
+                        public void onClick(AjaxRequestTarget target) {
+                            failureWindow.show(target);
+                        }
+                    };
+
                     switch (propTO.getStatus()) {
 
                         case SUCCESS:
@@ -173,6 +186,8 @@ public class ResultStatusModalPage exten
                                     + Constants.PNG_EXT);
                             alt = "success icon";
                             title = "success";
+                            failureWindow.setVisible(false);
+                            failureWindowLink.setEnabled(false);
                             break;
 
                         default:
@@ -192,8 +207,30 @@ public class ResultStatusModalPage exten
                             tag.put("title", title);
                         }
                     });
+                    final FailureMessageModalPage executionFailureMessagePage;
+                    if (propTO.getFailureReason() != null) {
+                        executionFailureMessagePage = new FailureMessageModalPage(failureWindow.getContentId(), propTO.
+                                getFailureReason());
+                    } else {
+                        executionFailureMessagePage = new FailureMessageModalPage(failureWindow.getContentId(),
+                                StringUtils.EMPTY);
+                    }
+
+                    failureWindow.setPageCreator(new ModalWindow.PageCreator() {
+
+                        private static final long serialVersionUID = -7834632442532690940L;
 
-                    attrhead.add(image);
+                        @Override
+                        public Page createPage() {
+                            return executionFailureMessagePage;
+                        }
+                    });
+                    failureWindow.setCookieName("failureWindow");
+                    failureWindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
+                    //attrhead.add(image);
+                    failureWindowLink.add(image);
+                    attrhead.add(failureWindowLink);
+                    attrhead.add(failureWindow);
                 }
             };
             fragment.add(propRes);

Added: syncope/branches/1_1_X/console/src/main/resources/org/apache/syncope/console/pages/FailureMessageModalPage.html
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/console/src/main/resources/org/apache/syncope/console/pages/FailureMessageModalPage.html?rev=1504872&view=auto
==============================================================================
--- syncope/branches/1_1_X/console/src/main/resources/org/apache/syncope/console/pages/FailureMessageModalPage.html (added)
+++ syncope/branches/1_1_X/console/src/main/resources/org/apache/syncope/console/pages/FailureMessageModalPage.html Fri Jul 19 13:32:27 2013
@@ -0,0 +1,45 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<!DOCTYPE html>
+<style>
+  .w_content_3 {
+    padding: 0;
+  }
+
+  .w_body_1{
+    color: #333333;
+    font-family: Verdana,Tahoma,sans-serif;
+    font-size: 62.5%;
+  }
+</style>
+<html>
+  <head>
+    <title></title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+  </head>
+  <body class="w_body_1">
+    <div class="w_content_3">
+      <div>
+          <div style="margin: 1em">
+            <pre wicket:id="failureMessage"></pre> 
+          </div>
+      </div>
+    </div>
+  </body>
+</html>

Modified: syncope/branches/1_1_X/console/src/main/resources/org/apache/syncope/console/pages/ResultStatusModalPage.html
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/console/src/main/resources/org/apache/syncope/console/pages/ResultStatusModalPage.html?rev=1504872&r1=1504871&r2=1504872&view=diff
==============================================================================
--- syncope/branches/1_1_X/console/src/main/resources/org/apache/syncope/console/pages/ResultStatusModalPage.html (original)
+++ syncope/branches/1_1_X/console/src/main/resources/org/apache/syncope/console/pages/ResultStatusModalPage.html Fri Jul 19 13:32:27 2013
@@ -91,12 +91,16 @@ under the License.
       display: table-cell;
       width: 220px;
       height: 30px;
-      padding: 3px 0px 5px 0px;
+      padding: 10px 0px 5px 0px;
     }
 
     div#resource img{
       width: 12px;
       height: 12px;
+      position: relative;
+      left: 3px;
+      top: 1px;
+      opacity: 1;
     }
 
     div#attrhead {
@@ -106,8 +110,8 @@ under the License.
       height: 30px;
       padding: 3px 0px 5px 0px;
       text-align: center;
-      vertical-align: bottom;
-      font-size: 8px;
+      vertical-align: middle;
+      font-size: 11px;
     }
   </style>
 </wicket:head>
@@ -159,13 +163,18 @@ under the License.
       <div id="resource">
         <div>
           <span wicket:id="resource">[resource name]</span>
-          <img wicket:id="icon"/>
-        </div>
+          <a wicket:id="showFailureWindow" href="#">
+            <img wicket:id="icon"/>
+          </a>
+         
+          <div id="propagation">
+            <wicket:message key="propresult">[propagation result message]</wicket:message>
+            &nbsp;
+            <span wicket:id="propagation">[propagation result]</span>
+          </div>
+         
+          <div wicket:id="failureWindow"></div>
 
-        <div id="propagation">
-          <wicket:message key="propresult">[propagation result message]</wicket:message>
-          &nbsp;
-          <span wicket:id="propagation">[propagation result]</span>
         </div>
       </div>
 
@@ -184,13 +193,18 @@ under the License.
       <div id="resource">
         <div>
           <span wicket:id="resource">[resource name]</span>
-          <img wicket:id="icon"/>
-        </div>
+          <a wicket:id="showFailureWindow" href="#">
+            <img wicket:id="icon"/>
+          </a>
+
+          <div id="propagation">
+            <wicket:message key="propresult">[propagation result message]</wicket:message>
+            &nbsp;
+            <span wicket:id="propagation">[propagation result]</span>
+            <div wicket:id="failureWindow"></div>
 
-        <div id="propagation">
-          <wicket:message key="propresult">[propagation result message]</wicket:message>
-          &nbsp;
-          <span wicket:id="propagation">[propagation result]</span>
+          </div>
+         
         </div>
       </div>
     </div>

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationHandler.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationHandler.java?rev=1504872&r1=1504871&r2=1504872&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationHandler.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationHandler.java Fri Jul 19 13:32:27 2013
@@ -32,9 +32,10 @@ public interface PropagationHandler {
      *
      * @param resourceName resource name.
      * @param execStatus propagation execution status.
+     * @param failureReason propagation execution failure message.
      * @param beforeObj retrieved connector object before operation execution.
      * @param afterObj retrieved connector object after operation execution.
      */
     void handle(String resourceName, PropagationTaskExecStatus execStatus,
-            String taskExecutionMessage, ConnectorObject beforeObj, ConnectorObject afterObj);
+            String failureReason, ConnectorObject beforeObj, ConnectorObject afterObj);
 }

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/AbstractPropagationTaskExecutor.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/AbstractPropagationTaskExecutor.java?rev=1504872&r1=1504871&r2=1504872&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/AbstractPropagationTaskExecutor.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/AbstractPropagationTaskExecutor.java Fri Jul 19 13:32:27 2013
@@ -275,6 +275,7 @@ public abstract class AbstractPropagatio
         execution.setStatus(PropagationTaskExecStatus.CREATED.name());
 
         String taskExecutionMessage = null;
+        String failureReason = null;
 
         // Flag to state whether any propagation has been attempted
         Set<String> propagationAttempted = new HashSet<String>();
@@ -314,11 +315,17 @@ public abstract class AbstractPropagatio
 
             if (e instanceof ConnectorException && e.getCause() != null) {
                 taskExecutionMessage = e.getCause().getMessage();
+                failureReason = e.getMessage() + "\n\n Cause: " + e.getCause().getMessage().split("\n")[0];
             } else {
                 StringWriter exceptionWriter = new StringWriter();
                 exceptionWriter.write(e.getMessage() + "\n\n");
                 e.printStackTrace(new PrintWriter(exceptionWriter));
                 taskExecutionMessage = exceptionWriter.toString();
+                if (e.getCause() != null) {
+                    failureReason = e.getMessage() + "\n\n Cause: " + e.getCause().getMessage().split("\n")[0];
+                } else {
+                    failureReason = e.getMessage();
+                }
             }
 
             try {
@@ -362,12 +369,12 @@ public abstract class AbstractPropagatio
                 // this flush call is needed to generate a value for the execution id
                 taskDAO.flush();
             }
-            
+
             if (handler != null) {
                 handler.handle(
                         task.getResource().getName(),
                         PropagationTaskExecStatus.valueOf(execution.getStatus()),
-                        taskExecutionMessage,
+                        failureReason,
                         beforeObj,
                         afterObj);
             }

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/DefaultPropagationHandler.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/DefaultPropagationHandler.java?rev=1504872&r1=1504871&r2=1504872&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/DefaultPropagationHandler.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/DefaultPropagationHandler.java Fri Jul 19 13:32:27 2013
@@ -45,12 +45,12 @@ public class DefaultPropagationHandler i
 
     @Override
     public void handle(final String resource, final PropagationTaskExecStatus executionStatus,
-            final String taskExecutionMessage, final ConnectorObject beforeObj, final ConnectorObject afterObj) {
+            final String failureReason, final ConnectorObject beforeObj, final ConnectorObject afterObj) {
 
         final PropagationStatusTO propagation = new PropagationStatusTO();
         propagation.setResource(resource);
         propagation.setStatus(executionStatus);
-        propagation.setExecutionMessage(taskExecutionMessage);
+        propagation.setFailureReason(failureReason);
 
         if (beforeObj != null) {
             propagation.setBeforeObj(connObjectUtil.getConnObjectTO(beforeObj));
@@ -75,7 +75,7 @@ public class DefaultPropagationHandler i
                 final PropagationStatusTO propagationStatusTO = new PropagationStatusTO();
                 propagationStatusTO.setResource(propagationTask.getResource().getName());
                 propagationStatusTO.setStatus(PropagationTaskExecStatus.FAILURE);
-                propagationStatusTO.setExecutionMessage(
+                propagationStatusTO.setFailureReason(
                         "Propagation error: " + failedResource + " primary resource failed to propagate.");
                 propagations.add(propagationStatusTO);
             }

Modified: syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java?rev=1504872&r1=1504871&r2=1504872&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java (original)
+++ syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java Fri Jul 19 13:32:27 2013
@@ -242,7 +242,7 @@ public class UserTestITCase extends Abst
         userMod.addResourceToBeAdded("ws-target-resource-1");
 
         userTO = userService.update(userMod.getId(), userMod);
-        assertNotNull(userTO.getPropagationStatusTOs().get(0).getExecutionMessage());
+        assertNotNull(userTO.getPropagationStatusTOs().get(0).getFailureReason());
 
         // 4. update assigning a resource NOT forcing mandatory constraints
         // BUT not primary: must succeed
@@ -1817,7 +1817,7 @@ public class UserTestITCase extends Abst
         userTO.addResource("ws-target-resource-timeout");
         userTO = createUser(userTO);
         assertEquals("ws-target-resource-timeout", userTO.getPropagationStatusTOs().get(0).getResource());
-        assertNotNull(userTO.getPropagationStatusTOs().get(0).getExecutionMessage());
+        assertNotNull(userTO.getPropagationStatusTOs().get(0).getFailureReason());
         assertEquals(PropagationTaskExecStatus.UNSUBMITTED, userTO.getPropagationStatusTOs().get(0).getStatus());
     }
 
@@ -2213,7 +2213,7 @@ public class UserTestITCase extends Abst
         userTO = userService.update(userMod.getId(), userMod);
         assertEquals(RESOURCE_NAME_TESTDB, userTO.getResources().iterator().next());
         assertFalse(userTO.getPropagationStatusTOs().get(0).getStatus().isSuccessful());
-        assertNotNull(userTO.getPropagationStatusTOs().get(0).getExecutionMessage());
+        assertNotNull(userTO.getPropagationStatusTOs().get(0).getFailureReason());
 
         // 3. request to change password only on testdb
         userMod = new UserMod();
@@ -2325,7 +2325,7 @@ public class UserTestITCase extends Abst
         userMod.addResourceToBeAdded("resource-testdb");
         userTO = userService.update(userMod.getId(), userMod);
         assertEquals("ws-target-resource-1", userTO.getPropagationStatusTOs().get(1).getResource());
-        assertNotNull(userTO.getPropagationStatusTOs().get(1).getExecutionMessage());
+        assertNotNull(userTO.getPropagationStatusTOs().get(1).getFailureReason());
         assertEquals(PropagationTaskExecStatus.UNSUBMITTED, userTO.getPropagationStatusTOs().get(1).getStatus());
     }