Search in sources :

Example 46 with Json

use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.

the class AmbariViewProvider method provideViewInformation.

public Cluster provideViewInformation(AmbariClient ambariClient, Cluster cluster) {
    try {
        LOGGER.info("Provide view definitions.");
        List<String> viewDefinitions = (List<String>) ambariClient.getViewDefinitions();
        Map<String, Object> obj = cluster.getAttributes().getMap();
        if (obj == null || obj.isEmpty()) {
            obj = new HashMap<>();
        }
        obj.put(VIEW_DEFINITIONS.name(), viewDefinitions);
        cluster.setAttributes(new Json(obj));
        return clusterRepository.save(cluster);
    } catch (Exception e) {
        LOGGER.warn("Failed to provide view definitions.", e);
    }
    return cluster;
}
Also used : List(java.util.List) Json(com.sequenceiq.cloudbreak.domain.json.Json)

Example 47 with Json

use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.

the class TestUtil method cluster.

public static Cluster cluster(Blueprint blueprint, Stack stack, Long id, KerberosConfig kerberosConfig) {
    Cluster cluster = new Cluster();
    cluster.setAmbariIp("50.51.52.100");
    cluster.setStack(stack);
    cluster.setId(id);
    cluster.setName("dummyCluster");
    cluster.setAmbariIp("10.0.0.1");
    cluster.setBlueprint(blueprint);
    cluster.setUpSince(new Date().getTime());
    cluster.setStatus(AVAILABLE);
    cluster.setStatusReason("statusReason");
    cluster.setUserName("admin");
    cluster.setPassword("admin");
    Gateway gateway = new Gateway();
    gateway.setEnableGateway(true);
    gateway.setTopologyName("cb");
    cluster.setGateway(gateway);
    cluster.setExecutorType(ExecutorType.DEFAULT);
    RDSConfig rdsConfig = new RDSConfig();
    Set<RDSConfig> rdsConfigs = new HashSet<>();
    rdsConfigs.add(rdsConfig);
    cluster.setRdsConfigs(rdsConfigs);
    cluster.setLdapConfig(ldapConfig());
    cluster.setHostGroups(hostGroups(cluster));
    Map<String, String> inputs = new HashMap<>();
    inputs.put("S3_BUCKET", "testbucket");
    try {
        cluster.setBlueprintInputs(new Json(inputs));
    } catch (JsonProcessingException ignored) {
        cluster.setBlueprintInputs(null);
    }
    Map<String, String> map = new HashMap<>();
    try {
        cluster.setAttributes(new Json(map));
    } catch (JsonProcessingException ignored) {
        cluster.setAttributes(null);
    }
    if (kerberosConfig != null) {
        cluster.setSecure(true);
        cluster.setKerberosConfig(kerberosConfig);
    }
    return cluster;
}
Also used : HashMap(java.util.HashMap) Gateway(com.sequenceiq.cloudbreak.domain.Gateway) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) JsonToString(com.sequenceiq.cloudbreak.domain.json.JsonToString) Json(com.sequenceiq.cloudbreak.domain.json.Json) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Date(java.util.Date) HashSet(java.util.HashSet)

Example 48 with Json

use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.

the class TestUtil method gateway.

public static Gateway gateway() throws JsonProcessingException {
    Gateway gateway = new Gateway();
    gateway.setEnableGateway(true);
    gateway.setTopologyName("topology");
    gateway.setPath("/path");
    gateway.setSsoProvider("simple");
    gateway.setGatewayType(GatewayType.CENTRAL);
    gateway.setSignCert("signcert");
    gateway.setSignKey("signkey");
    gateway.setTokenCert("tokencert");
    gateway.setSignPub("signpub");
    gateway.setExposedServices(new Json("{}"));
    return gateway;
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.Gateway) Json(com.sequenceiq.cloudbreak.domain.json.Json)

Example 49 with Json

use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.

the class DefaultBlueprintCache method loadBlueprintsFromFile.

