Search in sources :

Example 1 with ResourceEntity

use of io.gravitee.management.model.ResourceEntity in project gravitee-management-rest-api by gravitee-io.

the class ResourceServiceImpl method convert.

private ResourceEntity convert(ResourcePlugin resourcePlugin, boolean withPlugin) {
    ResourceEntity entity = new ResourceEntity();
    entity.setId(resourcePlugin.id());
    entity.setDescription(resourcePlugin.manifest().description());
    entity.setName(resourcePlugin.manifest().name());
    entity.setVersion(resourcePlugin.manifest().version());
    if (withPlugin) {
        // Plugin information
        Plugin plugin = resourcePlugin;
        PluginEntity pluginEntity = new PluginEntity();
        pluginEntity.setPlugin(plugin.clazz());
        pluginEntity.setPath(plugin.path().toString());
        pluginEntity.setType(plugin.type().toString().toLowerCase());
        pluginEntity.setDependencies(plugin.dependencies());
        entity.setPlugin(pluginEntity);
    }
    return entity;
}
Also used : PluginEntity(io.gravitee.management.model.PluginEntity) ResourceEntity(io.gravitee.management.model.ResourceEntity) ResourcePlugin(io.gravitee.plugin.resource.ResourcePlugin) Plugin(io.gravitee.plugin.core.api.Plugin)

Example 2 with ResourceEntity

use of io.gravitee.management.model.ResourceEntity 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);
    }
}
Also used : Logger(org.slf4j.Logger) ResourceService(io.gravitee.management.service.ResourceService) PluginEntity(io.gravitee.management.model.PluginEntity) ResourceEntity(io.gravitee.management.model.ResourceEntity) ResourceNotFoundException(io.gravitee.management.service.exceptions.ResourceNotFoundException) ResourcePlugin(io.gravitee.plugin.resource.ResourcePlugin) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) TechnicalManagementException(io.gravitee.management.service.exceptions.TechnicalManagementException) Autowired(org.springframework.beans.factory.annotation.Autowired) Set(java.util.Set) ResourcePluginManager(io.gravitee.plugin.resource.ResourcePluginManager) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) Component(org.springframework.stereotype.Component) Plugin(io.gravitee.plugin.core.api.Plugin) ResourcePlugin(io.gravitee.plugin.resource.ResourcePlugin) ResourceNotFoundException(io.gravitee.management.service.exceptions.ResourceNotFoundException) TechnicalManagementException(io.gravitee.management.service.exceptions.TechnicalManagementException) IOException(java.io.IOException) TechnicalManagementException(io.gravitee.management.service.exceptions.TechnicalManagementException)

Aggregations

PluginEntity (io.gravitee.management.model.PluginEntity)2 ResourceEntity (io.gravitee.management.model.ResourceEntity)2 Plugin (io.gravitee.plugin.core.api.Plugin)2 ResourcePlugin (io.gravitee.plugin.resource.ResourcePlugin)2 ResourceService (io.gravitee.management.service.ResourceService)1 ResourceNotFoundException (io.gravitee.management.service.exceptions.ResourceNotFoundException)1 TechnicalManagementException (io.gravitee.management.service.exceptions.TechnicalManagementException)1 ResourcePluginManager (io.gravitee.plugin.resource.ResourcePluginManager)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Component (org.springframework.stereotype.Component)1