dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21379
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10101: FRED-API: cleaned up exception handling
------------------------------------------------------------
revno: 10101
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2013-03-09 12:38:51 +0300
message:
FRED-API: cleaned up exception handling
removed:
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/ETagDoesNotMatchException.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/MessageResponseUtils.java
added:
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/DuplicateCodeException.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/DuplicateUidException.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/DuplicateUuidException.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/ETagVerificationException.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/FacilityNotFoundException.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/UuidFormatException.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/MessageUtils.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DeleteNotAllowedException.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityServiceController.java
--
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-api/src/main/java/org/hisp/dhis/common/DeleteNotAllowedException.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DeleteNotAllowedException.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DeleteNotAllowedException.java 2013-03-09 09:38:51 +0000
@@ -39,12 +39,12 @@
private static final long serialVersionUID = -4102764536406530234L;
public static final String ERROR_ASSOCIATED_BY_OTHER_OBJECTS = "Object associated by other objects";
-
+
private String errorCode;
-
+
public DeleteNotAllowedException( String errorCode, String message )
{
- super( message );
+ super( message );
this.errorCode = errorCode;
}
=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java 2013-03-09 08:58:06 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java 2013-03-09 09:38:51 +0000
@@ -42,9 +42,14 @@
import org.hisp.dhis.web.webapi.v1.domain.Facilities;
import org.hisp.dhis.web.webapi.v1.domain.Facility;
import org.hisp.dhis.web.webapi.v1.domain.Identifier;
-import org.hisp.dhis.web.webapi.v1.exception.ETagDoesNotMatchException;
+import org.hisp.dhis.web.webapi.v1.exception.DuplicateCodeException;
+import org.hisp.dhis.web.webapi.v1.exception.DuplicateUidException;
+import org.hisp.dhis.web.webapi.v1.exception.DuplicateUuidException;
+import org.hisp.dhis.web.webapi.v1.exception.ETagVerificationException;
+import org.hisp.dhis.web.webapi.v1.exception.FacilityNotFoundException;
+import org.hisp.dhis.web.webapi.v1.exception.UuidFormatException;
import org.hisp.dhis.web.webapi.v1.utils.ContextUtils;
-import org.hisp.dhis.web.webapi.v1.utils.MessageResponseUtils;
+import org.hisp.dhis.web.webapi.v1.utils.MessageUtils;
import org.hisp.dhis.web.webapi.v1.utils.ObjectMapperFactoryBean;
import org.hisp.dhis.web.webapi.v1.utils.ValidationUtils;
import org.hisp.dhis.web.webapi.v1.validation.group.Create;
@@ -467,8 +472,7 @@
}
catch ( IllegalArgumentException ignored )
{
- return new ResponseEntity<String>( MessageResponseUtils.jsonMessage( HttpStatus.PRECONDITION_FAILED.toString(),
- "Bad id: (does not match expected UUID string format)" ), HttpStatus.PRECONDITION_FAILED );
+ throw new UuidFormatException();
}
}
@@ -485,18 +489,15 @@
if ( organisationUnitService.getOrganisationUnit( organisationUnit.getUuid() ) != null )
{
- return new ResponseEntity<String>( MessageResponseUtils.jsonMessage( HttpStatus.CONFLICT.toString(),
- "An object with that UUID already exists." ), headers, HttpStatus.CONFLICT );
+ throw new DuplicateUuidException();
}
if ( organisationUnitService.getOrganisationUnit( organisationUnit.getUid() ) != null )
{
- return new ResponseEntity<String>( MessageResponseUtils.jsonMessage( HttpStatus.CONFLICT.toString(),
- "An object with that UID already exists." ), headers, HttpStatus.CONFLICT );
+ throw new DuplicateUidException();
}
else if ( organisationUnit.getCode() != null && organisationUnitService.getOrganisationUnitByCode( organisationUnit.getCode() ) != null )
{
- return new ResponseEntity<String>( MessageResponseUtils.jsonMessage( HttpStatus.CONFLICT.toString(),
- "An object with that code already exists." ), headers, HttpStatus.CONFLICT );
+ throw new DuplicateCodeException();
}
organisationUnitService.addOrganisationUnit( organisationUnit );
@@ -537,8 +538,7 @@
if ( organisationUnit == null )
{
- return new ResponseEntity<String>( MessageResponseUtils.jsonMessage( HttpStatus.NOT_FOUND.toString(),
- "Facility with that ID not found" ), headers, HttpStatus.NOT_FOUND );
+ throw new FacilityNotFoundException();
}
// getId == null is not legal, but will be catched by bean validation
@@ -552,8 +552,7 @@
}
catch ( IllegalArgumentException ignored )
{
- return new ResponseEntity<String>( MessageResponseUtils.jsonMessage( HttpStatus.PRECONDITION_FAILED.toString(),
- "Bad id: (does not match expected UUID string format)" ), headers, HttpStatus.PRECONDITION_FAILED );
+ throw new UuidFormatException();
}
}
@@ -577,7 +576,7 @@
if ( !ETag.equals( request.getHeader( "If-Match" ) ) )
{
- throw new ETagDoesNotMatchException();
+ throw new ETagVerificationException();
}
}
@@ -587,8 +586,7 @@
if ( ouByCode != null && !organisationUnit.getUid().equals( ouByCode.getUid() ) )
{
- return new ResponseEntity<String>( MessageResponseUtils.jsonMessage( HttpStatus.CONFLICT.toString(),
- "Another object with the same code already exists." ), headers, HttpStatus.CONFLICT );
+ throw new DuplicateCodeException();
}
}
@@ -628,14 +626,13 @@
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@PreAuthorize("hasRole('F_FRED_DELETE') or hasRole('ALL')")
- public ResponseEntity<String> deleteFacility( @PathVariable String id ) throws HierarchyViolationException, IOException
+ public ResponseEntity<String> deleteFacility( @PathVariable String id ) throws HierarchyViolationException, IOException, FacilityNotFoundException
{
OrganisationUnit organisationUnit = getOrganisationUnit( id );
if ( organisationUnit == null )
{
- return new ResponseEntity<String>( MessageResponseUtils.jsonMessage( HttpStatus.NOT_FOUND.toString(),
- "Facility with that ID not found" ), HttpStatus.NOT_FOUND );
+ throw new FacilityNotFoundException();
}
organisationUnitService.deleteOrganisationUnit( organisationUnit );
@@ -648,21 +645,38 @@
//--------------------------------------------------------------------------
@ExceptionHandler({ HttpClientErrorException.class, HttpServerErrorException.class })
- public ResponseEntity<String> statusCodeExceptionHandler( HttpStatusCodeException ex )
- {
- return new ResponseEntity<String>( ex.getMessage(), ex.getStatusCode() );
- }
-
- @ExceptionHandler({ DeleteNotAllowedException.class, HierarchyViolationException.class })
- public ResponseEntity<String> dhisExceptionHandler( Exception ex )
- {
- return new ResponseEntity<String>( ex.getMessage(), HttpStatus.FORBIDDEN );
- }
-
- public ResponseEntity<String> etagVerificationFailed( ETagDoesNotMatchException ex ) throws IOException
- {
- return new ResponseEntity<String>( MessageResponseUtils.jsonMessage( HttpStatus.PRECONDITION_FAILED.toString(),
- "ETag provided does not match current ETag of facility" ), HttpStatus.PRECONDITION_FAILED );
+ public ResponseEntity<String> statusCodeExceptionHandler( HttpStatusCodeException ex ) throws IOException
+ {
+ return new ResponseEntity<String>( MessageUtils.jsonMessage( ex.getStatusText(),
+ ex.getMessage() ), ex.getStatusCode() );
+ }
+
+ @ExceptionHandler( { DeleteNotAllowedException.class, HierarchyViolationException.class } )
+ public ResponseEntity<String> handleForbidden( Exception ex ) throws IOException
+ {
+ return new ResponseEntity<String>( MessageUtils.jsonMessage( HttpStatus.FORBIDDEN.toString(),
+ ex.getMessage() ), HttpStatus.FORBIDDEN );
+ }
+
+ @ExceptionHandler( { ETagVerificationException.class, UuidFormatException.class } )
+ public ResponseEntity<String> handlePreconditionFailed( Exception ex ) throws IOException
+ {
+ return new ResponseEntity<String>( MessageUtils.jsonMessage( HttpStatus.PRECONDITION_FAILED.toString(),
+ ex.getMessage() ), HttpStatus.PRECONDITION_FAILED );
+ }
+
+ @ExceptionHandler( { FacilityNotFoundException.class } )
+ public ResponseEntity<String> handleNotFound( Exception ex ) throws IOException
+ {
+ return new ResponseEntity<String>( MessageUtils.jsonMessage( HttpStatus.NOT_FOUND.toString(),
+ ex.getMessage() ), HttpStatus.NOT_FOUND );
+ }
+
+ @ExceptionHandler( { DuplicateCodeException.class, DuplicateUidException.class, DuplicateUuidException.class } )
+ public ResponseEntity<String> handleConflict( Exception ex ) throws IOException
+ {
+ return new ResponseEntity<String>( MessageUtils.jsonMessage( HttpStatus.CONFLICT.toString(),
+ ex.getMessage() ), HttpStatus.CONFLICT );
}
//--------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityServiceController.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityServiceController.java 2013-03-07 18:52:55 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityServiceController.java 2013-03-09 09:38:51 +0000
@@ -33,7 +33,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.web.webapi.v1.domain.Facility;
-import org.hisp.dhis.web.webapi.v1.utils.MessageResponseUtils;
+import org.hisp.dhis.web.webapi.v1.utils.MessageUtils;
import org.hisp.dhis.web.webapi.v1.utils.ValidationUtils;
import org.hisp.dhis.web.webapi.v1.validation.group.Create;
import org.hisp.dhis.web.webapi.v1.validation.group.Update;
@@ -140,17 +140,17 @@
if ( organisationUnitService.getOrganisationUnit( organisationUnit.getUid() ) != null )
{
- return new ResponseEntity<String>( MessageResponseUtils.jsonMessage( HttpStatus.CONFLICT.toString(),
+ return new ResponseEntity<String>( MessageUtils.jsonMessage( HttpStatus.CONFLICT.toString(),
"An object with that ID already exists." ), headers, HttpStatus.CONFLICT );
}
else if ( organisationUnitService.getOrganisationUnitByName( organisationUnit.getName() ) != null )
{
- return new ResponseEntity<String>( MessageResponseUtils.jsonMessage( HttpStatus.CONFLICT.toString(),
+ return new ResponseEntity<String>( MessageUtils.jsonMessage( HttpStatus.CONFLICT.toString(),
"An object with that name already exists." ), headers, HttpStatus.CONFLICT );
}
else if ( organisationUnit.getCode() != null && organisationUnitService.getOrganisationUnitByCode( organisationUnit.getCode() ) != null )
{
- return new ResponseEntity<String>( MessageResponseUtils.jsonMessage( HttpStatus.CONFLICT.toString(),
+ return new ResponseEntity<String>( MessageUtils.jsonMessage( HttpStatus.CONFLICT.toString(),
"An object with that code already exists." ), headers, HttpStatus.CONFLICT );
}
@@ -179,7 +179,7 @@
if ( ou == null )
{
- return new ResponseEntity<String>( MessageResponseUtils.jsonMessage( HttpStatus.NOT_FOUND.toString(),
+ return new ResponseEntity<String>( MessageUtils.jsonMessage( HttpStatus.NOT_FOUND.toString(),
"No object with that identifier exists." ), headers, HttpStatus.NOT_FOUND );
}
else if ( organisationUnit.getCode() != null )
@@ -188,7 +188,7 @@
if ( ouByCode != null && !ou.getUid().equals( ouByCode.getUid() ) )
{
- return new ResponseEntity<String>( MessageResponseUtils.jsonMessage( HttpStatus.CONFLICT.toString(),
+ return new ResponseEntity<String>( MessageUtils.jsonMessage( HttpStatus.CONFLICT.toString(),
"Another object with the same code already exists." ), headers, HttpStatus.CONFLICT );
}
}
=== added file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/DuplicateCodeException.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/DuplicateCodeException.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/DuplicateCodeException.java 2013-03-09 09:38:51 +0000
@@ -0,0 +1,44 @@
+package org.hisp.dhis.web.webapi.v1.exception;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class DuplicateCodeException extends Exception
+{
+ public DuplicateCodeException()
+ {
+ super( "A facility with that CODE already exists." );
+ }
+
+ public DuplicateCodeException( String message )
+ {
+ super( message );
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/DuplicateUidException.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/DuplicateUidException.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/DuplicateUidException.java 2013-03-09 09:38:51 +0000
@@ -0,0 +1,44 @@
+package org.hisp.dhis.web.webapi.v1.exception;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class DuplicateUidException extends Exception
+{
+ public DuplicateUidException()
+ {
+ super( "A facility with that UID already exists." );
+ }
+
+ public DuplicateUidException( String message )
+ {
+ super( message );
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/DuplicateUuidException.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/DuplicateUuidException.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/DuplicateUuidException.java 2013-03-09 09:38:51 +0000
@@ -0,0 +1,44 @@
+package org.hisp.dhis.web.webapi.v1.exception;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class DuplicateUuidException extends Exception
+{
+ public DuplicateUuidException()
+ {
+ super( "A facility with that UUID already exists." );
+ }
+
+ public DuplicateUuidException( String message )
+ {
+ super( message );
+ }
+}
=== removed file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/ETagDoesNotMatchException.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/ETagDoesNotMatchException.java 2013-03-09 08:58:06 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/ETagDoesNotMatchException.java 1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
-package org.hisp.dhis.web.webapi.v1.exception;
-
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class ETagDoesNotMatchException extends Exception
-{
-}
=== added file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/ETagVerificationException.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/ETagVerificationException.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/ETagVerificationException.java 2013-03-09 09:38:51 +0000
@@ -0,0 +1,44 @@
+package org.hisp.dhis.web.webapi.v1.exception;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class ETagVerificationException extends Exception
+{
+ public ETagVerificationException()
+ {
+ super( "ETag provided does not match current ETag of facility" );
+ }
+
+ public ETagVerificationException( String message )
+ {
+ super( message );
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/FacilityNotFoundException.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/FacilityNotFoundException.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/FacilityNotFoundException.java 2013-03-09 09:38:51 +0000
@@ -0,0 +1,44 @@
+package org.hisp.dhis.web.webapi.v1.exception;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class FacilityNotFoundException extends Exception
+{
+ public FacilityNotFoundException()
+ {
+ super( "Facility not found" );
+ }
+
+ public FacilityNotFoundException( String message )
+ {
+ super( message );
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/UuidFormatException.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/UuidFormatException.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/exception/UuidFormatException.java 2013-03-09 09:38:51 +0000
@@ -0,0 +1,44 @@
+package org.hisp.dhis.web.webapi.v1.exception;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class UuidFormatException extends Exception
+{
+ public UuidFormatException()
+ {
+ super("UUID does not match expected format.");
+ }
+
+ public UuidFormatException( String message )
+ {
+ super( message );
+ }
+}
=== removed file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/MessageResponseUtils.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/MessageResponseUtils.java 2013-03-06 09:21:16 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/MessageResponseUtils.java 1970-01-01 00:00:00 +0000
@@ -1,69 +0,0 @@
-package org.hisp.dhis.web.webapi.v1.utils;
-
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.codehaus.jackson.JsonGenerator;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.hisp.dhis.web.webapi.v1.domain.MessageResponse;
-
-import java.io.IOException;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public final class MessageResponseUtils
-{
- private static ObjectMapper objectMapper;
-
- static
- {
- objectMapper = new ObjectMapper();
- objectMapper.configure( JsonGenerator.Feature.ESCAPE_NON_ASCII, true );
- objectMapper.setSerializationInclusion( JsonSerialize.Inclusion.NON_EMPTY );
- }
-
- public static String jsonMessage( String message ) throws IOException
- {
- return messageToJson( new MessageResponse( null, message ) );
- }
-
- public static String jsonMessage( String code, String message ) throws IOException
- {
- return messageToJson( new MessageResponse( code, message ) );
- }
-
- public static String messageToJson( MessageResponse messageResponse ) throws IOException
- {
- return objectMapper.writeValueAsString( messageResponse );
- }
-
- private MessageResponseUtils()
- {
- }
-}
=== added file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/MessageUtils.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/MessageUtils.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/MessageUtils.java 2013-03-09 09:38:51 +0000
@@ -0,0 +1,69 @@
+package org.hisp.dhis.web.webapi.v1.utils;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.hisp.dhis.web.webapi.v1.domain.MessageResponse;
+
+import java.io.IOException;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public final class MessageUtils
+{
+ private static ObjectMapper objectMapper;
+
+ static
+ {
+ objectMapper = new ObjectMapper();
+ objectMapper.configure( JsonGenerator.Feature.ESCAPE_NON_ASCII, true );
+ objectMapper.setSerializationInclusion( JsonSerialize.Inclusion.NON_EMPTY );
+ }
+
+ public static String jsonMessage( String message ) throws IOException
+ {
+ return messageToJson( new MessageResponse( null, message ) );
+ }
+
+ public static String jsonMessage( String code, String message ) throws IOException
+ {
+ return messageToJson( new MessageResponse( code, message ) );
+ }
+
+ public static String messageToJson( MessageResponse messageResponse ) throws IOException
+ {
+ return objectMapper.writeValueAsString( messageResponse );
+ }
+
+ private MessageUtils()
+ {
+ }
+}