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

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


     * Get the resource details of the server group with the given name
     * @param group Name of the server group to query
     * @return Map with the properties of the group. Or an empty map if the group does not exist.
     */
    private Map<String, Object> getServerGroupMap(String group) {
        Operation op = new ReadResource("server-group", group);
        ComplexResult cr = getASConnection().executeComplex(op);
        if (cr.isSuccess()) {
            return cr.getResult();
        }

View Full Code Here


    }

    @Override
    public OperationResult invokeOperation(String name, Configuration parameters) throws InterruptedException,
        Exception {
        Operation op = new Operation(name, getAddress());
        op.addAdditionalProperty("blocking", Boolean.valueOf(parameters.getSimpleValue("blocking", "false")));
        Result res = getASConnection().execute(op,
            Integer.parseInt(parameters.getSimpleValue("operationTimeout", "120")));
        OperationResult opRes;
        if (res.isSuccess()) {
            opRes = new OperationResult("successfully invoked [" + name + "]");
View Full Code Here

        try {
   
            Address address = new Address(path);
   
            //create request to get metadata type information
            Operation op = new Operation("read-resource-description", address);
            //recurse down the tree.
            op.addAdditionalProperty("recursive", "true");
   
            //additionally request operation metadata
            if (mode == D2DMode.OPERATION) {
                op.addAdditionalProperty("operations", true);
            }
            //additionally request metric metadata
            if (mode == D2DMode.METRICS) {
                op.addAdditionalProperty("include-runtime", true);
            }
            //additionally request both metric and operations metadata
            if (mode == D2DMode.RECURSIVE) {
                op.addAdditionalProperty("operations", true);
                op.addAdditionalProperty("include-runtime", true);
            }
   
            ComplexResult res = conn.executeComplex(op);
            if (res == null) {
                System.err.println("Got no result");
View Full Code Here

     * @param asConnection ASConnection to the parent
     * @return Host name
     */
    private String getHostName(ASConnection asConnection) {

        Operation op = new ReadAttribute(new Address(),"local-host-name");
        String hostname;
        Result res = asConnection.execute(op);
        if (res.isSuccess()) {
            hostname = (String) res.getResult();
            return hostname;
View Full Code Here

        return hostname;
    }

    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

        return (String) result.getResult();
    }

    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) {
View Full Code Here

        return ret;
    }

    private HostInfo getHostInfo(String domainHost) {
        Address address = new Address("host", domainHost);
        Operation operation = new ReadResource(address);
        HostInfo info = new HostInfo();

        ComplexResult cres = parentComponent.getASConnection().executeComplex(operation);
        if (!cres.isSuccess())
            return null;
View Full Code Here

        if (!configurationUpdateHelper.isConnectorXorDiscoveryGroupNameConfigured()) {
            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;
View Full Code Here

                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));
View Full Code Here

                            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));

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

                //retrieve current config changes   
                Configuration conf = report.getConfiguration();
                //list current conf stated being defined.
                String mapKey = (String) conf.getMap().keySet().toArray()[0];
                PropertyMap mapType = (PropertyMap) conf.getMap().get(mapKey);
                //insert update logic.
                //set this new state passed in as state of the attribute.
                LinkedHashMap<String, Object> currentOptions = new LinkedHashMap<String, Object>();
                for (String propertyKey : mapType.getMap().keySet()) {
                    currentOptions.put(propertyKey, ((PropertySimple) mapType.get(propertyKey)).getStringValue());
                }

                //make these settings the new state for this part of the attribute.
                valueObject.setOptions(currentOptions);
                currentAttributeState.set(lmi, valueObject);

                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 {
            ConfigurationWriteDelegate delegate = new ConfigurationWriteDelegate(configDef, getASConnection(), address);
            delegate.updateResourceConfiguration(report);
View Full Code Here

TOP

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

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.