Examples of WriteAttribute


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

        Address address = new Address();
        address.add("subsystem", "web");
        address.add("connector", "http");

        Operation operation = new WriteAttribute(address, "socket-binding", "jndi");

        ObjectMapper mapper = new ObjectMapper();

        String result = mapper.writeValueAsString(operation);
        Operation op = mapper.readValue(result, Operation.class);
        assertNotSame(op, null);
        assertNotSame(op.getOperation(), null, "op.operation was null!");
        assertEquals(op.getOperation(), operation.getOperation(), "Operation is " + op.getOperation());
        assertNotSame(op.getName(), null, "op.getName is null");
        assertEquals("socket-binding", op.getName(), "attribute name  is " + op.getName() + " and not 'socket-binding'");
        assertEquals(op.getValue(), "jndi", "attribute value  is " + op.getValue());
        assertSame(op.getAddress().size(), 2, "Address did not contain 2 parts, but " + op.getAddress().size());
View Full Code Here

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

                    if (canUnset) {
                        val = null;
                    } else {
                        val = configDef.getPropertyDefinitionSimple(simplePropertyName).getDefaultValue();
                    }
                    updateOperation.addStep(new WriteAttribute(getAddress(), simplePropertyName, val));
                }
            } else if (!newConfigPropertySimpleValue.equals(currentConfigPropertySimpleValue)) {
                updateOperation.addStep(new WriteAttribute(getAddress(), simplePropertyName,
                    newConfigPropertySimpleValue));
            }
        }

        // 4. Capture connection property changes
View Full Code Here

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

        @Override
        public Operation getBatchOperation() {
            CompositeOperation compositeOperation = new CompositeOperation();
            if (hasDiscoveryGroupName()) {
                compositeOperation.addStep(new UndefineAttribute(address, CONNECTOR_ATTRIBUTE));
                compositeOperation.addStep(new WriteAttribute(address, DISCOVERY_GROUP_NAME, configuration
                    .getSimpleValue(DISCOVERY_GROUP_NAME)));
            } else {
                compositeOperation.addStep(new UndefineAttribute(address, DISCOVERY_GROUP_NAME));
                compositeOperation.addStep(new WriteAttribute(address, CONNECTOR_ATTRIBUTE, Collections.singletonMap(
                    configuration.getMap(CONNECTOR_PROPERTY).getSimpleValue("name:0", EMPTY_STRING), null)));
            }
            return compositeOperation;
        }
View Full Code Here

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

        @Override
        public Operation getBatchOperation() {
            CompositeOperation compositeOperation = new CompositeOperation();
            if (hasDiscoveryGroupName()) {
                compositeOperation.addStep(new UndefineAttribute(address, STATIC_CONNECTORS_ATTRIBUTE));
                compositeOperation.addStep(new WriteAttribute(address, DISCOVERY_GROUP_NAME, configuration
                    .getSimpleValue(DISCOVERY_GROUP_NAME)));
            } else {
                compositeOperation.addStep(new UndefineAttribute(address, DISCOVERY_GROUP_NAME));
                List<Property> propertyList = configuration.getList(STATIC_CONNECTORS_PROPERTY).getList();
                List<String> staticConnectors = new ArrayList<String>(propertyList.size());
                for (Property property : propertyList) {
                    if (property instanceof PropertySimple) {
                        PropertySimple propertySimple = (PropertySimple) property;
                        staticConnectors.add(propertySimple.getStringValue());
                    } else {
                        getLog().warn(property.getName() + " property has unexpected type: " + property.getClass());
                    }
                }
                compositeOperation.addStep(new WriteAttribute(address, STATIC_CONNECTORS_ATTRIBUTE, staticConnectors));
            }
            return compositeOperation;
        }
View Full Code Here

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

                   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

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

                            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

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

        ejbAddress.add("subsystem", "ejb3");
        try {
            ejb3StatisticsEnalbed = readAttribute(ejbAddress, "enable-statistics", Boolean.class);
            if (!Boolean.TRUE.equals(ejb3StatisticsEnalbed)) {
                getLog().debug("Enabling global EJB3 statistics");
                WriteAttribute op = new WriteAttribute(ejbAddress, "enable-statistics", true);
                Result result = getASConnection().execute(op);
                if (result.isSuccess()) {
                    getLog()
                        .info(
                            server.context.getResourceDetails()
View Full Code Here

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

                    Object value = getValueWithType(entry, propDef);
                    if (key1.endsWith(":expr")) {
                        key1 = key1.substring(0, key1.indexOf(':'));
                        Map<String, Object> tmp = new HashMap<String, Object>();
                        tmp.put("EXPRESSION_VALUE", value);
                        operation = new WriteAttribute(addr, key1, tmp);
                    } else {
                        operation = new WriteAttribute(addr, key1, value);
                    }
                    cop.addStep(operation);
                }
            }
View Full Code Here

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

            String name = property.getName();
            if (name.indexOf(':') != -1) {
                name = name.substring(0, name.indexOf(":"));
            }

            Operation writeAttribute = new WriteAttribute(address, name, null);
            cop.addStep(writeAttribute);
            return;
        }

        SimpleEntry<String, Object> entry = this.preparePropertySimple(property, propertyDefinition);
        Operation writeAttribute = new WriteAttribute(address, entry.getKey(), entry.getValue());
        cop.addStep(writeAttribute);
    }
View Full Code Here

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

    private void createWriteAttributePropertyList(CompositeOperation cop, PropertyList property,
        PropertyDefinitionList propertyDefinition, Address address) {

        SimpleEntry<String, List<Object>> entry = preparePropertyList(property, propertyDefinition);
        Operation writeAttribute = new WriteAttribute(address, entry.getKey(), entry.getValue());
        cop.addStep(writeAttribute);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.