use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class SyncopeLogic method readTypeExtension.
@PreAuthorize("isAuthenticated()")
public TypeExtensionTO readTypeExtension(final String groupName) {
Group group = groupDAO.findByName(groupName);
if (group == null) {
throw new NotFoundException("Group " + groupName);
}
Optional<? extends TypeExtension> typeExt = group.getTypeExtension(anyTypeDAO.findUser());
if (!typeExt.isPresent()) {
throw new NotFoundException("TypeExtension in " + groupName + " for users");
}
return groupDataBinder.getTypeExtensionTO(typeExt.get());
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class TaskLogic method updateSchedTask.
@PreAuthorize("hasRole('" + StandardEntitlement.TASK_UPDATE + "')")
public <T extends SchedTaskTO> T updateSchedTask(final TaskType type, final SchedTaskTO taskTO) {
SchedTask task = taskDAO.find(taskTO.getKey());
if (task == null) {
throw new NotFoundException("Task " + taskTO.getKey());
}
TaskUtils taskUtils = taskUtilsFactory.getInstance(task);
if (taskUtils.getType() != type) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
sce.getElements().add("Found " + type + ", expected " + taskUtils.getType());
throw sce;
}
binder.updateSchedTask(task, taskTO, taskUtils);
task = taskDAO.save(task);
try {
jobManager.register(task, task.getStartAt(), confDAO.find("tasks.interruptMaxRetries", 1L));
} catch (Exception e) {
LOG.error("While registering quartz job for task " + task.getKey(), e);
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Scheduling);
sce.getElements().add(e.getMessage());
throw sce;
}
return binder.getTaskTO(task, taskUtils, false);
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class TaskLogic method deleteExecution.
@PreAuthorize("hasRole('" + StandardEntitlement.TASK_DELETE + "')")
@Override
public ExecTO deleteExecution(final String execKey) {
TaskExec taskExec = taskExecDAO.find(execKey);
if (taskExec == null) {
throw new NotFoundException("Task execution " + execKey);
}
ExecTO taskExecutionToDelete = binder.getExecTO(taskExec);
taskExecDAO.delete(taskExec);
return taskExecutionToDelete;
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class TaskLogic method getJob.
@PreAuthorize("hasRole('" + StandardEntitlement.TASK_READ + "')")
@Override
public JobTO getJob(final String key) {
Task task = taskDAO.find(key);
if (task == null) {
throw new NotFoundException("Task " + key);
}
JobTO jobTO = null;
try {
jobTO = getJobTO(JobNamer.getJobKey(task));
} catch (SchedulerException e) {
LOG.error("Problems while retrieving scheduled job {}", JobNamer.getJobKey(task), e);
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Scheduling);
sce.getElements().add(e.getMessage());
throw sce;
}
if (jobTO == null) {
throw new NotFoundException("Job for task " + key);
}
return jobTO;
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class TaskLogic method delete.
@PreAuthorize("hasRole('" + StandardEntitlement.TASK_DELETE + "')")
public <T extends TaskTO> T delete(final TaskType type, final String key) {
Task task = taskDAO.find(key);
if (task == null) {
throw new NotFoundException("Task " + key);
}
TaskUtils taskUtils = taskUtilsFactory.getInstance(task);
if (type != null && taskUtils.getType() != type) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
sce.getElements().add("Found " + type + ", expected " + taskUtils.getType());
throw sce;
}
T taskToDelete = binder.getTaskTO(task, taskUtils, true);
if (TaskType.SCHEDULED == taskUtils.getType() || TaskType.PULL == taskUtils.getType() || TaskType.PUSH == taskUtils.getType()) {
jobManager.unregister(task);
}
taskDAO.delete(task);
return taskToDelete;
}
Aggregations