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 TestOpenDjNegative method test522SearchAccountsIterative.
@Test
public void test522SearchAccountsIterative() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, Exception {
final String TEST_NAME = "test522SearchAccountsIterative";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME);
final String resourceNamespace = ResourceTypeUtil.getResourceNamespace(resource);
QName objectClass = new QName(resourceNamespace, OBJECT_CLASS_INETORGPERSON_NAME);
ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(resource.getOid(), objectClass, prismContext);
ResultHandler handler = new ResultHandler<ObjectType>() {
@Override
public boolean handle(PrismObject<ObjectType> prismObject, OperationResult parentResult) {
AssertJUnit.fail("handler called unexpectedly");
return false;
}
};
try {
// WHEN
provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, null, result);
AssertJUnit.fail("searchObjectsIterative succeeded unexpectedly");
} catch (CommunicationException e) {
// This is expected
display("Expected exception", e);
}
result.computeStatus();
display(result);
TestUtil.assertFailure(result);
}
use of com.evolveum.midpoint.util.exception.CommunicationException in project midpoint by Evolveum.
the class ResourceContentPanel method updateResourceObjectStatusPerformed.
protected void updateResourceObjectStatusPerformed(ShadowType selected, AjaxRequestTarget target, boolean enabled) {
List<ShadowType> selectedShadow = getSelectedShadowsList(selected);
OperationResult result = new OperationResult(OPERATION_UPDATE_STATUS);
Task task = pageBase.createSimpleTask(OPERATION_UPDATE_STATUS);
if (selectedShadow == null || selectedShadow.isEmpty()) {
result.recordWarning("Nothing selected to update status");
getPageBase().showResult(result);
target.add(getPageBase().getFeedbackPanel());
return;
}
ModelExecuteOptions opts = createModelOptions();
for (ShadowType shadow : selectedShadow) {
ActivationStatusType status = enabled ? ActivationStatusType.ENABLED : ActivationStatusType.DISABLED;
try {
ObjectDelta<ShadowType> deleteDelta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, shadow.getOid(), SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, getPageBase().getPrismContext(), status);
getPageBase().getModelService().executeChanges(WebComponentUtil.createDeltaCollection(deleteDelta), opts, task, result);
} catch (ObjectAlreadyExistsException | ObjectNotFoundException | SchemaException | ExpressionEvaluationException | CommunicationException | ConfigurationException | PolicyViolationException | SecurityViolationException e) {
// TODO Auto-generated catch block
result.recordPartialError("Could not update status (to " + status + ") for " + shadow, e);
LOGGER.error("Could not update status (to {}) for {}, using option {}", status, shadow, opts, e);
continue;
}
}
result.computeStatusIfUnknown();
getPageBase().showResult(result);
getTable().refreshTable(null, target);
target.add(getPageBase().getFeedbackPanel());
}
use of com.evolveum.midpoint.util.exception.CommunicationException in project midpoint by Evolveum.
the class ResourceContentPanel method importResourceObject.
protected void importResourceObject(ShadowType selected, AjaxRequestTarget target) {
List<ShadowType> selectedShadow = null;
if (selected != null) {
selectedShadow = new ArrayList<>();
selectedShadow.add(selected);
} else {
selectedShadow = getTable().getSelectedObjects();
}
OperationResult result = new OperationResult(OPERATION_IMPORT_OBJECT);
Task task = pageBase.createSimpleTask(OPERATION_IMPORT_OBJECT);
if (selectedShadow == null || selectedShadow.isEmpty()) {
result.recordWarning("Nothing select to import");
getPageBase().showResult(result);
target.add(getPageBase().getFeedbackPanel());
return;
}
for (ShadowType shadow : selectedShadow) {
try {
getPageBase().getModelService().importFromResource(shadow.getOid(), task, result);
} catch (ObjectNotFoundException | SchemaException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
result.recordPartialError("Could not import account " + shadow, e);
LOGGER.error("Could not import account {} ", shadow, e);
continue;
}
}
result.computeStatusIfUnknown();
getPageBase().showResult(result);
getTable().refreshTable(null, target);
target.add(getPageBase().getFeedbackPanel());
}
Aggregations