← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5392: merged with dxf2

 

Merge authors:
  Morten Olav Hansen (mortenoh)
------------------------------------------------------------
revno: 5392 [merge]
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-12-13 17:49:00 +0100
message:
  merged with dxf2
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryComboController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ConstantController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupSetController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DocumentController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupSetController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorTypeController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MapController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupSetController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitLevelController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SqlViewController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ValidationRuleController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ValidationRuleGroupController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/HibernateObjectPersister.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ObjectPersister.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/dataelement/DataElementGroupSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java	2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSet.java	2011-12-12 13:03:59 +0000
@@ -94,6 +94,12 @@
     // Logic
     // -------------------------------------------------------------------------
 
+    public void addDataElementGroup( DataElementGroup dataElementGroup )
+    {
+        members.add( dataElementGroup );
+        dataElementGroup.setGroupSet( this );
+    }
+
     public Collection<DataElement> getDataElements()
     {
         List<DataElement> dataElements = new ArrayList<DataElement>();

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2011-12-13 10:24:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2011-12-13 16:47:13 +0000
@@ -187,6 +187,18 @@
     // Logic
     // -------------------------------------------------------------------------
 
+    public void addOrganisationUnitGroup( OrganisationUnitGroup organisationUnitGroup )
+    {
+        groups.add( organisationUnitGroup );
+        organisationUnitGroup.getMembers().add( this );
+    }
+
+    public void removeOrganisationUnitGroup( OrganisationUnitGroup organisationUnitGroup )
+    {
+        groups.remove( organisationUnitGroup );
+        organisationUnitGroup.getMembers().remove( this );
+    }
+
     public void addDataSet( DataSet dataSet )
     {
         dataSets.add( dataSet );
@@ -542,7 +554,7 @@
 
     public void setAlternativeName( String alternativeName )
     {
-        throw new UnsupportedOperationException( "Cannot set alternativename on OrganisationUnit: " + alternativeName );
+        throw new UnsupportedOperationException( "Cannot set alternativeName on OrganisationUnit: " + alternativeName );
     }
 
     @XmlElement
@@ -744,18 +756,6 @@
 
     @XmlElement
     @JsonProperty
-    public boolean isCurrentParent()
-    {
-        return currentParent;
-    }
-
-    public void setCurrentParent( boolean currentParent )
-    {
-        this.currentParent = currentParent;
-    }
-
-    @XmlElement
-    @JsonProperty
     public String getType()
     {
         return type;
@@ -808,4 +808,14 @@
     {
         this.value = value;
     }
+
+    public boolean isCurrentParent()
+    {
+        return currentParent;
+    }
+
+    public void setCurrentParent( boolean currentParent )
+    {
+        this.currentParent = currentParent;
+    }
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java	2011-12-11 13:47:04 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java	2011-12-13 16:47:13 +0000
@@ -73,16 +73,16 @@
     // Logic
     // -------------------------------------------------------------------------
 
-    public void addOrganisationUnit( OrganisationUnit unit )
+    public void addOrganisationUnit( OrganisationUnit organisationUnit )
     {
-        members.add( unit );
-        unit.getGroups().add( this );
+        members.add( organisationUnit );
+        organisationUnit.getGroups().add( this );
     }
 
-    public void removeOrganisationUnit( OrganisationUnit unit )
+    public void removeOrganisationUnit( OrganisationUnit organisationUnit )
     {
-        members.remove( unit );
-        unit.getGroups().remove( this );
+        members.remove( organisationUnit );
+        organisationUnit.getGroups().remove( this );
     }
 
     public void updateOrganisationUnits( Set<OrganisationUnit> updates )

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java	2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSet.java	2011-12-12 15:05:46 +0000
@@ -77,6 +77,18 @@
     // Logic
     // -------------------------------------------------------------------------
 
+    public void addOrganisationUnitGroup( OrganisationUnitGroup organisationUnitGroup )
+    {
+        organisationUnitGroups.add( organisationUnitGroup );
+        organisationUnitGroup.setGroupSet( this );
+    }
+
+    public void removeOrganisationUnitGroup( OrganisationUnitGroup organisationUnitGroup )
+    {
+        organisationUnitGroups.remove( organisationUnitGroup );
+        organisationUnitGroup.setGroupSet( null );
+    }
+
     public Collection<OrganisationUnit> getOrganisationUnits()
     {
         List<OrganisationUnit> units = new ArrayList<OrganisationUnit>();

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryComboController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryComboController.java	2011-12-08 17:11:47 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryComboController.java	2011-12-12 11:37:04 +0000
@@ -122,7 +122,7 @@
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
     public void putCategoryComboXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
     }
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryController.java	2011-12-08 17:11:47 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CategoryController.java	2011-12-12 11:37:04 +0000
@@ -122,7 +122,7 @@
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
     public void putCategoryXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
     }
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java	2011-12-13 14:04:12 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java	2011-12-13 16:47:13 +0000
@@ -27,12 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.io.IOException;
-import java.util.ArrayList;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 import org.hisp.dhis.api.utils.IdentifiableObjectParams;
 import org.hisp.dhis.api.utils.WebLinkPopulator;
 import org.hisp.dhis.chart.Chart;
@@ -43,12 +37,17 @@
 import org.jfree.chart.ChartUtilities;
 import org.jfree.chart.JFreeChart;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -123,4 +122,51 @@
         response.setContentType( "image/jpg" );
         ChartUtilities.writeChartAsJPEG( response.getOutputStream(), chart, width, height );
     }
+
+    //-------------------------------------------------------------------------------------------------------
+    // POST
+    //-------------------------------------------------------------------------------------------------------
+
+    @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+    @ResponseStatus( value = HttpStatus.CREATED )
+    public void postChartXML( HttpServletResponse response, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+    }
+
+    @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+    @ResponseStatus( value = HttpStatus.CREATED )
+    public void postChartJSON( HttpServletResponse response, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+    }
+
+    //-------------------------------------------------------------------------------------------------------
+    // PUT
+    //-------------------------------------------------------------------------------------------------------
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    public void putChartXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+    }
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    public void putChartJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+    }
+
+    //-------------------------------------------------------------------------------------------------------
+    // DELETE
+    //-------------------------------------------------------------------------------------------------------
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    public void deleteChart( @PathVariable( "uid" ) String uid ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ConstantController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ConstantController.java	2011-12-11 00:00:06 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ConstantController.java	2011-12-12 13:03:59 +0000
@@ -93,7 +93,7 @@
 
         model.addAttribute( "model", constant );
 
-        return "category";
+        return "constant";
     }
 
     //-------------------------------------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementController.java	2011-12-13 14:04:12 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementController.java	2011-12-13 16:47:13 +0000
