← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10025: minor fix

 

------------------------------------------------------------
revno: 10025
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-03-07 09:24:46 +0300
message:
  minor fix
modified:
  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/utils/FacilityToOrganisationUnitConverter.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-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-07 06:17:19 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java	2013-03-07 06:24:46 +0000
@@ -497,7 +497,7 @@
         return builder.toString();
     }
 
-    protected void checkUidIdentifier( Facility facility, String id ) throws IOException
+    protected void checkIdentifier( Facility facility, String id ) throws IOException
     {
         Identifier identifier = new Identifier();
 
@@ -552,7 +552,6 @@
             }
         }
 
-        checkUidIdentifier( facility, id );
         Set<ConstraintViolation<Facility>> constraintViolations = validator.validate( facility, Default.class, Update.class );
 
         String json = ValidationUtils.constraintViolationsToJson( constraintViolations );
@@ -560,7 +559,23 @@
         if ( constraintViolations.isEmpty() )
         {
             OrganisationUnit organisationUnitUpdate = conversionService.convert( facility, OrganisationUnit.class );
-            OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitUpdate.getUid() );
+            OrganisationUnit organisationUnit;
+
+            if ( id.length() == 11 )
+            {
+                organisationUnit = organisationUnitService.getOrganisationUnit( id );
+            }
+            else
+            {
+                organisationUnit = organisationUnitService.getOrganisationUnitByUuid( id );
+            }
+
+            if ( organisationUnit == null )
+            {
+                throw new HttpServerErrorException( HttpStatus.NOT_FOUND );
+            }
+
+            checkIdentifier( facility, organisationUnit.getUid() );
 
             if ( request.getHeader( "If-Match" ) != null )
             {

=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/FacilityToOrganisationUnitConverter.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/FacilityToOrganisationUnitConverter.java	2013-02-07 02:14:21 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/FacilityToOrganisationUnitConverter.java	2013-03-07 06:24:46 +0000
@@ -59,6 +59,7 @@
     {
         OrganisationUnit organisationUnit = new OrganisationUnit();
         organisationUnit.setName( facility.getName() );
+        organisationUnit.setUuid( facility.getId() );
 
         if ( facility.getName() != null && facility.getName().length() > 49 )
         {