* @throws WfsException If no typename or featureid is present, or if the
* filter list size doesn't match the feature list size.
*/
public FeatureRequest getRequest(boolean withLock, HttpServletRequest srequest)
throws WfsException {
FeatureRequest currentRequest = new FeatureRequest();
currentRequest.setHttpServletRequest(srequest);
boolean useLock = false;
if (withLock || keyExists("REQUEST")) {
String request = getValue("REQUEST");
useLock = withLock
|| request.equalsIgnoreCase("GETFEATUREWITHLOCK");
if (useLock) {
currentRequest = new FeatureWithLockRequest();
}
currentRequest.setRequest(request);
}
// set global request parameters
LOGGER.finest("setting global request parameters");
if (keyExists("MAXFEATURES")) {
currentRequest.setMaxFeatures(getValue("MAXFEATURES"));
}
if (keyExists("VERSION")) {
currentRequest.setVersion(getValue("VERSION"));
}
if (keyExists("REQUEST")) {
currentRequest.setRequest(getValue("REQUEST"));
}
if (keyExists("FEATUREVERSION")) {
currentRequest.setFeatureVersion(getValue("FEATUREVERSION"));
}
if (keyExists("OUTPUTFORMAT")) {
currentRequest.setOutputFormat(getValue("OUTPUTFORMAT"));
}
if (useLock && keyExists("EXPIRY")) {
((FeatureWithLockRequest) currentRequest).setExpiry(Integer
.parseInt(getValue("EXPIRY")));
}
// declare tokenizers for repeating elements
LOGGER.finest("setting query request parameters");
List typeList = readFlat(getValue("TYPENAME"), INNER_DELIMETER);
List propertyList = readNested(getValue("PROPERTYNAME"));
String fidKvps = getValue("FEATUREID");
List filterList = readFilters(fidKvps, getValue("FILTER"),
getValue("BBOX"));
int propertySize = propertyList.size();
int filterSize = filterList.size();
if (typeList.size() == 0) {
typeList = getTypesFromFids(fidKvps);
if (typeList.size() == 0) {
throw new WfsException("The typename element is mandatory if "
+ "no FEATUREID is present");
}
}
int featureSize = typeList.size();
// check for errors in the request
if (((propertySize != featureSize) && (propertySize > 1))
|| ((filterSize != featureSize) && (filterSize > 1))) {
throw new WfsException("Properties or filter sizes do not match"
+ " feature types. Property size: " + propertySize
+ " Filter size: " + filterSize + " Feature size: "
+ featureSize);
} else {
// loops through feature types, and creates queries based on them
LOGGER.finest("setting query request parameters");
for (int i = 0; i < featureSize; i++) {
String featureType = (String) typeList.get(i);
List properties;
Filter filter;
// permissive logic: lets one property list apply to all types
LOGGER.finest("setting properties: " + i);
if (propertySize == 0) {
properties = null;
} else if (propertySize == 1) {
properties = (List) propertyList.get(0);
} else {
properties = (List) propertyList.get(i);
}
// permissive logic: lets one filter apply to all types
LOGGER.finest("setting filters: " + i);
if (filterSize == 0) {
filter = null;
} else if (filterSize == 1) {
filter = (Filter) filterList.get(0);
} else {
filter = (Filter) filterList.get(i);
}
LOGGER.finest("query filter: " + filter);
// add query
currentRequest.addQuery(makeQuery(featureType, properties,
filter));
}
return currentRequest;
}