Refine search
throw new OgnlException("source is null for getProperty(null, \"" + propertyName + "\")"); final Class<?> targetClass = OgnlRuntime.getTargetClass(target); final PropertyAccessor ognlPropertyAccessor = OgnlRuntime.getPropertyAccessor(targetClass);
protected void processException(OgnlException e,String message,Object[] objs,Object expression,Object root,Map context) { String errInfo = ((e.getReason()!=null) ? "exception=" + e.getReason().toString() : "") + "\nexpression=" + expression + "\ncontext=" + context; logger.error(errInfo); if(e.getReason() instanceof RuntimeException) { throw (RuntimeException)e.getReason(); } throw new BuriOGNLRuntimeException(message,objs,e); }
public static PropertyAccessor getPropertyAccessor(Class cls) throws OgnlException { PropertyAccessor answer = (PropertyAccessor) getHandler(cls, _propertyAccessors); if (answer != null) return answer; throw new OgnlException("No property accessor for class " + cls); }
public static Object getIndexedProperty(OgnlContext context, Object source, String name, Object index) throws OgnlException { Object[] args = _objectArrayPool.create(index); try { PropertyDescriptor pd = getPropertyDescriptor((source == null) ? null : source.getClass(), name); Method m; if (pd instanceof IndexedPropertyDescriptor) { m = ((IndexedPropertyDescriptor) pd).getIndexedReadMethod(); } else { if (pd instanceof ObjectIndexedPropertyDescriptor) { m = ((ObjectIndexedPropertyDescriptor) pd).getIndexedReadMethod(); } else { throw new OgnlException("property '" + name + "' is not an indexed property"); } } return callMethod(context, source, m.getName(), args); } catch (OgnlException ex) { throw ex; } catch (Exception ex) { throw new OgnlException("getting indexed property descriptor for '" + name + "'", ex); } finally { _objectArrayPool.recycle(args); } }
private static Object getContextProperty( final String propertyName, final Map<String, Object> context, final Object target) throws OgnlException { if (OGNLContextPropertyAccessor.REQUEST_PARAMETERS_RESTRICTED_VARIABLE_NAME.equals(propertyName) && context != null && context.containsKey(OGNLContextPropertyAccessor.RESTRICT_REQUEST_PARAMETERS)) { throw new OgnlException( "Access to variable \"" + propertyName + "\" is forbidden in this context. Note some restrictions apply to " + "variable access. For example, accessing request parameters is forbidden in preprocessing and " + "unescaped expressions, and also in fragment inclusion specifications."); } // 'execInfo' translation from context variable to expression object - deprecated and to be removed in 3.1 if ("execInfo".equals(propertyName)) { // Quick check to avoid deprecated method call final Object execInfoResult = checkExecInfo(propertyName, context); if (execInfoResult != null) { return execInfoResult; } } return ((IContext) target).getVariable(propertyName); }
/** * Prints the stack trace for this (and possibly the encapsulated) exception on * System.err. */ public void printStackTrace() { printStackTrace( System.err ); }
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(message); e.setStackTrace(ognle.getStackTrace()); } } if (e instanceof InvocationTargetException) { throwMBeanException(e.getCause()); } LOGGER.warn("Unexpected exception.", e); if (e.getClass().getPackage().getName().matches("javax?\\..+")) { if (e instanceof Exception) { throw new MBeanException((Exception) e, e.getMessage()); } throw new MBeanException(new RuntimeException(e), e.getMessage()); } throw new MBeanException(new RuntimeException(e.getClass().getName() + ": " + e.getMessage()), e.getMessage()); }
public static boolean isInstance(OgnlContext context, Object value, String className) throws OgnlException { try { Class c = classForName(context, className); return c.isInstance(value); } catch (ClassNotFoundException e) { throw new OgnlException("No such class: " + className, e); } }
private InvalidExpressionException invalidExpressionException(OgnlException e) { Throwable cause = e; String message = e.getMessage(); if (e.getReason() != null) { message = e.getReason().getMessage(); cause = e.getReason(); } if (message == null) { message = ""; } if (e instanceof MethodFailedException) { MethodFailedException ex = ((MethodFailedException) e); Throwable realReason = ex.getReason(); if (realReason != null) { if (realReason instanceof NullPointerException) { message = "NullPointerException"; } else { message = realReason.getClass().getName() + ": " + message; } } message = message.replaceAll("java\\.lang\\.", ""); } return new InvalidExpressionException(message, cause); }
/** Returns OgnlRuntime.NotFound if the property does not exist. */ public Object getPossibleProperty( Map context, Object target, String name) throws OgnlException { Object result; OgnlContext ognlContext = (OgnlContext)context; try { if ((result = OgnlRuntime.getMethodValue(ognlContext, target, name, true)) == OgnlRuntime.NotFound) { result = OgnlRuntime.getFieldValue(ognlContext, target, name, true); } } catch (IntrospectionException ex) { throw new OgnlException(name, ex); } catch (OgnlException ex) { throw ex; } catch (Exception ex) { throw new OgnlException(name, ex); } return result; }
Map<String, PropertyDescriptor> descriptors = OgnlRuntime.getPropertyDescriptors(v.getClass()); Object value = OgnlRuntime.callMethod((OgnlContext) context, o, name, objects); Throwable reason = e.getReason(); throw new MethodFailedException(o, name, e.getReason());
if ((OgnlRuntime.hasGetProperty(ognlContext, o, name)) || ((o instanceof Map) && ((Map) o).containsKey(name))) { return OgnlRuntime.getProperty(ognlContext, o, name); if (e.getReason() != null) { final String msg = "Caught an Ognl exception while getting property " + name; throw new XWorkException(msg, e);
public boolean hasSetProperty(OgnlContext context, Object target, Object oname) throws OgnlException { try { return OgnlRuntime.hasSetProperty(context, target, oname); } catch (IntrospectionException ex) { throw new OgnlException("checking if " + target + " has settable property " + oname, ex); } }
public boolean hasGetProperty(OgnlContext context, Object target, Object oname) throws OgnlException { try { return OgnlRuntime.hasGetProperty(context, target, oname); } catch (IntrospectionException ex) { throw new OgnlException("checking if " + target + " has gettable property " + oname, ex); } }
/** Determines the index property type, if any. Returns <code>INDEXED_PROPERTY_NONE</code> if the property is not index-accessible as determined by OGNL or JavaBeans. If it is indexable then this will return whether it is a JavaBeans indexed property, conforming to the indexed property patterns (returns <code>INDEXED_PROPERTY_INT</code>) or if it conforms to the OGNL arbitrary object indexable (returns <code>INDEXED_PROPERTY_OBJECT</code>). */ public static final int getIndexedPropertyType( OgnlContext context, Class sourceClass, String name) throws OgnlException { int result = INDEXED_PROPERTY_NONE; try { PropertyDescriptor pd = getPropertyDescriptor(sourceClass, name); if (pd != null) { if (pd instanceof IndexedPropertyDescriptor) { result = INDEXED_PROPERTY_INT; } else { if (pd instanceof ObjectIndexedPropertyDescriptor) { result = INDEXED_PROPERTY_OBJECT; } } } } catch (Exception ex) { throw new OgnlException("problem determining if '" + name + "' is an indexed property", ex); } return result; }
public boolean shouldCreateIfNew(Class parentClass, String property, Object target, String keyProperty, boolean isIndexAccessed) { try { System.out.println("ognl:"+OgnlRuntime.getPropertyAccessor(Map.class)+" this:"+this); } catch (OgnlException e) { // TODO Auto-generated catch block e.printStackTrace(); } return isShouldCreateIfNew(); }
/** * Returns OgnlRuntime.NotFound if the property does not exist. */ public Object setPossibleProperty(Map context, Object target, String name, Object value) throws OgnlException { Object result = null; OgnlContext ognlContext = (OgnlContext) context; try { if (!OgnlRuntime.setMethodValue(ognlContext, target, name, value, true)) { result = OgnlRuntime.setFieldValue(ognlContext, target, name, value) ? null : OgnlRuntime.NotFound; } if (result == OgnlRuntime.NotFound) { Method m = OgnlRuntime.getWriteMethod(target.getClass(), name); if (m != null) { result = m.invoke(target, new Object[] { value}); } } } catch (IntrospectionException ex) { throw new OgnlException(name, ex); } catch (OgnlException ex) { throw ex; } catch (Exception ex) { throw new OgnlException(name, ex); } return result; }
protected void catchException(Exception re,Object expression,Object root,Map context,String messageID) { logger.debug("[OGNL ERROR]" + expression.toString() + "" + re.toString()); if(re instanceof OgnlException) { OgnlException oe = (OgnlException)re; if(oe.getReason() != null) { logger.debug(oe.getLocalizedMessage(), oe.getReason()); } else { logger.debug(oe.getLocalizedMessage(), oe); } } else if(re instanceof BuriException) { throw (BuriException)re; } else { new BuriOGNLRuntimeException(messageID,new Object[]{expression,root,re,context},re); } }
/** Returns OgnlRuntime.NotFound if the property does not exist. */ public Object setPossibleProperty( Map context, Object target, String name, Object value) throws OgnlException { Object result = null; OgnlContext ognlContext = (OgnlContext)context; try { if (!OgnlRuntime.setMethodValue(ognlContext, target, name, value, true)) { result = OgnlRuntime.setFieldValue(ognlContext, target, name, value) ? null : OgnlRuntime.NotFound; } } catch (IntrospectionException ex) { throw new OgnlException(name, ex); } catch (OgnlException ex) { throw ex; } catch (Exception ex) { throw new OgnlException(name, ex); } return result; }