//
// (I am using element rather than transaction sub request
// to agree with the spec docs)
for (Iterator it = elementHandlers.entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next();
TransactionElement element = (TransactionElement) entry.getKey();
TransactionElementHandler handler = (TransactionElementHandler) entry.getValue();
Map featureTypeInfos = new HashMap();
QName[] typeNames = handler.getTypeNames(element);
for (int i = 0; i < typeNames.length; i++) {
final QName typeName = typeNames[i];
final String name = typeName.getLocalPart();
final String namespaceURI;
if (typeName.getNamespaceURI() != null) {
namespaceURI = typeName.getNamespaceURI();
} else {
namespaceURI = catalog.getDefaultNamespace().getURI();
}
LOGGER.fine("Locating FeatureSource uri:'" + namespaceURI + "' name:'" + name + "'");
final FeatureTypeInfo meta = catalog.getFeatureTypeByName(namespaceURI, name);
if (meta == null) {
String msg = "Feature type '" + name + "' is not available: ";
throw new WFSTransactionException(msg, (String) null, element.getHandle());
}
featureTypeInfos.put(typeName, meta);
}
// check element validity
handler.checkValidity(element, featureTypeInfos);
// go through all feature type infos data objects, and load feature
// stores
for (Iterator m = featureTypeInfos.values().iterator(); m.hasNext();) {
FeatureTypeInfo meta = (FeatureTypeInfo) m.next();
String typeRef = meta.getStore().getName() + ":" + meta.getName();
String URI = meta.getNamespace().getURI();
QName elementName = new QName(URI, meta.getName(),
meta.getNamespace().getPrefix());
QName elementNameDefault = null;
if (catalog.getDefaultNamespace().getURI().equals(URI)) {
elementNameDefault = new QName(meta.getName());
}
LOGGER.fine("located FeatureType w/ typeRef '" + typeRef + "' and elementName '"
+ elementName + "'");
if (stores.containsKey(elementName)) {
// typeName already loaded
continue;
}
try {
FeatureSource<? extends FeatureType, ? extends Feature> source = meta.getFeatureSource(null,null);
if (source instanceof FeatureStore) {
FeatureStore<? extends FeatureType, ? extends Feature> store;
store = (FeatureStore<? extends FeatureType, ? extends Feature>) source;
store.setTransaction(transaction);
stores.put(elementName, source);
if (elementNameDefault != null) {
stores.put(elementNameDefault, source);
}
stores2.put(typeRef, source);
} else {
String msg = elementName + " is read-only";
throw new WFSTransactionException(msg, (String) null, element.getHandle());
}
} catch (IOException ioException) {
String msg = elementName + " is not available: "
+ ioException.getLocalizedMessage();
throw new WFSTransactionException(msg, ioException, element.getHandle());
}
}
}
// provide authorization for transaction
//
String authorizationID = request.getLockId();
if (authorizationID != null) {
if (!wfs.getServiceLevel().getOps().contains( WFSInfo.Operation.LOCKFEATURE)) {
throw new WFSException(request, "Lock support is not enabled");
}
LOGGER.finer("got lockId: " + authorizationID);
if (!lockExists(authorizationID)) {
String mesg = "Attempting to use a lockID that does not exist"
+ ", it has either expired or was entered wrong.";
throw new WFSException(request, mesg, "InvalidParameterValue");
}
try {
transaction.addAuthorization(authorizationID);
} catch (IOException ioException) {
// This is a real failure - not associated with a element
//
throw new WFSException(request, "Authorization ID '" + authorizationID + "' not useable",
ioException);
}
}
// result
TransactionResponse result = request.createResponse();
result.setHandle(request.getHandle());
// execute elements in order, recording results as we go
// I will need to record the damaged area for pre commit validation
// checks
// Envelope envelope = new Envelope();
Exception exception = null;
try {
for (Iterator it = elementHandlers.entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next();
TransactionElement element = (TransactionElement) entry.getKey();
TransactionElementHandler handler = (TransactionElementHandler) entry.getValue();
handler.execute(element, request, stores, result, multiplexer);
}
} catch (WFSTransactionException e) {