Package net.sourceforge.stripes.exception

Examples of net.sourceforge.stripes.exception.StripesRuntimeException


                }
            }
        }

        if (configuration == null) {
            StripesRuntimeException sre = new StripesRuntimeException(
                    "Something is trying to access the current Stripes configuration but the " +
                    "current request was never routed through the StripesFilter! As a result " +
                    "the appropriate Configuration object cannot be located. Please take a look " +
                    "at the exact URL in your browser's address bar and ensure that any " +
                    "requests to that URL will be filtered through the StripesFilter according " +
View Full Code Here


            evaluate(new ImplicitAllow());
            evaluate(new HonorValidateAnnotations());
            evaluate(new OverrideValidateAnnotations());
        }
        catch (Exception e) {
            StripesRuntimeException re = new StripesRuntimeException(e.getMessage(), e);
            re.setStackTrace(e.getStackTrace());
            throw re;
        }
    }
View Full Code Here

        else {
            try {
                out = new PrintStream(filename);
            }
            catch (FileNotFoundException fnfe) {
                throw new StripesRuntimeException("Could not open the requested output file " +
                    "for writing. Please check that file '" + filename + "' can be created " +
                     "and/or written to.", fnfe);
            }
        }

        // And in what format
        String format = getOption(FORMAT_PARAM);
        if (format == null) {
            if (filename != null && filename.endsWith("xml")) {
                format = "xml";
            }
            else {
                format = "text";
            }
        }

        // And then finally print out the output
        if ("text".equals(format)) {
            printTextFormat(out);
        }
        else if ("xml".equals(format)) {
            printXmlFormat(out);
        }
        else {
            throw new StripesRuntimeException("Unknown format requested: " + format + ". " +
                "Supported formats are 'text' and 'xml'.");
        }
    }
View Full Code Here

    }

    /** Default constructor that throws an exception if the JSP2.1 APIs are not available. */
    public Jsp21ExpressionExecutor() {
        if (getExpressionFactory() == null) {
            throw new StripesRuntimeException("Could not create a JSP2.1 ExpressionFactory.");
        }
    }
View Full Code Here

                // If this turns out to be slow we could probably cache the parsed expression
                expression = factory.createValueExpression(ctx, expressionString, Boolean.class);
            }
        }
        catch (ELException ele) {
            throw new StripesRuntimeException(
                    "Could not parse the EL expression being used to validate field " +
                    name.getName() + ". This is not a transient error. Please double " +
                    "check the following expression for errors: " +
                    validationInfo.expression(), ele);
        }
View Full Code Here

                                buf.append(" and ");
                            if (hasNested)
                                buf.append("@ValidateNestedProperties");
                            buf.append('\n');
                        }
                        throw new StripesRuntimeException(buf.toString());
                    }

                    // after the conflict check, stop processing fields we've already seen
                    if (seen.contains(propertyName))
                        continue;

                    // get the @Validate and/or @ValidateNestedProperties
                    Validate simple;
                    ValidateNestedProperties nested;
                    if (onAccessor) {
                        simple = accessor.getAnnotation(Validate.class);
                        nested = accessor.getAnnotation(ValidateNestedProperties.class);
                        seen.add(propertyName);
                    }
                    else if (onMutator) {
                        simple = mutator.getAnnotation(Validate.class);
                        nested = mutator.getAnnotation(ValidateNestedProperties.class);
                        seen.add(propertyName);
                    }
                    else if (onField) {
                        simple = field.getAnnotation(Validate.class);
                        nested = field.getAnnotation(ValidateNestedProperties.class);
                        seen.add(propertyName);
                    }
                    else {
                        simple = null;
                        nested = null;
                    }

                    // add to allow list if @Validate present
                    if (simple != null) {
                        if (simple.field() == null || "".equals(simple.field())) {
                            meta.put(propertyName, new ValidationMetadata(propertyName, simple));
                        }
                        else {
                            log.warn("Field name present in @Validate but should be omitted: ",
                                    clazz, ", property ", propertyName, ", given field name ",
                                    simple.field());
                        }
                    }

                    // add all sub-properties referenced in @ValidateNestedProperties
                    if (nested != null) {
                        Validate[] validates = nested.value();
                        if (validates != null) {
                            for (Validate validate : validates) {
                                if (validate.field() != null && !"".equals(validate.field())) {
                                    String fullName = propertyName + '.' + validate.field();
                                    if (meta.containsKey(fullName)) {
                                        log.warn("More than one nested @Validate with same field name: "
                                            + validate.field() + " on property " + propertyName);
                                    }
                                    meta.put(fullName, new ValidationMetadata(fullName, validate));
                                }
                                else {
                                    log.warn("Field name missing from nested @Validate: ", clazz,
                                            ", property ", propertyName);
                                }
                            }
                        }
                    }
                }
            }
        }
        catch (RuntimeException e) {
            log.error(e, "Failure checking @Validate annotations ", getClass().getName());
            throw e;
        }
        catch (Exception e) {
            log.error(e, "Failure checking @Validate annotations ", getClass().getName());
            StripesRuntimeException sre = new StripesRuntimeException(e.getMessage(), e);
            sre.setStackTrace(e.getStackTrace());
            throw sre;
        }

        // Print out a pretty debug message showing what validations got configured
        StringBuilder builder = new StringBuilder(128);
View Full Code Here

            String contents = ((StringWriter) writers.poll()).toString();
            log.trace("Closed buffer: \"", contents, "\"");
            return contents;
        }
        else {
            throw new StripesRuntimeException(
                    "Attempt to close a buffer without having first called openBuffer(..)!");
        }
    }
View Full Code Here

        }
        else if (out instanceof StringWriter) {
            ((StringWriter) out).getBuffer().setLength(0);
        }
        else {
            throw new StripesRuntimeException("How did I get a writer of type "
                    + out.getClass().getName() + "??");
        }
    }
View Full Code Here

                String expression = validationInfo.expression();
                expr = evaluator.parseExpression(expression, Boolean.class, null);
                resolver = new BeanVariableResolver(bean);
            }
            catch (ELException ele) {
                throw new StripesRuntimeException(
                        "Could not parse the EL expression being used to validate field " +
                        name.getName() + ". This is not a transient error. Please double " +
                        "check the following expression for errors: " +
                        validationInfo.expression(), ele);
            }
View Full Code Here

                    log.warn("Error closing input stream", e);
                }
            }
        }
        else {
            throw new StripesRuntimeException("A StreamingResolution was constructed without " +
                    "supplying a Reader or InputStream, but stream() was not overridden. Please " +
                    "either supply a source of streaming data, or override the stream() method.");
        }
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.stripes.exception.StripesRuntimeException

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.