@@ -42,6 +42,7 @@
 import org.hisp.dhis.dataelement.DataElements;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.HttpRequestMethodNotSupportedException;
@@ -107,6 +108,7 @@
     //-------------------------------------------------------------------------------------------------------
 
     @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_CREATE')" )
     public void postDataElementXML( HttpServletResponse response, InputStream input ) throws Exception
     {
         DataElement dataElement = Jaxb2Utils.unmarshal( DataElement.class, input );
@@ -114,6 +116,7 @@
     }
 
     @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_CREATE')" )
     public void postDataElementJSON( HttpServletResponse response, InputStream input ) throws Exception
     {
         throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
@@ -131,7 +134,7 @@
         {
             try
             {
-                objectPersister.persistDataElement( dataElement );
+                dataElement = objectPersister.persistDataElement( dataElement );
 
                 if ( dataElement.getUid() == null )
                 {
@@ -144,7 +147,6 @@
                 }
             } catch ( Exception e )
             {
-                e.printStackTrace();
                 response.setStatus( HttpServletResponse.SC_CONFLICT );
             }
         }
@@ -156,6 +158,7 @@
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_UPDATE')" )
     public void putDataElementXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
     {
         throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
@@ -163,6 +166,7 @@
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_UPDATE')" )
     public void putDataElementJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
     {
         throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
@@ -174,8 +178,16 @@
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_DELETE')" )
     public void deleteDataElement( @PathVariable( "uid" ) String uid ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+        // throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+
+        DataElement dataElement = dataElementService.getDataElement( uid );
+
+        if ( dataElement != null )
+        {
+            dataElementService.deleteDataElement( dataElement );
+        }
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupController.java	2011-12-08 17:11:47 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupController.java	2011-12-12 13:03:59 +0000
@@ -28,12 +28,15 @@
  */
 
 import org.hisp.dhis.api.utils.IdentifiableObjectParams;
+import org.hisp.dhis.api.utils.ObjectPersister;
 import org.hisp.dhis.api.utils.WebLinkPopulator;
+import org.hisp.dhis.api.view.Jaxb2Utils;
 import org.hisp.dhis.dataelement.DataElementGroup;
 import org.hisp.dhis.dataelement.DataElementGroups;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.HttpRequestMethodNotSupportedException;
@@ -56,6 +59,9 @@
     @Autowired
     private DataElementService dataElementService;
 
+    @Autowired
+    private ObjectPersister objectPersister;
+
     //-------------------------------------------------------------------------------------------------------
     // GET
     //-------------------------------------------------------------------------------------------------------
@@ -98,25 +104,55 @@
     //-------------------------------------------------------------------------------------------------------
 
     @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
-    @ResponseStatus( value = HttpStatus.CREATED )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_CREATE')" )
     public void postDataElementGroupXML( HttpServletResponse response, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+        DataElementGroup dataElementGroup = Jaxb2Utils.unmarshal( DataElementGroup.class, input );
+        postDataElementGroup( dataElementGroup, response );
     }
 
     @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
-    @ResponseStatus( value = HttpStatus.CREATED )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_CREATE')" )
     public void postDataElementGroupJSON( HttpServletResponse response, InputStream input ) throws Exception
     {
         throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
     }
 
+    public void postDataElementGroup( DataElementGroup dataElementGroup, HttpServletResponse response )
+    {
+        if ( dataElementGroup == null )
+        {
+            response.setStatus( HttpServletResponse.SC_NOT_IMPLEMENTED );
+        }
+        else
+        {
+            try
+            {
+                dataElementGroup = objectPersister.persistDataElementGroup( dataElementGroup );
+
+                if ( dataElementGroup.getUid() == null )
+                {
+                    response.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+                }
+                else
+                {
+                    response.setStatus( HttpServletResponse.SC_CREATED );
+                    response.setHeader( "Location", DataElementController.RESOURCE_PATH + "/" + dataElementGroup.getUid() );
+                }
+            } catch ( Exception e )
+            {
+                response.setStatus( HttpServletResponse.SC_CONFLICT );
+            }
+        }
+    }
+
     //-------------------------------------------------------------------------------------------------------
     // PUT
     //-------------------------------------------------------------------------------------------------------
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_UPDATE')" )
     public void putDataElementGroupXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
     {
         throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
@@ -124,6 +160,7 @@
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_UPDATE')" )
     public void putDataElementGroupJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
     {
         throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
@@ -135,8 +172,16 @@
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_DELETE')" )
     public void deleteDataElementGroup( @PathVariable( "uid" ) String uid ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+        // throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+
+        DataElementGroup dataElementGroup = dataElementService.getDataElementGroup( uid );
+
+        if ( dataElementGroup != null )
+        {
+            dataElementService.deleteDataElementGroup( dataElementGroup );
+        }
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupSetController.java	2011-12-08 17:11:47 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementGroupSetController.java	2011-12-12 13:03:59 +0000
@@ -28,18 +28,26 @@
  */
 
 import org.hisp.dhis.api.utils.IdentifiableObjectParams;
+import org.hisp.dhis.api.utils.ObjectPersister;
 import org.hisp.dhis.api.utils.WebLinkPopulator;
+import org.hisp.dhis.api.view.Jaxb2Utils;
 import org.hisp.dhis.dataelement.DataElementGroupSet;
 import org.hisp.dhis.dataelement.DataElementGroupSets;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
 import java.util.ArrayList;
 
 /**
@@ -54,6 +62,9 @@
     @Autowired
     private DataElementService dataElementService;
 
+    @Autowired
+    private ObjectPersister objectPersister;
+
     //-------------------------------------------------------------------------------------------------------
     // GET
     //-------------------------------------------------------------------------------------------------------
@@ -90,4 +101,90 @@
 
         return "dataElementGroupSet";
     }
+
+    //-------------------------------------------------------------------------------------------------------
+    // POST
+    //-------------------------------------------------------------------------------------------------------
+
+    @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_CREATE')" )
+    public void postDataElementGroupSetXML( HttpServletResponse response, InputStream input ) throws Exception
+    {
+        DataElementGroupSet dataElementGroupSet = Jaxb2Utils.unmarshal( DataElementGroupSet.class, input );
+        postDataElementGroupSet( dataElementGroupSet, response );
+    }
+
+    @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_CREATE')" )
+    public void postDataElementGroupSetJSON( HttpServletResponse response, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+    }
+
+    public void postDataElementGroupSet( DataElementGroupSet dataElementGroupSet, HttpServletResponse response )
+    {
+        if ( dataElementGroupSet == null )
+        {
+            response.setStatus( HttpServletResponse.SC_NOT_IMPLEMENTED );
+        }
+        else
+        {
+            try
+            {
+                dataElementGroupSet = objectPersister.persistDataElementGroupSet( dataElementGroupSet );
+
+                if ( dataElementGroupSet.getUid() == null )
+                {
+                    response.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+                }
+                else
+                {
+                    response.setStatus( HttpServletResponse.SC_CREATED );
+                    response.setHeader( "Location", DataElementController.RESOURCE_PATH + "/" + dataElementGroupSet.getUid() );
+                }
+            } catch ( Exception e )
+            {
+                response.setStatus( HttpServletResponse.SC_CONFLICT );
+            }
+        }
+    }
+
+    //-------------------------------------------------------------------------------------------------------
+    // PUT
+    //-------------------------------------------------------------------------------------------------------
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_UPDATE')" )
+    public void putDataElementGroupSetXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+    }
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_UPDATE')" )
+    public void putDataElementGroupSetJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+    }
+
+    //-------------------------------------------------------------------------------------------------------
+    // DELETE
+    //-------------------------------------------------------------------------------------------------------
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_DELETE')" )
+    public void deleteDataElementGroupSet( @PathVariable( "uid" ) String uid ) throws Exception
+    {
+        // throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+
+        DataElementGroupSet dataElementGroupSet = dataElementService.getDataElementGroupSet( uid );
+
+        if ( dataElementGroupSet != null )
+        {
+            dataElementService.deleteDataElementGroupSet( dataElementGroupSet );
+        }
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java	2011-12-08 14:31:31 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java	2011-12-12 11:37:04 +0000
@@ -120,7 +120,7 @@
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
     public void putDataSetXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
     }
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DocumentController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DocumentController.java	2011-12-10 23:03:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DocumentController.java	2011-12-12 13:03:59 +0000
@@ -93,7 +93,7 @@
 
         model.addAttribute( "model", document );
 
-        return "validationRule";
+        return "document";
     }
 
     //-------------------------------------------------------------------------------------------------------
@@ -122,7 +122,7 @@
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
     public void putDocumentXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
     }
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorController.java	2011-12-08 17:11:47 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorController.java	2011-12-12 11:37:04 +0000
@@ -122,7 +122,7 @@
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
     public void putIndicatorXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
     }
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupController.java	2011-12-08 17:11:47 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupController.java	2011-12-12 11:37:04 +0000
@@ -33,13 +33,18 @@
 import org.hisp.dhis.indicator.IndicatorGroups;
 import org.hisp.dhis.indicator.IndicatorService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
 import java.util.ArrayList;
 
 /**
@@ -90,4 +95,51 @@
 
         return "indicatorGroup";
     }
+
+    //-------------------------------------------------------------------------------------------------------
+    // POST
+    //-------------------------------------------------------------------------------------------------------
+
+    @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+    @ResponseStatus( value = HttpStatus.CREATED )
+    public void postIndicatorGroupXML( HttpServletResponse response, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+    }
+
+    @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+    @ResponseStatus( value = HttpStatus.CREATED )
+    public void postIndicatorGroupJSON( HttpServletResponse response, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+    }
+
+    //-------------------------------------------------------------------------------------------------------
+    // PUT
+    //-------------------------------------------------------------------------------------------------------
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    public void putIndicatorGroupXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+    }
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    public void putIndicatorGroupJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+    }
+
+    //-------------------------------------------------------------------------------------------------------
+    // DELETE
+    //-------------------------------------------------------------------------------------------------------
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    public void deleteIndicatorGroup( @PathVariable( "uid" ) String uid ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupSetController.java	2011-12-08 17:11:47 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorGroupSetController.java	2011-12-12 11:37:04 +0000
@@ -122,7 +122,7 @@
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
     public void putIndicatorGroupSetXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
     }
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorTypeController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorTypeController.java	2011-12-08 17:11:47 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorTypeController.java	2011-12-12 11:37:04 +0000
@@ -33,13 +33,18 @@
 import org.hisp.dhis.indicator.IndicatorType;
 import org.hisp.dhis.indicator.IndicatorTypes;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
 import java.util.ArrayList;
 
 /**
@@ -90,4 +95,51 @@
 
         return "indicatorType";
     }
+
+    //-------------------------------------------------------------------------------------------------------
+    // POST
+    //-------------------------------------------------------------------------------------------------------
+
+    @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+    @ResponseStatus( value = HttpStatus.CREATED )
+    public void postIndicatorTypeXML( HttpServletResponse response, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+    }
+
+    @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+    @ResponseStatus( value = HttpStatus.CREATED )
+    public void postIndicatorTypeJSON( HttpServletResponse response, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+    }
+
+    //-------------------------------------------------------------------------------------------------------
+    // PUT
+    //-------------------------------------------------------------------------------------------------------
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    public void putIndicatorTypeXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+    }
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    public void putIndicatorTypeJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+    }
+
+    //-------------------------------------------------------------------------------------------------------
+    // DELETE
+    //-------------------------------------------------------------------------------------------------------
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    public void deleteIndicatorType( @PathVariable( "uid" ) String uid ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MapController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MapController.java	2011-12-08 14:31:31 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MapController.java	2011-12-12 11:37:04 +0000
@@ -128,7 +128,7 @@
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
     public void putMapXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
     }
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitController.java	2011-12-08 17:11:47 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitController.java	2011-12-12 15:06:51 +0000
@@ -1,12 +1,15 @@
 package org.hisp.dhis.api.controller;
 
 import org.hisp.dhis.api.utils.IdentifiableObjectParams;
+import org.hisp.dhis.api.utils.ObjectPersister;
 import org.hisp.dhis.api.utils.WebLinkPopulator;
+import org.hisp.dhis.api.view.Jaxb2Utils;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.organisationunit.OrganisationUnits;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.HttpRequestMethodNotSupportedException;
@@ -32,6 +35,9 @@
     @Autowired
     private OrganisationUnitService organisationUnitService;
 
+    @Autowired
+    private ObjectPersister objectPersister;
+
     //-------------------------------------------------------------------------------------------------------
     // GET
     //-------------------------------------------------------------------------------------------------------
@@ -82,19 +88,48 @@
     //-------------------------------------------------------------------------------------------------------
 
     @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
-    @ResponseStatus( value = HttpStatus.CREATED )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_CREATE')" )
     public void postOrganisationUnitXML( HttpServletResponse response, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+        OrganisationUnit organisationUnit = Jaxb2Utils.unmarshal( OrganisationUnit.class, input );
+        postOrganisationUnit( organisationUnit, response );
     }
 
     @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
-    @ResponseStatus( value = HttpStatus.CREATED )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_CREATE')" )
     public void postOrganisationUnitJSON( HttpServletResponse response, InputStream input ) throws Exception
     {
         throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
     }
 
+    public void postOrganisationUnit( OrganisationUnit organisationUnit, HttpServletResponse response )
+    {
+        if ( organisationUnit == null )
+        {
+            response.setStatus( HttpServletResponse.SC_NOT_IMPLEMENTED );
+        }
+        else
+        {
+            try
+            {
+                organisationUnit = objectPersister.persistOrganisationUnit( organisationUnit );
+
+                if ( organisationUnit.getUid() == null )
+                {
+                    response.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+                }
+                else
+                {
+                    response.setStatus( HttpServletResponse.SC_CREATED );
+                    response.setHeader( "Location", DataElementController.RESOURCE_PATH + "/" + organisationUnit.getUid() );
+                }
+            } catch ( Exception e )
+            {
+                response.setStatus( HttpServletResponse.SC_CONFLICT );
+            }
+        }
+    }
+
     //-------------------------------------------------------------------------------------------------------
     // PUT
     //-------------------------------------------------------------------------------------------------------
@@ -103,7 +138,7 @@
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
     public void putOrganisationUnitXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
     }
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupController.java	2011-12-08 17:15:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupController.java	2011-12-12 15:06:51 +0000
@@ -1,18 +1,26 @@
 package org.hisp.dhis.api.controller;
 
 import org.hisp.dhis.api.utils.IdentifiableObjectParams;
+import org.hisp.dhis.api.utils.ObjectPersister;
 import org.hisp.dhis.api.utils.WebLinkPopulator;
+import org.hisp.dhis.api.view.Jaxb2Utils;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroups;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
 import java.util.ArrayList;
 
 /**
@@ -27,6 +35,9 @@
     @Autowired
     private OrganisationUnitGroupService organisationUnitGroupService;
 
+    @Autowired
+    private ObjectPersister objectPersister;
+
     //-------------------------------------------------------------------------------------------------------
     // GET
     //-------------------------------------------------------------------------------------------------------
@@ -63,4 +74,81 @@
 
         return "organisationUnitGroup";
     }
+
+    //-------------------------------------------------------------------------------------------------------
+    // POST
+    //-------------------------------------------------------------------------------------------------------
+
+    @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_CREATE')" )
+    public void postOrganisationUnitGroupXML( HttpServletResponse response, InputStream input ) throws Exception
+    {
+        OrganisationUnitGroup organisationUnitGroup = Jaxb2Utils.unmarshal( OrganisationUnitGroup.class, input );
+
+        postOrganisationUnitGroup( organisationUnitGroup, response );
+    }
+
+    @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_CREATE')" )
+    public void postOrganisationUnitGroupJSON( HttpServletResponse response, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+    }
+
+    public void postOrganisationUnitGroup( OrganisationUnitGroup organisationUnitGroup, HttpServletResponse response )
+    {
+        if ( organisationUnitGroup == null )
+        {
+            response.setStatus( HttpServletResponse.SC_NOT_IMPLEMENTED );
+        }
+        else
+        {
+            try
+            {
+                organisationUnitGroup = objectPersister.persistOrganisationUnitGroup( organisationUnitGroup );
+
+                if ( organisationUnitGroup.getUid() == null )
+                {
+                    response.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+                }
+                else
+                {
+                    response.setStatus( HttpServletResponse.SC_CREATED );
+                    response.setHeader( "Location", DataElementController.RESOURCE_PATH + "/" + organisationUnitGroup.getUid() );
+                }
+            } catch ( Exception e )
+            {
+                response.setStatus( HttpServletResponse.SC_CONFLICT );
+            }
+        }
+    }
+
+    //-------------------------------------------------------------------------------------------------------
+    // PUT
+    //-------------------------------------------------------------------------------------------------------
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/xml, text/xml"} )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    public void putOrganisationUnitGroupXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+    }
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    public void putOrganisationUnitGroupJSON( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
+    }
+
+    //-------------------------------------------------------------------------------------------------------
+    // DELETE
+    //-------------------------------------------------------------------------------------------------------
+
+    @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
+    @ResponseStatus( value = HttpStatus.NO_CONTENT )
+    public void deleteOrganisationUnitGroup( @PathVariable( "uid" ) String uid ) throws Exception
+    {
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupSetController.java	2011-12-08 17:11:47 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitGroupSetController.java	2011-12-12 15:06:51 +0000
@@ -28,12 +28,15 @@
  */
 
 import org.hisp.dhis.api.utils.IdentifiableObjectParams;
+import org.hisp.dhis.api.utils.ObjectPersister;
 import org.hisp.dhis.api.utils.WebLinkPopulator;
+import org.hisp.dhis.api.view.Jaxb2Utils;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupSets;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.HttpRequestMethodNotSupportedException;
@@ -59,6 +62,9 @@
     @Autowired
     private OrganisationUnitGroupService organisationUnitGroupService;
 
+    @Autowired
+    private ObjectPersister objectPersister;
+
     //-------------------------------------------------------------------------------------------------------
     // GET
     //-------------------------------------------------------------------------------------------------------
@@ -101,19 +107,48 @@
     //-------------------------------------------------------------------------------------------------------
 
     @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
-    @ResponseStatus( value = HttpStatus.CREATED )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_CREATE')" )
     public void postOrganisationUnitGroupSetXML( HttpServletResponse response, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+        OrganisationUnitGroupSet organisationUnitGroupSet = Jaxb2Utils.unmarshal( OrganisationUnitGroupSet.class, input );
+        postOrganisationUnitGroupSet( organisationUnitGroupSet, response );
     }
 
     @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
-    @ResponseStatus( value = HttpStatus.CREATED )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_CREATE')" )
     public void postOrganisationUnitGroupSetJSON( HttpServletResponse response, InputStream input ) throws Exception
     {
         throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
     }
 
+    public void postOrganisationUnitGroupSet( OrganisationUnitGroupSet organisationUnitGroupSet, HttpServletResponse response )
+    {
+        if ( organisationUnitGroupSet == null )
+        {
+            response.setStatus( HttpServletResponse.SC_NOT_IMPLEMENTED );
+        }
+        else
+        {
+            try
+            {
+                organisationUnitGroupSet = objectPersister.persistOrganisationUnitGroupSet( organisationUnitGroupSet );
+
+                if ( organisationUnitGroupSet.getUid() == null )
+                {
+                    response.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+                }
+                else
+                {
+                    response.setStatus( HttpServletResponse.SC_CREATED );
+                    response.setHeader( "Location", DataElementController.RESOURCE_PATH + "/" + organisationUnitGroupSet.getUid() );
+                }
+            } catch ( Exception e )
+            {
+                response.setStatus( HttpServletResponse.SC_CONFLICT );
+            }
+        }
+    }
+
     //-------------------------------------------------------------------------------------------------------
     // PUT
     //-------------------------------------------------------------------------------------------------------
@@ -122,7 +157,7 @@
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
     public void putOrganisationUnitGroupSetXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
     }
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitLevelController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitLevelController.java	2011-12-08 17:11:47 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitLevelController.java	2011-12-12 15:06:51 +0000
@@ -28,12 +28,15 @@
  */
 
 import org.hisp.dhis.api.utils.IdentifiableObjectParams;
+import org.hisp.dhis.api.utils.ObjectPersister;
 import org.hisp.dhis.api.utils.WebLinkPopulator;
+import org.hisp.dhis.api.view.Jaxb2Utils;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevels;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.HttpRequestMethodNotSupportedException;
@@ -59,6 +62,9 @@
     @Autowired
     private OrganisationUnitService organisationUnitService;
 
+    @Autowired
+    private ObjectPersister objectPersister;
+
     //-------------------------------------------------------------------------------------------------------
     // GET
     //-------------------------------------------------------------------------------------------------------
@@ -101,19 +107,48 @@
     //-------------------------------------------------------------------------------------------------------
 
     @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
-    @ResponseStatus( value = HttpStatus.CREATED )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_CREATE')" )
     public void postOrganisationUnitLevelXML( HttpServletResponse response, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
+        OrganisationUnitLevel organisationUnitLevel = Jaxb2Utils.unmarshal( OrganisationUnitLevel.class, input );
+        postOrganisationUnitLevel( organisationUnitLevel, response );
     }
 
     @RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/json"} )
-    @ResponseStatus( value = HttpStatus.CREATED )
+    @PreAuthorize( "hasRole('ALL') or hasRole('F_WEBAPI_CREATE')" )
     public void postOrganisationUnitLevelJSON( HttpServletResponse response, InputStream input ) throws Exception
     {
         throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() );
     }
 
+    public void postOrganisationUnitLevel( OrganisationUnitLevel organisationUnitLevel, HttpServletResponse response )
+    {
+        if ( organisationUnitLevel == null )
+        {
+            response.setStatus( HttpServletResponse.SC_NOT_IMPLEMENTED );
+        }
+        else
+        {
+            try
+            {
+                organisationUnitLevel = objectPersister.persistOrganisationUnitLevel( organisationUnitLevel );
+
+                if ( organisationUnitLevel.getUid() == null )
+                {
+                    response.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+                }
+                else
+                {
+                    response.setStatus( HttpServletResponse.SC_CREATED );
+                    response.setHeader( "Location", DataElementController.RESOURCE_PATH + "/" + organisationUnitLevel.getUid() );
+                }
+            } catch ( Exception e )
+            {
+                response.setStatus( HttpServletResponse.SC_CONFLICT );
+            }
+        }
+    }
+
     //-------------------------------------------------------------------------------------------------------
     // PUT
     //-------------------------------------------------------------------------------------------------------
@@ -122,7 +157,7 @@
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
     public void putOrganisationUnitLevelXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
     }
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SqlViewController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SqlViewController.java	2011-12-11 00:21:52 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SqlViewController.java	2011-12-12 13:03:59 +0000
@@ -93,7 +93,7 @@
 
         model.addAttribute( "model", sqlView );
 
-        return "indicator";
+        return "sqlView";
     }
 
     //-------------------------------------------------------------------------------------------------------
@@ -122,7 +122,7 @@
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
     public void putSqlViewXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
     }
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserController.java	2011-12-08 17:11:47 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/UserController.java	2011-12-12 11:37:04 +0000
@@ -122,7 +122,7 @@
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
     public void putUserXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
     }
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ValidationRuleController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ValidationRuleController.java	2011-12-10 23:22:51 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ValidationRuleController.java	2011-12-12 11:37:04 +0000
@@ -122,7 +122,7 @@
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
     public void putValidationRuleXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
     }
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ValidationRuleGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ValidationRuleGroupController.java	2011-12-10 23:03:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ValidationRuleGroupController.java	2011-12-12 11:37:04 +0000
@@ -122,7 +122,7 @@
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
     public void putValidationRuleGroupXML( @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
     {
-        throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() );
+        throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() );
     }
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = {"Content-Type=application/json"} )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/HibernateObjectPersister.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/HibernateObjectPersister.java	2011-12-09 15:05:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/HibernateObjectPersister.java	2011-12-12 15:05:46 +0000
@@ -27,22 +27,14 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.hisp.dhis.attribute.Attribute;
-import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.dataelement.*;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.indicator.IndicatorGroup;
-import org.hisp.dhis.indicator.IndicatorGroupSet;
-import org.hisp.dhis.indicator.IndicatorType;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
-import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
-import org.hisp.dhis.user.User;
+import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.organisationunit.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -51,6 +43,7 @@
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
 @Component
