Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 167036
Collapse All | Expand All

(-)src/org/eclipse/tptp/monitoring/managedagent/wsdm/provisional/agents/WSDMAgent.java (-1 / +51 lines)
Lines 26-31 Link Here
26
import java.util.Hashtable;
26
import java.util.Hashtable;
27
import java.util.Map;
27
import java.util.Map;
28
28
29
import javax.xml.namespace.QName;
30
31
import org.apache.muse.tools.inspector.ResourceInspector;
29
import org.eclipse.core.runtime.IStatus;
32
import org.eclipse.core.runtime.IStatus;
30
import org.eclipse.hyades.internal.execution.local.control.AgentConfiguration;
33
import org.eclipse.hyades.internal.execution.local.control.AgentConfiguration;
31
import org.eclipse.hyades.internal.execution.local.control.AgentConfigurationEntry;
34
import org.eclipse.hyades.internal.execution.local.control.AgentConfigurationEntry;
Lines 163-169 Link Here
163
	protected void setResourceProperty(String propertyName, Object[] values) throws Exception {
166
	protected void setResourceProperty(String propertyName, Object[] values) throws Exception {
164
		try {
167
		try {
165
			getResourceProperty(propertyName);
168
			getResourceProperty(propertyName);
166
			_runtime.updateResourceProperty(propertyName, values);
169
			String valErr = validateProperty(propertyName, values);
170
			if(!(valErr.length() > 0))
171
				_runtime.updateResourceProperty(propertyName, values);
167
		} catch (Exception e) {
172
		} catch (Exception e) {
168
			//TODO this is a hack, this should really be done more cleanly
173
			//TODO this is a hack, this should really be done more cleanly
169
			_runtime.insertResourceProperty(propertyName, values);
174
			_runtime.insertResourceProperty(propertyName, values);
Lines 177-181 Link Here
177
	protected Object invokeOperation(String methodName, Object[] params) throws Exception {
182
	protected Object invokeOperation(String methodName, Object[] params) throws Exception {
178
		return _runtime.invokeOperation(methodName, params);
183
		return _runtime.invokeOperation(methodName, params);
179
	}
184
	}
185
	
186
	private String validateProperty(String propName, Object[] values)
187
	{
188
		if(values == null || values.length == 0)
189
			return "Invalid value(s) for the property " + propName;
190
		ResourceInspector inspector = new ResourceInspector();
191
		QName qName = getQNameForProperty(propName);
192
		if(!inspector.isPropertyMutable(qName))
193
		{
194
			return "This property is read-only and cannot be modified";
195
		}
196
		else if(!inspector.isPropertyMultiple(qName) && values.length > 1)
197
		{
198
			return "The property can occur only once at the maximum";
199
		}
200
		else if(!inspector.isPropertyAppendable(qName))
201
		{
202
			return "This property is not appendable and cannot be modified";
203
		}
204
		return "";
205
	}
206
	
207
	private QName getQNameForProperty(String propName)
208
	{
209
		QName retQName = new QName("", "");
210
		if(propName == null)
211
			return retQName;
212
		propName = propName.trim();
213
		if(propName.length() == 0)
214
			return retQName;
215
		int tnsStartIdx = propName.indexOf('[');
216
		int nameStartIdx = propName.indexOf(':');
217
		String tns = "";
218
		String name = "";
219
		if(tnsStartIdx != -1)
220
		{
221
			tns = propName.substring(tnsStartIdx + 1, propName.length() - 1);
222
		}
223
		if(nameStartIdx != -1)
224
		{
225
			name = propName.substring(nameStartIdx + 1, tnsStartIdx).trim();
226
		}
227
		retQName = new QName(tns, name);
228
		return retQName;
229
	}
180
}
230
}
181
231

Return to bug 167036