Package org.rhq.modules.plugins.jbossas7.json

Examples of org.rhq.modules.plugins.jbossas7.json.Result


    }

    private String resolveSocketBindingGroup(String serverGroup) {
        Address address = new Address("server-group", serverGroup);
        Operation operation = new ReadAttribute(address, "socket-binding-group");
        Result result = parentComponent.getASConnection().execute(operation);
        return (String) result.getResult();
    }
View Full Code Here


    private List<ServerInfo> getManagedServers(String domainHost) {
        Address address = new Address("host", domainHost);
        Operation operation = new ReadChildrenNames(address, "server-config");
        ASConnection connection = parentComponent.getASConnection();
        Result res = connection.execute(operation);
        List<String> servers = (List<String>) res.getResult();
        List<ServerInfo> ret = new ArrayList<ServerInfo>(servers.size());
        for (String server : servers) {
            ServerInfo info = new ServerInfo();
            info.name = server;
            ret.add(info);
View Full Code Here

    private static MeasurementScheduleRequest newTraitRequest(String requestName) {
        return new MeasurementScheduleRequest(-1, requestName, -1, true, TRAIT);
    }

    private static Result result(Object value) {
        Result result = new Result();
        result.setOutcome(SUCCESS);
        result.setResult(value);
        return result;
    }
View Full Code Here

            report.setStatus(FAILURE);
            report.setErrorMessage(configurationUpdateHelper.getErrorMessage());
        } else {
            // First update the connector and discovery group name attributes in a batch
            Operation batchOperation = configurationUpdateHelper.getBatchOperation();
            Result result = getASConnection().execute(batchOperation);
            if (!result.isSuccess()) {
                report.setStatus(FAILURE);
                report.setErrorMessage(result.getFailureDescription());
                return;
            }

            // Now update the rest of the configuration attributes
            ConfigurationDefinition configDefCopy = resourceType.getResourceConfigurationDefinition().copy();
View Full Code Here

                    report.setStatus(CreateResourceStatus.INVALID_CONFIGURATION);
                    return report;
                }

                ReadChildrenNames op = new ReadChildrenNames(address, pathProperty.getStringValue());
                Result res = connection.execute(op);
                if (res.isSuccess()) {
                    List<String> entries = (List<String>) res.getResult();
                    if (!entries.isEmpty()) {
                        report.setErrorMessage("Resource is a singleton, but there are already children " + entries
                            + " please remove them and retry");
                        report.setStatus(CreateResourceStatus.FAILURE);
                        return report;
                    }
                }
            }

            //determine type then attribute
            ResourceType resourceType = report.getResourceType();
            String attribute = attributeMap.get(resourceType.getName());
            //determine new child name from attribute
            String newChild = newChildTypeMap.get(attribute);

            //get resourceConfig
            Configuration configuration = report.getResourceConfiguration();
           
            if(attribute!=null){//create executed from SecurityDomain level

                //retrieve the values passed in via config
                Value loaded = loadCodeFlagType(configuration, attribute, null);

                //populate the ModuleOptionType from the Configuration
                List<Value> newAttributeState = new ArrayList<Value>();
                newAttributeState.add(loaded);

                //build the operation
                //update the address to point to the new child being created
                Address newChildLocation = new Address(path + "," + newChild);
                Operation op = createAddModuleOptionTypeOperation(newChildLocation, attribute, newAttributeState);

                Result result = connection.execute(op);
                if (result.isSuccess()) {
                    report.setStatus(CreateResourceStatus.SUCCESS);
                    report.setResourceKey(newChildLocation.getPath());
                    report.setResourceName(report.getResourceType().getName());
                } else {
                    report.setStatus(CreateResourceStatus.FAILURE);
                    report.setErrorMessage(result.getFailureDescription());
                }
            }else{//Create executed from the 'Login Modules/Provider Modules/etc. level.
                //retrieve the parent type to lookup attribute to write to
                ResourceType parentType = (ResourceType) resourceType.getParentResourceTypes().toArray()[0];
                attribute = attributeMap.get(parentType.getName());
               
                //retrieve existing attribute definition
                //get the current attribute value
                ReadAttribute op = new ReadAttribute(address, attribute);
                Result result = getASConnection().execute(op);
                if (result.isSuccess()) {
                    //populate attribute values
                    List<Value> currentAttributeState = new ArrayList<Value>();
                    currentAttributeState = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
                        ModuleOptionsComponent.loadModuleOptionType(attribute));
                   //populate new Module type data
                   //retrieve the values passed in via config
                   Value loaded = loadCodeFlagType(configuration, attribute, null);

                    //append new type information
                    currentAttributeState.add(loaded);
                    //write values back out.
                    Operation write = new WriteAttribute(address);
                    write.addAdditionalProperty("name", attribute);//attribute to execute on

                    //now complete the write operation by updating the value
                    write.addAdditionalProperty("value", (Object) currentAttributeState);
                    result = connection.execute(write);
                    if (result.isSuccess()) {
                        report.setStatus(CreateResourceStatus.SUCCESS);
                        //Ex. subsystem=security,security-domain=createOne,authentication=classic,login-modules:0
                        report.setResourceKey(path + "," + attribute + ":" + (currentAttributeState.size() - 1));
                        //Ex. Login Modules 0
                        report.setResourceName(ModuleOptionType.readableNameMap.get(attribute) + " "
                            + (currentAttributeState.size() - 1));
                    } else {
                        report.setStatus(CreateResourceStatus.FAILURE);
                        report.setErrorMessage(result.getFailureDescription());
                    }
                }
            }
            return report;
        }
