use of org.apache.syncope.core.provisioning.camel.CamelException in project syncope by apache.
the class CamelRouteLogic method update.
@PreAuthorize("hasRole('" + CamelEntitlement.ROUTE_UPDATE + "')")
public void update(final AnyTypeKind anyTypeKind, final CamelRouteTO routeTO) {
CamelRoute route = routeDAO.find(routeTO.getKey());
if (route == null) {
throw new NotFoundException("CamelRoute with key=" + routeTO.getKey());
}
if (route.getAnyTypeKind() != anyTypeKind) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
sce.getElements().add("Found " + anyTypeKind + ", expected " + route.getAnyTypeKind());
throw sce;
}
String originalContent = route.getContent();
LOG.debug("Updating route {} with content {}", routeTO.getKey(), routeTO.getContent());
binder.update(route, routeTO);
try {
context.updateContext(routeTO.getKey());
} catch (CamelException e) {
// if an exception was thrown while updating the context, restore the former route definition
LOG.debug("Update of route {} failed, reverting", routeTO.getKey());
context.restoreRoute(routeTO.getKey(), originalContent);
throw e;
}
}
Aggregations