Author: objectiser
Date: 2008-08-27 12:12:50 -0400 (Wed, 27 Aug 2008)
New Revision: 283
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/actions/PerformAction.java
Log:
Additional validation of bind details.
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/actions/PerformAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/actions/PerformAction.java 2008-08-27
15:22:22 UTC (rev 282)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/actions/PerformAction.java 2008-08-27
16:12:50 UTC (rev 283)
@@ -29,6 +29,8 @@
*/
public class PerformAction extends AbstractESBAction {
+ private static final String BIND_ELEMENT = "bind";
+ private static final String TO_VARIABLE_ATTR = "to-variable";
public static final String SERVICE_NAME = "serviceName";
public static final String SERVICE_CATEGORY = "serviceCategory";
public static final String RETURN_SERVICE_NAME = "returnServiceName";
@@ -137,23 +139,32 @@
super.validate(l);
// Check if performed state starts with a create session action
- if (m_service != null) {
+ if (m_service != null &&
+ m_service.isCreateSession() == false) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.cdl.jbossesb.model.actions.Messages"),
+ "_NOT_FOUND_PERFORM_CREATE_SESSION",
+ new String[]{}), null);
+ }
+
+ // Check if performed service has relevant bind
+ // and parent properties
+ if (m_service != null &&
+ m_service.getSessionClass() != null) {
- if (m_service.isCreateSession() == false) {
- l.error(this, org.scribble.util.MessageUtil.format(
+ if (hasProperty(PARENT_PROPERTY)) {
+ String parentProperty=getPropertyValue(PARENT_PROPERTY);
+
+ if (PropertyUtil.isProperty(m_service.getSessionClass(),
+ parentProperty) == false) {
+ l.error(this, org.scribble.util.MessageUtil.format(
java.util.PropertyResourceBundle.getBundle(
"org.jboss.tools.overlord.cdl.jbossesb.model.actions.Messages"),
- "_NOT_FOUND_PERFORM_CREATE_SESSION",
- new String[]{}), null);
- }
-
- // Check if performed service has relevant bind
- // and parent properties
- if (m_service.getSessionClass() != null &&
- hasProperty(PARENT_PROPERTY)) {
- String parentProperty=getPropertyValue(PARENT_PROPERTY);
-
- if (PropertyUtil.hasWritableProperty(m_service.getSessionClass(),
+ "_NOT_FOUND_VARIABLE",
+ new String[]{parentProperty,
+ m_service.getSessionClass().getName()}), null);
+ } else if (PropertyUtil.hasWritableProperty(m_service.getSessionClass(),
parentProperty) == false) {
l.error(this, org.scribble.util.MessageUtil.format(
java.util.PropertyResourceBundle.getBundle(
@@ -162,8 +173,7 @@
new String[]{parentProperty,
m_service.getSessionClass().getName()}), null);
}
-
-
+
Class<?> parentCls=PropertyUtil.getPropertyType(
m_service.getSessionClass(), parentProperty);
@@ -178,7 +188,44 @@
m_service.getSessionClass().getName(),
getService().getSessionClass().getName()}), null);
}
+ }
+
+ if (hasProperty(BIND_DETAILS)) {
+ org.w3c.dom.Element elem=getPropertyElement(BIND_DETAILS);
+
+ org.w3c.dom.NodeList nl=elem.getElementsByTagName(BIND_ELEMENT);
+
+ for (int i=0; i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ org.w3c.dom.Element bind=(org.w3c.dom.Element)nl.item(i);
+
+ if (bind.hasAttribute(TO_VARIABLE_ATTR)) {
+ String variable=bind.getAttribute(TO_VARIABLE_ATTR);
+
+ if (PropertyUtil.isProperty(m_service.getSessionClass(),
+ variable) == false) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.cdl.jbossesb.model.actions.Messages"),
+ "_NOT_FOUND_VARIABLE",
+ new String[]{variable,
+ m_service.getSessionClass().getName()}), null);
+ } else if (PropertyUtil.hasWritableProperty(m_service.getSessionClass(),
+ variable) == false) {
+ l.error(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.cdl.jbossesb.model.actions.Messages"),
+ "_NOT_WRITABLE_PROPERTY",
+ new String[]{variable,
+ m_service.getSessionClass().getName()}), null);
+ }
+ } else {
+ // Possibly report if 'to-variable' not
+ // defined?
+ }
+ }
+ }
}
}
}
Show replies by date