You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by da...@apache.org on 2007/01/18 17:43:22 UTC
svn commit: r497492 - in
/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/metadata/impl:
Messages.properties PropertyMetadata.java
Author: danj
Date: Thu Jan 18 08:43:21 2007
New Revision: 497492
URL: http://svn.apache.org/viewvc?view=rev&rev=497492
Log:
added serialization for ValidValueRange and extended metadata. also added sanity checks to make sure
people don't have ValidValues *and* ValidValueRange.
Modified:
webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/metadata/impl/Messages.properties
webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/metadata/impl/PropertyMetadata.java
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/metadata/impl/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/metadata/impl/Messages.properties?view=diff&rev=497492&r1=497491&r2=497492
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/metadata/impl/Messages.properties (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/metadata/impl/Messages.properties Thu Jan 18 08:43:21 2007
@@ -15,5 +15,7 @@
ReadOnly=The metadata for property 'XXX' makes it read-only. It cannot be modified in any way via WS-RP SetResourceProperties.
UndefinedProperty=There is no wsrmd\:Property defined with the path 'XXX'. You cannot read metadata for a property that does not exist. Use the hasProperty method to determine if a property name is valid.
NullMetadataDescriptor=The MetadataDescriptor is null.
-NullPropertyName=The name for the wsrmd:Property is null.
+NullPropertyName=The name for the wsrmd\:Property is null.
PropertyExists=This MetadataDescriptor already has a property named 'XXX'. If you want to change the property name, use the setPropertyName() method; if you want to remove the property definition, use the removeProperty() method.
+ValidValueRangeExists=The wsrmd\:Property with path 'XXX' has a valid value range of (XXX, XXX). Properties can only define a set of valid values or a valid value range - not both. If you want to set valid values for a property, you must first ensure that the upper and lower bound values are null.
+ValidValuesExists=The wsrmd\:Property with path 'XXX' has a set of valid values specified. Properties can only define a valid value range (upper and lower bounds) if the set of valid values is null or empty.
\ No newline at end of file
Modified: webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/metadata/impl/PropertyMetadata.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/metadata/impl/PropertyMetadata.java?view=diff&rev=497492&r1=497491&r2=497492
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/metadata/impl/PropertyMetadata.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf-impl/src/org/apache/muse/ws/resource/metadata/impl/PropertyMetadata.java Thu Jan 18 08:43:21 2007
@@ -127,6 +127,11 @@
_qname = qname;
setModifiability(modifiability);
setMutability(mutability);
+
+ _extendedMetadata = new HashMap();
+ setInitialValues(Collections.EMPTY_LIST);
+ setStaticValues(Collections.EMPTY_LIST);
+ setValidValues(Collections.EMPTY_LIST);
}
/**
@@ -209,6 +214,11 @@
return (String)_extendedMetadata.get(elementName);
}
+ public Collection getExtendedMetadataNames()
+ {
+ return Collections.unmodifiableSet(_extendedMetadata.keySet());
+ }
+
public Collection getInitialValues()
{
return Collections.unmodifiableCollection(_initialValues);
@@ -453,6 +463,12 @@
public void setLowerBound(String value)
{
+ if (!getValidValues().isEmpty())
+ {
+ Object[] filler = { getPropertyName() };
+ throw new RuntimeException(_MESSAGES.get("ValidValuesExists", filler));
+ }
+
_valueLowerBound = value;
}
@@ -491,6 +507,9 @@
public void setPropertyName(QName propertyName)
{
+ if (propertyName == null)
+ throw new NullPointerException(_MESSAGES.get("NullPropertyName"));
+
_qname = propertyName;
}
@@ -501,11 +520,23 @@
public void setUpperBound(String value)
{
+ if (!getValidValues().isEmpty())
+ {
+ Object[] filler = { getPropertyName() };
+ throw new RuntimeException(_MESSAGES.get("ValidValuesExists", filler));
+ }
+
_valueUpperBound = value;
}
public void setValidValues(Collection values)
{
+ if (getLowerBound() != null || getUpperBound() != null)
+ {
+ Object[] filler = { getPropertyName(), getLowerBound(), getUpperBound() };
+ throw new RuntimeException(_MESSAGES.get("ValidValueRangeExists", filler));
+ }
+
_validValues = new ArrayList(values);
}
@@ -526,22 +557,39 @@
root.setAttribute(WsrmdConstants.MUTABILITY, getMutabilityString());
//
- // the InitialValues, StaticValues, and ValidValues are all composed
+ // the ValidValues, StaticValues, and InitialValues are all composed
// in a very similar fashion, so we try to loop through them that way
//
-
- Element initialValues = XmlUtils.createElement(doc, WsrmdConstants.INITIAL_VALUES_QNAME);
- Element staticValues = XmlUtils.createElement(doc, WsrmdConstants.STATIC_VALUES_QNAME);
+
Element validValues = XmlUtils.createElement(doc, WsrmdConstants.VALID_VALUES_QNAME);
+ Element staticValues = XmlUtils.createElement(doc, WsrmdConstants.STATIC_VALUES_QNAME);
+ Element initialValues = XmlUtils.createElement(doc, WsrmdConstants.INITIAL_VALUES_QNAME);
- Element[] values = new Element[]{ initialValues, staticValues, validValues };
- Collection[] instances = new Collection[] { getInitialValues(), getStaticValues(), getValidValues() };
+ Element[] values = new Element[]{ validValues, staticValues, initialValues };
+ Collection[] instances = new Collection[] { getValidValues(), getStaticValues(), getInitialValues() };
- for (int n = 0; n < values.length; ++n)
+ //
+ // almost-hack: we can only have ValidValues or ValidValueRange - not
+ // both. so, assuming we have no ValidValues, we check to see if a
+ // range is provided - it it is, we replace the ValidValues element
+ // with a ValidValueRange element that has the upper/lower bounds.
+ //
+ String lowerBound = getLowerBound();
+ String upperBound = getUpperBound();
+
+ if (instances[0].isEmpty() && (lowerBound != null || upperBound != null))
{
- if (instances[n].isEmpty())
- continue;
+ values[0] = XmlUtils.createElement(doc, WsrmdConstants.VALID_RANGE_QNAME);
+
+ if (lowerBound != null)
+ values[0].setAttribute(WsrmdConstants.LOWER_BOUND, lowerBound);
+ if (upperBound != null)
+ values[0].setAttribute(WsrmdConstants.UPPER_BOUND, upperBound);
+ }
+
+ for (int n = 0; n < values.length; ++n)
+ {
root.appendChild(values[n]);
Iterator i = instances[n].iterator();
@@ -552,6 +600,18 @@
next = (Element)doc.importNode(next, true);
values[n].appendChild(next);
}
+ }
+
+ //
+ // add custom metadata at the end of the wsrmd:Property
+ //
+ Iterator i = getExtendedMetadataNames().iterator();
+
+ while (i.hasNext())
+ {
+ QName name = (QName)i.next();
+ String value = getExtendedMetadata(name);
+ XmlUtils.setElement(root, name, value);
}
return root;
---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org