← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19337: Add uuid generator

 

------------------------------------------------------------
revno: 19337
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-06-10 18:00:04 +0700
message:
  Add uuid generator
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.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/SystemController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.java	2015-04-11 16:53:23 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.java	2015-06-10 11:00:04 +0000
@@ -31,8 +31,8 @@
 import org.hisp.dhis.common.CodeGenerator;
 import org.hisp.dhis.dataintegrity.DataIntegrityReport;
 import org.hisp.dhis.dataintegrity.FlattenedDataIntegrityReport;
+import org.hisp.dhis.dxf2.common.JacksonUtils;
 import org.hisp.dhis.dxf2.metadata.ImportSummary;
-import org.hisp.dhis.dxf2.common.JacksonUtils;
 import org.hisp.dhis.node.exception.InvalidTypeException;
 import org.hisp.dhis.node.types.CollectionNode;
 import org.hisp.dhis.node.types.RootNode;
@@ -60,6 +60,7 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.UUID;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -104,6 +105,27 @@
         return rootNode;
     }
 
+    @RequestMapping( value = "/uuid", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE } )
+    public @ResponseBody RootNode getUuid( @RequestParam( required = false, defaultValue = "1" ) Integer n, HttpServletResponse response )
+        throws IOException, InvalidTypeException
+    {
+        if ( n > 10000 )
+        {
+            n = 10000;
+        }
+
+        RootNode rootNode = new RootNode( "codes" );
+        CollectionNode collectionNode = rootNode.addChild( new CollectionNode( "codes" ) );
+        collectionNode.setWrapping( false );
+
+        for ( int i = 0; i < n; i++ )
+        {
+            collectionNode.addChild( new SimpleNode( "code", UUID.randomUUID().toString() ) );
+        }
+
+        return rootNode;
+    }
+
     @RequestMapping( value = "/tasks/{category}", method = RequestMethod.GET, produces = { "*/*", "application/json" } )
     public void getTaskJson( @PathVariable( "category" ) String category,
         @RequestParam( required = false ) String lastId, HttpServletResponse response ) throws IOException