use of org.finra.herd.model.api.xml.NamespaceIamRoleAuthorization in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceImpl method getNamespaceIamRoleAuthorizations.
@Override
public NamespaceIamRoleAuthorizations getNamespaceIamRoleAuthorizations() {
List<NamespaceIamRoleAuthorizationEntity> namespaceIamRoleAuthorizationEntities = namespaceIamRoleAuthorizationDao.getNamespaceIamRoleAuthorizations(null);
Map<String, NamespaceIamRoleAuthorization> map = new LinkedHashMap<>();
for (NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity : namespaceIamRoleAuthorizationEntities) {
String namespace = namespaceIamRoleAuthorizationEntity.getNamespace().getCode();
NamespaceIamRoleAuthorization namespaceIamRoleAuthorization = map.get(namespace);
if (namespaceIamRoleAuthorization == null) {
map.put(namespace, namespaceIamRoleAuthorization = new NamespaceIamRoleAuthorization(namespace, new ArrayList<>()));
}
namespaceIamRoleAuthorization.getIamRoles().add(new IamRole(namespaceIamRoleAuthorizationEntity.getIamRoleName(), namespaceIamRoleAuthorizationEntity.getDescription()));
}
return new NamespaceIamRoleAuthorizations(new ArrayList<>(map.values()));
}
use of org.finra.herd.model.api.xml.NamespaceIamRoleAuthorization in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceImpl method updateNamespaceIamRoleAuthorization.
@NamespacePermission(fields = "#namespace", permissions = NamespacePermissionEnum.GRANT)
@Override
public NamespaceIamRoleAuthorization updateNamespaceIamRoleAuthorization(String namespace, NamespaceIamRoleAuthorizationUpdateRequest request) {
Assert.hasText(namespace, "Namespace must be specified");
Assert.notNull(request, "NamespaceIamRoleAuthorizationCreateRequest must be specified");
validateIamRoles(request.getIamRoles());
NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(namespace.trim());
List<NamespaceIamRoleAuthorizationEntity> namespaceIamRoleAuthorizationEntities = getNamespaeIamRoleAuthorizationEntities(namespaceEntity);
for (NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity : namespaceIamRoleAuthorizationEntities) {
namespaceIamRoleAuthorizationDao.delete(namespaceIamRoleAuthorizationEntity);
}
NamespaceIamRoleAuthorization result = new NamespaceIamRoleAuthorization(namespaceEntity.getCode(), new ArrayList<>());
for (IamRole iamRole : request.getIamRoles()) {
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity = createNamespaceIamRoleAuthorizationEntity(namespaceEntity, iamRole);
namespaceIamRoleAuthorizationDao.saveAndRefresh(namespaceIamRoleAuthorizationEntity);
result.getIamRoles().add(new IamRole(namespaceIamRoleAuthorizationEntity.getIamRoleName(), namespaceIamRoleAuthorizationEntity.getDescription()));
}
return result;
}
use of org.finra.herd.model.api.xml.NamespaceIamRoleAuthorization in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceImpl method createNamespaceIamRoleAuthorization.
@NamespacePermission(fields = "#request?.namespace", permissions = NamespacePermissionEnum.GRANT)
@Override
public NamespaceIamRoleAuthorization createNamespaceIamRoleAuthorization(NamespaceIamRoleAuthorizationCreateRequest request) {
Assert.notNull(request, "NamespaceIamRoleAuthorizationCreateRequest must be specified");
Assert.hasText(request.getNamespace(), "Namespace must be specified");
validateIamRoles(request.getIamRoles());
NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(request.getNamespace().trim());
assertNamespaceIamRoleAuthorizationNotExist(namespaceEntity);
NamespaceIamRoleAuthorization result = new NamespaceIamRoleAuthorization(namespaceEntity.getCode(), new ArrayList<>());
for (IamRole iamRole : request.getIamRoles()) {
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity = createNamespaceIamRoleAuthorizationEntity(namespaceEntity, iamRole);
namespaceIamRoleAuthorizationDao.saveAndRefresh(namespaceIamRoleAuthorizationEntity);
result.getIamRoles().add(new IamRole(namespaceIamRoleAuthorizationEntity.getIamRoleName(), namespaceIamRoleAuthorizationEntity.getDescription()));
}
return result;
}
Aggregations