use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.
the class OrchestratorRequestToOrchestratorConverter method convert.
@Override
public Orchestrator convert(OrchestratorRequest source) {
Orchestrator orchestrator = new Orchestrator();
orchestrator.setApiEndpoint(source.getApiEndpoint());
orchestrator.setType(source.getType());
Map<String, Object> params = new HashMap<>();
if (source.getParameters() != null && !source.getParameters().isEmpty()) {
params = source.getParameters();
}
try {
orchestrator.setAttributes(new Json(params));
} catch (JsonProcessingException e) {
throw new BadRequestException("Invalid parameters", e);
}
return orchestrator;
}
use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.
the class ClusterToClusterResponseConverter method convertKnox.
private void convertKnox(Cluster source, ClusterResponse clusterResponse) {
Gateway gateway = source.getGateway();
GatewayJson cloudGatewayJson = new GatewayJson();
cloudGatewayJson.setEnableGateway(gateway.getEnableGateway());
cloudGatewayJson.setTopologyName(gateway.getTopologyName());
Json exposedJson = gateway.getExposedServices();
if (exposedJson != null && StringUtils.isNoneEmpty(exposedJson.getValue())) {
try {
cloudGatewayJson.setExposedServices(exposedJson.get(ExposedServices.class).getServices());
} catch (IOException e) {
LOGGER.error("Failed to add exposedServices to response", e);
throw new CloudbreakApiException("Failed to add exposedServices to response", e);
}
}
cloudGatewayJson.setPath(gateway.getPath());
cloudGatewayJson.setTokenCert(gateway.getTokenCert());
cloudGatewayJson.setSsoProvider(gateway.getSsoProvider());
cloudGatewayJson.setSsoType(gateway.getSsoType());
cloudGatewayJson.setGatewayType(gateway.getGatewayType());
clusterResponse.setGateway(cloudGatewayJson);
}
use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.
the class OrchestratorToOrchestratorResponseConverter method convert.
@Override
public OrchestratorResponse convert(Orchestrator source) {
OrchestratorResponse orchestratorResponse = new OrchestratorResponse();
orchestratorResponse.setType(source.getType());
orchestratorResponse.setApiEndpoint(source.getApiEndpoint());
Json attributes = source.getAttributes();
if (attributes != null) {
orchestratorResponse.setParameters(attributes.getMap());
}
return orchestratorResponse;
}
use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.
the class AmbariClusterService method createHDPRepoComponent.
private void createHDPRepoComponent(StackRepoDetails stackRepoDetailsUpdate, Stack stack) {
if (stackRepoDetailsUpdate != null) {
StackRepoDetails stackRepoDetails = clusterComponentConfigProvider.getHDPRepo(stack.getCluster().getId());
if (stackRepoDetails == null) {
try {
ClusterComponent clusterComp = new ClusterComponent(ComponentType.HDP_REPO_DETAILS, new Json(stackRepoDetailsUpdate), stack.getCluster());
clusterComponentConfigProvider.store(clusterComp);
} catch (JsonProcessingException ignored) {
throw new BadRequestException(String.format("HDP Repo parameters cannot be converted. %s", stackRepoDetailsUpdate));
}
} else {
ClusterComponent component = clusterComponentConfigProvider.getComponent(stack.getCluster().getId(), ComponentType.HDP_REPO_DETAILS);
stackRepoDetails.setHdpVersion(stackRepoDetailsUpdate.getHdpVersion());
stackRepoDetails.setVerify(stackRepoDetailsUpdate.isVerify());
stackRepoDetails.setStack(stackRepoDetailsUpdate.getStack());
stackRepoDetails.setUtil(stackRepoDetailsUpdate.getUtil());
stackRepoDetails.setEnableGplRepo(stackRepoDetailsUpdate.isEnableGplRepo());
stackRepoDetails.setKnox(stackRepoDetailsUpdate.getKnox());
try {
component.setAttributes(new Json(stackRepoDetails));
clusterComponentConfigProvider.store(component);
} catch (JsonProcessingException ignored) {
throw new BadRequestException(String.format("HDP Repo parameters cannot be converted. %s", stackRepoDetailsUpdate));
}
}
}
}
use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.
the class CredentialSourceDecorator method decorate.
public Credential decorate(Credential credential, CredentialSourceRequest credentialSourceRequest, IdentityUser user) {
if (credential == null) {
credential = Strings.isNullOrEmpty(credentialSourceRequest.getSourceName()) ? credentialService.get(credentialSourceRequest.getSourceId()) : credentialService.get(credentialSourceRequest.getSourceName(), user.getAccount());
if (credential == null) {
throw new BadRequestException("Source credential does not exist!");
} else {
Map<String, Object> map = credential.getAttributes().getMap();
for (Entry<String, Object> stringObjectEntry : credentialSourceRequest.getParameters().entrySet()) {
map.put(stringObjectEntry.getKey(), stringObjectEntry.getValue().toString());
}
credential.setId(null);
credential.setName(missingResourceNameGenerator.generateName(APIResourceType.CREDENTIAL));
try {
credential.setAttributes(new Json(map));
} catch (JsonProcessingException ignored) {
throw new BadRequestException("Could not create credential from source credential!");
}
}
}
return credential;
}
Aggregations