* @throws WfsException If no type is found, if filter length doesn't match
* feature length, or if no filter is found. We don't want users
* to accidentally delete their whole db.
*/
public Request getRequest(HttpServletRequest request) throws WfsException {
TransactionRequest parentRequest = new TransactionRequest();
parentRequest.setHttpServletRequest(request);
boolean releaseAll = true;
// set global request parameters
LOGGER.finest("setting global request parameters");
if (keyExists("VERSION")) {
parentRequest.setVersion(getValue("VERSION"));
}
if (keyExists("REQUEST")) {
parentRequest.setRequest(getValue("REQUEST"));
}
//REVISIT: This is not in spec, but really should be. Waiting to hear
//about features like this, that were just accidentally left out.
if (keyExists("LOCKID")) {
parentRequest.setLockId(getValue("LOCKID"));
}
// declare tokenizers for repeating elements
LOGGER.finest("setting query request parameters");
List typeList = readFlat(getValue("TYPENAME"), INNER_DELIMETER);
LOGGER.finest("type list size: " + typeList.size());
List filterList = null;
filterList = readFilters(getValue("FEATUREID"), getValue("FILTER"),
getValue("BBOX"));
if (typeList.size() == 0) {
typeList = getTypesFromFids(getValue("FEATUREID"));
if (typeList.size() == 0) {
throw new WfsException("The typename element is mandatory if "
+ "no FEATUREID is present");
}
}
int featureSize = typeList.size();
int filterSize = (filterList == null) ? 0 : filterList.size();
// prepare the release action boolean for all delete transactions
if (keyExists("RELEASEACTION")) {
String lockAction = getValue("RELEASEACTION");
parentRequest.setReleaseAction(lockAction);
}
// check for errors in the request
if (((filterSize != featureSize) && (filterSize > 0))
|| ((filterSize > 0) && (featureSize == 0))) {
throw new WfsException("Filter size does not match"
+ " feature types. Filter size: " + filterSize
+ " Feature size: " + featureSize);
} else if (filterSize == featureSize) {
for (int i = 0, n = featureSize; i < n; i++) {
DeleteRequest childRequest = new DeleteRequest();
childRequest.setTypeName((String) typeList.get(i));
childRequest.setFilter((Filter) filterList.get(i));
childRequest.setReleaseAll(releaseAll);
parentRequest.addSubRequest(childRequest);
}
} else if (filterSize == 0) {
String message = "No filter found. If you are sure you want to "
+ "wipe out your database, then use a filter that is always true"
+ ". We just don't want you to inadvertantly wipe everything "