Package org.mapfish.print.config

Examples of org.mapfish.print.config.ConfigurationException


    }

    @Override
    public void validate(final List<Throwable> validationErrors, final Configuration configuration) {
        if (this.requiredRoles == null) {
            validationErrors.add(new ConfigurationException("requiredRoles must be defined"));
        }
    }
View Full Code Here


    private Integer size = null;

    @Override
    public final void validate(final List<Throwable> validationErrors, final Configuration configuration) {
        if (this.size == null || this.size < 1) {
            validationErrors.add(new ConfigurationException("size field is not legal: " + this.size + " in " + getClass().getName()));
        }
    }
View Full Code Here

    private Integer height = null;

    @Override
    public final void validate(final List<Throwable> validationErrors, final Configuration configuration) {
        if (this.width == null || this.width < 1) {
            validationErrors.add(new ConfigurationException("width field is not legal: " + this.width + " in " + getClass().getName()));
        }

        if (this.height == null || this.height < 1) {
            validationErrors.add(new ConfigurationException("height field is not legal: " + this.height + " in " + getClass().getName()));
        }
    }
View Full Code Here

    }

    @Override
    protected void extraValidation(final List<Throwable> validationErrors, final Configuration configuration) {
        if (this.updates == null) {
            validationErrors.add(new ConfigurationException(
                    "The property 'attributeMap' in the !updatePdfConfig processor is required"));
        } else {
            if (this.updates.isEmpty()) {
                validationErrors.add(new ConfigurationException(
                        "At least one value for 'attributeMap' in !updatePdfConfig should be declared."));
            }
            for (Map.Entry<String, Update> entry : this.updates.entrySet()) {
                entry.getValue().validate(validationErrors, configuration);
            }
View Full Code Here

        }

        @Override
        public void validate(final List<Throwable> validationErrors, final Configuration configuration) {
            if (this.valueKey.isEmpty()) {
                validationErrors.add(new ConfigurationException(
                        "The value of '" + this.property + "' should not be empty. Error in !updatePdfConfig"));
                return;
            }
            if (this.valueKey.charAt(0) == '.') {
                validationErrors.add(new ConfigurationException(
                        "The value of '" + this.property + "' should start with a '.', it was " +
                        this.valueKey + ". Error in !updatePdfConfig"));
                return;
            }

            String[] attributeAccessorDefinition = this.valueKey.split("\\.");
            if (attributeAccessorDefinition.length == 0) {
                validationErrors.add(new ConfigurationException(
                        this.property + ": " + this.valueKey + " is not a valid mapping in !updatePdfConfig"));
                return;
            }

            final PropertyDescriptor propertyDescriptor = BeanUtils.getPropertyDescriptor(PDFConfig.class, this.property);
            if (propertyDescriptor == null || BeanUtils.getWriteMethodParameter(propertyDescriptor) == null) {
                PropertyDescriptor[] descriptors = BeanUtils.getPropertyDescriptors(PDFConfig.class);
                StringBuilder options = new StringBuilder();
                for (PropertyDescriptor descriptor : descriptors) {
                    options.append("\n\t* ").append(descriptor.getName());
                }
                validationErrors.add(new ConfigurationException(
                        "There is no pdf config property called '" + this.property + "'. Options include: " + options));
            }

        }
View Full Code Here

        } else {
            allInputAttributeNames = Collections.emptySet();
        }
        for (String inputAttributeName : this.inputMapper.values()) {
            if (!allInputAttributeNames.contains(inputAttributeName)) {
                errors.add(new ConfigurationException(inputAttributeName + " is not defined in processor '" + this + "'.  Check for " +
                                                        "typos. Options are " + allInputAttributeNames));
            }
        }

        Set<String> allOutputAttributeNames = ParserUtils.getAllAttributeNames(getOutputType());
        for (String outputAttributeName : this.outputMapper.keySet()) {
            if (!allOutputAttributeNames.contains(outputAttributeName)) {
                errors.add(new ConfigurationException(outputAttributeName + " is not defined in processor '" + this + "' as an output " +
                                                        "attribute.  Check for typos. Options are " + allOutputAttributeNames));
            }
        }

        extraValidation(errors, configuration);
