use of eu.bcvsolutions.idm.ic.exception.IcException in project CzechIdMng by bcvsolutions.
the class BasicVirtualConnector method internalDelete.
@Override
public void internalDelete(IcUidAttribute uid, IcObjectClass objectClass) {
Assert.notNull(objectClass, "Object class cannot be null!");
String uidValue = this.validateAndGetUid(uid);
if (!IcObjectClassInfo.ACCOUNT.equals(objectClass.getType())) {
throw new IcException("Only ACCOUNT object class is supported now!");
}
// Find account by UID and System ID
VsAccountDto account = accountService.findByUidSystem(uidValue, systemId);
if (account == null) {
throw new IcException(MessageFormat.format("Vs account was not found for UID [{0}] and system ID [{1}]!", uidValue, systemId));
}
// Delete vs account and connected form values
accountService.delete(account);
}
use of eu.bcvsolutions.idm.ic.exception.IcException in project CzechIdMng by bcvsolutions.
the class BasicVirtualConnector method create.
@Override
public IcUidAttribute create(IcObjectClass objectClass, List<IcAttribute> attributes) {
Assert.notNull(objectClass, "Object class cannot be null!");
Assert.notNull(attributes, "Attributes cannot be null!");
if (!IcObjectClassInfo.ACCOUNT.equals(objectClass.getType())) {
throw new IcException("Only ACCOUNT object class is supported now!");
}
IcAttribute uidAttribute = geAttribute(attributes, IcAttributeInfo.NAME);
if (uidAttribute == null) {
throw new IcException("UID attribute was not found!");
}
Object uidValue = uidAttribute.getValue();
if (!(uidValue instanceof String)) {
throw new IcException(MessageFormat.format("UID attribute value [{0}] must be String!", uidValue));
}
// Create and execute request
VsRequestDto request = createRequest(objectClass, attributes, (String) uidValue, VsOperationType.CREATE);
return requestService.execute(request);
}
use of eu.bcvsolutions.idm.ic.exception.IcException in project CzechIdMng by bcvsolutions.
the class BasicVirtualConnector method read.
@Override
public IcConnectorObject read(IcUidAttribute uid, IcObjectClass objectClass) {
Assert.notNull(objectClass, "Object class cannot be null!");
Assert.notNull(uid, "UID cannot be null!");
if (!IcObjectClassInfo.ACCOUNT.equals(objectClass.getType())) {
throw new IcException("Only ACCOUNT object class is supported now!");
}
String uidValue = uid.getUidValue();
if (uidValue == null) {
throw new IcException("UID value cannot be null!");
}
// Find account by UID and System ID
VsAccountDto account = accountService.findByUidSystem(uidValue, systemId);
// All attributes from VS account
List<IcAttribute> vsAttributes = new ArrayList<>();
// Create uid attribute
IcAttributeImpl uidAttribute = new IcAttributeImpl(IcAttributeInfo.NAME, uidValue);
vsAttributes.add(uidAttribute);
if (account != null) {
// Create enable attribute
if (this.virtualConfiguration.isDisableSupported()) {
IcAttributeImpl enableAttribute = new IcAttributeImpl(IcAttributeInfo.ENABLE, account.isEnable());
vsAttributes.add(enableAttribute);
}
// Attributes from definition and configuration
UUID accountId = account.getId();
Arrays.asList(virtualConfiguration.getAttributes()).forEach(virtualAttirbute -> {
IcAttribute attribute = accountService.getIcAttribute(accountId, virtualAttirbute, formDefinition);
if (attribute == null) {
return;
}
vsAttributes.add(attribute);
});
}
// Overwrite attributes form VS account with attributes from unresloved
// requests
List<IcAttribute> attributes = this.overwriteAttributesByUnresolvedRequests(account, uidValue, vsAttributes);
if (attributes == null) {
return null;
}
IcConnectorObjectImpl connectorObject = new IcConnectorObjectImpl();
connectorObject.setUidValue(uidValue);
connectorObject.setObjectClass(new IcObjectClassImpl(IcObjectClassInfo.ACCOUNT));
connectorObject.setAttributes(attributes);
return connectorObject;
}
use of eu.bcvsolutions.idm.ic.exception.IcException in project CzechIdMng by bcvsolutions.
the class BasicVirtualConnector method delete.
@Override
public void delete(IcUidAttribute uid, IcObjectClass objectClass) {
Assert.notNull(objectClass, "Object class cannot be null!");
String uidValue = validateAndGetUid(uid);
if (!IcObjectClassInfo.ACCOUNT.equals(objectClass.getType())) {
throw new IcException("Only ACCOUNT object class is supported now!");
}
// Create and execute request
VsRequestDto request = createRequest(objectClass, null, (String) uidValue, VsOperationType.DELETE);
requestService.execute(request);
}
use of eu.bcvsolutions.idm.ic.exception.IcException in project CzechIdMng by bcvsolutions.
the class BasicVirtualConnector method updateSystemEntity.
/**
* We have to change system entity directly from VS module (request can be
* started/executed async => standard process update UID in system entity (ACC
* module) will not works!)
*
* @param uidValue
* @param attributeUidValue
* @param systemEntityMustExists
*/
private void updateSystemEntity(String uidValue, Object attributeUidValue, boolean systemEntityMustExists) {
SysSystemEntityFilter systemEntityFilter = new SysSystemEntityFilter();
systemEntityFilter.setUid(uidValue);
systemEntityFilter.setSystemId(systemId);
List<SysSystemEntityDto> systemEntities = systemEntityService.find(systemEntityFilter, null).getContent();
if (systemEntities.isEmpty() && !systemEntityMustExists) {
return;
}
if (systemEntities.isEmpty()) {
throw new IcException(MessageFormat.format("System entity was not found for UID [{0}] and system ID [{1}]! Change UID attribute (new [{2}]) cannot be executed!", uidValue, systemId, attributeUidValue));
}
if (systemEntities.size() > 1) {
throw new IcException(MessageFormat.format("For UID [{0}] and system ID [{1}] was found too many items [{2}]! Change UID attribute (new [{3}]) cannot be executed!", uidValue, systemId, systemEntities.size(), attributeUidValue));
}
SysSystemEntityDto systemEntity = systemEntities.get(0);
systemEntity.setUid((String) attributeUidValue);
systemEntity.setWish(false);
// Save changed system entity
systemEntityService.save(systemEntity);
LOG.info("Update account - UID was changed (old: {} new: {}). System entity was updated.", uidValue, attributeUidValue);
}
Aggregations