[228588] StructuredFilePropertyTester should avoid starting plug-in
diff --git a/bundles/org.eclipse.wst.sse.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.wst.sse.core/META-INF/MANIFEST.MF
index 0ac223e..fc0d4a7 100644
--- a/bundles/org.eclipse.wst.sse.core/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.wst.sse.core/META-INF/MANIFEST.MF
@@ -46,5 +46,5 @@
org.eclipse.wst.validation;bundle-version="[1.2.0,2.0.0)";resolution:=optional,
com.ibm.icu;bundle-version="[3.8.1,4.0.0)",
org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)"
-Bundle-ActivationPolicy: lazy
+Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.wst.sse.core.internal.propertytester"
Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/propertytester/StructuredFilePropertyTester.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/propertytester/StructuredFilePropertyTester.java
index 4cb2c18..a56edc2 100644
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/propertytester/StructuredFilePropertyTester.java
+++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/propertytester/StructuredFilePropertyTester.java
@@ -13,9 +13,11 @@
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.wst.sse.core.internal.Logger;
/**
* A Property Tester that operates on IFiles and validates
@@ -32,16 +34,27 @@
* the content type matching the given identifier. The identifier is
* provided as the expected value.
*/
- private static final String CONTENT_TYPE_ID = "contentTypeId"; //$NON-NLS-1$
+ private static final String PROPERTY_CONTENT_TYPE_ID = "contentTypeId"; //$NON-NLS-1$
+
+ private static final String PLUGIN_ID = "org.eclipse.wst.sse.core";
/*
* (non-Javadoc)
* @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
*/
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
- if ((receiver instanceof IFile) && property.equals(CONTENT_TYPE_ID))
- return testContentType((IFile) receiver, toString(expectedValue));
- return false;
+ if (!PROPERTY_CONTENT_TYPE_ID.equals(property)) {
+ Platform.getLog(Platform.getBundle(PLUGIN_ID)).log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "Invalid expression property:" + property, null)); //$NON-NLS-1$
+ return false;
+ }
+ if (!(receiver instanceof IFile)) {
+ Platform.getLog(Platform.getBundle(PLUGIN_ID)).log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "Invalid test receiver:" + receiver, null)); //$NON-NLS-1$
+ return false;
+ }
+ if (expectedValue == null) {
+ return false;
+ }
+ return testContentType((IFile) receiver, expectedValue.toString());
}
/**
@@ -66,29 +79,16 @@
IContentDescription contentDescription = file.getContentDescription();
if (contentDescription != null) {
IContentType contentType = contentDescription.getContentType();
- while(contentType != null) {
- if(expectedValue.equals(contentType.getId()))
+ while (contentType != null) {
+ if (expectedValue.equals(contentType.getId()))
return true;
contentType = contentType.getBaseType();
}
}
- } catch (CoreException e) {
- Logger.logException("Core exception while retrieving the content description", e); //$NON-NLS-1$
+ }
+ catch (CoreException e) {
+ Platform.getLog(Platform.getBundle(PLUGIN_ID)).log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "Core exception while retrieving the content description", e)); //$NON-NLS-1$
}
return false;
}
-
- /**
- * Converts the given expected value to a <code>String</code>.
- *
- * @param expectedValue
- * the expected value (may be <code>null</code>).
- * @return the empty string if the expected value is <code>null</code>,
- * otherwise the <code>toString()</code> representation of the
- * expected value
- */
- protected String toString(Object expectedValue) {
- return expectedValue == null ? "" : expectedValue.toString(); //$NON-NLS-1$
- }
-
}