Search in sources :

Example 1 with Entrypoint

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

the class EntrypointServiceImpl method convert.

private Entrypoint convert(final NewEntryPointEntity entrypointEntity, String referenceId, EntrypointReferenceType referenceType) {
    final Entrypoint entrypoint = new Entrypoint();
    entrypoint.setId(UuidString.generateRandom());
    entrypoint.setValue(entrypointEntity.getValue());
    entrypoint.setTags(String.join(SEPARATOR, entrypointEntity.getTags()));
    entrypoint.setReferenceId(referenceId);
    entrypoint.setReferenceType(repoEntrypointReferenceType(referenceType));
    return entrypoint;
}
Also used : Entrypoint(io.gravitee.repository.management.model.Entrypoint)

Example 2 with Entrypoint

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

the class EntrypointServiceImpl method convert.

private Entrypoint convert(final UpdateEntryPointEntity entrypointEntity) {
    final Entrypoint entrypoint = new Entrypoint();
    entrypoint.setId(entrypointEntity.getId());
    entrypoint.setValue(entrypointEntity.getValue());
    entrypoint.setTags(String.join(SEPARATOR, entrypointEntity.getTags()));
    return entrypoint;
}
Also used : Entrypoint(io.gravitee.repository.management.model.Entrypoint)

Example 3 with Entrypoint

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

the class EntrypointServiceImpl method findByIdAndReference.

@Override
public EntrypointEntity findByIdAndReference(final String entrypointId, String referenceId, EntrypointReferenceType referenceType) {
    try {
        LOGGER.debug("Find by id {}", entrypointId);
        final Optional<Entrypoint> optionalEntryPoint = entrypointRepository.findByIdAndReference(entrypointId, referenceId, repoEntrypointReferenceType(referenceType));
        if (!optionalEntryPoint.isPresent()) {
            throw new EntrypointNotFoundException(entrypointId);
        }
        return convert(optionalEntryPoint.get());
    } catch (TechnicalException ex) {
        LOGGER.error("An error occurs while trying to find all entrypoints", ex);
        throw new TechnicalManagementException("An error occurs while trying to find all entrypoints", ex);
    }
}
Also used : EntrypointNotFoundException(io.gravitee.rest.api.service.exceptions.EntrypointNotFoundException) TechnicalException(io.gravitee.repository.exceptions.TechnicalException) Entrypoint(io.gravitee.repository.management.model.Entrypoint) TechnicalManagementException(io.gravitee.rest.api.service.exceptions.TechnicalManagementException)

Example 4 with Entrypoint

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

the class EntrypointServiceImpl method update.

@Override
public EntrypointEntity update(final UpdateEntryPointEntity entrypointEntity, String referenceId, EntrypointReferenceType referenceType) {
    try {
        final Optional<Entrypoint> entrypointOptional = entrypointRepository.findByIdAndReference(entrypointEntity.getId(), referenceId, repoEntrypointReferenceType(referenceType));
        if (entrypointOptional.isPresent()) {
            final Entrypoint entrypoint = convert(entrypointEntity);
            Entrypoint existingEntrypoint = entrypointOptional.get();
            entrypoint.setReferenceId(existingEntrypoint.getReferenceId());
            entrypoint.setReferenceType(existingEntrypoint.getReferenceType());
            final EntrypointEntity savedEntryPoint = convert(entrypointRepository.update(entrypoint));
            auditService.createEnvironmentAuditLog(Collections.singletonMap(ENTRYPOINT, entrypoint.getId()), ENTRYPOINT_UPDATED, new Date(), entrypointOptional.get(), entrypoint);
            return savedEntryPoint;
        } else {
            throw new EntrypointNotFoundException(entrypointEntity.getId());
        }
    } catch (TechnicalException ex) {
        LOGGER.error("An error occurs while trying to update entrypoint {}", entrypointEntity.getValue(), ex);
        throw new TechnicalManagementException("An error occurs while trying to update entrypoint " + entrypointEntity.getValue(), ex);
    }
}
Also used : EntrypointNotFoundException(io.gravitee.rest.api.service.exceptions.EntrypointNotFoundException) TechnicalException(io.gravitee.repository.exceptions.TechnicalException) Entrypoint(io.gravitee.repository.management.model.Entrypoint) EntrypointEntity(io.gravitee.rest.api.model.EntrypointEntity) TechnicalManagementException(io.gravitee.rest.api.service.exceptions.TechnicalManagementException)

Example 5 with Entrypoint

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

the class EntrypointServiceImpl method delete.

@Override
public void delete(final String entrypointId, String referenceId, EntrypointReferenceType referenceType) {
    try {
        Optional<Entrypoint> entrypointOptional = entrypointRepository.findByIdAndReference(entrypointId, referenceId, repoEntrypointReferenceType(referenceType));
        if (entrypointOptional.isPresent()) {
            entrypointRepository.delete(entrypointId);
            auditService.createEnvironmentAuditLog(Collections.singletonMap(ENTRYPOINT, entrypointId), ENTRYPOINT_DELETED, new Date(), null, entrypointOptional.get());
        } else {
            throw new EntrypointNotFoundException(entrypointId);
        }
    } catch (TechnicalException ex) {
        LOGGER.error("An error occurs while trying to delete entrypoint {}", entrypointId, ex);
        throw new TechnicalManagementException("An error occurs while trying to delete entrypoint " + entrypointId, ex);
    }
}
Also used : EntrypointNotFoundException(io.gravitee.rest.api.service.exceptions.EntrypointNotFoundException) TechnicalException(io.gravitee.repository.exceptions.TechnicalException) Entrypoint(io.gravitee.repository.management.model.Entrypoint) TechnicalManagementException(io.gravitee.rest.api.service.exceptions.TechnicalManagementException)

Aggregations

Entrypoint (io.gravitee.repository.management.model.Entrypoint)6 TechnicalException (io.gravitee.repository.exceptions.TechnicalException)4 TechnicalManagementException (io.gravitee.rest.api.service.exceptions.TechnicalManagementException)4 EntrypointNotFoundException (io.gravitee.rest.api.service.exceptions.EntrypointNotFoundException)3 EntrypointEntity (io.gravitee.rest.api.model.EntrypointEntity)2