Search in sources :

Example 96 with ObjectAlreadyExistsException

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

the class ActivitiInterface method notifyMidpointAboutProcessEvent.

private void notifyMidpointAboutProcessEvent(ProcessEvent event) {
    OperationResult result = new OperationResult(DOT_CLASS + "notifyMidpointAboutProcessEvent");
    String taskOid = ActivitiUtil.getTaskOid(event.getVariables());
    Task task;
    try {
        task = taskManager.getTask(taskOid, result);
    } catch (ObjectNotFoundException | SchemaException | RuntimeException e) {
        throw new SystemException("Couldn't get task " + taskOid + " from repository: " + e.getMessage(), e);
    }
    if (task.getExecutionStatus() != TaskExecutionStatus.WAITING) {
        LOGGER.trace("Asynchronous message received in a state different from WAITING (actual state: {}), ignoring it. Task = {}", task.getExecutionStatus(), task);
        return;
    }
    try {
        wfTaskController.onProcessEvent(event, task, result);
    } catch (SchemaException | ObjectNotFoundException | ObjectAlreadyExistsException | RuntimeException e) {
        throw new SystemException("Couldn't process a process-related event: " + e.getMessage(), e);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) DelegateTask(org.activiti.engine.delegate.DelegateTask) SystemException(com.evolveum.midpoint.util.exception.SystemException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)

Example 97 with ObjectAlreadyExistsException

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

the class DummyItsmIntegrationConnectorInstance method createTicketModify.

@Override
protected String createTicketModify(ResourceObjectDefinition objectDefinition, PrismObject<ShadowType> shadow, Collection<? extends ResourceAttribute<?>> identifiers, String resourceOid, Collection<Operation> changes, Task task, OperationResult result) throws CommunicationException, GenericFrameworkException, SchemaException, ObjectAlreadyExistsException, ConfigurationException {
    DummyItsm itsm = DummyItsm.getInstance();
    String identifier;
    try {
        identifier = itsm.createTicket("MODIFY " + identifiers + ": " + changes);
    } catch (CommunicationException | SchemaException | ObjectAlreadyExistsException | ConfigurationException e) {
        LOGGER.info("MODIFY " + identifiers + ": " + changes + " => " + e);
        throw e;
    } catch (Exception e) {
        LOGGER.info("MODIFY " + identifiers + ": " + changes + " => " + e);
        throw new GenericFrameworkException(e);
    }
    LOGGER.info("MODIFY " + identifiers + ": " + changes + " => " + identifier);
    return identifier;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException)

Example 98 with ObjectAlreadyExistsException

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

the class DummyItsmIntegrationConnectorInstance method createTicketAdd.

@Override
protected String createTicketAdd(PrismObject<? extends ShadowType> object, Task task, OperationResult result) throws CommunicationException, GenericFrameworkException, SchemaException, ObjectAlreadyExistsException, ConfigurationException {
    DummyItsm itsm = DummyItsm.getInstance();
    String identifier;
    try {
        identifier = itsm.createTicket("ADD " + object);
    } catch (CommunicationException | SchemaException | ObjectAlreadyExistsException | ConfigurationException e) {
        LOGGER.info("ADD " + object + " => " + e);
        throw e;
    } catch (Exception e) {
        LOGGER.info("ADD " + object + " => " + e);
        throw new GenericFrameworkException(e);
    }
    LOGGER.info("ADD " + object + " => " + identifier);
    return identifier;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException)

Example 99 with ObjectAlreadyExistsException

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

the class AbstractModelIntegrationTest method replaceTriggers.

protected void replaceTriggers(String oid, Collection<XMLGregorianCalendar> timestamps, String uri) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException {
    Task task = createPlainTask("replaceTriggers");
    OperationResult result = task.getResult();
    Collection<TriggerType> triggers = timestamps.stream().map(ts -> new TriggerType().timestamp(ts).handlerUri(uri)).collect(Collectors.toList());
    ObjectDelta<ObjectType> delta = prismContext.deltaFor(ObjectType.class).item(ObjectType.F_TRIGGER).replaceRealValues(triggers).asObjectDeltaCast(oid);
    executeChanges(delta, null, task, result);
    result.computeStatus();
    TestUtil.assertSuccess(result);
}
Also used : com.evolveum.midpoint.model.test.asserter(com.evolveum.midpoint.model.test.asserter) StringUtils(org.apache.commons.lang.StringUtils) AuditReferenceValue(com.evolveum.midpoint.audit.api.AuditReferenceValue) Autowired(org.springframework.beans.factory.annotation.Autowired) com.evolveum.midpoint.util.exception(com.evolveum.midpoint.util.exception) Entry(org.opends.server.types.Entry) com.evolveum.midpoint.test.asserter(com.evolveum.midpoint.test.asserter) PrismTestUtil(com.evolveum.midpoint.prism.util.PrismTestUtil) EvaluatedPolicyRule(com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) MidpointFunctions(com.evolveum.midpoint.model.api.expr.MidpointFunctions) MutableInt(org.apache.commons.lang.mutable.MutableInt) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) TransportService(com.evolveum.midpoint.notifications.api.transports.TransportService) com.evolveum.prism.xml.ns._public.types_3(com.evolveum.prism.xml.ns._public.types_3) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) Task(com.evolveum.midpoint.task.api.Task) TaskUtil(com.evolveum.midpoint.task.api.TaskUtil) PreconditionViolationException(com.evolveum.midpoint.repo.api.PreconditionViolationException) FilterInvocation(org.springframework.security.web.FilterInvocation) ModuleWebSecurityConfiguration(com.evolveum.midpoint.authentication.api.ModuleWebSecurityConfiguration) SystemObjectCache(com.evolveum.midpoint.model.common.SystemObjectCache) QName(javax.xml.namespace.QName) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) FocusValuePolicyOriginResolver(com.evolveum.midpoint.model.common.stringpolicy.FocusValuePolicyOriginResolver) Clock(com.evolveum.midpoint.common.Clock) java.util(java.util) Authorization(com.evolveum.midpoint.security.api.Authorization) AuthenticationModuleNameConstants(com.evolveum.midpoint.authentication.api.util.AuthenticationModuleNameConstants) com.evolveum.midpoint.util(com.evolveum.midpoint.util) AuthenticationModuleState(com.evolveum.midpoint.authentication.api.AuthenticationModuleState) MiscUtil.or0(com.evolveum.midpoint.util.MiscUtil.or0) AuditEventStage(com.evolveum.midpoint.audit.api.AuditEventStage) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) ActivityBasedTaskHandler(com.evolveum.midpoint.repo.common.activity.run.task.ActivityBasedTaskHandler) EquivalenceStrategy(com.evolveum.midpoint.prism.equivalence.EquivalenceStrategy) com.evolveum.midpoint.model.api(com.evolveum.midpoint.model.api) HookRegistry(com.evolveum.midpoint.model.api.hooks.HookRegistry) TestUtil(com.evolveum.midpoint.test.util.TestUtil) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) ConnectException(java.net.ConnectException) AfterClass(org.testng.annotations.AfterClass) SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) AuthorizationParameters(com.evolveum.midpoint.security.enforcer.api.AuthorizationParameters) IOException(java.io.IOException) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ObjectResolver(com.evolveum.midpoint.repo.common.ObjectResolver) File(java.io.File) ActivityReportUtil(com.evolveum.midpoint.repo.common.activity.run.reports.ActivityReportUtil) ModelElementContext(com.evolveum.midpoint.model.api.context.ModelElementContext) AtomicLong(java.util.concurrent.atomic.AtomicLong) ReferenceResolver(com.evolveum.midpoint.model.api.util.ReferenceResolver) OpenDJController(com.evolveum.midpoint.test.ldap.OpenDJController) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal) ItemName(com.evolveum.midpoint.prism.path.ItemName) AuditEventType(com.evolveum.midpoint.audit.api.AuditEventType) MiscUtil.argCheck(com.evolveum.midpoint.util.MiscUtil.argCheck) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) AuthorityUtils(org.springframework.security.core.authority.AuthorityUtils) ProvisioningStatistics(com.evolveum.midpoint.schema.statistics.ProvisioningStatistics) TaskDebugUtil(com.evolveum.midpoint.task.api.TaskDebugUtil) com.evolveum.midpoint.schema.util(com.evolveum.midpoint.schema.util) NotificationManager(com.evolveum.midpoint.notifications.api.NotificationManager) CommonTaskBeans(com.evolveum.midpoint.repo.common.activity.run.CommonTaskBeans) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SecurityContextManager(com.evolveum.midpoint.security.api.SecurityContextManager) AuthorizationConstants(com.evolveum.midpoint.security.api.AuthorizationConstants) PerformanceInformation(com.evolveum.midpoint.repo.api.perf.PerformanceInformation) com.evolveum.icf.dummy.resource(com.evolveum.icf.dummy.resource) InternalsConfig(com.evolveum.midpoint.schema.internals.InternalsConfig) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) Collections.singleton(java.util.Collections.singleton) TaskActivityManager(com.evolveum.midpoint.repo.common.activity.TaskActivityManager) InformationSource(com.evolveum.midpoint.schema.util.task.ActivityProgressInformationBuilder.InformationSource) ItemSecurityConstraints(com.evolveum.midpoint.security.enforcer.api.ItemSecurityConstraints) DirectoryException(org.opends.server.types.DirectoryException) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) PrismObject.asObjectableList(com.evolveum.midpoint.prism.PrismObject.asObjectableList) ConfigAttribute(org.springframework.security.access.ConfigAttribute) XmlTypeConverter(com.evolveum.midpoint.prism.xml.XmlTypeConverter) Experimental(com.evolveum.midpoint.util.annotation.Experimental) CompiledGuiProfile(com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile) PrismAsserts(com.evolveum.midpoint.prism.util.PrismAsserts) BeforeMethod(org.testng.annotations.BeforeMethod) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) ValuePolicyProcessor(com.evolveum.midpoint.model.common.stringpolicy.ValuePolicyProcessor) PrismObjectAsserter(com.evolveum.midpoint.test.asserter.prism.PrismObjectAsserter) SecurityContext(org.springframework.security.core.context.SecurityContext) ProvisioningService(com.evolveum.midpoint.provisioning.api.ProvisioningService) DashboardService(com.evolveum.midpoint.model.api.interaction.DashboardService) com.evolveum.midpoint.prism.delta(com.evolveum.midpoint.prism.delta) F_TIMESTAMP(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType.F_TIMESTAMP) SecurityConfig(org.springframework.security.access.SecurityConfig) AnonymousAuthenticationToken(org.springframework.security.authentication.AnonymousAuthenticationToken) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) NotNull(org.jetbrains.annotations.NotNull) Authentication(org.springframework.security.core.Authentication) com.evolveum.midpoint.schema(com.evolveum.midpoint.schema) AssertJUnit(org.testng.AssertJUnit) ActivityPath(com.evolveum.midpoint.schema.util.task.ActivityPath) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) GuiProfiledPrincipal(com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) OrgFilter(com.evolveum.midpoint.prism.query.OrgFilter) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) ModelContext(com.evolveum.midpoint.model.api.context.ModelContext) BucketingConfigurationOverrides(com.evolveum.midpoint.repo.common.activity.run.buckets.BucketingConfigurationOverrides) Objects.requireNonNull(java.util.Objects.requireNonNull) Qualifier(org.springframework.beans.factory.annotation.Qualifier) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) PrismContainerDefinitionAsserter(com.evolveum.midpoint.test.asserter.prism.PrismContainerDefinitionAsserter) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) BucketingManager(com.evolveum.midpoint.repo.common.activity.run.buckets.BucketingManager) GuiProfiledPrincipalManager(com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipalManager) ModuleAuthentication(com.evolveum.midpoint.authentication.api.config.ModuleAuthentication) SecurityEnforcer(com.evolveum.midpoint.security.enforcer.api.SecurityEnforcer) FileInputStream(java.io.FileInputStream) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Consumer(java.util.function.Consumer) Message(com.evolveum.midpoint.notifications.api.transports.Message) UnusedTestElement(com.evolveum.midpoint.tools.testng.UnusedTestElement) MatchingRule(com.evolveum.midpoint.prism.match.MatchingRule) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication) com.evolveum.midpoint.schema.processor(com.evolveum.midpoint.schema.processor) com.evolveum.midpoint.test(com.evolveum.midpoint.test) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 100 with ObjectAlreadyExistsException

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

