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;
}
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);
}
}
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);
}
}
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;
}
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();
}
}
Aggregations