use of com.evolveum.midpoint.util.exception.CommunicationException in project midpoint by Evolveum.
the class ConnectorInstanceConnIdImpl method fetchCurrentToken.
@Override
public <T> PrismProperty<T> fetchCurrentToken(ObjectClassComplexTypeDefinition objectClassDef, StateReporter reporter, OperationResult parentResult) throws CommunicationException, GenericFrameworkException {
OperationResult result = parentResult.createSubresult(ConnectorInstance.class.getName() + ".fetchCurrentToken");
result.addParam("objectClass", objectClassDef);
ObjectClass icfObjectClass;
if (objectClassDef == null) {
icfObjectClass = ObjectClass.ALL;
} else {
icfObjectClass = connIdNameMapper.objectClassToIcf(objectClassDef, getSchemaNamespace(), connectorType, legacySchema);
}
OperationResult icfResult = result.createSubresult(ConnectorFacade.class.getName() + ".sync");
icfResult.addContext("connector", connIdConnectorFacade.getClass());
icfResult.addArbitraryObjectAsParam("icfObjectClass", icfObjectClass);
SyncToken syncToken = null;
try {
InternalMonitor.recordConnectorOperation("getLatestSyncToken");
recordIcfOperationStart(reporter, ProvisioningOperation.ICF_GET_LATEST_SYNC_TOKEN, objectClassDef);
syncToken = connIdConnectorFacade.getLatestSyncToken(icfObjectClass);
recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET_LATEST_SYNC_TOKEN, objectClassDef);
icfResult.recordSuccess();
icfResult.addReturn("syncToken", syncToken == null ? null : String.valueOf(syncToken.getValue()));
} catch (Throwable ex) {
recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET_LATEST_SYNC_TOKEN, objectClassDef, ex);
Throwable midpointEx = processIcfException(ex, this, icfResult);
result.computeStatus();
// exception
if (midpointEx instanceof CommunicationException) {
throw (CommunicationException) midpointEx;
} else if (midpointEx instanceof GenericFrameworkException) {
throw (GenericFrameworkException) midpointEx;
} else if (midpointEx instanceof RuntimeException) {
throw (RuntimeException) midpointEx;
} else if (midpointEx instanceof Error) {
throw (Error) midpointEx;
} else {
throw new SystemException("Got unexpected exception: " + ex.getClass().getName() + ": " + ex.getMessage(), ex);
}
}
if (syncToken == null) {
result.recordWarning("Resource have not provided a current sync token");
return null;
}
PrismProperty<T> property = getToken(syncToken);
result.recordSuccess();
return property;
}
use of com.evolveum.midpoint.util.exception.CommunicationException in project midpoint by Evolveum.
the class AbstractManualConnectorInstance method deleteObject.
@Override
public AsynchronousOperationResult deleteObject(ObjectClassComplexTypeDefinition objectClass, Collection<Operation> additionalOperations, Collection<? extends ResourceAttribute<?>> identifiers, StateReporter reporter, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, GenericFrameworkException, SchemaException, ConfigurationException {
OperationResult result = parentResult.createSubresult(OPERATION_DELETE);
String ticketIdentifier = null;
try {
ticketIdentifier = createTicketDelete(objectClass, identifiers, result);
} catch (ObjectNotFoundException | CommunicationException | GenericFrameworkException | SchemaException | ConfigurationException | RuntimeException | Error e) {
result.recordFatalError(e);
throw e;
}
result.recordInProgress();
result.setAsynchronousOperationReference(ticketIdentifier);
return AsynchronousOperationResult.wrap(result);
}
use of com.evolveum.midpoint.util.exception.CommunicationException 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 | CommunicationException | ConfigurationException | SecurityViolationException 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.CommunicationException in project midpoint by Evolveum.
the class AssignmentPolicyAspectPart method extractAssignmentBasedInstructions.
void extractAssignmentBasedInstructions(ObjectTreeDeltas<?> objectTreeDeltas, PrismObject<? extends FocusType> requester, List<PcpStartInstruction> instructions, ModelInvocationContext<?> ctx, OperationResult parentResult) throws SchemaException, ObjectNotFoundException {
OperationResult result = parentResult.subresult(OP_EXTRACT_ASSIGNMENT_BASED_INSTRUCTIONS).setMinor().build();
ApprovalProcessStartInstructionCreationTraceType trace;
if (result.isTracingNormal(ApprovalProcessStartInstructionCreationTraceType.class)) {
trace = new ApprovalProcessStartInstructionCreationTraceType(prismContext);
result.addTrace(trace);
} else {
trace = null;
}
try {
DeltaSetTriple<? extends EvaluatedAssignment<?>> evaluatedAssignmentTriple = ((LensContext<?>) ctx.modelContext).getEvaluatedAssignmentTriple();
LOGGER.trace("Processing evaluatedAssignmentTriple:\n{}", DebugUtil.debugDumpLazily(evaluatedAssignmentTriple));
if (evaluatedAssignmentTriple == null) {
return;
}
List<PcpStartInstruction> newInstructions = new ArrayList<>();
for (EvaluatedAssignment<?> assignmentAdded : evaluatedAssignmentTriple.union()) {
addIgnoreNull(newInstructions, createInstructionFromAssignment(assignmentAdded, objectTreeDeltas, requester, ctx, result));
}
int newInstructionsCount = newInstructions.size();
if (trace != null) {
for (PcpStartInstruction newInstruction : newInstructions) {
trace.getCaseRef().add(ObjectTypeUtil.createObjectRefWithFullObject(newInstruction.getCase(), prismContext));
}
}
instructions.addAll(newInstructions);
CompiledGuiProfile adminGuiConfiguration;
try {
adminGuiConfiguration = modelInteractionService.getCompiledGuiProfile(ctx.task, result);
} catch (CommunicationException | ConfigurationException | SecurityViolationException | ExpressionEvaluationException e) {
throw new SystemException(e.getMessage(), e);
}
Integer limit = adminGuiConfiguration.getRoleManagement() != null ? adminGuiConfiguration.getRoleManagement().getAssignmentApprovalRequestLimit() : null;
LOGGER.trace("Assignment-related approval instructions: {}; limit is {}", newInstructionsCount, limit);
if (limit != null && newInstructionsCount > limit) {
// TODO think about better error reporting
throw new IllegalStateException("Assignment approval request limit (" + limit + ") exceeded: you are trying to submit " + newInstructionsCount + " requests");
}
if (limit != null) {
result.addContext("assignmentApprovalRequestLimit", limit);
}
result.addReturn("instructionsCreated", newInstructions.size());
} catch (Throwable t) {
result.recordFatalError(t);
throw t;
} finally {
result.computeStatusIfUnknown();
}
}
use of com.evolveum.midpoint.util.exception.CommunicationException in project midpoint by Evolveum.
the class DiscoverConnectorsExecutor method rebindResources.
private void rebindResources(Map<String, String> rebindMap, ExecutionContext context, OperationResult result) throws ScriptExecutionException {
List<PrismObject<ResourceType>> resources;
try {
resources = modelService.searchObjects(ResourceType.class, null, null, null, result);
} catch (SchemaException | ConfigurationException | ObjectNotFoundException | CommunicationException | SecurityViolationException | ExpressionEvaluationException e) {
throw new ScriptExecutionException("Couldn't list resources: " + e.getMessage(), e);
}
for (PrismObject<ResourceType> resource : resources) {
if (resource.asObjectable().getConnectorRef() != null) {
String connectorOid = resource.asObjectable().getConnectorRef().getOid();
String newOid = rebindMap.get(connectorOid);
if (newOid != null) {
String msg = "resource " + resource + " from connector " + connectorOid + " to new one: " + newOid;
LOGGER.info("Rebinding {}", msg);
ReferenceDelta refDelta = prismContext.deltaFactory().reference().createModificationReplace(ResourceType.F_CONNECTOR_REF, resource.getDefinition(), newOid);
ObjectDelta<ResourceType> objDelta = prismContext.deltaFactory().object().createModifyDelta(resource.getOid(), refDelta, ResourceType.class);
operationsHelper.applyDelta(objDelta, context, result);
context.println("Rebound " + msg);
}
}
}
}
Aggregations