=== 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 + */ +@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 + */ +@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 + */ +@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 + */ +@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 + */ +@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 + */ +@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 byLastUpdated = new ArrayList( + 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 @@ + + @@ -66,6 +68,10 @@ + + + +