@PostConstruct
public void loadBlueprintsFromFile() {
    for (String blueprintStrings : blueprintArray) {
        try {
            String[] split = blueprintStrings.split("=");
            if (blueprintUtils.isBlueprintNamePreConfigured(blueprintStrings, split)) {
                LOGGER.info("Load default validation '{}'.", blueprintStrings);
                BlueprintRequest blueprintJson = new BlueprintRequest();
                blueprintJson.setName(split[0].trim());
                JsonNode jsonNode = blueprintUtils.convertStringToJsonNode(blueprintUtils.readDefaultBlueprintFromFile(split));
                blueprintJson.setAmbariBlueprint(jsonNode.get("blueprint").toString());
                Blueprint bp = converter.convert(blueprintJson);
                JsonNode inputs = jsonNode.get("inputs");
                JsonNode description = jsonNode.get("description");
                bp.setDescription(description == null ? split[0] : description.asText(split[0]));
                BlueprintInputParameters inputParameters = new BlueprintInputParameters(blueprintUtils.prepareInputs(inputs));
                bp.setInputParameters(new Json(inputParameters));
                defaultBlueprints.put(bp.getName(), bp);
            }
        } catch (IOException e) {
            LOGGER.info("Can not read default validation from file: ", e);
        }
    }
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) JsonNode(com.fasterxml.jackson.databind.JsonNode) Json(com.sequenceiq.cloudbreak.domain.json.Json) IOException(java.io.IOException) BlueprintRequest(com.sequenceiq.cloudbreak.api.model.BlueprintRequest) BlueprintInputParameters(com.sequenceiq.cloudbreak.domain.BlueprintInputParameters) PostConstruct(javax.annotation.PostConstruct)

Example 50 with Json

use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.

the class UserProfileService method put.

public void put(UserProfileRequest request, IdentityUser user) {
    UserProfile userProfile = get(user.getAccount(), user.getUserId(), user.getUsername());
    if (request.getCredentialId() != null) {
        Credential credential = credentialService.get(request.getCredentialId(), userProfile.getAccount());
        userProfile.setCredential(credential);
    } else if (request.getCredentialName() != null) {
        Credential credential = credentialService.get(request.getCredentialName(), userProfile.getAccount());
        userProfile.setCredential(credential);
    }
    for (Entry<String, Object> uiStringObjectEntry : request.getUiProperties().entrySet()) {
        Map<String, Object> map = userProfile.getUiProperties().getMap();
        if (map == null || map.isEmpty()) {
            map = new HashMap<>();
        }
        map.put(uiStringObjectEntry.getKey(), uiStringObjectEntry.getValue());
        try {
            userProfile.setUiProperties(new Json(map));
        } catch (JsonProcessingException ignored) {
            throw new BadRequestException("The modification of the ui properties was unsuccesfull.");
        }
    }
    userProfileRepository.save(userProfile);
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential) UserProfile(com.sequenceiq.cloudbreak.domain.UserProfile) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) Json(com.sequenceiq.cloudbreak.domain.json.Json) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

Json (com.sequenceiq.cloudbreak.domain.json.Json)50 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)21 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)11 Credential (com.sequenceiq.cloudbreak.domain.Credential)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 BlueprintInputJson (com.sequenceiq.cloudbreak.api.model.BlueprintInputJson)6 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)6 IOException (java.io.IOException)6 Test (org.junit.Test)6 ClusterComponent (com.sequenceiq.cloudbreak.domain.ClusterComponent)5 AmbariRepoDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariRepoDetailsJson)4 BlueprintParameterJson (com.sequenceiq.cloudbreak.api.model.BlueprintParameterJson)4 Component (com.sequenceiq.cloudbreak.domain.Component)4 HashSet (java.util.HashSet)4 GatewayJson (com.sequenceiq.cloudbreak.api.model.GatewayJson)3 Gateway (com.sequenceiq.cloudbreak.domain.Gateway)3 AmbariStackDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson)2 GcsFileSystemConfiguration (com.sequenceiq.cloudbreak.api.model.GcsFileSystemConfiguration)2 HostGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson)2