Package ognl

Examples of ognl.OgnlException


      annotated.setMethod(name.toString());
      return annotated;
    }

    public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException {
      throw new OgnlException("Cannot set properties on a Action instance - operation not allowed");
    }
View Full Code Here


        return messageSource.getMessage(name.toString(), null, null, null);
      }
    }

    public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException {
      throw new OgnlException("Cannot set properties on a MessageSource instance - operation not allowed");
    }
View Full Code Here

                Class<?> associationType = (Class) api.associationDescriptorFor( association ).type();
                Object convertedValue = getConvertedType(
                    ognlContext, aTarget, null, fieldName, aPropertyValue, associationType );
                if( convertedValue == OgnlRuntime.NoConversionPossible )
                {
                    throw new OgnlException( "Could not convert value to association type" );
                }
                try
                {
                    association.set( convertedValue );
                }
                catch( ConstraintViolationException e )
                {
                    Collection<ConstraintViolation> violations = e.constraintViolations();
                    handleConstraintViolation( aContext, aTarget, fieldName, aPropertyValue, violations );
                }

                return;
            }
            else if( ManyAssociation.class.isAssignableFrom( memberClass ) )
            {
                throw new OgnlException( "Setting many association [" + fieldName + "] is impossible." );
            }
            else if( NamedAssociation.class.isAssignableFrom( memberClass ) )
            {
                throw new OgnlException( "Setting named association [" + fieldName + "] is impossible." );
            }
        }

        super.setProperty( aContext, aTarget, aPropertyName, aPropertyValue );
    }
View Full Code Here

            if (result instanceof Boolean) {
                if (((Boolean) result).booleanValue()) {
                    answer.add(s);
                }
            } else {
                throw new OgnlException(
                        "Query didn't return a boolean value: " + query);
            }
        }
       
        return answer;
View Full Code Here

    @Override
    public final Object setPossibleProperty(Map context, Object target, String name,
            Object value) throws OgnlException {
        if (context.containsKey(READ_ONLY_MODE)) {
            throw new OgnlException("Expression must be read-only: " + context.get(QUERY));
        }
       
        Object answer = setProperty0((OgnlContext) context, target, name, value);
        if (answer == OgnlRuntime.NotFound) {
            answer = super.setPossibleProperty(context, target, name, value);
View Full Code Here

        return dst;
    }

    private void throwMBeanException(Throwable e) throws MBeanException {
        if (e instanceof OgnlException) {
            OgnlException ognle = (OgnlException) e;
            if (ognle.getReason() != null) {
                throwMBeanException(ognle.getReason());
            } else {
                String message = ognle.getMessage();
                if (e instanceof NoSuchPropertyException) {
                    message = "No such property: " + message;
                } else if (e instanceof ExpressionSyntaxException) {
                    message = "Illegal expression syntax: " + message;
                } else if (e instanceof InappropriateExpressionException) {
                    message = "Inappropriate expression: " + message;
                }
                e = new IllegalArgumentException(ognle.getMessage());
                e.setStackTrace(ognle.getStackTrace());
            }
        }
        if (e instanceof InvocationTargetException) {
            throwMBeanException(e.getCause());
        }
View Full Code Here

        Class keyType = null;
        Class toGetTypeFrom = (collClass != null) ? collClass : c.iterator().next().getClass();
        try {
            keyType = OgnlRuntime.getPropertyDescriptor(toGetTypeFrom, keyProperty).getPropertyType();
        } catch (Exception exc) {
            throw new OgnlException("Error getting property descriptor: " + exc.getMessage());
        }


        if (ReflectionContextState.isCreatingNullObjects(context)) {
            Map collMap = getSetMap(context, c, keyProperty, collClass);
            if (key.toString().equals(KEY_PROPERTY_FOR_CREATION)) {
                //this should return the XWorkList
                //for this set that contains new entries
                //then the ListPropertyAccessor will be called
                //to access it in the next sequence
                return collMap.get(null);
            }
            Object realKey = xworkConverter.convertValue(context, key, keyType);
            Object value = collMap.get(realKey);
            if (value == null
                    && ReflectionContextState.isCreatingNullObjects(context)
                    && objectTypeDeterminer
                    .shouldCreateIfNew(lastBeanClass,lastPropertyClass,c,keyProperty,false)) {
                  //create a new element and
                    //set the value of keyProperty
                    //to be the given value
                  try {
                      value=objectFactory.buildBean(collClass, context);
                     
                      //set the value of the keyProperty
                      _accessor.setProperty(context,value,keyProperty,realKey);
                     
                      //add the new object to the collection
                      c.add(value);
                     
                      //add to the Map if accessed later
                      collMap.put(realKey, value);
                     
                     
                  catch (Exception exc) {
                      throw new OgnlException("Error adding new element to collection", exc);
                     
                  }
               
            }
            return value;
View Full Code Here

            if (result instanceof Boolean) {
                if (((Boolean) result).booleanValue()) {
                    answer.add(s);
                }
            } else {
                throw new OgnlException(
                        "Query didn't return a boolean value: " + query);
            }
        }
       
        return answer;
View Full Code Here

    @Override
    public final Object setPossibleProperty(Map context, Object target, String name,
            Object value) throws OgnlException {
        if (context.containsKey(READ_ONLY_MODE)) {
            throw new OgnlException("Expression must be read-only: " + context.get(QUERY));
        }
       
        Object answer = setProperty0((OgnlContext) context, target, name, value);
        if (answer == OgnlRuntime.NotFound) {
            answer = super.setPossibleProperty(context, target, name, value);
View Full Code Here

        return dst;
    }

    private void throwMBeanException(Throwable e) throws MBeanException {
        if (e instanceof OgnlException) {
            OgnlException ognle = (OgnlException) e;
            if (ognle.getReason() != null) {
                throwMBeanException(ognle.getReason());
            } else {
                String message = ognle.getMessage();
                if (e instanceof NoSuchPropertyException) {
                    message = "No such property: " + message;
                } else if (e instanceof ExpressionSyntaxException) {
                    message = "Illegal expression syntax: " + message;
                } else if (e instanceof InappropriateExpressionException) {
                    message = "Inappropriate expression: " + message;
                }
                e = new IllegalArgumentException(ognle.getMessage());
                e.setStackTrace(ognle.getStackTrace());
            }
        }
        if (e instanceof InvocationTargetException) {
            throwMBeanException(e.getCause());
        }
View Full Code Here

TOP

Related Classes of ognl.OgnlException

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.