dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #27532
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13706: csd: handle soap based getModificationRequests, for now, returns normal meta-data xml
------------------------------------------------------------
revno: 13706
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-01-14 11:02:39 +0700
message:
csd: handle soap based getModificationRequests, for now, returns normal meta-data xml
added:
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/Body.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/Envelope.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/GetModificationsRequest.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/Header.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/package-info.java
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/webapi/
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/webapi/CsdController.java
modified:
dhis-2/dhis-web/dhis-web-api-fred/src/main/resources/META-INF/dhis/webapi-fred.xml
--
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-fred/src/main/java/org/hisp/dhis/web/csd'
=== added directory 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain'
=== added file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/Body.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/Body.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/Body.java 2014-01-14 04:02:39 +0000
@@ -0,0 +1,59 @@
+package org.hisp.dhis.web.csd.domain;
+
+/*
+ * Copyright (c) 2004-2013, 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.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@XmlAccessorType( XmlAccessType.FIELD )
+@XmlRootElement( name = "Body", namespace = "http://www.w3.org/2003/05/soap-envelope" )
+public class Body
+{
+ @XmlElement( name = "getModificationsRequest", namespace = "urn:ihe:iti:csd:2013" )
+ private GetModificationsRequest getModificationsRequest;
+
+ public Body()
+ {
+ }
+
+ public GetModificationsRequest getGetModificationsRequest()
+ {
+ return getModificationsRequest;
+ }
+
+ public void setGetModificationsRequest( GetModificationsRequest getModificationsRequest )
+ {
+ this.getModificationsRequest = getModificationsRequest;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/Envelope.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/Envelope.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/Envelope.java 2014-01-14 04:02:39 +0000
@@ -0,0 +1,80 @@
+package org.hisp.dhis.web.csd.domain;
+
+/*
+ * Copyright (c) 2004-2013, 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.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@XmlAccessorType( XmlAccessType.FIELD )
+@XmlRootElement( name = "Envelope", namespace = "http://www.w3.org/2003/05/soap-envelope" )
+public class Envelope
+{
+ @XmlElement( name = "Header", required = true, namespace = "http://www.w3.org/2003/05/soap-envelope" )
+ private Header header;
+
+ @XmlElement( name = "Body", required = true, namespace = "http://www.w3.org/2003/05/soap-envelope" )
+ private Body body;
+
+ public Envelope()
+ {
+ }
+
+ public Header getHeader()
+ {
+ return header;
+ }
+
+ public void setHeader( Header header )
+ {
+ this.header = header;
+ }
+
+ public Body getBody()
+ {
+ return body;
+ }
+
+ public void setBody( Body body )
+ {
+ this.body = body;
+ }
+
+ @Override public String toString()
+ {
+ return "Envelope{" +
+ "header=" + header +
+ ", body=" + body +
+ '}';
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/GetModificationsRequest.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/GetModificationsRequest.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/GetModificationsRequest.java 2014-01-14 04:02:39 +0000
@@ -0,0 +1,60 @@
+package org.hisp.dhis.web.csd.domain;
+
+/*
+ * Copyright (c) 2004-2013, 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.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.Date;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@XmlAccessorType( XmlAccessType.FIELD )
+@XmlRootElement( name = "getModificationsRequest", namespace = "urn:ihe:iti:csd:2013" )
+public class GetModificationsRequest
+{
+ @XmlElement( name = "lastModified", required = true, namespace = "urn:ihe:iti:csd:2013" )
+ private Date lastModified;
+
+ public GetModificationsRequest()
+ {
+ }
+
+ public Date getLastModified()
+ {
+ return lastModified;
+ }
+
+ public void setLastModified( Date lastModified )
+ {
+ this.lastModified = lastModified;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/Header.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/Header.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/Header.java 2014-01-14 04:02:39 +0000
@@ -0,0 +1,45 @@
+package org.hisp.dhis.web.csd.domain;
+
+/*
+ * Copyright (c) 2004-2013, 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.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@XmlAccessorType( XmlAccessType.FIELD )
+@XmlRootElement( name = "Header", namespace = "http://www.w3.org/2003/05/soap-envelope" )
+public class Header
+{
+ public Header()
+ {
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/package-info.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/package-info.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/domain/package-info.java 2014-01-14 04:02:39 +0000
@@ -0,0 +1,12 @@
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@XmlSchema( xmlns = {
+ @XmlNs( prefix = "soap", namespaceURI = "http://www.w3.org/2003/05/soap-envelope" ),
+ @XmlNs( prefix = "wsa", namespaceURI = "http://www.w3.org/2005/08/addressing" ),
+ @XmlNs( prefix = "csd", namespaceURI = "urn:ihe:iti:csd:2013" )
+} )
+package org.hisp.dhis.web.csd.domain;
+
+import javax.xml.bind.annotation.XmlNs;
+import javax.xml.bind.annotation.XmlSchema;
=== added directory 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/webapi'
=== added file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/webapi/CsdController.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/webapi/CsdController.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/webapi/CsdController.java 2014-01-14 04:02:39 +0000
@@ -0,0 +1,89 @@
+package org.hisp.dhis.web.csd.webapi;
+
+/*
+ * Copyright (c) 2004-2013, 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 org.hisp.dhis.dxf2.metadata.MetaData;
+import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.web.csd.domain.Envelope;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.client.HttpClientErrorException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@Controller
+@RequestMapping( value = "/csd" )
+public class CsdController
+{
+ @Autowired
+ private OrganisationUnitService organisationUnitService;
+
+ @RequestMapping( value = "", method = RequestMethod.GET )
+ public void index( HttpServletRequest request, HttpServletResponse response ) throws IOException
+ {
+ response.getWriter().println( "Hello." );
+ }
+
+ @RequestMapping( value = "", method = RequestMethod.POST )
+ public void csdRequest( @RequestBody Envelope envelope, HttpServletResponse response ) throws IOException
+ {
+ Date lastModified = null;
+
+ try
+ {
+ lastModified = envelope.getBody().getGetModificationsRequest().getLastModified();
+ }
+ catch ( NullPointerException ex )
+ {
+ throw new HttpClientErrorException( HttpStatus.BAD_REQUEST );
+ }
+
+ List<OrganisationUnit> byLastUpdated = new ArrayList<OrganisationUnit>(
+ organisationUnitService.getAllOrganisationUnitsByLastUpdated( lastModified ) );
+
+ MetaData metaData = new MetaData();
+ metaData.setOrganisationUnits( byLastUpdated );
+
+ JacksonUtils.toXml( response.getOutputStream(), metaData );
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/resources/META-INF/dhis/webapi-fred.xml'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/resources/META-INF/dhis/webapi-fred.xml 2014-01-13 16:47:26 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/resources/META-INF/dhis/webapi-fred.xml 2014-01-14 04:02:39 +0000
@@ -14,6 +14,8 @@
<context:component-scan base-package="org.hisp.dhis.web.fred" />
+ <context:component-scan base-package="org.hisp.dhis.web.csd" />
+
<context:annotation-config />
<bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean">
@@ -66,6 +68,10 @@
<property name="extractValueFromSingleKeyModel" value="true" />
</bean>
+ <bean class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
+ <property name="packagesToScan" value="org.hisp.dhis.web.csd.domain" />
+ </bean>
+
<mvc:annotation-driven>
<mvc:message-converters register-defaults="false">
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">