use of io.gravitee.management.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.
the class ResourceServiceImpl method findAll.
@Override
public Set<ResourceEntity> findAll() {
try {
LOGGER.debug("List all resources");
final Collection<ResourcePlugin> resourceDefinitions = resourcePluginManager.findAll();
return resourceDefinitions.stream().map(resourceDefinition -> convert(resourceDefinition, false)).collect(Collectors.toSet());
} catch (Exception ex) {
LOGGER.error("An error occurs while trying to list all resources", ex);
throw new TechnicalManagementException("An error occurs while trying to list all resources", ex);
}
}
use of io.gravitee.management.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.
the class RoleServiceImpl method findById.
@Override
public RoleEntity findById(final RoleScope scope, final String name) {
try {
LOGGER.debug("Find Role by id");
Optional<Role> role = roleRepository.findById(scope, name);
if (!role.isPresent()) {
throw new RoleNotFoundException(scope, name);
}
return convert(role.get());
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while trying to find a role : {} {}", scope, name, ex);
throw new TechnicalManagementException("An error occurs while trying to find a role : " + scope + " " + name, ex);
}
}
use of io.gravitee.management.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.
the class RoleServiceImpl method findDefaultRoleByScopes.
@Override
public List<RoleEntity> findDefaultRoleByScopes(RoleScope... scopes) {
try {
LOGGER.debug("Find default Roles by scope");
List<RoleEntity> roles = new ArrayList<>();
for (RoleScope scope : scopes) {
roles.addAll(roleRepository.findByScope(scope).stream().filter(Role::isDefaultRole).map(this::convert).collect(Collectors.toList()));
}
return roles;
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while trying to find default roles by scope", ex);
throw new TechnicalManagementException("An error occurs while trying to find default roles by scope", ex);
}
}
use of io.gravitee.management.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.
the class RoleServiceImpl method createOrUpdateSystemRoles.
@Override
public void createOrUpdateSystemRoles() {
try {
// MANAGEMENT - ADMIN
createOrUpdateSystemRole(SystemRole.ADMIN, RoleScope.MANAGEMENT, io.gravitee.management.model.permissions.RoleScope.MANAGEMENT, ManagementPermission.values());
// PORTAL - ADMIN
createOrUpdateSystemRole(SystemRole.ADMIN, RoleScope.PORTAL, io.gravitee.management.model.permissions.RoleScope.PORTAL, PortalPermission.values());
// API - PRIMARY_OWNER
createOrUpdateSystemRole(SystemRole.PRIMARY_OWNER, RoleScope.API, io.gravitee.management.model.permissions.RoleScope.API, ApiPermission.values());
// APPLICATION - PRIMARY_OWNER
createOrUpdateSystemRole(SystemRole.PRIMARY_OWNER, RoleScope.APPLICATION, io.gravitee.management.model.permissions.RoleScope.APPLICATION, ApplicationPermission.values());
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while trying to create admin roles", ex);
throw new TechnicalManagementException("An error occurs while trying to create admin roles ", ex);
}
}
use of io.gravitee.management.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.
the class ApiKeyServiceImpl method update.
@Override
public ApiKeyEntity update(ApiKeyEntity apiKeyEntity) {
try {
LOGGER.debug("Update API Key {}", apiKeyEntity.getKey());
Optional<ApiKey> optKey = apiKeyRepository.findById(apiKeyEntity.getKey());
if (!optKey.isPresent()) {
throw new ApiKeyNotFoundException();
}
ApiKey key = optKey.get();
setExpiration(apiKeyEntity.getExpireAt(), key);
return convert(key);
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while updating an API Key {}", apiKeyEntity.getKey(), ex);
throw new TechnicalManagementException(String.format("An error occurs while updating an API Key %s", apiKeyEntity.getKey()), ex);
}
}
Aggregations