Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2009-04-20 21:48:40 +0000
committerpfullbright2009-04-20 21:48:40 +0000
commit29ec9560df6fe5961f7bbfb678d3d0290b037c95 (patch)
treee08b21daeb92c36a541175b77b6ec89c63f7d36e
parentcc69c134b024613655083a28f8483e4c253c44db (diff)
downloadwebtools.dali-29ec9560df6fe5961f7bbfb678d3d0290b037c95.tar.gz
webtools.dali-29ec9560df6fe5961f7bbfb678d3d0290b037c95.tar.xz
webtools.dali-29ec9560df6fe5961f7bbfb678d3d0290b037c95.zip
hooked up jar file validation/added duplicate jar file validation
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties1
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java41
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java1
3 files changed, 40 insertions, 3 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties
index 0637416e5b..d0225c4c43 100644
--- a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties
+++ b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties
@@ -26,6 +26,7 @@ PERSISTENCE_UNIT_NONEXISTENT_CLASS=Class \"{0}\" cannot be resolved
PERSISTENCE_UNIT_INVALID_CLASS=Class \"{0}\" is listed in the persistence.xml file but not mapped
PERSISTENCE_UNIT_DUPLICATE_CLASS=Duplicate class \"{0}\"
PERSISTENCE_UNIT_REDUNDANT_CLASS=Class \"{0}\" is already specified in mapping file \"{1}\"
+PERSISTENCE_UNIT_DUPLICATE_JAR_FILE=Duplicate JAR file \"{0}\"
PERSISTENCE_UNIT_UNSPECIFIED_JAR_FILE=Unspecified JAR file
PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE=JAR file \"{0}\" cannot be resolved
GENERATOR_DUPLICATE_NAME=Duplicate generator named \"{0}\" defined in this persistence unit
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java
index c090e6daea..51dc8d7a34 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java
@@ -16,7 +16,6 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Set;
import java.util.Vector;
-
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jpt.core.JpaStructureNode;
import org.eclipse.jpt.core.JptCorePlugin;
@@ -1167,8 +1166,9 @@ public abstract class AbstractPersistenceUnit
@Override
public void validate(List<IMessage> messages, IReporter reporter) {
super.validate(messages, reporter);
- this.validateMappingFiles(messages, reporter);
- this.validateClassRefs(messages, reporter);
+ validateMappingFiles(messages, reporter);
+ validateClassRefs(messages, reporter);
+ validateJarFileRefs(messages, reporter);
}
protected void validateMappingFiles(List<IMessage> messages, IReporter reporter) {
@@ -1265,6 +1265,41 @@ public abstract class AbstractPersistenceUnit
}
};
}
+
+ protected void validateJarFileRefs(List<IMessage> messages, IReporter reporter) {
+ checkForDuplicateJarFileRefs(messages);
+ for (JarFileRef each : CollectionTools.iterable(jarFileRefs())) {
+ each.validate(messages, reporter);
+ }
+ }
+
+ protected void checkForDuplicateJarFileRefs(List<IMessage> messages) {
+ HashBag<String> jarFileNames = new HashBag<String>();
+ CollectionTools.addAll(jarFileNames, jarFileNames());
+ for (JarFileRef jarFileRef : CollectionTools.iterable(jarFileRefs())) {
+ String jarFileName = jarFileRef.getFileName();
+ if ((jarFileName != null) && (jarFileNames.count(jarFileName) > 1)) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.PERSISTENCE_UNIT_DUPLICATE_JAR_FILE,
+ new String[] {jarFileName},
+ jarFileRef,
+ jarFileRef.getValidationTextRange()
+ )
+ );
+ }
+ }
+ }
+
+ protected Iterator<String> jarFileNames() {
+ return new TransformationIterator<JarFileRef, String>(jarFileRefs()) {
+ @Override
+ protected String transform(JarFileRef jarFileRef) {
+ return jarFileRef.getFileName();
+ }
+ };
+ }
// ********** misc **********
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java
index 1dd40f0b01..632aadb4c5 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java
@@ -32,6 +32,7 @@ public interface JpaValidationMessages {
public static final String PERSISTENCE_UNIT_INVALID_CLASS = "PERSISTENCE_UNIT_INVALID_CLASS";
public static final String PERSISTENCE_UNIT_DUPLICATE_CLASS = "PERSISTENCE_UNIT_DUPLICATE_CLASS";
public static final String PERSISTENCE_UNIT_REDUNDANT_CLASS = "PERSISTENCE_UNIT_REDUNDANT_CLASS";
+ public static final String PERSISTENCE_UNIT_DUPLICATE_JAR_FILE = "PERSISTENCE_UNIT_DUPLICATE_JAR_FILE";
public static final String PERSISTENCE_UNIT_UNSPECIFIED_JAR_FILE = "PERSISTENCE_UNIT_UNSPECIFIED_JAR_FILE";
public static final String PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE = "PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE";
public static final String GENERATOR_DUPLICATE_NAME = "GENERATOR_DUPLICATE_NAME";

Back to the top