use of org.apache.syncope.core.provisioning.api.TimeoutException in project syncope by apache.
the class ConnectorFacadeProxy method delete.
@Override
public void delete(final ObjectClass objectClass, final Uid uid, final OperationOptions options, final AtomicReference<Boolean> propagationAttempted) {
if (connInstance.getCapabilities().contains(ConnectorCapability.DELETE)) {
propagationAttempted.set(true);
Future<Uid> future = asyncFacade.delete(connector, objectClass, uid, options);
try {
future.get(connInstance.getConnRequestTimeout(), TimeUnit.SECONDS);
} catch (java.util.concurrent.TimeoutException e) {
future.cancel(true);
throw new TimeoutException("Request timeout");
} catch (Exception e) {
LOG.error("Connector request execution failure", e);
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
} else {
throw new RuntimeException(e.getCause());
}
}
} else {
LOG.info("Delete for {} was attempted, although the connector only has these capabilities: {}. No action.", uid.getUidValue(), connInstance.getCapabilities());
}
}
use of org.apache.syncope.core.provisioning.api.TimeoutException in project syncope by apache.
the class ConnectorFacadeProxy method create.
@Override
public Uid create(final ObjectClass objectClass, final Set<Attribute> attrs, final OperationOptions options, final AtomicReference<Boolean> propagationAttempted) {
Uid result = null;
if (connInstance.getCapabilities().contains(ConnectorCapability.CREATE)) {
propagationAttempted.set(true);
Future<Uid> future = asyncFacade.create(connector, objectClass, attrs, options);
try {
result = future.get(connInstance.getConnRequestTimeout(), TimeUnit.SECONDS);
} catch (java.util.concurrent.TimeoutException e) {
future.cancel(true);
throw new TimeoutException("Request timeout");
} catch (Exception e) {
LOG.error("Connector request execution failure", e);
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
} else {
throw new RuntimeException(e.getCause());
}
}
} else {
LOG.info("Create was attempted, although the connector only has these capabilities: {}. No action.", connInstance.getCapabilities());
}
return result;
}
use of org.apache.syncope.core.provisioning.api.TimeoutException in project syncope by apache.
the class AbstractPropagationTaskExecutor method getRemoteObject.
/**
* Get remote object for given task.
*
* @param connector connector facade proxy.
* @param task current propagation task.
* @param orgUnit orgUnit
* @param latest 'FALSE' to retrieve object using old connObjectKey if not null.
* @return remote connector object.
*/
protected ConnectorObject getRemoteObject(final PropagationTask task, final Connector connector, final OrgUnit orgUnit, final boolean latest) {
String connObjectKey = latest || task.getOldConnObjectKey() == null ? task.getConnObjectKey() : task.getOldConnObjectKey();
ConnectorObject obj = null;
Optional<? extends OrgUnitItem> connObjectKeyItem = orgUnit.getConnObjectKeyItem();
if (connObjectKeyItem.isPresent()) {
try {
obj = connector.getObject(new ObjectClass(task.getObjectClassName()), AttributeBuilder.build(connObjectKeyItem.get().getExtAttrName(), connObjectKey), MappingUtils.buildOperationOptions(MappingUtils.getPropagationItems(orgUnit.getItems()).iterator()));
} catch (TimeoutException toe) {
LOG.debug("Request timeout", toe);
throw toe;
} catch (RuntimeException ignore) {
LOG.debug("While resolving {}", connObjectKey, ignore);
}
}
return obj;
}
use of org.apache.syncope.core.provisioning.api.TimeoutException in project syncope by apache.
the class AbstractPropagationTaskExecutor method getRemoteObject.
/**
* Get remote object for given task.
*
* @param connector connector facade proxy.
* @param task current propagation task.
* @param provision provision
* @param latest 'FALSE' to retrieve object using old connObjectKey if not null.
* @return remote connector object.
*/
protected ConnectorObject getRemoteObject(final PropagationTask task, final Connector connector, final Provision provision, final boolean latest) {
String connObjectKey = latest || task.getOldConnObjectKey() == null ? task.getConnObjectKey() : task.getOldConnObjectKey();
Set<MappingItem> linkingMappingItems = virSchemaDAO.findByProvision(provision).stream().map(schema -> schema.asLinkingMappingItem()).collect(Collectors.toSet());
ConnectorObject obj = null;
Optional<MappingItem> connObjectKeyItem = MappingUtils.getConnObjectKeyItem(provision);
if (connObjectKeyItem.isPresent()) {
try {
obj = connector.getObject(new ObjectClass(task.getObjectClassName()), AttributeBuilder.build(connObjectKeyItem.get().getExtAttrName(), connObjectKey), MappingUtils.buildOperationOptions(new IteratorChain<>(MappingUtils.getPropagationItems(provision.getMapping().getItems()).iterator(), linkingMappingItems.iterator())));
for (MappingItem item : linkingMappingItems) {
Attribute attr = obj.getAttributeByName(item.getExtAttrName());
if (attr == null) {
virAttrCache.expire(task.getAnyType(), task.getEntityKey(), item.getIntAttrName());
} else {
VirAttrCacheValue cacheValue = new VirAttrCacheValue();
cacheValue.setValues(attr.getValue());
virAttrCache.put(task.getAnyType(), task.getEntityKey(), item.getIntAttrName(), cacheValue);
}
}
} catch (TimeoutException toe) {
LOG.debug("Request timeout", toe);
throw toe;
} catch (RuntimeException ignore) {
LOG.debug("While resolving {}", connObjectKey, ignore);
}
}
return obj;
}
use of org.apache.syncope.core.provisioning.api.TimeoutException in project syncope by apache.
the class ConnectorFacadeProxy method update.
@Override
public Uid update(final ObjectClass objectClass, final Uid uid, final Set<Attribute> attrs, final OperationOptions options, final AtomicReference<Boolean> propagationAttempted) {
Uid result = null;
if (connInstance.getCapabilities().contains(ConnectorCapability.UPDATE)) {
propagationAttempted.set(true);
Future<Uid> future = asyncFacade.update(connector, objectClass, uid, attrs, options);
try {
result = future.get(connInstance.getConnRequestTimeout(), TimeUnit.SECONDS);
} catch (java.util.concurrent.TimeoutException e) {
future.cancel(true);
throw new TimeoutException("Request timeout");
} catch (Exception e) {
LOG.error("Connector request execution failure", e);
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
} else {
throw new RuntimeException(e.getCause());
}
}
} else {
LOG.info("Update for {} was attempted, although the " + "connector only has these capabilities: {}. No action.", uid.getUidValue(), connInstance.getCapabilities());
}
return result;
}
Aggregations