Search in sources :

Example 21 with TechnicalManagementException

use of io.gravitee.rest.api.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.

the class IdentityProviderActivationServiceImpl method activateIdpOnTargets.

@Override
public Set<IdentityProviderActivationEntity> activateIdpOnTargets(String identityProviderId, ActivationTarget... targetsToAdd) {
    LOGGER.debug("Activate identity provider {} on targets {} ", identityProviderId, targetsToAdd);
    try {
        Set<IdentityProviderActivationEntity> createdActivations = new HashSet<>();
        for (ActivationTarget target : targetsToAdd) {
            IdentityProviderActivation createdIdentityProviderActivation = createIdentityProviderActivation(identityProviderId, target);
            createdActivations.add(convert(createdIdentityProviderActivation));
        }
        return createdActivations;
    } catch (TechnicalException ex) {
        LOGGER.error("An error occurs while trying to Activate identity provider {} on targets {}", identityProviderId, targetsToAdd, ex);
        throw new TechnicalManagementException("An error occurs while trying to Activate identity provider " + identityProviderId + " on targets " + Arrays.toString(targetsToAdd), ex);
    }
}
Also used : IdentityProviderActivation(io.gravitee.repository.management.model.IdentityProviderActivation) TechnicalException(io.gravitee.repository.exceptions.TechnicalException) IdentityProviderActivationEntity(io.gravitee.rest.api.model.configuration.identity.IdentityProviderActivationEntity) TechnicalManagementException(io.gravitee.rest.api.service.exceptions.TechnicalManagementException)

Example 22 with TechnicalManagementException

use of io.gravitee.rest.api.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.

the class IdentityProviderActivationServiceImpl method addIdpsOnTarget.

@Override
public Set<IdentityProviderActivationEntity> addIdpsOnTarget(ActivationTarget target, String... identityProviderIdsToAdd) {
    LOGGER.debug("Add identity providers {} on target {} ", identityProviderIdsToAdd, target);
    try {
        Set<IdentityProviderActivationEntity> createdActivations = new HashSet<>();
        for (String identityProviderId : identityProviderIdsToAdd) {
            IdentityProviderActivation createdIdentityProviderActivation = createIdentityProviderActivation(identityProviderId, target);
            createdActivations.add(convert(createdIdentityProviderActivation));
        }
        return createdActivations;
    } catch (TechnicalException ex) {
        LOGGER.error("An error occurs while trying to add identity providers {} on target {}", identityProviderIdsToAdd, target, ex);
        throw new TechnicalManagementException("An error occurs while trying to add identity providers " + Arrays.toString(identityProviderIdsToAdd) + " on target " + target, ex);
    }
}
Also used : IdentityProviderActivation(io.gravitee.repository.management.model.IdentityProviderActivation) TechnicalException(io.gravitee.repository.exceptions.TechnicalException) IdentityProviderActivationEntity(io.gravitee.rest.api.model.configuration.identity.IdentityProviderActivationEntity) TechnicalManagementException(io.gravitee.rest.api.service.exceptions.TechnicalManagementException)

Example 23 with TechnicalManagementException

use of io.gravitee.rest.api.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.

the class FlowServiceImpl method getPlatformFlowSchemaForm.

