use of com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException in project midpoint by Evolveum.
the class TaskManagerQuartzImpl method persist.
private void persist(Task task, OperationResult parentResult) {
if (task.getPersistenceStatus() == TaskPersistenceStatus.PERSISTENT) {
// Task already persistent. Nothing to do.
return;
}
TaskQuartzImpl taskImpl = (TaskQuartzImpl) task;
if (task.getName() == null) {
PolyStringType polyStringName = new PolyStringType("Task " + task.getTaskIdentifier());
taskImpl.setNameTransient(polyStringName);
}
if (taskImpl.getOid() != null) {
// We don't support user-specified OIDs
throw new IllegalArgumentException("Transient task must not have OID (task:" + task + ")");
}
// hack: set Category if it is not set yet
if (taskImpl.getCategory() == null) {
taskImpl.setCategoryTransient(taskImpl.getCategoryFromHandler());
}
// Make sure that the task has repository service instance, so it can fully work as "persistent"
if (taskImpl.getRepositoryService() == null) {
RepositoryService repoService = (RepositoryService) this.beanFactory.getBean("repositoryService");
taskImpl.setRepositoryService(repoService);
}
try {
addTaskToRepositoryAndQuartz(taskImpl, parentResult);
} catch (ObjectAlreadyExistsException ex) {
// This should not happen. If it does, it is a bug. It is OK to convert to a runtime exception
throw new IllegalStateException("Got ObjectAlreadyExistsException while not expecting it (task:" + task + ")", ex);
} catch (SchemaException ex) {
// This should not happen. If it does, it is a bug. It is OK to convert to a runtime exception
throw new IllegalStateException("Got SchemaException while not expecting it (task:" + task + ")", ex);
}
}
use of com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException in project midpoint by Evolveum.
the class TaskQuartzImpl method setOtherHandlersUriStackImmediate.
public void setOtherHandlersUriStackImmediate(UriStack value, OperationResult parentResult) throws ObjectNotFoundException, SchemaException {
try {
processModificationNow(setOtherHandlersUriStackAndPrepareDelta(value), parentResult);
checkHandlerUriConsistency();
} catch (ObjectAlreadyExistsException ex) {
throw new SystemException(ex);
}
}
use of com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException in project midpoint by Evolveum.
the class TestReport method initSystem.
@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
repoAddObjectFromFile(USER_JACK_FILE, true, initResult).asObjectable();
repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult);
// System Configuration
modelService.postInit(initResult);
try {
repoAddObjectFromFile(SYSTEM_CONFIGURATION_FILE, initResult);
} catch (ObjectAlreadyExistsException e) {
throw new ObjectAlreadyExistsException("System configuration already exists in repository;" + "looks like the previous test haven't cleaned it up", e);
}
// User administrator
PrismObject<UserType> userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, initResult);
importObjectFromFile(RESOURCE_DUMMY_FILE, initResult);
login(userAdministrator);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
// caseIgnoreMatchingRule = matchingRuleRegistry.getMatchingRule(StringIgnoreCaseMatchingRule.NAME, DOMUtil.XSD_STRING);
// importSystemTasks(initResult);
}
use of com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException in project midpoint by Evolveum.
the class AbstractUninitializedCertificationTest method initSystem.
@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
logger.trace("initSystem");
super.initSystem(initTask, initResult);
modelService.postInit(initResult);
// System Configuration
try {
repoAddObjectFromFile(getSystemConfigurationFile(), initResult);
} catch (ObjectAlreadyExistsException e) {
throw new ObjectAlreadyExistsException("System configuration already exists in repository;" + "looks like the previous test haven't cleaned it up", e);
}
// Administrator
roleSuperuser = repoAddObjectFromFile(ROLE_SUPERUSER_FILE, RoleType.class, initResult).asObjectable();
userAdministrator = repoAddObjectFromFile(getUserAdministratorFile(), UserType.class, initResult).asObjectable();
login(userAdministrator.asPrismObject());
}
use of com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException in project midpoint by Evolveum.
the class TriggerScanItemProcessor method removeTriggers.
private void removeTriggers(PrismObject<? extends ObjectType> object, Collection<TriggerType> triggers, Task task, PrismContainerDefinition<TriggerType> triggerContainerDef) {
ContainerDelta<TriggerType> triggerDelta = triggerContainerDef.createEmptyDelta(F_TRIGGER);
for (TriggerType trigger : triggers) {
// noinspection unchecked
triggerDelta.addValueToDelete(trigger.asPrismContainerValue().clone());
}
Collection<? extends ItemDelta<?, ?>> modifications = MiscSchemaUtil.createCollection(triggerDelta);
// This is detached result. It will not take part of the task result. We do not really care.
OperationResult result = new OperationResult(TriggerScanActivityHandler.class.getName() + ".removeTriggers");
try {
activityRun.getModelBeans().cacheRepositoryService.modifyObject(requireNonNull(object.getCompileTimeClass()), object.getOid(), modifications, result);
result.computeStatus();
task.recordObjectActionExecuted(object, ChangeType.MODIFY, null);
} catch (ObjectNotFoundException e) {
// Object is gone. Ergo there are no triggers left. Ergo the trigger was removed.
// Ergo this is not really an error.
task.recordObjectActionExecuted(object, ChangeType.MODIFY, e);
LOGGER.trace("Unable to remove trigger from {}: {} (but this is probably OK)", object, e.getMessage(), e);
} catch (SchemaException | ObjectAlreadyExistsException e) {
task.recordObjectActionExecuted(object, ChangeType.MODIFY, e);
LOGGER.error("Unable to remove trigger from {}: {}", object, e.getMessage(), e);
} catch (Throwable t) {
task.recordObjectActionExecuted(object, ChangeType.MODIFY, t);
throw t;
}
}
Aggregations