View Full Code Here

    }

    @Override
    protected final void extraValidation(final List<Throwable> validationErrors, final Configuration configuration) {
        if (this.paramName == null) {
            validationErrors.add(new ConfigurationException("No paramName defined in " + getClass().getName()));
        }
    }
View Full Code Here

    @Override
    protected void extraValidation(final List<Throwable> validationErrors, final Configuration configuration) {
        final boolean styleRefDeclared = this.firstHeaderStyle != null || this.lastHeaderStyle != null || this.headerStyle != null ||
                                         this.firstDetailStyle != null || this.lastDetailStyle != null || this.detailStyle != null;
        if (styleRefDeclared && this.jasperTemplate == null) {
            validationErrors.add(new ConfigurationException(
                    "if a style is declared a 'jasperTemplate' must also be declared (in !tableProcessor)."));
    }
        if (styleRefDeclared && !this.dynamic) {
            validationErrors.add(new ConfigurationException(
                    "if a style is declared dynamic must be true (in !tableProcessor)."));
    }
        if (this.dynamic) {
            if (this.jasperTemplate == null) {
                validationErrors.add(new ConfigurationException(
                        "'jasperTemplate' property must be declared if !tableProcessor is dynamic."));
    }
            if (this.headerStyle == null) {
                validationErrors.add(new ConfigurationException(
                        "'headerStyle' property must be declared if !tableProcessor is dynamic."));
            }
            if (this.detailStyle == null) {
                validationErrors.add(new ConfigurationException(
                        "'detailStyle' property must be declared if !tableProcessor is dynamic."));
        }

            try {
                byte[] bytes = configuration.loadFile(this.jasperTemplate);
                final JasperDesign templateDesign = JRXmlLoader.load(new ByteArrayInputStream(bytes));
                final Map<String, JRStyle> stylesMap = templateDesign.getStylesMap();
                if (templateDesign.getColumnHeader() == null) {
                    validationErrors.add(new ConfigurationException(
                            "JasperTemplate must have a column band defined for height and positioning information"));
                } else if (templateDesign.getColumnHeader().getElements().length == 0) {
                        validationErrors.add(new ConfigurationException(
                                "column header band must have at least one element defined for to height and positioning information"));
                }

                final JRDesignSection detailSection = (JRDesignSection) templateDesign.getDetailSection();
                if (detailSection.getBands().length == 0) {
                    validationErrors.add(new ConfigurationException(
                            "JasperTemplate must have a detail band defined for height and positioning information"));
                } else if (detailSection.getBands()[0].getElements().length == 0) {
                    validationErrors.add(new ConfigurationException(
                            "detail band must have at least one element defined for to height and positioning information"));
                }

                checkStyleExists(validationErrors, stylesMap, this.firstDetailStyle);
                checkStyleExists(validationErrors, stylesMap, this.detailStyle);
View Full Code Here

    private void checkStyleExists(final List<Throwable> validationErrors,
                                  final Map<String, JRStyle> stylesMap,
                                  final String styleRef) {
        if (styleRef != null && !stylesMap.containsKey(styleRef)) {
            validationErrors.add(new ConfigurationException(
                    "No style with id: '" + styleRef + "' exists in " + this.jasperTemplate));
        }
    }
View Full Code Here

    }

    @Override
    protected void extraValidation(final List<Throwable> validationErrors, final Configuration configuration) {
        if (this.imageType == null) {
            validationErrors.add(new ConfigurationException("No imageType defined in " + getClass().getName()));
        }
    }
View Full Code Here

TOP

Related Classes of org.mapfish.print.config.ConfigurationException

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.