=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/webmessage/WebMessage.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/webmessage/WebMessage.java 2015-06-05 11:20:06 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/webmessage/WebMessage.java 2015-06-08 08:45:54 +0000 @@ -28,21 +28,20 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import org.hisp.dhis.common.DxfNamespaces; -import org.springframework.http.HttpStatus; - import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import com.google.common.base.MoreObjects; +import org.hisp.dhis.common.DxfNamespaces; +import org.springframework.http.HttpStatus; /** * @author Morten Olav Hansen */ @JacksonXmlRootElement( localName = "webMessage", namespace = DxfNamespaces.DXF_2_0 ) @JsonPropertyOrder( { - "status", "code", "httpStatusCode", "message", "devMessage", "response" + "status", "code", "httpStatus", "httpStatusCode", "message", "devMessage", "response" } ) public class WebMessage { @@ -61,6 +60,11 @@ protected Integer code; /** + * HTTP status. + */ + protected String httpStatus = HttpStatus.OK.getReasonPhrase(); + + /** * HTTP status code. Default value is 200. */ protected Integer httpStatusCode = HttpStatus.OK.value(); @@ -101,13 +105,13 @@ public WebMessage( WebMessageStatus status, Integer httpStatusCode ) { this.status = status; - this.httpStatusCode = httpStatusCode; + setHttpStatusCode( httpStatusCode ); } // ------------------------------------------------------------------------- // Logic // ------------------------------------------------------------------------- - + public boolean okStatus() { return WebMessageStatus.OK.equals( status ); @@ -117,7 +121,7 @@ { return WebMessageStatus.ERROR.equals( status ); } - + // ------------------------------------------------------------------------- // Get and set methods // ------------------------------------------------------------------------- @@ -148,6 +152,13 @@ @JsonProperty @JacksonXmlProperty( isAttribute = true ) + public String getHttpStatus() + { + return httpStatus; + } + + @JsonProperty + @JacksonXmlProperty( isAttribute = true ) public Integer getHttpStatusCode() { return httpStatusCode; @@ -155,6 +166,14 @@ public void setHttpStatusCode( Integer httpStatusCode ) { + try + { + this.httpStatus = HttpStatus.valueOf( httpStatusCode ).getReasonPhrase(); + } + catch ( IllegalArgumentException ignored ) + { + } + this.httpStatusCode = httpStatusCode; }