View Full Code Here

                attribute = ModuleOptionsComponent.attributeMap.get(resourceType.getName());
            }

            //get the current attribute value
            ReadAttribute op = new ReadAttribute(address, attribute);
            Result result = getASConnection().execute(op);
            if (result.isSuccess()) {
                //populate attribute values
                List<Value> currentAttributeState = new ArrayList<Value>();
                currentAttributeState = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
                    ModuleOptionsComponent.loadModuleOptionType(attribute));
                if (currentNodeIsModuleType) {//grab first available module type
                    Value loaded = currentAttributeState.get(0);
                    //populate configuration
                    populateCodeFlagType(configuration, attribute, loaded);
                } else {//Need to locate specific module type
                    //locate specific node and populate the config
                    //Ex."login-modules:";
                    String moduleTypeIdentifier = attribute + ":";
                    int index = path.indexOf(moduleTypeIdentifier);
                    String loginModuleIndex = path.substring(index + moduleTypeIdentifier.length());
                    int lmi = Integer.valueOf(loginModuleIndex);//Ex 0,1,30
                    if (currentAttributeState.size() > lmi) {//then retrieve.
                        Value loaded = currentAttributeState.get(lmi);
                        //populate configuration
                        populateCodeFlagType(configuration, attribute, loaded);
                    }
                }
            }
            //read attribute
            return configuration;
        }
        //Module Options child, Ex. 'Login Modules (Classic', ..-Managed, .. - Profile
        else if (supportsLoginModuleOptionType(grandParentType)) {
            //get type and lookup supported node and type
            String attribute = ModuleOptionsComponent.attributeMap.get(grandParentType.getName());

            //get the current attribute value
            ReadAttribute op = new ReadAttribute(address, attribute);
            Result result = getASConnection().execute(op);
            if (result.isSuccess()) {
                //populate attribute values
                List<Value> currentAttributeState = new ArrayList<Value>();
                currentAttributeState = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
                    ModuleOptionsComponent.loadModuleOptionType(attribute));
View Full Code Here

                attribute = ModuleOptionsComponent.attributeMap.get(resourceType.getName());
            }

            //get the current attribute value. Will write module types back out exactly as read in with these new updates
            ReadAttribute op = new ReadAttribute(address, attribute);
            Result result = getASConnection().execute(op);
            if (result.isSuccess()) {
                List<String> entries = (List<String>) result.getResult();

                //populate attribute values
                List<Value> currentAttributeState = new ArrayList<Value>();
                currentAttributeState = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
                    ModuleOptionsComponent.loadModuleOptionType(attribute));

                //retrieve current config changes   
                Configuration conf = report.getConfiguration();

                if (currentNodeIsModuleType) {//grab first available module type
                    Value loaded = currentAttributeState.get(0);
                    //iterate over properties and update values appropriately
                    for (String pKey : conf.getSimpleProperties().keySet()) {
                        if (pKey.equals("flag")) {
                            loaded.setFlag(conf.getSimpleProperties().get(pKey).getStringValue());
                        } else if (pKey.equals("code")) {
                            loaded.setCode(conf.getSimpleProperties().get(pKey).getStringValue());
                        } else if (pKey.equals("type")) {
                            loaded.setType(conf.getSimpleProperties().get(pKey).getStringValue());
                        }
                    }
                    Operation write = new WriteAttribute(address);
                    write.addAdditionalProperty("name", attribute);//attribute to execute on

                    //now complete the write operation by updating the value
                    write.addAdditionalProperty("value", (Object) currentAttributeState);
                    executeWriteAndGenerateAs7ServerUpdate(report, conf, write);
                } else {//Need to locate specific module type

                //locate specific node and populate the config
                    String loginModuleIdentifier = attribute + ":";
                int index = path.indexOf(loginModuleIdentifier);
                String loginModuleIndex = path.substring(index + loginModuleIdentifier.length());
                int lmi = Integer.valueOf(loginModuleIndex);//Ex 0,1,30
                Value valueObject = currentAttributeState.get(lmi);

                //iterate over properties and update values appropriately
                for (String pKey : conf.getSimpleProperties().keySet()) {
                    if (pKey.equals("flag")) {
                        valueObject.setFlag(conf.getSimpleProperties().get(pKey).getStringValue());
                    } else if (pKey.equals("code")) {
                        valueObject.setCode(conf.getSimpleProperties().get(pKey).getStringValue());
                        } else if (pKey.equals("type")) {
                            valueObject.setType(conf.getSimpleProperties().get(pKey).getStringValue());
                    }
                }
                Operation write = new WriteAttribute(address);
                write.addAdditionalProperty("name", attribute);//attribute to execute on

                //now complete the write operation by updating the value
                write.addAdditionalProperty("value", (Object) currentAttributeState);
                executeWriteAndGenerateAs7ServerUpdate(report, conf, write);
                }
            }
        } else if (supportsLoginModuleOptionType(grandParentType)) {//Module Options child.
            //get type and lookup supported node and type
            String attribute = ModuleOptionsComponent.attributeMap.get(grandParentType.getName());

            //get the current attribute value. Will write module types back out exactly as read in with these new updates
            ReadAttribute op = new ReadAttribute(address, attribute);
            Result result = getASConnection().execute(op);
            if (result.isSuccess()) {

                //populate attribute values
                List<Value> currentAttributeState = new ArrayList<Value>();
                currentAttributeState = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
                    ModuleOptionsComponent.loadModuleOptionType(attribute));
View Full Code Here

     * @param conf
     * @param write
     */
    private void executeWriteAndGenerateAs7ServerUpdate(ConfigurationUpdateReport report, Configuration conf,
        Operation write) {
        Result result;
        result = getASConnection().execute(write);
        if (!result.isSuccess()) {
            report.setStatus(ConfigurationUpdateStatus.FAILURE);
            report.setErrorMessage(result.getFailureDescription());
        } else {
            report.setStatus(ConfigurationUpdateStatus.SUCCESS);
            // signal "need reload"
            if (result.isReloadRequired()) {
                PropertySimple oobMessage = new PropertySimple("__OOB",
                    "The server needs a reload for the latest changes to come effective.");
                conf.put(oobMessage);
            }
            if (result.isRestartRequired()) {
                PropertySimple oobMessage = new PropertySimple("__OOB",
                    "The server needs a restart for the latest changes to come effective.");
                conf.put(oobMessage);
            }
        }
View Full Code Here

     * @param report
     * @param conf
     * @param write
     */
    private void executeAndGenerateServerUpdateIfNecessary(Configuration configuration, ReadAttribute op) {
        Result res = getASConnection().execute(op);
        if (res.isReloadRequired()) {
            PropertySimple oobMessage = new PropertySimple("__OOB",
                "The server needs a reload for the latest changes to come effective.");
            configuration.put(oobMessage);
        }
        if (res.isRestartRequired()) {
            PropertySimple oobMessage = new PropertySimple("__OOB",
                "The server needs a restart for the latest changes to come effective.");
            configuration.put(oobMessage);
        }
    }
View Full Code Here

    private void loadHandleProperties(Configuration config, List<PropertyDefinition> definitions, Operation op)
        throws Exception {
        if (definitions.size() == 0)
            return;

        Result operationResult = connection.execute(op);
        if (!operationResult.isSuccess()) {
            // check if the definition is needed -- required==true or not. Only complain for required ones
            if (definitions.size()==1 && definitions.get(0).isRequired()==false) {
                return;
            }

            throw new IOException("Operation " + op + " failed: " + operationResult.getFailureDescription());
        }

        if (operationResult.getResult() instanceof List) {
            PropertyList propertyList = loadHandlePropertyList((PropertyDefinitionList) definitions.get(0),
                operationResult.getResult());

            if (propertyList != null)
                config.put(propertyList);
            return;
        }

        Map<String, Object> results = (Map<String, Object>) operationResult.getResult();

        for (PropertyDefinition propDef : definitions) {

            /*
             * We may have a mismatch for groups where the <c:group name="children:*"> child is a list of maps
View Full Code Here

TOP

Related Classes of org.rhq.modules.plugins.jbossas7.json.Result

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.