use of eu.bcvsolutions.idm.ic.exception.IcException in project CzechIdMng by bcvsolutions.
the class DefaultVsRequestService method getVirtualConnector.
/**
* Get virtual connector by vs request
*
* @param request
* @return
*/
private VsVirtualConnector getVirtualConnector(VsRequestDto request) {
IcConnectorInfo connectorInfo = //
czechIdMConfigurationService.getAvailableLocalConnectors().stream().filter(//
info -> request.getConnectorKey().equals(info.getConnectorKey().getFullName())).findFirst().orElse(null);
if (connectorInfo == null) {
throw new IcException(MessageFormat.format("We cannot found connector info by connector key [{0}] from virtual system request!", request.getConnectorKey()));
}
IcConnectorInstance connectorKeyInstance = new IcConnectorInstanceImpl(null, connectorInfo.getConnectorKey(), false);
IcConnector connectorInstance = czechIdMConnectorService.getConnectorInstance(connectorKeyInstance, request.getConfiguration());
if (!(connectorInstance instanceof VsVirtualConnector)) {
throw new IcException("Found connector instance is not virtual system connector!");
}
VsVirtualConnector virtualConnector = (VsVirtualConnector) connectorInstance;
return virtualConnector;
}
use of eu.bcvsolutions.idm.ic.exception.IcException in project CzechIdMng by bcvsolutions.
the class CzechIdMIcConnectorService method updateObject.
@Override
public IcUidAttribute updateObject(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, IcUidAttribute uid, List<IcAttribute> replaceAttributes) {
Assert.notNull(connectorInstance, "Connector instance is required.");
Assert.notNull(connectorInstance.getConnectorKey(), "Connector key is required.");
Assert.notNull(connectorConfiguration, "Configuration is required.");
Assert.notNull(replaceAttributes, "Replace attributes are required.");
Assert.notNull(uid, "Uid is required.");
String key = connectorInstance.getConnectorKey().toString();
LOG.debug("Update object - CzechIdM (Uid= {} {} {})", uid, key, replaceAttributes.toString());
if (objectClass == null) {
objectClass = new IcObjectClassImpl(IcObjectClassInfo.ACCOUNT);
}
IcConnector connector = this.getConnectorInstance(connectorInstance, connectorConfiguration);
if (!(connector instanceof IcCanUpdate)) {
throw new IcException(MessageFormat.format("Connector [{0}] not supports update operation!", key));
}
IcUidAttribute updatedUid = ((IcCanUpdate) connector).update(uid, objectClass, replaceAttributes);
LOG.debug("Updated object - CzechIdM ({} {}) Uid= {})", connectorInstance.getConnectorKey().toString(), replaceAttributes.toString(), updatedUid);
return updatedUid;
}
use of eu.bcvsolutions.idm.ic.exception.IcException in project CzechIdMng by bcvsolutions.
the class CzechIdMIcConnectorService method getConnectorInstance.
@Override
public IcConnector getConnectorInstance(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration) {
Assert.notNull(connectorInstance.getConnectorKey(), "Connector key is required.");
Assert.notNull(connectorConfiguration, "Configuration is required.");
// String key = connectorInstance.getConnectorKey().getFullName();
// Cache is not thread safety
// if(this.connectorInstances.containsKey(key)){
// IcConnector connector = connectorInstances.get(key);
// connector.init(connectorConfiguration);
// return connector;
// }
Class<? extends IcConnector> connectorClass = this.configurationService.getConnectorClass(connectorInstance);
try {
IcConnector connector = connectorClass.getDeclaredConstructor().newInstance();
// Manually autowire on this connector instance
this.applicationContext.getAutowireCapableBeanFactory().autowireBean(connector);
connector.init(connectorConfiguration);
// this.connectorInstances.put(key, connector);
return connector;
} catch (ReflectiveOperationException e) {
throw new IcException(e);
}
}
use of eu.bcvsolutions.idm.ic.exception.IcException in project CzechIdMng by bcvsolutions.
the class CzechIdMIcConnectorService method synchronization.
@Override
public IcSyncToken synchronization(IcConnectorInstance connectorInstance, IcConnectorConfiguration connectorConfiguration, IcObjectClass objectClass, IcSyncToken token, IcSyncResultsHandler handler) {
Assert.notNull(connectorInstance, "Connector instance is required.");
Assert.notNull(connectorInstance.getConnectorKey(), "Connector key is required.");
Assert.notNull(connectorConfiguration, "Configuration is required.");
Assert.notNull(objectClass, "Object class is required.");
Assert.notNull(handler, "Handler is required.");
String key = connectorInstance.getConnectorKey().toString();
LOG.debug("Start synchronization for connector {} and objectClass {} - CzechIdM", key, objectClass.getDisplayName());
throw new IcException(MessageFormat.format("Connector [{0}] not supports sync operation!", key));
}
use of eu.bcvsolutions.idm.ic.exception.IcException in project CzechIdMng by bcvsolutions.
the class CzechIdMIcConvertUtil method convertIcConnectorConfiguration.
public static ConfigurationClass convertIcConnectorConfiguration(IcConnectorConfiguration configuration, Class<? extends ConfigurationClass> configurationClass) {
if (configuration == null || configuration.getConfigurationProperties() == null || configuration.getConfigurationProperties().getProperties() == null) {
return null;
}
List<IcConfigurationProperty> properties = configuration.getConfigurationProperties().getProperties();
try {
ConfigurationClass configurationClassInstance = configurationClass.getDeclaredConstructor().newInstance();
PropertyDescriptor[] descriptors;
descriptors = Introspector.getBeanInfo(configurationClass).getPropertyDescriptors();
Lists.newArrayList(descriptors).stream().forEach(descriptor -> {
String propertyName = descriptor.getName();
Method writeMethod = descriptor.getWriteMethod();
IcConfigurationProperty propertyToConvert = properties.stream().filter(property -> propertyName.equals(property.getName())).findFirst().orElse(null);
if (propertyToConvert == null) {
return;
}
try {
writeMethod.invoke(configurationClassInstance, propertyToConvert.getValue());
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new IcException(e);
}
});
return configurationClassInstance;
} catch (IntrospectionException | ReflectiveOperationException e) {
throw new IcException(e);
}
}
Aggregations