@Override
public String getPlatformFlowSchemaForm() {
    LOGGER.debug("Get platform schema form");
    String fileContent = getFileContent("/flow/platform-flow-schema-form.json");
    List<TagEntity> tags = tagService.findByReference(GraviteeContext.getCurrentOrganization(), TagReferenceType.ORGANIZATION);
    if (tags.size() > 0) {
        LOGGER.debug("Append {} tag(s) to platform schema form", tags.size());
        try {
            final ObjectMapper mapper = new ObjectMapper();
            JsonNode jsonSchema = mapper.readTree(fileContent);
            final ObjectNode consumers = (ObjectNode) jsonSchema.get("properties").get("consumers");
            final ArrayNode enumNode = (ArrayNode) consumers.get("items").get("enum");
            Map<String, String> titleMap = new HashMap<>();
            tags.forEach(tagEntity -> titleMap.put(tagEntity.getId(), tagEntity.getName()));
            titleMap.keySet().forEach(enumNode::add);
            JsonNode titleMapNode = mapper.valueToTree(titleMap);
            ObjectNode xSchemaForm = mapper.createObjectNode();
            consumers.set("x-schema-form", xSchemaForm);
            xSchemaForm.set("titleMap", titleMapNode);
            return jsonSchema.toPrettyString();
        } catch (JsonProcessingException ex) {
            final String error = "An error occurs while append tags to platform flow schema form";
            LOGGER.error(error, ex);
            throw new TechnicalManagementException(error, ex);
        }
    }
    return fileContent;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) TagEntity(io.gravitee.rest.api.model.TagEntity) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) TechnicalManagementException(io.gravitee.rest.api.service.exceptions.TechnicalManagementException)

Example 24 with TechnicalManagementException

use of io.gravitee.rest.api.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.

the class SearchEngineServiceImpl method process.

@Override
public void process(CommandSearchIndexerEntity content) {
    if (ACTION_DELETE.equals(content.getAction())) {
        try {
            Indexable source = createInstance(content.getClazz());
            source.setId(content.getId());
            deleteLocally(source);
        } catch (Exception ex) {
            throw new TechnicalManagementException("Unable to delete document for content [ " + content.getId() + " - " + content.getClazz() + " ]", ex);
        }
    } else if (ACTION_INDEX.equals(content.getAction())) {
        Indexable source = getSource(content.getClazz(), content.getId());
        if (source != null) {
            indexLocally(source);
        }
    }
}
Also used : Indexable(io.gravitee.rest.api.model.search.Indexable) TechnicalException(io.gravitee.repository.exceptions.TechnicalException) TechnicalManagementException(io.gravitee.rest.api.service.exceptions.TechnicalManagementException) AbstractNotFoundException(io.gravitee.rest.api.service.exceptions.AbstractNotFoundException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) TechnicalManagementException(io.gravitee.rest.api.service.exceptions.TechnicalManagementException)

Example 25 with TechnicalManagementException

use of io.gravitee.rest.api.service.exceptions.TechnicalManagementException in project gravitee-management-rest-api by gravitee-io.

the class HelloCommandProducerTest method produceWithException.

@Test(expected = TechnicalManagementException.class)
public void produceWithException() {
    when(installationService.getOrInitialize()).thenThrow(new TechnicalManagementException());
    final TestObserver<HelloCommand> obs = cut.prepare(new HelloCommand()).test();
}
Also used : HelloCommand(io.gravitee.cockpit.api.command.hello.HelloCommand) TechnicalManagementException(io.gravitee.rest.api.service.exceptions.TechnicalManagementException) Test(org.junit.Test)

Aggregations

TechnicalManagementException (io.gravitee.rest.api.service.exceptions.TechnicalManagementException)149 TechnicalException (io.gravitee.repository.exceptions.TechnicalException)120 UuidString (io.gravitee.rest.api.service.common.UuidString)26 Date (java.util.Date)23 Component (org.springframework.stereotype.Component)18 Logger (org.slf4j.Logger)17 LoggerFactory (org.slf4j.LoggerFactory)17 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)16 Collectors (java.util.stream.Collectors)13 Autowired (org.springframework.beans.factory.annotation.Autowired)13 IOException (java.io.IOException)12 JsonNode (com.fasterxml.jackson.databind.JsonNode)11 Rating (io.gravitee.repository.management.model.Rating)9 ApiRatingUnavailableException (io.gravitee.rest.api.service.exceptions.ApiRatingUnavailableException)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 Dictionary (io.gravitee.repository.management.model.Dictionary)8 AuditService (io.gravitee.rest.api.service.AuditService)8 java.util (java.util)8 Theme (io.gravitee.repository.management.model.Theme)6 List (java.util.List)6