Package org.jvnet.hk2.config

Examples of org.jvnet.hk2.config.ValidationException


        }
    }

    public void generateAttributeChangeEvent(String property, String propertyDetail, Map props) {
        PropertyChangeEvent pce = new PropertyChangeEvent(this, property, propertyDetail, props.get(property));
        UnprocessedChangeEvents ucel = new UnprocessedChangeEvents(new UnprocessedChangeEvent(pce, "server log file attribute " + property + " changed."));
        List<UnprocessedChangeEvents> b = new ArrayList();
        b.add(ucel);
        ucl.unprocessedTransactedEvents(b);
    }
View Full Code Here


     * @param value
     * @throws org.jvnet.hk2.config.ValidationException
     */
    public void validate(String value) throws ValidationException {
        if (value == null)
            throw new ValidationException("null value is not of type NonNegativeInteger");
        if (isTokenized(value))
            return; //a token is always valid
        try {
            long number = Long.parseLong(value);
            if (number < 0 || number > Integer.MAX_VALUE) {
                String msg = "value: " + number + " not applicable for NonNegativeInteger [0, " + Integer.MAX_VALUE + "] data type";
                throw new ValidationException(msg);
            }
        } catch(NumberFormatException e) {
            throw new ValidationException(e);
        }
    }
View Full Code Here

     * @throws org.jvnet.hk2.config.ValidationException if the value does not represent
     * integer value.
     */
    public void validate(String value) throws ValidationException {
        if (value == null)
            throw new ValidationException("null value is not of type Port");
        if (NonNegativeInteger.isTokenized(value))
            return; //a token is always valid       
        try {
            int port = Integer.parseInt(value);
            if (port < 0 || port > 0xFFFF) { //taken from ServerSocket.java
                String msg = "value: " + port + " not applicable for Port [0, " + 0xFFFF + "] data type";
                throw new ValidationException(msg);
            }
        } catch(NumberFormatException e) {
            String msg = value + " does not represent an Integer";
            throw new ValidationException(msg);
        }
    }
View Full Code Here

     * @param value
     * @throws org.jvnet.hk2.config.ValidationException
     */
    public void validate(String value) throws ValidationException {
        if (value == null)
            throw new ValidationException("null value is not of type PositiveInteger");
        if (NonNegativeInteger.isTokenized(value))
            return; //a token is always valid            
        try {
            long number = Long.parseLong(value);
            if (number < 1 || number > Integer.MAX_VALUE) { //taken from ServerSocket.java
                String msg = "value: " + number + " not applicable for PositiveInteger [1, " + Integer.MAX_VALUE + "] data type";
                throw new ValidationException(msg);
            }
        } catch(NumberFormatException e) {
            String msg = "value: " + value + " does not represent an Integer";
            throw new ValidationException(msg);
        }
    }
View Full Code Here

            List<String> vsList = StringUtils.parseStringList(vsIDs, " ,");
            if (httpService != null && vsList != null && !vsList.isEmpty()) {
                for (VirtualServer vsBean : httpService.getVirtualServer()) {
                    if (vsList.contains(vsBean.getId())) {
                        Boolean csr = null;
                        Property prop = vsBean.getProperty("contextXmlDefault");
                        if (prop != null) {
                            File contextXml = new File(serverEnvironment.getInstanceRoot(),
                                    prop.getValue());
                            if (contextXml.exists()) {  // vs context.xml
                                ContextXmlParser parser = new ContextXmlParser(contextXml);
                                csr = parser.getClearReferencesStatic();
                            }
                        }
View Full Code Here

    @DuckTyped
    String getGroupMapping();

    class Duck {
        public static String getGroupMapping(AuthRealm me) {
            Property prop = me.getProperty("group-mapping"); //have to hard-code this, unfortunately :(
            if (prop != null)
                return prop.getValue();
            return null;
        }
View Full Code Here

                    jmsHost.setHost(mqhost);
                    jmsHost.setPort(mqport);
        if(props != null)
        {
          for (Map.Entry e: props.entrySet()){
        Property prop = jmsHost.createChild(Property.class);
        prop.setName((String)e.getKey());
        prop.setValue((String)e.getValue());
        jmsHost.getProperty().add(prop);
      }
        }
                    param.getJmsHost().add(jmsHost);
View Full Code Here

            Map<String, Property> existing = getExistingProperties();
            deleteMissingProperties(existing, properties);
            Map<String, String> data = new LinkedHashMap<String, String>();

            for (Map<String, String> property : properties) {
                Property existingProp = existing.get(property.get("name"));
                String escapedName = getEscapedPropertyName(property.get("name"));
                String value = property.get("value");
                String description = property.get("description");
                final String unescapedValue = value.replaceAll("\\\\", "");

                // the prop name can not contain .
                // need to remove the . test when http://java.net/jira/browse/GLASSFISH-15418  is fixed
                boolean canSaveDesc = property.get("name").indexOf(".") == -1;

                if ((existingProp == null) || !unescapedValue.equals(existingProp.getValue())) {
                    data.put(escapedName, property.get("value"));
                    if (canSaveDesc && (description != null)) {
                        data.put(escapedName + ".description", description);
                    }
                }

                //update the description only if not null/blank
                if ((description != null) && (existingProp != null)) {
                     if (!"".equals(description) && (!description.equals(existingProp.getDescription()))) {
                        if (canSaveDesc) {
                            data.put(escapedName + ".description", description);
                        }
                    }
                }
View Full Code Here

    protected Map<String, Property> getExistingProperties() {
        Map<String, Property> properties = new HashMap<>();
        if (parent != null) {
            for (Dom child : parent.nodeElements(tagName)) {
                Property property = child.createProxy();
                properties.put(property.getName(), property);
            }
        }
        return properties;
    }
View Full Code Here

    private void createVirtualServerProperty(VirtualServer vs) throws PropertyVetoException {
        while (!(parser.getEventType() == END_ELEMENT && parser.getLocalName().equals("virtual-server"))) {
            try {
                if (parser.next() == START_ELEMENT) {
                    if (parser.getLocalName().equals("property")) {
                        Property p = vs.createChild(Property.class);
                        vs.getProperty().add(p);
                        createProperty(p);
                    }
                }
            } catch (TransactionFailure ex) {
View Full Code Here

TOP

Related Classes of org.jvnet.hk2.config.ValidationException

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.