Search in sources :

Example 66 with SystemException

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

the class PrimaryChangeAspectHelper method getPcpAspectConfigurationType.

public PcpAspectConfigurationType getPcpAspectConfigurationType(PrimaryChangeProcessorConfigurationType processorConfigurationType, PrimaryChangeAspect aspect) {
    if (processorConfigurationType == null) {
        return null;
    }
    String aspectName = aspect.getBeanName();
    String getterName = "get" + StringUtils.capitalizeFirstLetter(aspectName);
    Object aspectConfigurationObject;
    try {
        Method getter = processorConfigurationType.getClass().getDeclaredMethod(getterName);
        try {
            aspectConfigurationObject = getter.invoke(processorConfigurationType);
        } catch (IllegalAccessException | InvocationTargetException e) {
            throw new SystemException("Couldn't obtain configuration for aspect " + aspectName + " from the workflow configuration.", e);
        }
        if (aspectConfigurationObject != null) {
            return (PcpAspectConfigurationType) aspectConfigurationObject;
        }
        LOGGER.trace("Specific configuration for {} not found, trying generic configuration", aspectName);
    } catch (NoSuchMethodException e) {
        // nothing wrong with this, let's try generic configuration
        LOGGER.trace("Configuration getter method for {} not found, trying generic configuration", aspectName);
    }
    for (GenericPcpAspectConfigurationType genericConfig : processorConfigurationType.getOtherAspect()) {
        if (aspectName.equals(genericConfig.getName())) {
            return genericConfig;
        }
    }
    return null;
}
Also used : SystemException(com.evolveum.midpoint.util.exception.SystemException) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 67 with SystemException

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

the class MidpointUtil method getApprovalStageDefinition.

public static ApprovalStageDefinitionType getApprovalStageDefinition(String taskOid) {
    RepositoryService cacheRepositoryService = getCacheRepositoryService();
    OperationResult result = new OperationResult(MidpointUtil.class.getName() + ".getApprovalStageDefinition");
    try {
        PrismObject<TaskType> task = cacheRepositoryService.getObject(TaskType.class, taskOid, null, result);
        return WfContextUtil.getCurrentStageDefinition(task.asObjectable().getWorkflowContext());
    } catch (Exception e) {
        throw new SystemException("Couldn't retrieve approval stage for task " + taskOid + ": " + e.getMessage(), e);
    }
}
Also used : SystemException(com.evolveum.midpoint.util.exception.SystemException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) SystemException(com.evolveum.midpoint.util.exception.SystemException) SpringApplicationContextHolder.getCacheRepositoryService(com.evolveum.midpoint.wf.impl.processes.common.SpringApplicationContextHolder.getCacheRepositoryService) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService)

Example 68 with SystemException

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

the class ApprovalSchemaHelper method prepareStage.

public void prepareStage(ApprovalStageDefinitionType stageDef, RelationResolver relationResolver, ReferenceResolver referenceResolver) {
    try {
        // resolves filters in approvers
        List<ObjectReferenceType> resolvedApprovers = new ArrayList<>();
        for (ObjectReferenceType ref : stageDef.getApproverRef()) {
            resolvedApprovers.addAll(referenceResolver.resolveReference(ref, "approver ref"));
        }
        // resolves approver relations
        resolvedApprovers.addAll(relationResolver.getApprovers(stageDef.getApproverRelation()));
        stageDef.getApproverRef().clear();
        stageDef.getApproverRef().addAll(resolvedApprovers);
        stageDef.getApproverRelation().clear();
        // default values
        if (stageDef.getOutcomeIfNoApprovers() == null) {
            stageDef.setOutcomeIfNoApprovers(ApprovalLevelOutcomeType.REJECT);
        }
        if (stageDef.getGroupExpansion() == null) {
            stageDef.setGroupExpansion(GroupExpansionType.BY_CLAIMING_WORK_ITEMS);
        }
    } catch (ExpressionEvaluationException | ObjectNotFoundException | SchemaException e) {
        // todo propagate these exceptions?
        throw new SystemException("Couldn't prepare approval schema for execution: " + e.getMessage(), e);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SystemException(com.evolveum.midpoint.util.exception.SystemException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ArrayList(java.util.ArrayList)

Example 69 with SystemException

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

the class ItemApprovalProcessInterface method extractWorkItemResult.

@Override
public WorkItemResultType extractWorkItemResult(Map<String, Object> variables) {
    Boolean wasCompleted = ActivitiUtil.getVariable(variables, VARIABLE_WORK_ITEM_WAS_COMPLETED, Boolean.class, prismContext);
    if (BooleanUtils.isNotTrue(wasCompleted)) {
        return null;
    }
    WorkItemResultType result = new WorkItemResultType(prismContext);
    result.setOutcome(ActivitiUtil.getVariable(variables, FORM_FIELD_OUTCOME, String.class, prismContext));
    result.setComment(ActivitiUtil.getVariable(variables, FORM_FIELD_COMMENT, String.class, prismContext));
    String additionalDeltaString = ActivitiUtil.getVariable(variables, FORM_FIELD_ADDITIONAL_DELTA, String.class, prismContext);
    boolean isApproved = ApprovalUtils.isApproved(result);
    if (isApproved && StringUtils.isNotEmpty(additionalDeltaString)) {
        try {
            ObjectDeltaType additionalDelta = prismContext.parserFor(additionalDeltaString).parseRealValue(ObjectDeltaType.class);
            ObjectTreeDeltasType treeDeltas = new ObjectTreeDeltasType();
            treeDeltas.setFocusPrimaryDelta(additionalDelta);
            result.setAdditionalDeltas(treeDeltas);
        } catch (SchemaException e) {
            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't parse delta received from the activiti form:\n{}", e, additionalDeltaString);
            throw new SystemException("Couldn't parse delta received from the activiti form: " + e.getMessage(), e);
        }
    }
    return result;
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException)

Example 70 with SystemException

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

the class AuditTest method getAuditEventRecord.

private AuditEventRecord getAuditEventRecord(int expectedCount, int index) {
    Session session = getFactory().openSession();
    try {
        session.beginTransaction();
        Query query = session.createQuery("from " + RAuditEventRecord.class.getSimpleName() + " order by id");
        List<RAuditEventRecord> records = query.list();
        assertEquals(expectedCount, records.size());
        AuditEventRecord eventRecord = RAuditEventRecord.fromRepo(records.get(index), prismContext);
        session.getTransaction().commit();
        return eventRecord;
    } catch (DtoTranslationException e) {
        throw new SystemException(e);
    } finally {
        session.close();
    }
}
Also used : DtoTranslationException(com.evolveum.midpoint.repo.sql.util.DtoTranslationException) Query(org.hibernate.Query) RAuditEventRecord(com.evolveum.midpoint.repo.sql.data.audit.RAuditEventRecord) SystemException(com.evolveum.midpoint.util.exception.SystemException) RAuditEventRecord(com.evolveum.midpoint.repo.sql.data.audit.RAuditEventRecord) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) Session(org.hibernate.Session)

Aggregations

SystemException (com.evolveum.midpoint.util.exception.SystemException)201 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)113 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)76 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)65 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)35 PrismObject (com.evolveum.midpoint.prism.PrismObject)32 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)32 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)31 QName (javax.xml.namespace.QName)28 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)26 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)26 Task (com.evolveum.midpoint.task.api.Task)23 ArrayList (java.util.ArrayList)21 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)16 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)16 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)14 Test (org.testng.annotations.Test)14 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)12 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)12 ResultHandler (com.evolveum.midpoint.schema.ResultHandler)12