+@Transactional
 public class HibernateObjectPersister implements ObjectPersister
 {
     @Autowired
@@ -62,27 +55,33 @@
     @Autowired
     private DataSetService dataSetService;
 
+    @Autowired
+    private IndicatorService indicatorService;
+
+    @Autowired
+    private OrganisationUnitService organisationUnitService;
+
+    @Autowired
+    private OrganisationUnitGroupService organisationUnitGroupService;
+
     @Override
-    public void persistAttribute( Attribute attribute )
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    public void persistDataElement( DataElement dataElement )
-    {
-        if ( dataElement.getCategoryCombo() != null )
-        {
-            DataElementCategoryCombo dataElementCategoryCombo = dataElementCategoryService.getDataElementCategoryCombo( dataElement.getCategoryCombo().getUid() );
-            dataElement.setCategoryCombo( dataElementCategoryCombo );
-        }
-
+    public DataElement persistDataElement( DataElement dataElement )
+    {
         Collection<DataElementGroup> dataElementGroups = new ArrayList<DataElementGroup>( dataElement.getGroups() );
         Collection<DataSet> dataSets = new ArrayList<DataSet>( dataElement.getDataSets() );
         dataElement.getGroups().clear();
         dataElement.getDataSets().clear();
+        dataElement.getAttributeValues().clear();
+        dataElement.setCategoryCombo( null );
 
         dataElementService.addDataElement( dataElement );
 
+        if ( dataElement.getCategoryCombo() != null )
+        {
+            DataElementCategoryCombo dataElementCategoryCombo = dataElementCategoryService.getDataElementCategoryCombo( dataElement.getCategoryCombo().getUid() );
+            dataElement.setCategoryCombo( dataElementCategoryCombo );
+        }
+
         for ( DataElementGroup dataElementGroup : dataElementGroups )
         {
             dataElementGroup = dataElementService.getDataElementGroup( dataElementGroup.getUid() );
@@ -96,107 +95,145 @@
         }
 
         dataElementService.updateDataElement( dataElement );
-    }
-
-    @Override
-    public void persistDataElementGroup( DataElementGroup dataElementGroup )
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public void persistDataElementGroupSet( DataElementGroupSet dataElementGroupSet )
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public void persistCategory( DataElementCategory category )
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public void persistCategoryOption( DataElementCategoryOption categoryOption )
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public void persistCategoryCombo( DataElementCategoryCombo categoryCombo )
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public void persistCategoryOptionCombo( DataElementCategoryOptionCombo categoryOptionCombo )
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public void persistIndicator( Indicator indicator )
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public void persistIndicatorType( IndicatorType indicatorType )
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public void persistIndicatorGroup( IndicatorGroup indicatorGroup )
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public void persistIndicatorGroupSet( IndicatorGroupSet indicatorGroupSet )
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public void persistOrganisationUnit( OrganisationUnit organisationUnit )
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public void persistOrganisationUnitLevel( OrganisationUnitLevel organisationUnitLevel )
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public void persistOrganisationUnitGroup( OrganisationUnitGroup organisationUnitGroup )
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public void persistOrganisationUnitGroupSet( OrganisationUnitGroupSet organisationUnitGroupSet )
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public void persistDataSet( DataSet dataSet )
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public void persistChart( Chart chart )
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    @Override
-    public void persistUser( User user )
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
+
+        return dataElement;
+    }
+
+    @Override
+    public DataElementGroup persistDataElementGroup( DataElementGroup dataElementGroup )
+    {
+        Collection<DataElement> dataElements = new ArrayList<DataElement>( dataElementGroup.getMembers() );
+        DataElementGroupSet dataElementGroupSet = dataElementGroup.getGroupSet();
+        dataElementGroup.getMembers().clear();
+        dataElementGroup.setGroupSet( null );
+
+        dataElementService.addDataElementGroup( dataElementGroup );
+
+        for ( DataElement dataElement : dataElements )
+        {
+            dataElement = dataElementService.getDataElement( dataElement.getUid() );
+            dataElementGroup.addDataElement( dataElement );
+        }
+
+        if ( dataElementGroupSet != null )
+        {
+            dataElementGroupSet = dataElementService.getDataElementGroupSet( dataElementGroup.getGroupSet().getUid() );
+            dataElementGroup.setGroupSet( dataElementGroupSet );
+        }
+
+        dataElementService.updateDataElementGroup( dataElementGroup );
+
+        return dataElementGroup;
+    }
+
+    @Override
+    public DataElementGroupSet persistDataElementGroupSet( DataElementGroupSet dataElementGroupSet )
+    {
+        Collection<DataElementGroup> dataElementGroups = new ArrayList<DataElementGroup>( dataElementGroupSet.getMembers() );
+        dataElementGroupSet.getMembers().clear();
+
+        dataElementService.addDataElementGroupSet( dataElementGroupSet );
+
+        for ( DataElementGroup dataElementGroup : dataElementGroups )
+        {
+            dataElementGroup = dataElementService.getDataElementGroup( dataElementGroup.getUid() );
+            dataElementGroupSet.addDataElementGroup( dataElementGroup );
+        }
+
+        dataElementService.updateDataElementGroupSet( dataElementGroupSet );
+
+        return dataElementGroupSet;
+    }
+
+    @Override
+    public OrganisationUnit persistOrganisationUnit( OrganisationUnit organisationUnit )
+    {
+        Collection<OrganisationUnitGroup> organisationUnitGroups = new ArrayList<OrganisationUnitGroup>( organisationUnit.getGroups() );
+        Collection<DataSet> dataSets = new ArrayList<DataSet>( organisationUnit.getDataSets() );
+        OrganisationUnit parent = organisationUnit.getParent();
+
+        organisationUnit.getGroups().clear();
+        organisationUnit.getDataSets().clear();
+        organisationUnit.setParent( null );
+        organisationUnit.getAttributeValues().clear();
+
+        organisationUnitService.addOrganisationUnit( organisationUnit );
+
+        for ( OrganisationUnitGroup organisationUnitGroup : organisationUnitGroups )
+        {
+            organisationUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( organisationUnitGroup.getUid() );
+            organisationUnit.addOrganisationUnitGroup( organisationUnitGroup );
+        }
+
+        for ( DataSet dataSet : dataSets )
+        {
+            dataSet = dataSetService.getDataSet( dataSet.getUid() );
+            organisationUnit.addDataSet( dataSet );
+        }
+
+        if ( parent != null )
+        {
+            parent = organisationUnitService.getOrganisationUnit( parent.getUid() );
+            organisationUnit.setParent( parent );
+        }
+
+        organisationUnitService.updateOrganisationUnit( organisationUnit );
+
+        return organisationUnit;
+    }
+
+    @Override
+    public OrganisationUnitLevel persistOrganisationUnitLevel( OrganisationUnitLevel organisationUnitLevel )
+    {
+        organisationUnitService.addOrganisationUnitLevel( organisationUnitLevel );
+
+        return organisationUnitLevel;
+    }
+
+    @Override
+    public OrganisationUnitGroup persistOrganisationUnitGroup( OrganisationUnitGroup organisationUnitGroup )
+    {
+        Collection<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>( organisationUnitGroup.getMembers() );
+        OrganisationUnitGroupSet organisationUnitGroupSet = organisationUnitGroup.getGroupSet();
+
+        organisationUnitGroup.getMembers().clear();
+        organisationUnitGroup.setGroupSet( null );
+
+        organisationUnitGroupService.addOrganisationUnitGroup( organisationUnitGroup );
+
+        for ( OrganisationUnit organisationUnit : organisationUnits )
+        {
+            organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnit.getUid() );
+            organisationUnitGroup.addOrganisationUnit( organisationUnit );
+        }
+
+        if ( organisationUnitGroupSet != null )
+        {
+            organisationUnitGroupSet = organisationUnitGroupService.getOrganisationUnitGroupSet( organisationUnitGroupSet.getUid() );
+            organisationUnitGroupSet.addOrganisationUnitGroup( organisationUnitGroup );
+        }
+
+        organisationUnitGroupService.updateOrganisationUnitGroup( organisationUnitGroup );
+
+        return organisationUnitGroup;
+    }
+
+    @Override
+    public OrganisationUnitGroupSet persistOrganisationUnitGroupSet( OrganisationUnitGroupSet organisationUnitGroupSet )
+    {
+        Collection<OrganisationUnitGroup> organisationUnitGroups = new ArrayList<OrganisationUnitGroup>( organisationUnitGroupSet.getOrganisationUnitGroups() );
+        organisationUnitGroupSet.getOrganisationUnitGroups().clear();
+
+        organisationUnitGroupService.addOrganisationUnitGroupSet( organisationUnitGroupSet );
+
+        for ( OrganisationUnitGroup organisationUnitGroup : organisationUnitGroups )
+        {
+            organisationUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( organisationUnitGroup.getUid() );
+            organisationUnitGroupSet.addOrganisationUnitGroup( organisationUnitGroup );
+        }
+
+        organisationUnitGroupService.updateOrganisationUnitGroupSet( organisationUnitGroupSet );
+
+        return organisationUnitGroupSet;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ObjectPersister.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ObjectPersister.java	2011-12-09 15:05:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ObjectPersister.java	2011-12-12 13:03:59 +0000
@@ -46,41 +46,17 @@
  */
 public interface ObjectPersister
 {
-    public void persistAttribute( Attribute attribute );
-
-    public void persistDataElement( DataElement dataElement );
-
-    public void persistDataElementGroup( DataElementGroup dataElementGroup );
-
-    public void persistDataElementGroupSet( DataElementGroupSet dataElementGroupSet );
-
-    public void persistCategory( DataElementCategory category );
-
-    public void persistCategoryOption( DataElementCategoryOption categoryOption );
-
-    public void persistCategoryCombo( DataElementCategoryCombo categoryCombo );
-
-    public void persistCategoryOptionCombo( DataElementCategoryOptionCombo categoryOptionCombo );
-
-    public void persistIndicator( Indicator indicator );
-
-    public void persistIndicatorType( IndicatorType indicatorType );
-
-    public void persistIndicatorGroup( IndicatorGroup indicatorGroup );
-
-    public void persistIndicatorGroupSet( IndicatorGroupSet indicatorGroupSet );
-
-    public void persistOrganisationUnit( OrganisationUnit organisationUnit );
-
-    public void persistOrganisationUnitLevel( OrganisationUnitLevel organisationUnitLevel );
-
-    public void persistOrganisationUnitGroup( OrganisationUnitGroup organisationUnitGroup );
-
-    public void persistOrganisationUnitGroupSet( OrganisationUnitGroupSet organisationUnitGroupSet );
-
-    public void persistDataSet( DataSet dataSet );
-
-    public void persistChart( Chart chart );
-
-    public void persistUser( User user );
+    public DataElement persistDataElement( DataElement dataElement );
+
+    public DataElementGroup persistDataElementGroup( DataElementGroup dataElementGroup );
+
+    public DataElementGroupSet persistDataElementGroupSet( DataElementGroupSet dataElementGroupSet );
+
+    public OrganisationUnit persistOrganisationUnit( OrganisationUnit organisationUnit );
+
+    public OrganisationUnitLevel persistOrganisationUnitLevel( OrganisationUnitLevel organisationUnitLevel );
+
+    public OrganisationUnitGroup persistOrganisationUnitGroup( OrganisationUnitGroup organisationUnitGroup );
+
+    public OrganisationUnitGroupSet persistOrganisationUnitGroupSet( OrganisationUnitGroupSet organisationUnitGroupSet );
 }