// initialize
ServiceProperties svcProps = context.getServiceProperties();
String httpContextPath = Val.chkStr(svcProps.getHttpContextPath());
String cswBaseUrl = Val.chkStr(svcProps.getCswBaseURL());
OperationResponse opResponse = context.getOperationResponse();
Document responseDom = opResponse.getResponseDom();
PropertyMeaning meaning = returnable.getMeaning();
PropertyMeaningType meaningType = meaning.getMeaningType();
Object[] values = returnable.getValues();
DcElement dcElement = meaning.getDcElement();
if ((dcElement == null) || dcElement.getElementName().startsWith("!")) {
return;
}
// TODO create an empty element if the values are null?
// return if the values are null
if (values == null) {
//Element elField = dom.createElement(returnable.getClientName());
//elField.appendChild(dom.createTextNode(""));
//record.appendChild(elField);
return;
}
// add an element for each value found
for (Object oValue: values) {
if (oValue != null) {
if (meaning.getValueType().equals(PropertyValueType.GEOMETRY)) {
if (oValue instanceof Envelope) {
// TODO include multiple envelope types in the response
Envelope env = (Envelope)oValue;
String sLower = env.getMinX()+" "+env.getMinY();
String sUpper = env.getMaxX()+" "+env.getMaxY();
Element elField = responseDom.createElement("ows:WGS84BoundingBox");
Element elLower = responseDom.createElement("ows:LowerCorner");
Element elUpper = responseDom.createElement("ows:UpperCorner");
elLower.appendChild(responseDom.createTextNode(sLower));
elUpper.appendChild(responseDom.createTextNode(sUpper));
elField.appendChild(elLower);
elField.appendChild(elUpper);
record.appendChild(elField);
elField = responseDom.createElement("ows:BoundingBox");
elLower = responseDom.createElement("ows:LowerCorner");
elUpper = responseDom.createElement("ows:UpperCorner");
elLower.appendChild(responseDom.createTextNode(sLower));
elUpper.appendChild(responseDom.createTextNode(sUpper));
elField.appendChild(elLower);
elField.appendChild(elUpper);
record.appendChild(elField);
}
} else {
String sValue = oValue.toString();
if (oValue instanceof Timestamp) {
if (meaningType.equals(PropertyMeaningType.DATEMODIFIED)) {
sValue = opResponse.toIso8601((Timestamp)oValue);
} else {
sValue = opResponse.toIso8601Date((Timestamp)oValue);
}
}
if (meaningType.equals(PropertyMeaningType.XMLURL)) {
if ((sValue != null) && sValue.startsWith("?getxml=")) {
sValue = cswBaseUrl+sValue;