use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class FlowableUserWorkflowAdapter method getHistoricFormTO.
protected WorkflowFormTO getHistoricFormTO(final String processInstanceId, final String taskId, final String formKey, final List<HistoricFormPropertyEntity> props) {
WorkflowFormTO formTO = new WorkflowFormTO();
User user = userDAO.findByWorkflowId(processInstanceId);
if (user == null) {
throw new NotFoundException("User with workflow id " + processInstanceId);
}
formTO.setUsername(user.getUsername());
formTO.setTaskId(taskId);
formTO.setKey(formKey);
formTO.setUserTO(engine.getRuntimeService().getVariable(processInstanceId, USER_TO, UserTO.class));
formTO.setUserPatch(engine.getRuntimeService().getVariable(processInstanceId, USER_PATCH, UserPatch.class));
props.stream().map(prop -> {
WorkflowFormPropertyTO propertyTO = new WorkflowFormPropertyTO();
propertyTO.setId(prop.getPropertyId());
propertyTO.setName(prop.getPropertyId());
propertyTO.setValue(prop.getPropertyValue());
return propertyTO;
}).forEachOrdered(propertyTO -> {
formTO.getProperties().add(propertyTO);
});
return formTO;
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class FlowableUserWorkflowAdapter method checkTask.
protected Pair<Task, TaskFormData> checkTask(final String taskId, final String authUser) {
Task task;
try {
task = engine.getTaskService().createTaskQuery().taskId(taskId).singleResult();
if (task == null) {
throw new FlowableException("NULL result");
}
} catch (FlowableException e) {
throw new NotFoundException("Flowable Task " + taskId, e);
}
TaskFormData formData;
try {
formData = engine.getFormService().getTaskFormData(task.getId());
} catch (FlowableException e) {
throw new NotFoundException("Form for Flowable Task " + taskId, e);
}
if (!adminUser.equals(authUser)) {
User user = userDAO.findByUsername(authUser);
if (user == null) {
throw new NotFoundException("Syncope User " + authUser);
}
}
return Pair.of(task, formData);
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException 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;
}
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class CamelRouteLogic method read.
@PreAuthorize("hasRole('" + CamelEntitlement.ROUTE_READ + "')")
@Transactional(readOnly = true)
public CamelRouteTO read(final AnyTypeKind anyTypeKind, final String key) {
CamelRoute route = routeDAO.find(key);
if (route == null) {
throw new NotFoundException("CamelRoute with key=" + key);
}
if (route.getAnyTypeKind() != anyTypeKind) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
sce.getElements().add("Found " + anyTypeKind + ", expected " + route.getAnyTypeKind());
throw sce;
}
return binder.getRouteTO(route);
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class JPAConnInstanceDAO method save.
@Override
public ConnInstance save(final ConnInstance connector) {
final ConnInstance merged = entityManager().merge(connector);
merged.getResources().forEach(resource -> {
try {
connRegistry.registerConnector(resource);
} catch (NotFoundException e) {
LOG.error("While registering connector for resource", e);
}
});
return merged;
}
Aggregations