Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Fullbright2013-04-09 17:36:44 +0000
committerPaul Fullbright2013-04-09 17:36:44 +0000
commita95a5d592ad325352554f43ed43ebfd1f32ae31b (patch)
tree16a225ae3cf9f3fa29370764933aee0ff2489242 /jaxb/plugins
parent65b0246334ac6f46fb9020cc2db28f03a8ea1975 (diff)
downloadwebtools.dali-a95a5d592ad325352554f43ed43ebfd1f32ae31b.tar.gz
webtools.dali-a95a5d592ad325352554f43ed43ebfd1f32ae31b.tar.xz
webtools.dali-a95a5d592ad325352554f43ed43ebfd1f32ae31b.zip
added "not latest version" validation
Diffstat (limited to 'jaxb/plugins')
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/property_files/jpt_jaxb_eclipselink_core_validation.properties1
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/oxm/OxmXmlBindingsImpl.java26
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/validation/JptJaxbEclipseLinkCoreValidationMessages.java5
3 files changed, 32 insertions, 0 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/property_files/jpt_jaxb_eclipselink_core_validation.properties b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/property_files/jpt_jaxb_eclipselink_core_validation.properties
index 3fc4983e54..5c2d49ee8f 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/property_files/jpt_jaxb_eclipselink_core_validation.properties
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/property_files/jpt_jaxb_eclipselink_core_validation.properties
@@ -15,6 +15,7 @@
PROJECT_MISSING_ECLIPSELINK_JAXB_CONTEXT_FACTORY = Project is missing a jaxb.properties file specifying the EclipseLink JAXB context factory
+OXM_FILE__NOT_LATEST_VERSION = A more recent version of OXM file is supported by this platform.
OXM_FILE__NO_PACKAGE_SPECIFIED = No package name is associated with this OXM file.
OXM_FILE__NO_SUCH_PACKAGE = Could not associate with package ''{0}''.
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/oxm/OxmXmlBindingsImpl.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/oxm/OxmXmlBindingsImpl.java
index d10fe5cb72..28e8aa3fb6 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/oxm/OxmXmlBindingsImpl.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/oxm/OxmXmlBindingsImpl.java
@@ -10,6 +10,8 @@
package org.eclipse.jpt.jaxb.eclipselink.core.internal.context.oxm;
import java.util.List;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jpt.common.core.internal.utility.ValidationMessageTools;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.internal.ClassNameTools;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
@@ -30,6 +32,7 @@ import org.eclipse.jpt.jaxb.eclipselink.core.resource.oxm.EJavaType;
import org.eclipse.jpt.jaxb.eclipselink.core.resource.oxm.EXmlBindings;
import org.eclipse.jpt.jaxb.eclipselink.core.resource.oxm.EXmlEnum;
import org.eclipse.jpt.jaxb.eclipselink.core.resource.oxm.OxmFactory;
+import org.eclipse.jpt.jaxb.eclipselink.core.validation.JptJaxbEclipseLinkCoreValidationMessages;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -477,11 +480,34 @@ public class OxmXmlBindingsImpl
public void validate(List<IMessage> messages, IReporter reporter) {
super.validate(messages, reporter);
+ validateVersion(messages);
+
for (OxmXmlEnum xmlEnum : getXmlEnums()) {
xmlEnum.validate(messages, reporter);
}
for (OxmJavaType javaType : getJavaTypes()) {
javaType.validate(messages, reporter);
}
+ }
+
+ protected void validateVersion(List<IMessage> messages) {
+ if (ObjectTools.notEquals(getLatestDocumentVersion(), this.eXmlBindings.getDocumentVersion())) {
+ messages.add(
+ ValidationMessageTools.buildValidationMessage(
+ getResource(),
+ this.eXmlBindings.getVersionTextRange(),
+ JptJaxbEclipseLinkCoreValidationMessages.OXM_FILE__NOT_LATEST_VERSION));
+ }
+ }
+
+ /**
+ * Return the latest version of the document supported by the platform
+ */
+ protected String getLatestDocumentVersion() {
+ return getJaxbProject().getPlatform().getDefinition().getMostRecentSupportedResourceType(getContentType()).getVersion();
+ }
+
+ protected IContentType getContentType() {
+ return EXmlBindings.CONTENT_TYPE;
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/validation/JptJaxbEclipseLinkCoreValidationMessages.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/validation/JptJaxbEclipseLinkCoreValidationMessages.java
index 8c3a398724..5c1e375ed2 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/validation/JptJaxbEclipseLinkCoreValidationMessages.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/validation/JptJaxbEclipseLinkCoreValidationMessages.java
@@ -14,6 +14,7 @@ import org.eclipse.jpt.common.core.internal.utility.ValidationMessageLoader;
import org.eclipse.jpt.common.core.utility.ValidationMessage;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
import org.eclipse.jpt.jaxb.core.JaxbProject;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
/**
* Localized validation messages used by Dali EclipseLink JAXB core.
@@ -29,6 +30,7 @@ public class JptJaxbEclipseLinkCoreValidationMessages {
public static ValidationMessage PROJECT_MISSING_ECLIPSELINK_JAXB_CONTEXT_FACTORY;
// oxm file
+ public static ValidationMessage OXM_FILE__NOT_LATEST_VERSION;
public static ValidationMessage OXM_FILE__NO_PACKAGE_SPECIFIED;
public static ValidationMessage OXM_FILE__NO_SUCH_PACKAGE;
@@ -103,5 +105,8 @@ public class JptJaxbEclipseLinkCoreValidationMessages {
private static final Class<?> BUNDLE_CLASS = JptJaxbEclipseLinkCoreValidationMessages.class;
static {
ValidationMessageLoader.load(BUNDLE_CLASS, MESSAGE_BUNDLE_NAME, DESCRIPTION_BUNDLE_NAME, JaxbProject.MARKER_TYPE, PREFERENCES_ADAPTER);
+
+ // INFOs
+ OXM_FILE__NOT_LATEST_VERSION.setDefaultSeverity(IMessage.LOW_SEVERITY);
}
}

Back to the top