← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2256: Mainly implemented validation handling for uploading of datasets/activites.

 

------------------------------------------------------------
revno: 2256
committer: Jo Størset <storset@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2010-12-02 16:23:14 +0530
message:
  Mainly implemented validation handling for uploading of datasets/activites. 
  (now reports 409 if content is not valid)
removed:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/AbstractDataSerializableConsumer.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/ActivityValueConsumer.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/DataSetValueConsumer.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/DataStreamSerializableProvider.java
added:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/AbstractDataSerializableConsumer.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/ActivityValueConsumer.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/DataSetValueConsumer.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/DataStreamSerializableProvider.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/NotAllowedExceptionMapper.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/NotAllowedException.java
  dhis-2/dhis-web/dhis-web-api/src/test/java/org/hisp/dhis/web/api/model/DataSetValueTest.java
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataSetValue.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataValue.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ActivityReportingService.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ActivityReportingServiceImpl.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingService.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/utils/PeriodUtil.java
  dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-api/src/main/webapp/WEB-INF/web.xml
  dhis-2/dhis-web/dhis-web-api/src/test/java/org/hisp/dhis/web/api/provider/DataStreamSerializableProviderTest.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
=== added directory 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping'
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/AbstractDataSerializableConsumer.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/AbstractDataSerializableConsumer.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/AbstractDataSerializableConsumer.java	2010-12-02 10:53:14 +0000
@@ -0,0 +1,80 @@
+package org.hisp.dhis.web.api.mapping;
+
+/*
+ * Copyright (c) 2004-2010, 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 java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+
+import org.hisp.dhis.web.api.model.DataStreamSerializable;
+import org.hisp.dhis.web.api.resources.DhisMediaType;
+
+/**
+ * An abstract class mapping from the {@link DhisMediaType.MOBILE_SERIALIZED} to implementations of {@link DataStreamSerializable}
+ * 
+ * <p>Implementations only need to define T and specify the relevant annotations
+ * 
+ * @param <T> The concrete implementation of {@link DataStreamSerializable} this consumer creates and populates
+ */
+public abstract class AbstractDataSerializableConsumer<T extends DataStreamSerializable> implements MessageBodyReader<T>
+{
+    @Override
+    public boolean isReadable( Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType )
+    {
+        return DataStreamSerializable.class.isAssignableFrom( type );
+    }
+
+    @Override
+    public T readFrom( Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType,
+        MultivaluedMap<String, String> httpHeaders, InputStream entityStream )
+        throws IOException, WebApplicationException
+    {
+        T t;
+        try
+        {
+            t = type.newInstance();
+            t.deSerialize( new DataInputStream( entityStream ) );
+            return t;
+        }
+        catch ( InstantiationException e )
+        {
+            throw new IOException("Can't instantiate class " + type.getName(), e);
+        }
+        catch ( IllegalAccessException e )
+        {
+            throw new IOException("Not allowed to instantiate class " + type.getName(), e);
+        }
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/ActivityValueConsumer.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/ActivityValueConsumer.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/ActivityValueConsumer.java	2010-12-02 10:53:14 +0000
@@ -0,0 +1,44 @@
+package org.hisp.dhis.web.api.mapping;
+
+/*
+ * Copyright (c) 2004-2010, 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 javax.ws.rs.Consumes;
+import javax.ws.rs.ext.Provider;
+
+import org.hisp.dhis.web.api.model.ActivityValue;
+import org.hisp.dhis.web.api.resources.DhisMediaType;
+
+import com.sun.jersey.spi.resource.Singleton;
+
+@Provider
+@Singleton
+@Consumes( DhisMediaType.MOBILE_SERIALIZED )
+public class ActivityValueConsumer
+    extends AbstractDataSerializableConsumer<ActivityValue>
+{
+}

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/DataSetValueConsumer.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/DataSetValueConsumer.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/DataSetValueConsumer.java	2010-12-02 10:53:14 +0000
@@ -0,0 +1,44 @@
+package org.hisp.dhis.web.api.mapping;
+
+/*
+ * Copyright (c) 2004-2010, 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 javax.ws.rs.Consumes;
+import javax.ws.rs.ext.Provider;
+
+import org.hisp.dhis.web.api.model.DataSetValue;
+import org.hisp.dhis.web.api.resources.DhisMediaType;
+
+import com.sun.jersey.spi.resource.Singleton;
+
+@Provider
+@Singleton
+@Consumes( DhisMediaType.MOBILE_SERIALIZED )
+public class DataSetValueConsumer
+    extends AbstractDataSerializableConsumer<DataSetValue>
+{
+}

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/DataStreamSerializableProvider.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/DataStreamSerializableProvider.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/DataStreamSerializableProvider.java	2010-12-02 10:53:14 +0000
@@ -0,0 +1,106 @@
+package org.hisp.dhis.web.api.mapping;
+
+/*
+ * Copyright (c) 2004-2010, 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 java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+import org.hisp.dhis.web.api.model.DataStreamSerializable;
+
+import com.jcraft.jzlib.JZlib;
+import com.jcraft.jzlib.ZOutputStream;
+import com.sun.jersey.spi.resource.Singleton;
+
+@Provider
+@Singleton
+@Produces( org.hisp.dhis.web.api.resources.DhisMediaType.MOBILE_SERIALIZED )
+public class DataStreamSerializableProvider
+    implements MessageBodyWriter<DataStreamSerializable>
+{
+
+    @Override
+    public boolean isWriteable( Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType )
+    {
+        return DataStreamSerializable.class.isAssignableFrom( type );
+    }
+
+    @Override
+    public long getSize( DataStreamSerializable t, Class<?> type, Type genericType, Annotation[] annotations,
+        MediaType mediaType )
+    {
+        return -1;
+    }
+
+    @Override
+    public void writeTo( DataStreamSerializable t, Class<?> type, Type genericType, Annotation[] annotations,
+        MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream )
+        throws IOException, WebApplicationException
+    {
+        ByteArrayOutputStream baos = serializePersistent( t );
+        ZOutputStream gzip = new ZOutputStream( entityStream, JZlib.Z_BEST_COMPRESSION );
+        DataOutputStream dos = new DataOutputStream( gzip );
+
+        try
+        {
+            byte[] res = baos.toByteArray();
+            dos.write( res );
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+        finally
+        {
+            dos.flush();
+            gzip.finish();
+        }
+
+    }
+
+    public ByteArrayOutputStream serializePersistent( DataStreamSerializable entity )
+        throws IOException
+    {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        DataOutputStream out = new DataOutputStream( baos );
+        entity.serialize( out );
+        out.flush();
+        return baos;
+    }
+
+}

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/NotAllowedExceptionMapper.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/NotAllowedExceptionMapper.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/mapping/NotAllowedExceptionMapper.java	2010-12-02 10:53:14 +0000
@@ -0,0 +1,25 @@
+package org.hisp.dhis.web.api.mapping;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+import org.hisp.dhis.web.api.service.NotAllowedException;
+
+import com.sun.jersey.spi.resource.Singleton;
+
+@Provider
+@Singleton
+public class NotAllowedExceptionMapper
+    implements ExceptionMapper<NotAllowedException>
+{
+
+    @Override
+    public Response toResponse( NotAllowedException exception )
+    {
+        return Response.status( Status.CONFLICT ).entity( exception.getReason() ).type( MediaType.TEXT_PLAIN ).build();
+    }
+
+}

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataSetValue.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataSetValue.java	2010-11-30 19:36:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataSetValue.java	2010-12-02 10:53:14 +0000
@@ -33,6 +33,11 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
 public class DataSetValue
     extends Model
 {
@@ -43,6 +48,7 @@
 
     private List<DataValue> dataValues = new ArrayList<DataValue>();
 
+    @XmlAttribute
     public boolean isCompleted()
     {
         return completed;
@@ -53,6 +59,7 @@
         this.completed = completed;
     }
 
+    @XmlAttribute
     public String getPeriodName()
     {
         return periodName;
@@ -68,6 +75,7 @@
         this.dataValues = dataValues;
     }
 
+    @XmlElement(name="dataValue")
     public List<DataValue> getDataValues()
     {
         return dataValues;
@@ -96,7 +104,7 @@
             DataValue dv = new DataValue();
             dv.setId( din.readInt() );
             dv.setCategoryOptComboID( din.readInt() );
-            dv.setVal( din.readUTF() );
+            dv.setValue( din.readUTF() );
             this.dataValues.add( dv );
         }
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataValue.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataValue.java	2010-11-18 06:08:29 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/DataValue.java	2010-12-02 10:53:14 +0000
@@ -31,6 +31,8 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 
+import javax.xml.bind.annotation.XmlAttribute;
+
 public class DataValue
     implements DataStreamSerializable
 {
@@ -39,8 +41,9 @@
 
     private int categoryOptComboID;
 
-    private String val;
+    private String value;
 
+    @XmlAttribute
     public int getId()
     {
         return id;
@@ -51,16 +54,18 @@
         this.id = id;
     }
 
-    public String getVal()
-    {
-        return val;
-    }
-
-    public void setVal( String val )
-    {
-        this.val = val;
-    }
-
+    @XmlAttribute
+    public String getValue()
+    {
+        return value;
+    }
+
+    public void setValue( String value )
+    {
+        this.value = value;
+    }
+
+    @XmlAttribute
     public int getCategoryOptComboID()
     {
         return categoryOptComboID;
@@ -85,7 +90,7 @@
     {
         setId( din.readInt() );
         setCategoryOptComboID( din.readInt() );
-        setVal( din.readUTF() );
+        setValue( din.readUTF() );
     }
 
 }

=== removed directory 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider'
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/AbstractDataSerializableConsumer.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/AbstractDataSerializableConsumer.java	2010-11-26 11:00:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/AbstractDataSerializableConsumer.java	1970-01-01 00:00:00 +0000
@@ -1,80 +0,0 @@
-package org.hisp.dhis.web.api.provider;
-
-/*
- * Copyright (c) 2004-2010, 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 java.io.DataInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.MessageBodyReader;
-
-import org.hisp.dhis.web.api.model.DataStreamSerializable;
-import org.hisp.dhis.web.api.resources.DhisMediaType;
-
-/**
- * An abstract class mapping from the {@link DhisMediaType.MOBILE_SERIALIZED} to implementations of {@link DataStreamSerializable}
- * 
- * <p>Implementations only need to define T and specify the relevant annotations
- * 
- * @param <T> The concrete implementation of {@link DataStreamSerializable} this consumer creates and populates
- */
-public abstract class AbstractDataSerializableConsumer<T extends DataStreamSerializable> implements MessageBodyReader<T>
-{
-    @Override
-    public boolean isReadable( Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType )
-    {
-        return DataStreamSerializable.class.isAssignableFrom( type );
-    }
-
-    @Override
-    public T readFrom( Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType,
-        MultivaluedMap<String, String> httpHeaders, InputStream entityStream )
-        throws IOException, WebApplicationException
-    {
-        T t;
-        try
-        {
-            t = type.newInstance();
-            t.deSerialize( new DataInputStream( entityStream ) );
-            return t;
-        }
-        catch ( InstantiationException e )
-        {
-            throw new IOException("Can't instantiate class " + type.getName(), e);
-        }
-        catch ( IllegalAccessException e )
-        {
-            throw new IOException("Not allowed to instantiate class " + type.getName(), e);
-        }
-    }
-}

=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/ActivityValueConsumer.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/ActivityValueConsumer.java	2010-11-18 11:32:14 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/ActivityValueConsumer.java	1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
-package org.hisp.dhis.web.api.provider;
-
-/*
- * Copyright (c) 2004-2010, 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 javax.ws.rs.Consumes;
-import javax.ws.rs.ext.Provider;
-
-import org.hisp.dhis.web.api.model.ActivityValue;
-import org.hisp.dhis.web.api.resources.DhisMediaType;
-
-import com.sun.jersey.spi.resource.Singleton;
-
-@Provider
-@Singleton
-@Consumes( DhisMediaType.MOBILE_SERIALIZED )
-public class ActivityValueConsumer
-    extends AbstractDataSerializableConsumer<ActivityValue>
-{
-}

=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/DataSetValueConsumer.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/DataSetValueConsumer.java	2010-11-18 11:32:14 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/DataSetValueConsumer.java	1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
-package org.hisp.dhis.web.api.provider;
-
-/*
- * Copyright (c) 2004-2010, 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 javax.ws.rs.Consumes;
-import javax.ws.rs.ext.Provider;
-
-import org.hisp.dhis.web.api.model.DataSetValue;
-import org.hisp.dhis.web.api.resources.DhisMediaType;
-
-import com.sun.jersey.spi.resource.Singleton;
-
-@Provider
-@Singleton
-@Consumes( DhisMediaType.MOBILE_SERIALIZED )
-public class DataSetValueConsumer
-    extends AbstractDataSerializableConsumer<DataSetValue>
-{
-}

=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/DataStreamSerializableProvider.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/DataStreamSerializableProvider.java	2010-11-18 11:32:14 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/provider/DataStreamSerializableProvider.java	1970-01-01 00:00:00 +0000
@@ -1,106 +0,0 @@
-package org.hisp.dhis.web.api.provider;
-
-/*
- * Copyright (c) 2004-2010, 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 java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-
-import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.MessageBodyWriter;
-import javax.ws.rs.ext.Provider;
-
-import org.hisp.dhis.web.api.model.DataStreamSerializable;
-
-import com.jcraft.jzlib.JZlib;
-import com.jcraft.jzlib.ZOutputStream;
-import com.sun.jersey.spi.resource.Singleton;
-
-@Provider
-@Singleton
-@Produces( org.hisp.dhis.web.api.resources.DhisMediaType.MOBILE_SERIALIZED )
-public class DataStreamSerializableProvider
-    implements MessageBodyWriter<DataStreamSerializable>
-{
-
-    @Override
-    public boolean isWriteable( Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType )
-    {
-        return DataStreamSerializable.class.isAssignableFrom( type );
-    }
-
-    @Override
-    public long getSize( DataStreamSerializable t, Class<?> type, Type genericType, Annotation[] annotations,
-        MediaType mediaType )
-    {
-        return -1;
-    }
-
-    @Override
-    public void writeTo( DataStreamSerializable t, Class<?> type, Type genericType, Annotation[] annotations,
-        MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream )
-        throws IOException, WebApplicationException
-    {
-        ByteArrayOutputStream baos = serializePersistent( t );
-        ZOutputStream gzip = new ZOutputStream( entityStream, JZlib.Z_BEST_COMPRESSION );
-        DataOutputStream dos = new DataOutputStream( gzip );
-
-        try
-        {
-            byte[] res = baos.toByteArray();
-            dos.write( res );
-        }
-        catch ( Exception e )
-        {
-            e.printStackTrace();
-        }
-        finally
-        {
-            dos.flush();
-            gzip.finish();
-        }
-
-    }
-
-    public ByteArrayOutputStream serializePersistent( DataStreamSerializable entity )
-        throws IOException
-    {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        DataOutputStream out = new DataOutputStream( baos );
-        entity.serialize( out );
-        out.flush();
-        return baos;
-    }
-
-}

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java	2010-11-26 11:00:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java	2010-12-02 10:53:14 +0000
@@ -19,10 +19,11 @@
 import org.hisp.dhis.web.api.service.ActivityReportingServiceImpl;
 import org.hisp.dhis.web.api.service.FacilityReportingService;
 import org.hisp.dhis.web.api.service.IProgramService;
+import org.hisp.dhis.web.api.service.NotAllowedException;
 import org.springframework.beans.factory.annotation.Required;
 
 @Produces( { DhisMediaType.MOBILE_SERIALIZED, MediaType.APPLICATION_XML } )
-@Consumes( DhisMediaType.MOBILE_SERIALIZED )
+@Consumes( { DhisMediaType.MOBILE_SERIALIZED, MediaType.APPLICATION_XML } )
 public class OrgUnitResource
 {
 
@@ -69,18 +70,16 @@
 
     @POST
     @Path( "dataSets" )
-    @Produces( MediaType.TEXT_PLAIN )
-    public String saveDataSetValues( DataSetValue dataSetValue )
+    public void saveDataSetValues( DataSetValue dataSetValue ) throws NotAllowedException
     {
-        return facilityReportingService.saveDataSetValues( unit, dataSetValue );
+        facilityReportingService.saveDataSetValues( unit, dataSetValue );
     }
 
     @POST
     @Path( "activities" )
-    @Produces( MediaType.TEXT_PLAIN )
-    public String saveActivityReport( ActivityValue activityValue )
+    public void saveActivityReport( ActivityValue activityValue ) throws NotAllowedException
     {
-        return activityReportingService.saveActivityReport( unit, activityValue );
+        activityReportingService.saveActivityReport( unit, activityValue );
     }
 
     // Setters...

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ActivityReportingService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ActivityReportingService.java	2010-11-18 06:08:29 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ActivityReportingService.java	2010-12-02 10:53:14 +0000
@@ -9,6 +9,6 @@
 
     public ActivityPlan getCurrentActivityPlan( OrganisationUnit unit, String localeString );
 
-    public String saveActivityReport( OrganisationUnit unit, ActivityValue activityValue );
+    public void saveActivityReport( OrganisationUnit unit, ActivityValue activityValue ) throws NotAllowedException;
 
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ActivityReportingServiceImpl.java	2010-11-26 11:00:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ActivityReportingServiceImpl.java	2010-12-02 10:53:14 +0000
@@ -290,7 +290,7 @@
     // -------------------------------------------------------------------------
 
     @Override
-    public String saveActivityReport( OrganisationUnit unit, ActivityValue activityValue )
+    public void saveActivityReport( OrganisationUnit unit, ActivityValue activityValue ) throws NotAllowedException
     {
 
         ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( activityValue
@@ -298,7 +298,7 @@
 
         if ( programStageInstance == null )
         {
-            return "INVALID_PROGRAM_STAGE";
+            throw new NotAllowedException( "INVALID_PROGRAM_STAGE");
         }
 
         programStageInstance.getProgramStage();
@@ -319,7 +319,7 @@
 
         if ( dataElements.size() != dataElementIds.size() )
         {
-            return "INVALID_PROGRAM_STAGE";
+            throw new NotAllowedException( "INVALID_PROGRAM_STAGE" );
         }
 
         Map<Integer, org.hisp.dhis.dataelement.DataElement> dataElementMap = new HashMap<Integer, org.hisp.dhis.dataelement.DataElement>();
@@ -327,7 +327,7 @@
         {
             if ( !dataElementIds.contains( dataElement.getId() ) )
             {
-                return "INVALID_PROGRAM_STAGE";
+                throw new NotAllowedException( "INVALID_PROGRAM_STAGE" );
             }
             dataElementMap.put( dataElement.getId(), dataElement );
         }
@@ -339,8 +339,6 @@
         saveDataValues( activityValue, programStageInstance, dataElementMap, unit,
             categoryService.getDefaultDataElementCategoryOptionCombo() );
 
-        return "SUCCESS";
-
     }
 
     // -------------------------------------------------------------------------
@@ -356,7 +354,7 @@
 
         for ( DataValue dv : activityValue.getDataValues() )
         {
-            value = dv.getVal();
+            value = dv.getValue();
             DataElementCategoryOptionCombo cateOptCombo = categoryService.getDataElementCategoryOptionCombo( dv
                 .getCategoryOptComboID() );
             if ( value != null && value.trim().length() == 0 )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingService.java	2010-11-16 18:26:11 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingService.java	2010-12-02 10:53:14 +0000
@@ -41,6 +41,6 @@
 
     public DataSet getDataSetForLocale( int dataSetId, Locale locale );
 
-    public String saveDataSetValues( OrganisationUnit unit, DataSetValue dataSetValue );
+    public void saveDataSetValues( OrganisationUnit unit, DataSetValue dataSetValue ) throws NotAllowedException;
 
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java	2010-12-01 07:03:19 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/FacilityReportingServiceImpl.java	2010-12-02 10:53:14 +0000
@@ -66,6 +66,8 @@
 {
     private static Log log = LogFactory.getLog( FacilityReportingServiceImpl.class );
 
+    private static boolean DEBUG = log.isDebugEnabled();
+    
     private DataElementSortOrderComparator dataElementComparator = new DataElementSortOrderComparator();
 
     // -------------------------------------------------------------------------
@@ -94,6 +96,9 @@
         List<DataSet> datasets = new ArrayList<DataSet>();
         Locale locale = LocaleUtil.getLocale( localeString );
 
+        if (DEBUG)
+            log.debug( "Getting data sets for unit " + unit.getName() );
+        
         for ( org.hisp.dhis.dataset.DataSet dataSet : dataSetService.getDataSetsForMobile( unit ) )
         {
             PeriodType periodType = dataSet.getPeriodType();
@@ -103,6 +108,9 @@
                 || periodType instanceof YearlyPeriodType
                 || periodType instanceof QuarterlyPeriodType )
             {
+                if (DEBUG)
+                    log.debug( "Found data set " + dataSet.getName() );
+
                 datasets.add( getDataSetForLocale( dataSet.getId(), locale ) );
             }
             else
@@ -183,25 +191,25 @@
     }
 
     @Override
-    public String saveDataSetValues( OrganisationUnit unit, DataSetValue dataSetValue )
+    public void saveDataSetValues( OrganisationUnit unit, DataSetValue dataSetValue ) throws NotAllowedException
     {
 
         org.hisp.dhis.dataset.DataSet dataSet = dataSetService.getDataSet( dataSetValue.getId() );
 
         if ( !dataSetService.getDataSetsBySource( unit ).contains( dataSet ) )
         {
-            return "INVALID_DATASET_ASSOCIATION";
+            throw new NotAllowedException( "INVALID_DATASET_ASSOCIATION" );
         }
 
         Period selectedPeriod = getPeriod( dataSetValue.getPeriodName(), dataSet.getPeriodType() );
 
         if ( selectedPeriod == null )
         {
-            return "INVALID_PERIOD";
+            throw new NotAllowedException("INVALID_PERIOD");
         }
         
         if (isDataSetLocked(unit, dataSet, selectedPeriod)){
-            return "DATASET_LOCKED";
+            throw new NotAllowedException("DATASET_LOCKED");
         }
 
         Collection<org.hisp.dhis.dataelement.DataElement> dataElements = dataSet.getDataElements();
@@ -227,8 +235,6 @@
         saveDataValues( dataSetValue, dataElementMap, selectedPeriod, unit,
             categoryService.getDefaultDataElementCategoryOptionCombo() );
 
-        return "SUCCESS";
-
     }
 
     // -------------------------------------------------------------------------
@@ -252,7 +258,7 @@
 
         for ( DataValue dv : dataSetValue.getDataValues() )
         {
-            value = dv.getVal();
+            value = dv.getValue();
             DataElementCategoryOptionCombo cateOptCombo = categoryService.getDataElementCategoryOptionCombo( dv
                 .getCategoryOptComboID() );
             if ( value != null && value.trim().length() == 0 )

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/NotAllowedException.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/NotAllowedException.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/NotAllowedException.java	2010-12-02 10:53:14 +0000
@@ -0,0 +1,26 @@
+package org.hisp.dhis.web.api.service;
+
+public class NotAllowedException
+    extends Exception
+{
+
+    private String reason;
+
+    public NotAllowedException( String reason )
+    {
+        this.reason = reason;
+    }
+
+    public NotAllowedException( String reason, String message )
+    {
+        super(message);
+        this.reason = reason;
+    }
+
+    public String getReason()
+    {
+        return reason;
+    }
+
+
+}

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/utils/PeriodUtil.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/utils/PeriodUtil.java	2010-11-30 19:36:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/utils/PeriodUtil.java	2010-12-02 10:53:14 +0000
@@ -39,8 +39,14 @@
 
         if ( periodType instanceof WeeklyPeriodType )
         {
-            int week = Integer.parseInt( periodName.substring( 0, periodName.indexOf( '-' ) ) );
-            int year = Integer.parseInt( periodName.substring( periodName.indexOf( '-' ) + 1, periodName.length() ) );
+            int dashIndex = periodName.indexOf( '-' );
+
+            if (dashIndex < 0) {
+                return null;
+            }
+
+            int week = Integer.parseInt( periodName.substring( 0, dashIndex ) );
+            int year = Integer.parseInt( periodName.substring( dashIndex + 1, periodName.length() ) );
 
             Calendar cal = Calendar.getInstance();
             cal.set( Calendar.YEAR, year );
@@ -53,8 +59,14 @@
 
         if ( periodType instanceof MonthlyPeriodType )
         {
-            int month = Integer.parseInt( periodName.substring( 0, periodName.indexOf( '-' ) ) );
-            int year = Integer.parseInt( periodName.substring( periodName.indexOf( '-' ) + 1, periodName.length() ) );
+            int dashIndex = periodName.indexOf( '-' );
+
+            if (dashIndex < 0) {
+                return null;
+            }
+
+            int month = Integer.parseInt( periodName.substring( 0, dashIndex ) );
+            int year = Integer.parseInt( periodName.substring( dashIndex + 1, periodName.length() ) );
 
             Calendar cal = Calendar.getInstance();
             cal.set( Calendar.YEAR, year );

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml	2010-12-01 07:03:19 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml	2010-12-02 10:53:14 +0000
@@ -46,14 +46,18 @@
 
   <!-- Jax-RS serialization writers and readers -->
 
-  <bean id="org.hisp.dhis.web.api.provider.DataSerializableProvider" class="org.hisp.dhis.web.api.provider.DataStreamSerializableProvider"
+  <bean id="org.hisp.dhis.web.api.mapping.DataSerializableProvider" class="org.hisp.dhis.web.api.mapping.DataStreamSerializableProvider"
     scope="singleton" />
 	
-  <bean id="org.hisp.dhis.web.api.consumer.DataSetValueConsumer" class="org.hisp.dhis.web.api.provider.DataSetValueConsumer"
-    scope="singleton" />
-
-  <bean id="org.hisp.dhis.web.api.consumer.ActivityValueConsumer" class="org.hisp.dhis.web.api.provider.ActivityValueConsumer"
-    scope="singleton" />
+  <bean id="org.hisp.dhis.web.api.mapping.DataSetValueConsumer" class="org.hisp.dhis.web.api.mapping.DataSetValueConsumer"
+    scope="singleton" />
+
+  <bean id="org.hisp.dhis.web.api.mapping.ActivityValueConsumer" class="org.hisp.dhis.web.api.mapping.ActivityValueConsumer"
+    scope="singleton" />
+
+  <bean id="org.hisp.dhis.web.api.mapping.StringSerializedProvider" class="org.hisp.dhis.web.api.mapping.NotAllowedExceptionMapper"
+    scope="singleton" />
+
 
   <!-- ImportDataValue beans -->
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/webapp/WEB-INF/web.xml'
--- dhis-2/dhis-web/dhis-web-api/src/main/webapp/WEB-INF/web.xml	2010-09-24 11:12:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/webapp/WEB-INF/web.xml	2010-12-02 10:53:14 +0000
@@ -85,6 +85,10 @@
 			<param-value>
 				com.sun.jersey.api.container.filter.LoggingFilter</param-value>
 		</init-param>
+<!--        <init-param>         -->
+<!--          <param-name>com.sun.jersey.config.feature.Trace</param-name>-->
+<!--          <param-value>true</param-value>-->
+<!--        </init-param>-->
 		<load-on-startup>1</load-on-startup>
 	</servlet>
 	<servlet-mapping>

=== added file 'dhis-2/dhis-web/dhis-web-api/src/test/java/org/hisp/dhis/web/api/model/DataSetValueTest.java'
--- dhis-2/dhis-web/dhis-web-api/src/test/java/org/hisp/dhis/web/api/model/DataSetValueTest.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/test/java/org/hisp/dhis/web/api/model/DataSetValueTest.java	2010-12-02 10:53:14 +0000
@@ -0,0 +1,59 @@
+package org.hisp.dhis.web.api.model;
+
+import static org.junit.Assert.*;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class DataSetValueTest
+{
+
+    static JAXBContext JC;
+    String s = "<dataSetValue completed=\"true\" periodName=\"10-2010\" id=\"54\" name=\"Handicaped Data Set -mobile\"><dataValue categoryOptComboID=\"1\" id=\"1743\" value=\"12\" /></dataSetValue>";
+
+    @BeforeClass
+    public static void init() throws JAXBException {
+        JC = JAXBContext.newInstance( DataSetValue.class );
+    }
+    
+    @Test
+    public void unmarshall()
+        throws JAXBException
+    {
+        Unmarshaller unmarshaller = JC.createUnmarshaller();
+        DataSetValue dataSetValue = (DataSetValue) unmarshaller.unmarshal( new StringReader( s ) );
+
+        assertEquals( 54, dataSetValue.getId() );
+        List<DataValue> dataValues = dataSetValue.getDataValues();
+        assertNotNull(dataValues);
+        assertEquals( 1, dataValues.size() );
+        assertEquals( 1743, dataValues.get( 0 ).getId() );
+    }
+
+    @Test
+    public void marshall()
+        throws JAXBException
+    {
+        Unmarshaller unmarshaller = JC.createUnmarshaller();
+        DataSetValue dataSetValue = (DataSetValue) unmarshaller.unmarshal( new StringReader( s ) );
+
+        Marshaller marshaller = JC.createMarshaller();
+        StringWriter stringWriter = new StringWriter();
+        marshaller.marshal( dataSetValue, stringWriter );
+        String xml = stringWriter.toString();
+        System.out.println(xml);
+        assertTrue( xml.contains( "name=\"Handicaped Data Set -mobile\"" ) );
+        assertTrue( xml.contains( "id=\"1743\"" ) );
+    }
+
+    
+}

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/test/java/org/hisp/dhis/web/api/provider/DataStreamSerializableProviderTest.java'
--- dhis-2/dhis-web/dhis-web-api/src/test/java/org/hisp/dhis/web/api/provider/DataStreamSerializableProviderTest.java	2010-11-18 06:08:29 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/test/java/org/hisp/dhis/web/api/provider/DataStreamSerializableProviderTest.java	2010-12-02 10:53:14 +0000
@@ -2,6 +2,7 @@
 
 import static org.junit.Assert.assertTrue;
 
+import org.hisp.dhis.web.api.mapping.DataStreamSerializableProvider;
 import org.hisp.dhis.web.api.model.OrgUnits;
 import org.junit.Test;