use of io.gravitee.rest.api.model.EntrypointEntity 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);
}
}
use of io.gravitee.rest.api.model.EntrypointEntity in project gravitee-management-rest-api by gravitee-io.
the class EntrypointServiceImpl method convert.
private EntrypointEntity convert(final Entrypoint entrypoint) {
final EntrypointEntity entrypointEntity = new EntrypointEntity();
entrypointEntity.setId(entrypoint.getId());
entrypointEntity.setValue(entrypoint.getValue());
entrypointEntity.setTags(entrypoint.getTags().split(SEPARATOR));
return entrypointEntity;
}
use of io.gravitee.rest.api.model.EntrypointEntity in project gravitee-management-rest-api by gravitee-io.
the class EntrypointServiceImpl method create.
@Override
public EntrypointEntity create(final NewEntryPointEntity entrypointEntity, String referenceId, EntrypointReferenceType referenceType) {
try {
final Entrypoint entrypoint = convert(entrypointEntity, referenceId, referenceType);
final EntrypointEntity savedEntryPoint = convert(entrypointRepository.create(entrypoint));
auditService.createEnvironmentAuditLog(Collections.singletonMap(ENTRYPOINT, entrypoint.getId()), ENTRYPOINT_CREATED, new Date(), null, entrypoint);
return savedEntryPoint;
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while trying to create entrypoint {}", entrypointEntity.getValue(), ex);
throw new TechnicalManagementException("An error occurs while trying to create entrypoint " + entrypointEntity.getValue(), ex);
}
}
use of io.gravitee.rest.api.model.EntrypointEntity in project gravitee-management-rest-api by gravitee-io.
the class EntrypointServiceTest method shouldCreate.
@Test
public void shouldCreate() {
final NewEntryPointEntity entrypoint = new NewEntryPointEntity();
entrypoint.setValue(VALUE);
entrypoint.setTags(TAGS);
final EntrypointEntity entrypointEntity = entrypointService.create(entrypoint, REFERENCE_ID, REFERENCE_TYPE);
assertEquals(ID, entrypointEntity.getId());
assertEquals(VALUE, entrypointEntity.getValue());
assertNotNull(entrypointEntity.getTags());
assertEquals(2, entrypointEntity.getTags().length);
}
use of io.gravitee.rest.api.model.EntrypointEntity in project gravitee-management-rest-api by gravitee-io.
the class EntrypointServiceTest method shouldUpdate.
@Test
public void shouldUpdate() {
final UpdateEntryPointEntity entrypoint = new UpdateEntryPointEntity();
entrypoint.setId(ID);
entrypoint.setValue(NEW_VALUE);
entrypoint.setTags(NEW_TAGS);
final EntrypointEntity entrypointEntity = entrypointService.update(entrypoint, REFERENCE_ID, REFERENCE_TYPE);
assertEquals(ID, entrypointEntity.getId());
assertEquals(NEW_VALUE, entrypointEntity.getValue());
assertNotNull(entrypointEntity.getTags());
assertEquals(2, entrypointEntity.getTags().length);
}
Aggregations