ioException);
}
}
// result
TransactionResponseType result = WfsFactory.eINSTANCE.createTransactionResponseType();
result.setTransactionResults(WfsFactory.eINSTANCE.createTransactionResultsType());
result.getTransactionResults().setHandle(request.getHandle());
result.setTransactionSummary(WfsFactory.eINSTANCE.createTransactionSummaryType());
result.getTransactionSummary().setTotalInserted(BigInteger.valueOf(0));
result.getTransactionSummary().setTotalUpdated(BigInteger.valueOf(0));
result.getTransactionSummary().setTotalDeleted(BigInteger.valueOf(0));
result.setInsertResults(WfsFactory.eINSTANCE.createInsertResultsType());
// 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();
boolean exception = false;
try {
for (Iterator it = elementHandlers.entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next();
EObject element = (EObject) entry.getKey();
TransactionElementHandler handler = (TransactionElementHandler) entry.getValue();
handler.execute(element, request, stores, result, multiplexer);
}
} catch (WFSTransactionException e) {
exception = true;
LOGGER.log(Level.SEVERE, "Transaction failed", e);
// transaction failed, rollback
ActionType action = WfsFactory.eINSTANCE.createActionType();
if (e.getCode() != null) {
action.setCode(e.getCode());
} else {
action.setCode("InvalidParameterValue");
}
action.setLocator(e.getLocator());
action.setMessage(e.getMessage());
result.getTransactionResults().getAction().add(action);
}
// commit
boolean committed = false;
try {
if (exception) {
transaction.rollback();
} else {
// inform plugins we're about to commit
for (Iterator it = transactionPlugins.iterator(); it.hasNext();) {
TransactionPlugin tp = (TransactionPlugin) it.next();
tp.beforeCommit(request);
}
transaction.commit();
committed = true;
//
// Lets deal with the locks
//
// Q: Why talk to Data you ask
// A: Only class that knows all the DataStores
//
// We really need to ask all DataStores to release/refresh
// because we may have locked Features with this Authorizations
// on them, even though we did not refer to them in this
// transaction.
//
// Q: Why here, why now?
// A: The opperation was a success, and we have completed the
// opperation
//
// We also need to do this if the opperation is not a success,
// you can find this same code in the abort method
//
if (request.getLockId() != null) {
if (request.getReleaseAction() == AllSomeType.ALL_LITERAL) {
lockRelease(request.getLockId());
} else if (request.getReleaseAction() == AllSomeType.SOME_LITERAL) {
lockRefresh(request.getLockId());
}
}
}
} finally {
transaction.close();
transaction = null;
}
// inform plugins we're done
for (Iterator it = transactionPlugins.iterator(); it.hasNext();) {
TransactionPlugin tp = (TransactionPlugin) it.next();
tp.afterTransaction(request, committed);
}
//
// if ( result.getTransactionResult().getStatus().getPARTIAL() != null )
// {
// throw new WFSException("Canceling PARTIAL response");
// }
//
// try {
// if ( result.getTransactionResult().getStatus().getFAILED() != null )
// {
// //transaction failed, roll it back
// transaction.rollback();
// }
// else {
// transaction.commit();
// result.getTransactionResult().getStatus().setSUCCESS(
// WfsFactory.eINSTANCE.createEmptyType() );
// }
//
// }
// finally {
// transaction.close();
// transaction = null;
// }
// JD: this is an issue with the spec, InsertResults must be present,
// even if no insert
// occured, howwever insert results needs to have at least one
// "FeatureId" eliement, sp
// we create an FeatureId with an empty fid
if (result.getInsertResults().getFeature().isEmpty()) {
InsertedFeatureType insertedFeature = WfsFactory.eINSTANCE.createInsertedFeatureType();
insertedFeature.getFeatureId().add(filterFactory.featureId("none"));
result.getInsertResults().getFeature().add(insertedFeature);
}
return result;
// we will commit in the writeTo method