the class TestDummy method test600AddAccountAlreadyExist.

/**
 * Test for proper handling of "already exists" exception. We try to add a shadow.
 * It fails, because there is unknown conflicting object on the resource. But a new
 * shadow for the conflicting object should be created in the repository.
 * MID-3603
 */
@Test
public void test600AddAccountAlreadyExist() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    syncServiceMock.reset();
    dummyResourceCtl.addAccount(ACCOUNT_MURRAY_USERNAME, ACCOUNT_MURRAY_USERNAME);
    PrismObject<ShadowType> account = createShadowNameOnly(resource, ACCOUNT_MURRAY_USERNAME);
    account.checkConsistence();
    display("Adding shadow", account);
    when();
    try {
        provisioningService.addObject(account, null, null, task, result);
        assertNotReached();
    } catch (ObjectAlreadyExistsException e) {
        then();
        displayExpectedException(e);
    }
    assertFailure(result);
    syncServiceMock.assertNotifyChange();
    // Even though the operation failed a shadow should be created for the conflicting object
    PrismObject<ShadowType> accountRepo = findAccountShadowByUsername(getMurrayRepoIcfName(), resource, result);
    assertNotNull("Shadow for conflicting object was not created in the repository", accountRepo);
    display("Repository shadow", accountRepo);
    checkRepoAccountShadow(accountRepo);
    assertEquals("Wrong ICF NAME in murray (repo) shadow", getMurrayRepoIcfName(), getIcfName(accountRepo));
    assertSteadyResource();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) Test(org.testng.annotations.Test)

Aggregations

ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)142 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)84 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)76 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)69 SystemException (com.evolveum.midpoint.util.exception.SystemException)50 PrismObject (com.evolveum.midpoint.prism.PrismObject)39 Test (org.testng.annotations.Test)36 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)31 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)29 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)28 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)27 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)24 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)24 RepositoryService (com.evolveum.midpoint.repo.api.RepositoryService)22 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)22 QName (javax.xml.namespace.QName)22 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)20 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)17 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)17 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)17