← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17176: minor fix in id collection crud

 

------------------------------------------------------------
revno: 17176
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-10-20 13:26:55 +0700
message:
  minor fix in id collection crud
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.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-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java	2014-10-06 06:14:06 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java	2014-10-20 06:26:55 +0000
@@ -534,11 +534,13 @@
         if ( objects.isEmpty() )
         {
             ContextUtils.notFoundResponse( response, getEntityName() + " does not exist: " + pvUid );
+            return;
         }
 
         if ( !getSchema().getPropertyMap().containsKey( pvProperty ) )
         {
             ContextUtils.notFoundResponse( response, "Property " + pvProperty + " does not exist on " + getEntityName() );
+            return;
         }
 
         Property property = getSchema().getPropertyMap().get( pvProperty );
@@ -546,11 +548,13 @@
         if ( !property.isCollection() || !property.isIdentifiableObject() )
         {
             ContextUtils.conflictResponse( response, "Only adds within identifiable collection are allowed." );
+            return;
         }
 
         if ( !property.isOwner() )
         {
             ContextUtils.conflictResponse( response, getEntityName() + " is not the owner of this relationship." );
+            return;
         }
 
         Collection<IdentifiableObject> identifiableObjects =
@@ -561,6 +565,7 @@
         if ( candidate == null )
         {
             ContextUtils.notFoundResponse( response, "Collection " + pvProperty + " does not have an item with ID: " + pvItemId );
+            return;
         }
 
         // if it already contains this object, don't add it. It might be a list and not set, and we don't want duplicates.
@@ -592,11 +597,13 @@
         if ( objects.isEmpty() )
         {
             ContextUtils.notFoundResponse( response, getEntityName() + " does not exist: " + pvUid );
+            return;
         }
 
         if ( !getSchema().getPropertyMap().containsKey( pvProperty ) )
         {
             ContextUtils.notFoundResponse( response, "Property " + pvProperty + " does not exist on " + getEntityName() );
+            return;
         }
 
         Property property = getSchema().getPropertyMap().get( pvProperty );
@@ -604,11 +611,13 @@
         if ( !property.isCollection() || !property.isIdentifiableObject() )
         {
             ContextUtils.conflictResponse( response, "Only deletes within identifiable collection are allowed." );
+            return;
         }
 
         if ( !property.isOwner() )
         {
             ContextUtils.conflictResponse( response, getEntityName() + " is not the owner of this relationship." );
+            return;
         }
 
         Collection<IdentifiableObject> identifiableObjects =
@@ -633,6 +642,7 @@
         if ( candidate == null )
         {
             ContextUtils.notFoundResponse( response, "Collection " + pvProperty + " does not have an item with ID: " + pvItemId );
+            return;
         }
 
         if ( !aclService.canUpdate( currentUserService.getCurrentUser(), objects.get( 0 ) ) )