dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #43263
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21964: minor, moved SchemaValidator to service-core
------------------------------------------------------------
revno: 21964
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2016-02-15 11:57:22 +0700
message:
minor, moved SchemaValidator to service-core
removed:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationViolation.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationViolations.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/DefaultSchemaValidator.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/SchemaValidator.java
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/validation/
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/validation/SchemaValidator.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/validation/ValidationViolation.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/validation/ValidationViolations.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/validation/
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/validation/DefaultSchemaValidator.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/DefaultAttributeService.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundleValidation.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/webmessage/responses/ValidationViolationsWebMessageResponse.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MaintenanceController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchemaController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/WebMessageUtils.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/attribute/AttributeService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeService.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeService.java 2016-02-15 04:57:22 +0000
@@ -30,7 +30,7 @@
import org.hisp.dhis.attribute.exception.NonUniqueAttributeValueException;
import org.hisp.dhis.common.IdentifiableObject;
-import org.hisp.dhis.validation.ValidationViolation;
+import org.hisp.dhis.schema.validation.ValidationViolation;
import java.util.List;
import java.util.Set;
=== added directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/validation'
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/validation/SchemaValidator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/validation/SchemaValidator.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/validation/SchemaValidator.java 2016-02-15 04:57:22 +0000
@@ -0,0 +1,56 @@
+package org.hisp.dhis.schema.validation;
+
+/*
+ * Copyright (c) 2004-2016, 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.util.List;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public interface SchemaValidator
+{
+ /**
+ * Validate object against its schema, the object is required to be non-null and have a schema associated with it.
+ *
+ * @param object Object to validate
+ * @param persisted Only include persisted properties
+ * @return WebMessage containing validation response
+ */
+ List<ValidationViolation> validate( Object object, boolean persisted );
+
+ /**
+ * Validate object against its schema, the object is required to be non-null and have a schema associated with it.
+ * <p>
+ * Only persisted values will be checked.
+ *
+ * @param object Object to validate
+ * @return WebMessage containing validation response
+ */
+ List<ValidationViolation> validate( Object object );
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/validation/ValidationViolation.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/validation/ValidationViolation.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/validation/ValidationViolation.java 2016-02-15 04:57:22 +0000
@@ -0,0 +1,111 @@
+package org.hisp.dhis.schema.validation;
+
+/*
+ * Copyright (c) 2004-2016, 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 com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import com.google.common.base.MoreObjects;
+import org.hisp.dhis.common.DxfNamespaces;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@JsonPropertyOrder( {
+ "message"
+} )
+@JacksonXmlRootElement( localName = "validationViolation", namespace = DxfNamespaces.DXF_2_0 )
+public class ValidationViolation
+{
+ private String property;
+
+ private String message;
+
+ private Object value;
+
+ public ValidationViolation( String property, String message )
+ {
+ this.property = property;
+ this.message = message;
+ }
+
+ public ValidationViolation( String property, String message, Object value )
+ {
+ this.property = property;
+ this.message = message;
+ this.value = value;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public String getProperty()
+ {
+ return property;
+ }
+
+ public void setProperty( String property )
+ {
+ this.property = property;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public String getMessage()
+ {
+ return message;
+ }
+
+ public void setMessage( String message )
+ {
+ this.message = message;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public Object getValue()
+ {
+ return value;
+ }
+
+ public void setValue( Object value )
+ {
+ this.value = value;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MoreObjects.toStringHelper( this )
+ .add( "property", property )
+ .add( "message", message )
+ .add( "value", value )
+ .toString();
+ }
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/validation/ValidationViolations.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/validation/ValidationViolations.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/validation/ValidationViolations.java 2016-02-15 04:57:22 +0000
@@ -0,0 +1,71 @@
+package org.hisp.dhis.schema.validation;
+
+/*
+ * Copyright (c) 2004-2016, 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 com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import org.hisp.dhis.common.DxfNamespaces;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Temporary wrapper for ValidationViolation
+ *
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@JacksonXmlRootElement( localName = "validationViolations", namespace = DxfNamespaces.DXF_2_0 )
+public class ValidationViolations
+{
+ private List<ValidationViolation> validationViolations = new ArrayList<>();
+
+ public ValidationViolations()
+ {
+ }
+
+ public ValidationViolations( List<ValidationViolation> validationViolations )
+ {
+ this.validationViolations = validationViolations;
+ }
+
+ @JsonProperty
+ @JacksonXmlElementWrapper( localName = "validationViolations", namespace = DxfNamespaces.DXF_2_0, useWrapping = false )
+ @JacksonXmlProperty( localName = "validationViolation", namespace = DxfNamespaces.DXF_2_0 )
+ public List<ValidationViolation> getValidationViolations()
+ {
+ return validationViolations;
+ }
+
+ public void setValidationViolations( List<ValidationViolation> validationViolations )
+ {
+ this.validationViolations = validationViolations;
+ }
+}
=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationViolation.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationViolation.java 2016-02-11 08:11:40 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationViolation.java 1970-01-01 00:00:00 +0000
@@ -1,111 +0,0 @@
-package org.hisp.dhis.validation;
-
-/*
- * Copyright (c) 2004-2016, 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 com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-import com.google.common.base.MoreObjects;
-import org.hisp.dhis.common.DxfNamespaces;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-@JsonPropertyOrder( {
- "message"
-} )
-@JacksonXmlRootElement( localName = "validationViolation", namespace = DxfNamespaces.DXF_2_0 )
-public class ValidationViolation
-{
- private String property;
-
- private String message;
-
- private Object value;
-
- public ValidationViolation( String property, String message )
- {
- this.property = property;
- this.message = message;
- }
-
- public ValidationViolation( String property, String message, Object value )
- {
- this.property = property;
- this.message = message;
- this.value = value;
- }
-
- @JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
- public String getProperty()
- {
- return property;
- }
-
- public void setProperty( String property )
- {
- this.property = property;
- }
-
- @JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
- public String getMessage()
- {
- return message;
- }
-
- public void setMessage( String message )
- {
- this.message = message;
- }
-
- @JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
- public Object getValue()
- {
- return value;
- }
-
- public void setValue( Object value )
- {
- this.value = value;
- }
-
- @Override
- public String toString()
- {
- return MoreObjects.toStringHelper( this )
- .add( "property", property )
- .add( "message", message )
- .add( "value", value )
- .toString();
- }
-}
=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationViolations.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationViolations.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationViolations.java 1970-01-01 00:00:00 +0000
@@ -1,71 +0,0 @@
-package org.hisp.dhis.validation;
-
-/*
- * Copyright (c) 2004-2016, 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 com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-import org.hisp.dhis.common.DxfNamespaces;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Temporary wrapper for ValidationViolation
- *
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-@JacksonXmlRootElement( localName = "validationViolations", namespace = DxfNamespaces.DXF_2_0 )
-public class ValidationViolations
-{
- private List<ValidationViolation> validationViolations = new ArrayList<>();
-
- public ValidationViolations()
- {
- }
-
- public ValidationViolations( List<ValidationViolation> validationViolations )
- {
- this.validationViolations = validationViolations;
- }
-
- @JsonProperty
- @JacksonXmlElementWrapper( localName = "validationViolations", namespace = DxfNamespaces.DXF_2_0, useWrapping = false )
- @JacksonXmlProperty( localName = "validationViolation", namespace = DxfNamespaces.DXF_2_0 )
- public List<ValidationViolation> getValidationViolations()
- {
- return validationViolations;
- }
-
- public void setValidationViolations( List<ValidationViolation> validationViolations )
- {
- this.validationViolations = validationViolations;
- }
-}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/DefaultAttributeService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/DefaultAttributeService.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/DefaultAttributeService.java 2016-02-15 04:57:22 +0000
@@ -34,7 +34,7 @@
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.i18n.I18nService;
-import org.hisp.dhis.validation.ValidationViolation;
+import org.hisp.dhis.schema.validation.ValidationViolation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
=== added directory 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/validation'
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/validation/DefaultSchemaValidator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/validation/DefaultSchemaValidator.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/validation/DefaultSchemaValidator.java 2016-02-15 04:57:22 +0000
@@ -0,0 +1,239 @@
+package org.hisp.dhis.schema.validation;
+
+/*
+ * Copyright (c) 2004-2016, 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.apache.commons.validator.GenericValidator;
+import org.hisp.dhis.schema.Property;
+import org.hisp.dhis.schema.PropertyType;
+import org.hisp.dhis.schema.Schema;
+import org.hisp.dhis.schema.SchemaService;
+import org.hisp.dhis.system.util.ReflectionUtils;
+import org.hisp.dhis.system.util.ValidationUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class DefaultSchemaValidator implements SchemaValidator
+{
+ @Autowired
+ private SchemaService schemaService;
+
+ @Override
+ public List<ValidationViolation> validate( Object object )
+ {
+ return validate( object, true );
+ }
+
+ @Override
+ public List<ValidationViolation> validate( Object object, boolean persisted )
+ {
+ if ( object == null || schemaService.getSchema( object.getClass() ) == null )
+ {
+ return new ArrayList<>();
+ }
+
+ Schema schema = schemaService.getSchema( object.getClass() );
+
+ List<ValidationViolation> validationViolations = new ArrayList<>();
+
+ for ( Property property : schema.getProperties() )
+ {
+ if ( persisted && !property.isPersisted() )
+ {
+ continue;
+ }
+
+ Object value = ReflectionUtils.invokeMethod( object, property.getGetterMethod() );
+
+ if ( value == null )
+ {
+ if ( property.isRequired() )
+ {
+ validationViolations.add( new ValidationViolation( property.getName(), "Required property missing." ) );
+ }
+
+ continue;
+ }
+
+ validationViolations.addAll( validateString( value, property ) );
+ validationViolations.addAll( validateCollection( value, property ) );
+ validationViolations.addAll( validateInteger( value, property ) );
+ validationViolations.addAll( validateFloat( value, property ) );
+ validationViolations.addAll( validateDouble( value, property ) );
+ }
+
+ return validationViolations;
+ }
+
+ private Collection<? extends ValidationViolation> validateString( Object object, Property property )
+ {
+ List<ValidationViolation> validationViolations = new ArrayList<>();
+
+ // TODO How should empty strings be handled? they are not valid color, password, url, etc of course.
+ if ( !String.class.isInstance( object ) || StringUtils.isEmpty( object ) )
+ {
+ return validationViolations;
+ }
+
+ String value = (String) object;
+
+ // check column max length
+ if ( value.length() > property.getLength() )
+ {
+ validationViolations.add( new ValidationViolation( property.getName(), "Maximum length for property is "
+ + property.getLength() + ", length is " + value.length(), value ) );
+
+ return validationViolations;
+ }
+
+ if ( value.length() < property.getMin() || value.length() > property.getMax() )
+ {
+ validationViolations.add( new ValidationViolation( property.getName(), "Allowed range for length ["
+ + property.getMin() + ", " + property.getMax() + "], length is " + value.length(), value ) );
+ }
+
+ if ( PropertyType.EMAIL == property.getPropertyType() && !GenericValidator.isEmail( value ) )
+ {
+ validationViolations.add( new ValidationViolation( property.getName(), "Not a valid email.", value ) );
+ }
+ else if ( PropertyType.URL == property.getPropertyType() && !isUrl( value ) )
+ {
+ validationViolations.add( new ValidationViolation( property.getName(), "Not a valid URL.", value ) );
+ }
+ else if ( PropertyType.PASSWORD == property.getPropertyType() && !ValidationUtils.passwordIsValid( value ) )
+ {
+ validationViolations.add( new ValidationViolation( property.getName(), "Not a valid password.", value ) );
+ }
+ else if ( PropertyType.COLOR == property.getPropertyType() && !ValidationUtils.isValidHexColor( value ) )
+ {
+ validationViolations.add( new ValidationViolation( property.getName(), "Not a valid hex color.", value ) );
+ }
+
+ /* TODO add proper validation for both Points and Polygons, ValidationUtils only supports points at this time
+ if ( PropertyType.GEOLOCATION == property.getPropertyType() && !ValidationUtils.coordinateIsValid( value ) )
+ {
+ validationViolations.add( new ValidationViolation( "Value is not a valid coordinate pair [lon, lat]." ) );
+ }
+ */
+
+ return validationViolations;
+ }
+
+ // Commons validator have some issues in latest version, replacing with a very simple test for now
+ private boolean isUrl( String url )
+ {
+ return !StringUtils.isEmpty( url ) && (url.startsWith( "http://" ) || url.startsWith( "https://" ));
+ }
+
+ private Collection<? extends ValidationViolation> validateCollection( Object object, Property property )
+ {
+ List<ValidationViolation> validationViolations = new ArrayList<>();
+
+ if ( !Collection.class.isInstance( object ) )
+ {
+ return validationViolations;
+ }
+
+ Collection<?> value = (Collection<?>) object;
+
+ if ( value.size() < property.getMin() || value.size() > property.getMax() )
+ {
+ validationViolations.add( new ValidationViolation( property.getName(), "Invalid range for size ["
+ + property.getMin() + ", " + property.getMax() + "], size is " + value.size(), value ) );
+ }
+
+ return validationViolations;
+ }
+
+ private Collection<? extends ValidationViolation> validateInteger( Object object, Property property )
+ {
+ List<ValidationViolation> validationViolations = new ArrayList<>();
+
+ if ( !Integer.class.isInstance( object ) )
+ {
+ return validationViolations;
+ }
+
+ Integer value = (Integer) object;
+
+ if ( !GenericValidator.isInRange( value, property.getMin(), property.getMax() ) )
+ {
+ validationViolations.add( new ValidationViolation( property.getName(), "Invalid range for value ["
+ + property.getMin() + ", " + property.getMax() + "], value is " + value, value ) );
+ }
+
+ return validationViolations;
+ }
+
+ private Collection<? extends ValidationViolation> validateFloat( Object object, Property property )
+ {
+ List<ValidationViolation> validationViolations = new ArrayList<>();
+
+ if ( !Float.class.isInstance( object ) )
+ {
+ return validationViolations;
+ }
+
+ Float value = (Float) object;
+
+ if ( !GenericValidator.isInRange( value, property.getMin(), property.getMax() ) )
+ {
+ validationViolations.add( new ValidationViolation( property.getName(), "Invalid range for value ["
+ + property.getMin() + ", " + property.getMax() + "], value is " + value, value ) );
+ }
+
+ return validationViolations;
+ }
+
+ private Collection<? extends ValidationViolation> validateDouble( Object object, Property property )
+ {
+ List<ValidationViolation> validationViolations = new ArrayList<>();
+
+ if ( !Double.class.isInstance( object ) )
+ {
+ return validationViolations;
+ }
+
+ Double value = (Double) object;
+
+ if ( !GenericValidator.isInRange( value, property.getMin(), property.getMax() ) )
+ {
+ validationViolations.add( new ValidationViolation( property.getName(), "Invalid range for value ["
+ + property.getMin() + ", " + property.getMax() + "], value is " + value, value ) );
+ }
+
+ return validationViolations;
+ }
+}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2016-02-11 07:20:33 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2016-02-15 04:57:22 +0000
@@ -39,6 +39,8 @@
<bean id="org.hisp.dhis.render.RenderService" class="org.hisp.dhis.render.DefaultRenderService" />
+ <bean id="org.hisp.dhis.schema.validation.SchemaValidator" class="org.hisp.dhis.schema.validation.DefaultSchemaValidator" />
+
<!-- Store definitions -->
<bean id="org.hisp.dhis.dataentryform.DataEntryFormStore" class="org.hisp.dhis.dataentryform.hibernate.HibernateDataEntryFormStore">
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java 2016-02-12 05:38:40 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java 2016-02-15 04:57:22 +0000
@@ -58,7 +58,7 @@
import org.hisp.dhis.dxf2.metadata.ObjectBridge;
import org.hisp.dhis.dxf2.metadata.handlers.ObjectHandler;
import org.hisp.dhis.dxf2.metadata.handlers.ObjectHandlerUtils;
-import org.hisp.dhis.dxf2.schema.SchemaValidator;
+import org.hisp.dhis.schema.validation.SchemaValidator;
import org.hisp.dhis.eventchart.EventChart;
import org.hisp.dhis.eventreport.EventReport;
import org.hisp.dhis.expression.Expression;
@@ -80,7 +80,7 @@
import org.hisp.dhis.user.UserCredentials;
import org.hisp.dhis.user.UserService;
import org.hisp.dhis.validation.ValidationRule;
-import org.hisp.dhis.validation.ValidationViolation;
+import org.hisp.dhis.schema.validation.ValidationViolation;
import org.springframework.beans.factory.annotation.Autowired;
import java.lang.reflect.Field;
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.java 2016-02-11 09:13:07 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.java 2016-02-15 04:57:22 +0000
@@ -29,11 +29,11 @@
*/
import org.hisp.dhis.common.IdentifiableObject;
-import org.hisp.dhis.dxf2.schema.SchemaValidator;
+import org.hisp.dhis.schema.validation.SchemaValidator;
import org.hisp.dhis.preheat.PreheatMode;
import org.hisp.dhis.preheat.PreheatParams;
import org.hisp.dhis.preheat.PreheatService;
-import org.hisp.dhis.validation.ValidationViolation;
+import org.hisp.dhis.schema.validation.ValidationViolation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundleValidation.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundleValidation.java 2016-02-11 08:11:40 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundleValidation.java 2016-02-15 04:57:22 +0000
@@ -31,7 +31,7 @@
import com.google.common.base.MoreObjects;
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.preheat.PreheatValidation;
-import org.hisp.dhis.validation.ValidationViolation;
+import org.hisp.dhis.schema.validation.ValidationViolation;
import java.util.HashMap;
import java.util.List;
=== removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/DefaultSchemaValidator.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/DefaultSchemaValidator.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/DefaultSchemaValidator.java 1970-01-01 00:00:00 +0000
@@ -1,240 +0,0 @@
-package org.hisp.dhis.dxf2.schema;
-
-/*
- * Copyright (c) 2004-2016, 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.apache.commons.validator.GenericValidator;
-import org.hisp.dhis.schema.Property;
-import org.hisp.dhis.schema.PropertyType;
-import org.hisp.dhis.schema.Schema;
-import org.hisp.dhis.schema.SchemaService;
-import org.hisp.dhis.system.util.ReflectionUtils;
-import org.hisp.dhis.system.util.ValidationUtils;
-import org.hisp.dhis.validation.ValidationViolation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.StringUtils;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class DefaultSchemaValidator implements SchemaValidator
-{
- @Autowired
- private SchemaService schemaService;
-
- @Override
- public List<ValidationViolation> validate( Object object )
- {
- return validate( object, true );
- }
-
- @Override
- public List<ValidationViolation> validate( Object object, boolean persisted )
- {
- if ( object == null || schemaService.getSchema( object.getClass() ) == null )
- {
- return new ArrayList<>();
- }
-
- Schema schema = schemaService.getSchema( object.getClass() );
-
- List<ValidationViolation> validationViolations = new ArrayList<>();
-
- for ( Property property : schema.getProperties() )
- {
- if ( persisted && !property.isPersisted() )
- {
- continue;
- }
-
- Object value = ReflectionUtils.invokeMethod( object, property.getGetterMethod() );
-
- if ( value == null )
- {
- if ( property.isRequired() )
- {
- validationViolations.add( new ValidationViolation( property.getName(), "Required property missing." ) );
- }
-
- continue;
- }
-
- validationViolations.addAll( validateString( value, property ) );
- validationViolations.addAll( validateCollection( value, property ) );
- validationViolations.addAll( validateInteger( value, property ) );
- validationViolations.addAll( validateFloat( value, property ) );
- validationViolations.addAll( validateDouble( value, property ) );
- }
-
- return validationViolations;
- }
-
- private Collection<? extends ValidationViolation> validateString( Object object, Property property )
- {
- List<ValidationViolation> validationViolations = new ArrayList<>();
-
- // TODO How should empty strings be handled? they are not valid color, password, url, etc of course.
- if ( !String.class.isInstance( object ) || StringUtils.isEmpty( object ) )
- {
- return validationViolations;
- }
-
- String value = (String) object;
-
- // check column max length
- if ( value.length() > property.getLength() )
- {
- validationViolations.add( new ValidationViolation( property.getName(), "Maximum length for property is "
- + property.getLength() + ", length is " + value.length(), value ) );
-
- return validationViolations;
- }
-
- if ( value.length() < property.getMin() || value.length() > property.getMax() )
- {
- validationViolations.add( new ValidationViolation( property.getName(), "Allowed range for length ["
- + property.getMin() + ", " + property.getMax() + "], length is " + value.length(), value ) );
- }
-
- if ( PropertyType.EMAIL == property.getPropertyType() && !GenericValidator.isEmail( value ) )
- {
- validationViolations.add( new ValidationViolation( property.getName(), "Not a valid email.", value ) );
- }
- else if ( PropertyType.URL == property.getPropertyType() && !isUrl( value ) )
- {
- validationViolations.add( new ValidationViolation( property.getName(), "Not a valid URL.", value ) );
- }
- else if ( PropertyType.PASSWORD == property.getPropertyType() && !ValidationUtils.passwordIsValid( value ) )
- {
- validationViolations.add( new ValidationViolation( property.getName(), "Not a valid password.", value ) );
- }
- else if ( PropertyType.COLOR == property.getPropertyType() && !ValidationUtils.isValidHexColor( value ) )
- {
- validationViolations.add( new ValidationViolation( property.getName(), "Not a valid hex color.", value ) );
- }
-
- /* TODO add proper validation for both Points and Polygons, ValidationUtils only supports points at this time
- if ( PropertyType.GEOLOCATION == property.getPropertyType() && !ValidationUtils.coordinateIsValid( value ) )
- {
- validationViolations.add( new ValidationViolation( "Value is not a valid coordinate pair [lon, lat]." ) );
- }
- */
-
- return validationViolations;
- }
-
- // Commons validator have some issues in latest version, replacing with a very simple test for now
- private boolean isUrl( String url )
- {
- return !StringUtils.isEmpty( url ) && (url.startsWith( "http://" ) || url.startsWith( "https://" ));
- }
-
- private Collection<? extends ValidationViolation> validateCollection( Object object, Property property )
- {
- List<ValidationViolation> validationViolations = new ArrayList<>();
-
- if ( !Collection.class.isInstance( object ) )
- {
- return validationViolations;
- }
-
- Collection<?> value = (Collection<?>) object;
-
- if ( value.size() < property.getMin() || value.size() > property.getMax() )
- {
- validationViolations.add( new ValidationViolation( property.getName(), "Invalid range for size ["
- + property.getMin() + ", " + property.getMax() + "], size is " + value.size(), value ) );
- }
-
- return validationViolations;
- }
-
- private Collection<? extends ValidationViolation> validateInteger( Object object, Property property )
- {
- List<ValidationViolation> validationViolations = new ArrayList<>();
-
- if ( !Integer.class.isInstance( object ) )
- {
- return validationViolations;
- }
-
- Integer value = (Integer) object;
-
- if ( !GenericValidator.isInRange( value, property.getMin(), property.getMax() ) )
- {
- validationViolations.add( new ValidationViolation( property.getName(), "Invalid range for value ["
- + property.getMin() + ", " + property.getMax() + "], value is " + value, value ) );
- }
-
- return validationViolations;
- }
-
- private Collection<? extends ValidationViolation> validateFloat( Object object, Property property )
- {
- List<ValidationViolation> validationViolations = new ArrayList<>();
-
- if ( !Float.class.isInstance( object ) )
- {
- return validationViolations;
- }
-
- Float value = (Float) object;
-
- if ( !GenericValidator.isInRange( value, property.getMin(), property.getMax() ) )
- {
- validationViolations.add( new ValidationViolation( property.getName(), "Invalid range for value ["
- + property.getMin() + ", " + property.getMax() + "], value is " + value, value ) );
- }
-
- return validationViolations;
- }
-
- private Collection<? extends ValidationViolation> validateDouble( Object object, Property property )
- {
- List<ValidationViolation> validationViolations = new ArrayList<>();
-
- if ( !Double.class.isInstance( object ) )
- {
- return validationViolations;
- }
-
- Double value = (Double) object;
-
- if ( !GenericValidator.isInRange( value, property.getMin(), property.getMax() ) )
- {
- validationViolations.add( new ValidationViolation( property.getName(), "Invalid range for value ["
- + property.getMin() + ", " + property.getMax() + "], value is " + value, value ) );
- }
-
- return validationViolations;
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/SchemaValidator.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/SchemaValidator.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/SchemaValidator.java 1970-01-01 00:00:00 +0000
@@ -1,58 +0,0 @@
-package org.hisp.dhis.dxf2.schema;
-
-/*
- * Copyright (c) 2004-2016, 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.validation.ValidationViolation;
-
-import java.util.List;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public interface SchemaValidator
-{
- /**
- * Validate object against its schema, the object is required to be non-null and have a schema associated with it.
- *
- * @param object Object to validate
- * @param persisted Only include persisted properties
- * @return WebMessage containing validation response
- */
- List<ValidationViolation> validate( Object object, boolean persisted );
-
- /**
- * Validate object against its schema, the object is required to be non-null and have a schema associated with it.
- *
- * Only persisted values will be checked.
- *
- * @param object Object to validate
- * @return WebMessage containing validation response
- */
- List<ValidationViolation> validate( Object object );
-}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/webmessage/responses/ValidationViolationsWebMessageResponse.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/webmessage/responses/ValidationViolationsWebMessageResponse.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/webmessage/responses/ValidationViolationsWebMessageResponse.java 2016-02-15 04:57:22 +0000
@@ -32,7 +32,7 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import org.hisp.dhis.common.DxfNamespaces;
-import org.hisp.dhis.validation.ValidationViolation;
+import org.hisp.dhis.schema.validation.ValidationViolation;
import org.hisp.dhis.dxf2.webmessage.AbstractWebMessageResponse;
import java.util.ArrayList;
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml 2016-02-12 05:38:40 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml 2016-02-15 04:57:22 +0000
@@ -14,8 +14,6 @@
<bean id="org.hisp.dhis.dxf2.csv.CsvImportService" class="org.hisp.dhis.dxf2.csv.DefaultCsvImportService" />
- <bean id="org.hisp.dhis.dxf2.schema.SchemaValidator" class="org.hisp.dhis.dxf2.schema.DefaultSchemaValidator" />
-
<bean id="org.hisp.dhis.dxf2.metadata.ExportService" class="org.hisp.dhis.dxf2.metadata.DefaultExportService" scope="prototype" />
<bean id="org.hisp.dhis.dxf2.metadata.ImportService" class="org.hisp.dhis.dxf2.metadata.DefaultImportService" scope="prototype">
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MaintenanceController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MaintenanceController.java 2016-02-02 06:34:22 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MaintenanceController.java 2016-02-15 04:57:22 +0000
@@ -36,9 +36,9 @@
import org.hisp.dhis.dxf2.metadata.ExportService;
import org.hisp.dhis.dxf2.metadata.Metadata;
import org.hisp.dhis.render.RenderService;
-import org.hisp.dhis.dxf2.schema.SchemaValidator;
+import org.hisp.dhis.schema.validation.SchemaValidator;
import org.hisp.dhis.dxf2.webmessage.WebMessage;
-import org.hisp.dhis.validation.ValidationViolation;
+import org.hisp.dhis.schema.validation.ValidationViolation;
import org.hisp.dhis.webapi.service.WebMessageService;
import org.hisp.dhis.webapi.utils.WebMessageUtils;
import org.hisp.dhis.maintenance.MaintenanceService;
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchemaController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchemaController.java 2016-02-01 07:36:06 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchemaController.java 2016-02-15 04:57:22 +0000
@@ -30,8 +30,8 @@
import com.google.common.collect.Lists;
import org.hisp.dhis.render.RenderService;
-import org.hisp.dhis.dxf2.schema.SchemaValidator;
-import org.hisp.dhis.validation.ValidationViolation;
+import org.hisp.dhis.schema.validation.SchemaValidator;
+import org.hisp.dhis.schema.validation.ValidationViolation;
import org.hisp.dhis.dxf2.webmessage.WebMessage;
import org.hisp.dhis.fieldfilter.FieldFilterService;
import org.hisp.dhis.node.NodeUtils;
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/WebMessageUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/WebMessageUtils.java 2016-01-04 04:14:42 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/WebMessageUtils.java 2016-02-15 04:57:22 +0000
@@ -32,7 +32,7 @@
import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
import org.hisp.dhis.dxf2.metadata.ImportTypeSummary;
-import org.hisp.dhis.validation.ValidationViolation;
+import org.hisp.dhis.schema.validation.ValidationViolation;
import org.hisp.dhis.dxf2.webmessage.WebMessage;
import org.hisp.dhis.dxf2.common.Status;
import org.hisp.dhis.dxf2.webmessage.responses.ValidationViolationsWebMessageResponse;