← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19610: Changed DataValueController to use WebMessage

 

------------------------------------------------------------
revno: 19610
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-07-10 12:22:40 +0700
message:
  Changed DataValueController to use WebMessage
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CompleteDataSetRegistrationController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/ContextUtils.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/InputUtils.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/user.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CompleteDataSetRegistrationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CompleteDataSetRegistrationController.java	2015-07-10 02:24:25 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CompleteDataSetRegistrationController.java	2015-07-10 05:22:40 +0000
@@ -278,7 +278,7 @@
             throw new WebMessageException( WebMessageUtils.conflict( "Illegal organisation unit identifier: " + ou ) );
         }
 
-        DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( response, cc, cp );
+        DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( cc, cp );
 
         if ( attributeOptionCombo == null )
         {
@@ -371,7 +371,7 @@
 
             String cc = completeDataSetRegistrationRequest.getCc();
             String cp = completeDataSetRegistrationRequest.getCp();
-            DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( response, cc, cp );
+            DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( cc, cp );
 
             if ( attributeOptionCombo == null )
             {
@@ -456,7 +456,7 @@
             throw new WebMessageException( WebMessageUtils.conflict( "Illegal organisation unit identifier: " + ou ) );
         }
 
-        DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( response, cc, cp );
+        DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( cc, cp );
 
         if ( attributeOptionCombo == null )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueController.java	2015-07-08 05:42:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueController.java	2015-07-10 05:22:40 +0000
@@ -28,12 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import javax.servlet.http.HttpServletResponse;
-
 import org.apache.commons.lang3.StringUtils;
 import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.dataelement.DataElement;
@@ -42,14 +36,15 @@
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.datavalue.DataValue;
 import org.hisp.dhis.datavalue.DataValueService;
+import org.hisp.dhis.dxf2.webmessage.WebMessageException;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.system.util.ValidationUtils;
 import org.hisp.dhis.user.CurrentUserService;
-import org.hisp.dhis.webapi.utils.ContextUtils;
 import org.hisp.dhis.webapi.utils.InputUtils;
+import org.hisp.dhis.webapi.utils.WebMessageUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
@@ -58,6 +53,11 @@
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
 /**
  * @author Lars Helge Overland
  */
@@ -88,7 +88,7 @@
 
     @Autowired
     private IdentifiableObjectManager idObjectManager;
-    
+
     @Autowired
     private InputUtils inputUtils;
 
@@ -107,18 +107,17 @@
         @RequestParam String ou,
         @RequestParam( required = false ) String value,
         @RequestParam( required = false ) String comment,
-        @RequestParam( required = false ) boolean followUp, HttpServletResponse response )
+        @RequestParam( required = false ) boolean followUp, HttpServletResponse response ) throws WebMessageException
     {
         // ---------------------------------------------------------------------
         // Input validation
         // ---------------------------------------------------------------------
 
         DataElement dataElement = idObjectManager.get( DataElement.class, de );
-        
+
         if ( dataElement == null )
         {
-            ContextUtils.conflictResponse( response, "Illegal data element identifier: " + de );
-            return;
+            throw new WebMessageException( WebMessageUtils.conflict( "Illegal data element identifier: " + de ) );
         }
 
         DataElementCategoryOptionCombo categoryOptionCombo;
@@ -134,11 +133,10 @@
 
         if ( categoryOptionCombo == null )
         {
-            ContextUtils.conflictResponse( response, "Illegal category option combo identifier: " + co );
-            return;
+            throw new WebMessageException( WebMessageUtils.conflict( "Illegal category option combo identifier: " + co ) );
         }
 
-        DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( response, cc, cp );
+        DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( cc, cp );
 
         if ( attributeOptionCombo == null )
         {
@@ -149,50 +147,44 @@
 
         if ( period == null )
         {
-            ContextUtils.conflictResponse( response, "Illegal period identifier: " + pe );
-            return;
+            throw new WebMessageException( WebMessageUtils.conflict( "Illegal period identifier: " + pe ) );
         }
 
         OrganisationUnit organisationUnit = idObjectManager.get( OrganisationUnit.class, ou );
 
         if ( organisationUnit == null )
         {
-            ContextUtils.conflictResponse( response, "Illegal organisation unit identifier: " + ou );
-            return;
+            throw new WebMessageException( WebMessageUtils.conflict( "Illegal organisation unit identifier: " + ou ) );
         }
 
         boolean isInHierarchy = organisationUnitService.isInUserHierarchy( organisationUnit );
 
         if ( !isInHierarchy )
         {
-            ContextUtils.conflictResponse( response, "Organisation unit is not in the hierarchy of the current user: " + ou );
-            return;
+            throw new WebMessageException( WebMessageUtils.conflict( "Organisation unit is not in the hierarchy of the current user: " + ou ) );
         }
 
         String valid = ValidationUtils.dataValueIsValid( value, dataElement );
 
         if ( valid != null )
         {
-            ContextUtils.conflictResponse( response, "Invalid value: " + value + ", must match data element type: " + dataElement.getDetailedType() );
-            return;
+            throw new WebMessageException( WebMessageUtils.conflict( "Invalid value: " + value + ", must match data element type: " + dataElement.getDetailedType() ) );
         }
 
         valid = ValidationUtils.commentIsValid( comment );
 
         if ( valid != null )
         {
-            ContextUtils.conflictResponse( response, "Invalid comment: " + comment );
-            return;
+            throw new WebMessageException( WebMessageUtils.conflict( "Invalid comment: " + comment ) );
         }
 
         // ---------------------------------------------------------------------
         // Future period constraint check //TODO better check
         // ---------------------------------------------------------------------
-        
+
         if ( period.isFuture() && dataElement.getOpenFuturePeriods() <= 0 )
         {
-            ContextUtils.conflictResponse( response, "One or more data sets for data element does not allow future periods: " + de );
-            return;
+            throw new WebMessageException( WebMessageUtils.conflict( "One or more data sets for data element does not allow future periods: " + de ) );
         }
 
         // ---------------------------------------------------------------------
@@ -201,8 +193,7 @@
 
         if ( dataSetService.isLocked( dataElement, period, organisationUnit, null ) )
         {
-            ContextUtils.conflictResponse( response, "Data set is locked" );
-            return;
+            throw new WebMessageException( WebMessageUtils.conflict( "Data set is locked" ) );
         }
 
         // ---------------------------------------------------------------------
@@ -271,7 +262,7 @@
         @RequestParam( required = false ) String cc,
         @RequestParam( required = false ) String cp,
         @RequestParam String pe,
-        @RequestParam String ou, HttpServletResponse response )
+        @RequestParam String ou, HttpServletResponse response ) throws WebMessageException
     {
         // ---------------------------------------------------------------------
         // Input validation
@@ -281,8 +272,7 @@
 
         if ( dataElement == null )
         {
-            ContextUtils.conflictResponse( response, "Illegal data element identifier: " + de );
-            return;
+            throw new WebMessageException( WebMessageUtils.conflict( "Illegal data element identifier: " + de ) );
         }
 
         DataElementCategoryOptionCombo categoryOptionCombo;
@@ -298,11 +288,10 @@
 
         if ( categoryOptionCombo == null )
         {
-            ContextUtils.conflictResponse( response, "Illegal category option combo identifier: " + co );
-            return;
+            throw new WebMessageException( WebMessageUtils.conflict( "Illegal category option combo identifier: " + co ) );
         }
 
-        DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( response, cc, cp );
+        DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( cc, cp );
 
         if ( attributeOptionCombo == null )
         {
@@ -313,24 +302,21 @@
 
         if ( period == null )
         {
-            ContextUtils.conflictResponse( response, "Illegal period identifier: " + pe );
-            return;
+            throw new WebMessageException( WebMessageUtils.conflict( "Illegal period identifier: " + pe ) );
         }
 
         OrganisationUnit organisationUnit = idObjectManager.get( OrganisationUnit.class, ou );
 
         if ( organisationUnit == null )
         {
-            ContextUtils.conflictResponse( response, "Illegal organisation unit identifier: " + ou );
-            return;
+            throw new WebMessageException( WebMessageUtils.conflict( "Illegal organisation unit identifier: " + ou ) );
         }
 
         boolean isInHierarchy = organisationUnitService.isInUserHierarchy( organisationUnit );
 
         if ( !isInHierarchy )
         {
-            ContextUtils.conflictResponse( response, "Organisation unit is not in the hierarchy of the current user: " + ou );
-            return;
+            throw new WebMessageException( WebMessageUtils.conflict( "Organisation unit is not in the hierarchy of the current user: " + ou ) );
         }
 
         // ---------------------------------------------------------------------
@@ -339,8 +325,7 @@
 
         if ( dataSetService.isLocked( dataElement, period, organisationUnit, null ) )
         {
-            ContextUtils.conflictResponse( response, "Data set is locked" );
-            return;
+            throw new WebMessageException( WebMessageUtils.conflict( "Data set is locked" ) );
         }
 
         // ---------------------------------------------------------------------
@@ -351,8 +336,7 @@
 
         if ( dataValue == null )
         {
-            ContextUtils.conflictResponse( response, "Data value cannot be deleted because it does not exist" );
-            return;
+            throw new WebMessageException( WebMessageUtils.conflict( "Data value cannot be deleted because it does not exist" ) );
         }
 
         dataValueService.deleteDataValue( dataValue );
@@ -370,7 +354,7 @@
         @RequestParam( required = false ) String cp,
         @RequestParam String pe,
         @RequestParam String ou,
-        Model model, HttpServletResponse response )
+        Model model, HttpServletResponse response ) throws WebMessageException
     {
         // ---------------------------------------------------------------------
         // Input validation
@@ -380,11 +364,10 @@
 
         if ( dataElement == null )
         {
-            ContextUtils.conflictResponse( response, "Illegal data element identifier: " + de );
-            return null;
+            throw new WebMessageException( WebMessageUtils.conflict( "Illegal data element identifier: " + de ) );
         }
 
-        DataElementCategoryOptionCombo categoryOptionCombo = null;
+        DataElementCategoryOptionCombo categoryOptionCombo;
 
         if ( co != null )
         {
@@ -397,11 +380,10 @@
 
         if ( categoryOptionCombo == null )
         {
-            ContextUtils.conflictResponse( response, "Illegal category option combo identifier: " + co );
-            return null;
+            throw new WebMessageException( WebMessageUtils.conflict( "Illegal category option combo identifier: " + co ) );
         }
 
-        DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( response, cc, cp );
+        DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( cc, cp );
 
         if ( attributeOptionCombo == null )
         {
@@ -412,24 +394,21 @@
 
         if ( period == null )
         {
-            ContextUtils.conflictResponse( response, "Illegal period identifier: " + pe );
-            return null;
+            throw new WebMessageException( WebMessageUtils.conflict( "Illegal period identifier: " + pe ) );
         }
 
         OrganisationUnit organisationUnit = idObjectManager.get( OrganisationUnit.class, ou );
 
         if ( organisationUnit == null )
         {
-            ContextUtils.conflictResponse( response, "Illegal organisation unit identifier: " + ou );
-            return null;
+            throw new WebMessageException( WebMessageUtils.conflict( "Illegal organisation unit identifier: " + ou ) );
         }
 
         boolean isInHierarchy = organisationUnitService.isInUserHierarchy( organisationUnit );
 
         if ( !isInHierarchy )
         {
-            ContextUtils.conflictResponse( response, "Organisation unit is not in the hierarchy of the current user: " + ou );
-            return null;
+            throw new WebMessageException( WebMessageUtils.conflict( "Organisation unit is not in the hierarchy of the current user: " + ou ) );
         }
 
         // ---------------------------------------------------------------------
@@ -438,8 +417,7 @@
 
         if ( dataSetService.isLocked( dataElement, period, organisationUnit, null ) )
         {
-            ContextUtils.conflictResponse( response, "Data set is locked" );
-            return null;
+            throw new WebMessageException( WebMessageUtils.conflict( "Data set is locked" ) );
         }
 
         // ---------------------------------------------------------------------
@@ -450,8 +428,7 @@
 
         if ( dataValue == null )
         {
-            ContextUtils.conflictResponse( response, "Data value does not exist" );
-            return null;
+            throw new WebMessageException( WebMessageUtils.conflict( "Data value does not exist" ) );
         }
 
         List<String> value = new ArrayList<>();

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/ContextUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/ContextUtils.java	2015-06-15 13:44:20 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/ContextUtils.java	2015-07-10 05:22:40 +0000
@@ -161,31 +161,6 @@
         setResponse( response, HttpServletResponse.SC_OK, message );
     }
 
-    public static void createdResponse( HttpServletResponse response, String message, String location )
-    {
-        if ( location != null )
-        {
-            response.addHeader( HEADER_LOCATION, location );
-        }
-
-        setResponse( response, HttpServletResponse.SC_CREATED, message );
-    }
-
-    public static void notFoundResponse( HttpServletResponse response, String message )
-    {
-        setResponse( response, HttpServletResponse.SC_NOT_FOUND, message );
-    }
-
-    public static void conflictResponse( HttpServletResponse response, String message )
-    {
-        setResponse( response, HttpServletResponse.SC_CONFLICT, message );
-    }
-
-    public static void errorResponse( HttpServletResponse response, String message )
-    {
-        setResponse( response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message );
-    }
-
     public static void badRequestResponse( HttpServletResponse response, String message )
     {
         setResponse( response, HttpServletResponse.SC_BAD_REQUEST, message );

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/InputUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/InputUtils.java	2015-03-16 13:56:13 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/InputUtils.java	2015-07-10 05:22:40 +0000
@@ -28,18 +28,17 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletResponse;
-
 import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.dataelement.DataElementCategoryCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryOption;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.dxf2.webmessage.WebMessageException;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * @author Lars Helge Overland
  */
@@ -47,22 +46,21 @@
 {
     @Autowired
     private DataElementCategoryService categoryService;
-    
+
     @Autowired
     private IdentifiableObjectManager idObjectManager;
-    
+
     /**
      * Validates and retrieves the attribute option combo. 409 conflict as status
      * code along with a textual message will be set on the response in case of
      * invalid input.
-     * 
-     * @param response the servlet response.
-     * @param cc the category combo identifier.
-     * @param cp the category and option query string.
+     *
+     * @param cc       the category combo identifier.
+     * @param cp       the category and option query string.
      * @return the attribute option combo identified from the given input, or null
-     *         if the input was invalid.
+     * if the input was invalid.
      */
-    public DataElementCategoryOptionCombo getAttributeOptionCombo( HttpServletResponse response, String cc, String cp )
+    public DataElementCategoryOptionCombo getAttributeOptionCombo( String cc, String cp ) throws WebMessageException
     {
         Set<String> opts = ContextUtils.getQueryParamValues( cp );
 
@@ -70,18 +68,16 @@
         // Attribute category combo validation
         // ---------------------------------------------------------------------
 
-        if ( ( cc == null && opts != null || ( cc != null && opts == null ) ) )
+        if ( (cc == null && opts != null || (cc != null && opts == null)) )
         {
-            ContextUtils.conflictResponse( response, "Both or none of category combination and category options must be present" );
-            return null;
+            throw new WebMessageException( WebMessageUtils.conflict( "Both or none of category combination and category options must be present" ) );
         }
 
         DataElementCategoryCombo categoryCombo = null;
-        
-        if ( cc != null && ( categoryCombo = idObjectManager.get( DataElementCategoryCombo.class, cc ) ) == null )
+
+        if ( cc != null && (categoryCombo = idObjectManager.get( DataElementCategoryCombo.class, cc )) == null )
         {
-            ContextUtils.conflictResponse( response, "Illegal category combo identifier: " + cc );
-            return null;
+            throw new WebMessageException( WebMessageUtils.conflict( "Illegal category combo identifier: " + cc ) );
         }
 
         // ---------------------------------------------------------------------
@@ -97,22 +93,20 @@
             for ( String uid : opts )
             {
                 DataElementCategoryOption categoryOption = idObjectManager.get( DataElementCategoryOption.class, uid );
-                
+
                 if ( categoryOption == null )
                 {
-                    ContextUtils.conflictResponse( response, "Illegal category option identifier: " + uid );
-                    return null;
+                    throw new WebMessageException( WebMessageUtils.conflict( "Illegal category option identifier: " + uid ) );
                 }
-                
+
                 categoryOptions.add( categoryOption );
             }
-            
+
             attributeOptionCombo = categoryService.getDataElementCategoryOptionCombo( categoryCombo, categoryOptions );
-            
+
             if ( attributeOptionCombo == null )
             {
-                ContextUtils.conflictResponse( response, "Attribute option combo does not exist for given category combo and category options" );
-                return null;
+                throw new WebMessageException( WebMessageUtils.conflict( "Attribute option combo does not exist for given category combo and category options" ) );
             }
         }
 
@@ -120,13 +114,12 @@
         {
             attributeOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
         }
-        
+
         if ( attributeOptionCombo == null )
         {
-            ContextUtils.conflictResponse( response, "Default attribute option combo does not exist" );
-            return null;
+            throw new WebMessageException( WebMessageUtils.conflict( "Default attribute option combo does not exist" ) );
         }
-        
+
         return attributeOptionCombo;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2014-11-24 11:04:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2015-07-10 05:22:40 +0000
@@ -364,7 +364,8 @@
     	if ( 409 == xhr.status || 500 == xhr.status ) // Invalid value or locked
     	{
     		markValue( fieldId, dhis2.de.cst.colorRed );
-    		setHeaderDelayMessage( xhr.responseText );
+        var errorText = JSON.parse( xhr.responseText );
+    		setHeaderDelayMessage( errorText.message );
     	}
     	else // Offline, keep local value
     	{

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2015-06-11 10:25:44 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2015-07-10 05:22:40 +0000
@@ -478,7 +478,7 @@
 	                setHeaderMessage( message );
 
 	                $( '#sync_button' ).bind( 'click', dhis2.de.uploadLocalData );
-                    $( '#discard_button' ).bind( 'click', dhis2.de.discardLocalData );
+                  $( '#discard_button' ).bind( 'click', dhis2.de.discardLocalData );
             	}
             }
         } );

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js	2015-02-04 23:11:02 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js	2015-07-10 05:22:40 +0000
@@ -61,8 +61,9 @@
 
     function handleError( xhr, textStatus, errorThrown )
     {
+        var errorText = JSON.parse( xhr.responseText );
         markComment( dhis2.de.cst.colorRed );
-        window.alert( i18n_saving_comment_failed_error_code + '\n\n' + xhr.responseText );
+        window.alert( i18n_saving_comment_failed_error_code + '\n\n' + errorText.message );
     }
 }
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/user.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/user.js	2015-07-10 02:55:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/user.js	2015-07-10 05:22:40 +0000
@@ -232,7 +232,7 @@
 		},
 		error: function( xhr, status, error ) {
       var errorText = JSON.parse( xhr.responseText );
-			setHeaderDelayMessage( errorText );
+			setHeaderDelayMessage( errorText.message );
 		}
 	});
 }
@@ -252,7 +252,7 @@
 		},
 		error: function( xhr, status, error ) {
       var errorText = JSON.parse( xhr.responseText );
-			setHeaderDelayMessage( errorText );
+			setHeaderDelayMessage( errorText.message );
 		}
 	} );
 }