protected void processRestConfig() { if (this.getClass().isAnnotationPresent(RestConfig.class)) { restConfig = this.getClass().getAnnotation(RestConfig.class); } else { LOG.warn("No RestConfig declared. Use @RestConfig annotation to set configuration. Using defaults."); } }
protected void processRestConfig() { if (this.getClass().isAnnotationPresent(RestConfig.class)) { restConfig = this.getClass().getAnnotation(RestConfig.class); } else { LOG.warn("No RestConfig declared. Use @RestConfig annotation to set configuration. Using defaults."); } }
@Inject(value = XWorkConstants.ENABLE_OGNL_EVAL_EXPRESSION, required = false) public void setEnableEvalExpression(String evalExpression) { enableEvalExpression = "true".equals(evalExpression); if(enableEvalExpression){ LOG.warn("Enabling OGNL expression evaluation may introduce security risks " + "(see http://struts.apache.org/release/2.3.x/docs/s2-013.html for further details)"); } }
private void load(Collection<URL> urls){ for (URL location : urls) { try { this.urls.put(location.toExternalForm(), location); } catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Cannot translate url to external form!", e); } } } }
@Override public InputSource resolveEntity(String publicId, String systemId) { if (dtdMappings != null && dtdMappings.containsKey(publicId)) { String dtdFile = dtdMappings.get(publicId); return new InputSource(ClassLoaderUtil.getResourceAsStream(dtdFile, DomHelper.class)); } else if (LOG.isWarnEnabled()) { LOG.warn("Local DTD is missing for publicID: #0 - defined mappings: #1", publicId, dtdMappings); } return null; }
protected boolean isPackageExcluded(Package targetPackage, Package memberPackage) { if (LOG.isWarnEnabled() && (targetPackage == null || memberPackage == null)) { LOG.warn("The use of the default (unnamed) package is discouraged!"); } String targetPackageName = targetPackage == null ? "" : targetPackage.getName(); String memberPackageName = memberPackage == null ? "" : memberPackage.getName(); for (Pattern pattern : excludedPackageNamePatterns) { if (pattern.matcher(targetPackageName).matches() || pattern.matcher(memberPackageName).matches()) { return true; } } targetPackageName = targetPackageName + "."; memberPackageName = memberPackageName + "."; for (String packageName: excludedPackageNames) { if (targetPackageName.startsWith(packageName) || memberPackageName.startsWith(packageName)) { return true; } } return false; }
protected Class verifyResultType(String className, Location loc) { try { return objectFactory.getClassInstance(className); } catch (ClassNotFoundException e) { if (LOG.isWarnEnabled()) { LOG.warn("Result class [#0] doesn't exist (ClassNotFoundException) at #1, ignoring", e, className, loc.toString()); } } catch (NoClassDefFoundError e) { if (LOG.isWarnEnabled()) { LOG.warn("Result class [#0] doesn't exist (NoClassDefFoundError) at #1, ignoring", e, className, loc.toString()); } } return null; }
private void clearContainerProvider(ContainerProvider containerProvider) { try { containerProvider.destroy(); } catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("Error while destroying container provider [#0]", e, containerProvider.toString()); } } }
@Inject(value = XWorkConstants.OVERRIDE_EXCLUDED_PATTERNS, required = false) public void setOverrideExcludePatterns(String excludePatterns) { if (LOG.isWarnEnabled()) { LOG.warn("Overriding excluded patterns [#0] with [#1], be aware that this affects all instances and safety of your application!", XWorkConstants.OVERRIDE_EXCLUDED_PATTERNS, excludePatterns); } excludedPatterns = new HashSet<Pattern>(); for (String pattern : TextParseUtil.commaDelimitedStringToSet(excludePatterns)) { excludedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE)); } }
@Inject(value = XWorkConstants.OVERRIDE_ACCEPTED_PATTERNS, required = false) public void setOverrideAcceptedPatterns(String acceptablePatterns) { if (LOG.isWarnEnabled()) { LOG.warn("Overriding accepted patterns [#0] with [#1], be aware that this affects all instances and safety of your application!", XWorkConstants.OVERRIDE_ACCEPTED_PATTERNS, acceptablePatterns); } acceptedPatterns = new HashSet<Pattern>(); for (String pattern : TextParseUtil.commaDelimitedStringToSet(acceptablePatterns)) { acceptedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE)); } }
private void notifyDeveloper(String message, String... parameters) { if (devMode) { LOG.warn(message, parameters); } else { if (LOG.isDebugEnabled()) { LOG.debug(message, parameters); } } }
@Inject(value = XWorkConstants.ADDITIONAL_ACCEPTED_PATTERNS, required = false) public void setAdditionalAcceptedPatterns(String acceptablePatterns) { if (LOG.isDebugEnabled()) { LOG.warn("Adding additional global patterns [#0] to accepted patterns!", acceptablePatterns); } for (String pattern : TextParseUtil.commaDelimitedStringToSet(acceptablePatterns)) { acceptedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE)); } }
protected boolean evaluateExpression(String expression, Object object) throws ValidationException { Object obj = null; try { obj = getFieldValue(expression, object); } catch (ValidationException e) { throw e; } catch (Exception e) { log.error(e.getMessage(), e); // let this pass, but it will be logged right below } Boolean answer = Boolean.FALSE; if (obj != null && obj instanceof Boolean) { answer = (Boolean) obj; } else { log.warn("Got result of " + obj + " when trying to get Boolean for expression " + expression); } return answer; }
void internalSetProperty(String name, Object value, Object o, Map<String, Object> context, boolean throwPropertyExceptions) throws ReflectionException{ try { setValue(name, context, o, value); } catch (OgnlException e) { Throwable reason = e.getReason(); String msg = "Caught OgnlException while setting property '" + name + "' on type '" + o.getClass().getName() + "'."; Throwable exception = (reason == null) ? e : reason; if (throwPropertyExceptions) { throw new ReflectionException(msg, exception); } else if (devMode) { LOG.warn(msg, exception); } } }
private void reloadProviders(List<ContainerProvider> providers) { for (ContainerProvider containerProvider : containerProviders) { try { containerProvider.destroy(); } catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn("error while destroying configuration provider [#0]", e, containerProvider.toString()); } } } packageProviders = this.configuration.reloadContainer(providers); }
/** * Log a failed lookup, being more verbose when devMode=true. * * @param expr The failed expression * @param e The thrown exception. */ private void logLookupFailure(String expr, Exception e) { String msg = LoggerUtils.format("Caught an exception while evaluating expression '#0' against value stack", expr); if (devMode && LOG.isWarnEnabled()) { LOG.warn(msg, e); LOG.warn("NOTE: Previous warning message was issued due to devMode set to true."); } else if (LOG.isDebugEnabled()) { LOG.debug(msg, e); } }
private Object handleOgnlException(String expr, boolean throwExceptionOnFailure, OgnlException e) { Object ret = findInContext(expr); if (ret == null) { if (shouldLogMissingPropertyWarning(e)) { LOG.warn("Could not find property [#0]!", e, expr); } if (throwExceptionOnFailure) { throw new XWorkException(e); } } return ret; }
public void validate(Object object) throws ValidationException { String fieldName = getFieldName(); Boolean answer = Boolean.FALSE; Object obj = null; try { obj = getFieldValue(expression, object); } catch (ValidationException e) { throw e; } catch (Exception e) { // let this pass, but it will be logged right below } if ((obj != null) && (obj instanceof Boolean)) { answer = (Boolean) obj; } else { log.warn("Got result of " + obj + " when trying to get Boolean."); } if (!answer.booleanValue()) { addFieldError(fieldName, object); } } }
private void handleRuntimeException(String expr, Object value, boolean throwExceptionOnFailure, RuntimeException re) { if (throwExceptionOnFailure) { String message = ErrorMessageBuilder.create() .errorSettingExpressionWithValue(expr, value) .build(); throw new XWorkException(message, re); } else { if (LOG.isWarnEnabled()) { LOG.warn("Error setting value [#0] with expression [#1]", re, value.toString(), expr); } } }
private void handleOgnlException(String expr, Object value, boolean throwExceptionOnFailure, OgnlException e) { boolean shouldLog = shouldLogMissingPropertyWarning(e); String msg = null; if (throwExceptionOnFailure || shouldLog) { msg = ErrorMessageBuilder.create() .errorSettingExpressionWithValue(expr, value) .build(); } if (shouldLog) { LOG.warn(msg, e); } if (throwExceptionOnFailure) { throw new XWorkException(msg, e); } }