Search in sources :

Example 1 with LifecycleState

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

the class SyncManager method convert.

private ApiEntity convert(Api api) {
    ApiEntity apiEntity = new ApiEntity();
    apiEntity.setId(api.getId());
    apiEntity.setName(api.getName());
    apiEntity.setDeployedAt(api.getDeployedAt());
    apiEntity.setCreatedAt(api.getCreatedAt());
    if (api.getDefinition() != null) {
        try {
            io.gravitee.definition.model.Api apiDefinition = objectMapper.readValue(api.getDefinition(), io.gravitee.definition.model.Api.class);
            apiEntity.setProxy(apiDefinition.getProxy());
            apiEntity.setPaths(apiDefinition.getPaths());
            apiEntity.setServices(apiDefinition.getServices());
            apiEntity.setResources(apiDefinition.getResources());
            apiEntity.setProperties(apiDefinition.getProperties());
            apiEntity.setTags(apiDefinition.getTags());
        } catch (IOException ioe) {
            logger.error("Unexpected error while generating API definition", ioe);
        }
    }
    apiEntity.setUpdatedAt(api.getUpdatedAt());
    apiEntity.setVersion(api.getVersion());
    apiEntity.setDescription(api.getDescription());
    apiEntity.setPicture(api.getPicture());
    apiEntity.setViews(api.getViews());
    final LifecycleState lifecycleState = api.getLifecycleState();
    if (lifecycleState != null) {
        apiEntity.setState(Lifecycle.State.valueOf(lifecycleState.name()));
    }
    if (api.getVisibility() != null) {
        apiEntity.setVisibility(io.gravitee.management.model.Visibility.valueOf(api.getVisibility().toString()));
    }
    return apiEntity;
}
Also used : ApiEntity(io.gravitee.management.model.ApiEntity) LifecycleState(io.gravitee.repository.management.model.LifecycleState) IOException(java.io.IOException)

Aggregations

ApiEntity (io.gravitee.management.model.ApiEntity)1 LifecycleState (io.gravitee.repository.management.model.LifecycleState)1 IOException (java.io.IOException)1