Search in sources :

Example 56 with ObjectAlreadyExistsException

use of com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException in project midpoint by Evolveum.

the class TaskManagerQuartzImpl method addTaskToRepositoryAndQuartz.

private String addTaskToRepositoryAndQuartz(Task task, OperationResult parentResult) throws ObjectAlreadyExistsException, SchemaException {
    if (task.isLightweightAsynchronousTask()) {
        throw new IllegalStateException("A task with lightweight task handler cannot be made persistent; task = " + task);
    // otherwise, there would be complications on task restart: the task handler is not stored in the repository,
    // so it is just not possible to restart such a task
    }
    OperationResult result = parentResult.createSubresult(DOT_IMPL_CLASS + "addTaskToRepositoryAndQuartz");
    result.addArbitraryObjectAsParam("task", task);
    PrismObject<TaskType> taskPrism = task.getTaskPrismObject();
    String oid;
    try {
        oid = repositoryService.addObject(taskPrism, null, result);
    } catch (ObjectAlreadyExistsException e) {
        result.recordFatalError("Couldn't add task to repository: " + e.getMessage(), e);
        throw e;
    } catch (SchemaException e) {
        result.recordFatalError("Couldn't add task to repository: " + e.getMessage(), e);
        throw e;
    }
    ((TaskQuartzImpl) task).setOid(oid);
    synchronizeTaskWithQuartz((TaskQuartzImpl) task, result);
    result.computeStatus();
    return oid;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)

Example 57 with ObjectAlreadyExistsException

use of com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException in project midpoint by Evolveum.

the class TaskQuartzImpl method storeOperationStats.

@Override
public void storeOperationStats() {
    try {
        setOperationStats(getAggregatedLiveOperationStats());
        // TODO fixme
        savePendingModifications(new OperationResult(DOT_INTERFACE + ".storeOperationStats"));
    } catch (SchemaException | ObjectNotFoundException | ObjectAlreadyExistsException | RuntimeException e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't store statistical information into task {}", e, this);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)

Example 58 with ObjectAlreadyExistsException

use of com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException in project midpoint by Evolveum.

the class TestLdapComplex method initSystem.

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
    super.initSystem(initTask, initResult);
    modelService.postInit(initResult);
    // System Configuration
    PrismObject<SystemConfigurationType> config;
    try {
        config = 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);
    }
    LoggingConfigurationManager.configure(ProfilingConfigurationManager.checkSystemProfilingConfiguration(config), config.asObjectable().getVersion(), initResult);
    // administrator
    PrismObject<UserType> userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, initResult);
    repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult);
    login(userAdministrator);
    // Roles
    repoAddObjectFromFile(ROLE_CAPTAIN_FILE, initResult);
    repoAddObjectFromFile(ROLE_JUDGE_FILE, initResult);
    repoAddObjectFromFile(ROLE_PIRATE_FILE, initResult);
    repoAddObjectFromFile(ROLE_SAILOR_FILE, initResult);
    // templates
    repoAddObjectFromFile(USER_TEMPLATE_FILE, initResult);
    // Resources
    resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, RESOURCE_OPENDJ_FILE, RESOURCE_OPENDJ_OID, initTask, initResult);
    resourceOpenDjType = resourceOpenDj.asObjectable();
    openDJController.setResource(resourceOpenDj);
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
    openDJController.addEntriesFromLdifFile(ROLES_LDIF_FILE.getPath());
    display("initial LDAP content", openDJController.dumpEntries());
}
Also used : SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 59 with ObjectAlreadyExistsException

use of com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException in project midpoint by Evolveum.

the class TestLdapUniversity method initSystem.

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
    super.initSystem(initTask, initResult);
    modelService.postInit(initResult);
    // System Configuration
    PrismObject<SystemConfigurationType> config;
    try {
        config = 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);
    }
    LoggingConfigurationManager.configure(ProfilingConfigurationManager.checkSystemProfilingConfiguration(config), config.asObjectable().getVersion(), initResult);
    // administrator
    PrismObject<UserType> userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, initResult);
    repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult);
    login(userAdministrator);
    // Resources
    resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, RESOURCE_OPENDJ_FILE, RESOURCE_OPENDJ_OID, initTask, initResult);
    resourceOpenDjType = resourceOpenDj.asObjectable();
    openDJController.setResource(resourceOpenDj);
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
    display("initial LDAP content", openDJController.dumpEntries());
}
Also used : SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 60 with ObjectAlreadyExistsException

use of com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException in project midpoint by Evolveum.

the class AbstractLdapTest method initSystem.

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
    super.initSystem(initTask, initResult);
    // System Configuration
    PrismObject<SystemConfigurationType> config;
    try {
        config = 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);
    }
    modelService.postInit(initResult);
    // to get profiling facilities (until better API is available)
    //        LoggingConfigurationManager.configure(
    //                ProfilingConfigurationManager.checkSystemProfilingConfiguration(config),
    //                config.asObjectable().getVersion(), initResult);
    // administrator
    PrismObject<UserType> userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, initResult);
    repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult);
    login(userAdministrator);
    // Resources
    if (isImportResourceAtInit()) {
        resource = importAndGetObjectFromFile(ResourceType.class, getResourceFile(), getResourceOid(), initTask, initResult);
        resourceType = resource.asObjectable();
    }
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
    //initProfiling - start
    ProfilingDataManager profilingManager = ProfilingDataManager.getInstance();
    Map<ProfilingDataManager.Subsystem, Boolean> subsystems = new HashMap<>();
    subsystems.put(ProfilingDataManager.Subsystem.MODEL, true);
    subsystems.put(ProfilingDataManager.Subsystem.REPOSITORY, true);
    profilingManager.configureProfilingDataManagerForTest(subsystems, true);
    profilingManager.appendProfilingToTest();
    //initProfiling - end
    ciMatchingRule = matchingRuleRegistry.getMatchingRule(StringIgnoreCaseMatchingRule.NAME, DOMUtil.XSD_STRING);
    dnMatchingRule = matchingRuleRegistry.getMatchingRule(DistinguishedNameMatchingRule.NAME, DOMUtil.XSD_STRING);
    logTrustManagers();
    if (isAssertOpenFiles()) {
        lsof = new Lsof(TestUtil.getPid());
    }
}
Also used : ProfilingDataManager(com.evolveum.midpoint.util.aspect.ProfilingDataManager) HashMap(java.util.HashMap) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) Lsof(com.evolveum.midpoint.test.util.Lsof) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Aggregations

ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)93 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)57 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)50 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)45 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)35 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)33 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)32 SystemException (com.evolveum.midpoint.util.exception.SystemException)31 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)25 PrismObject (com.evolveum.midpoint.prism.PrismObject)21 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)18 Task (com.evolveum.midpoint.task.api.Task)17 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)14 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)14 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)13 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)12 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)12 ArrayList (java.util.ArrayList)11 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)10 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)9