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);
}
}
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);
}
}
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;
}
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);
}
}
}
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();
}
Aggregations