Skip to content

Commit

Permalink
createDataSource now default to no processor
Browse files Browse the repository at this point in the history
Was crashing if no processor was configured.
  • Loading branch information
Patrick Valsecchi committed Mar 29, 2017
1 parent b1864c7 commit 0b3214b
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.PostConstruct;

import static org.mapfish.print.attribute.DataSourceAttribute.DataSourceAttributeValue;

Expand Down Expand Up @@ -83,6 +85,12 @@ public DataSourceProcessor() {
super(Output.class);
}

@PostConstruct
private void init() {
// default to no processors
this.processorGraph = this.processorGraphFactory.build(Collections.<Processor>emptyList());
}

/**
* The path to the report template used to render each row of the data. This is only required if a subreport needs to be
* compiled and is referenced in the containing report's detail section.
Expand Down Expand Up @@ -202,10 +210,6 @@ private void addAttributes(@Nonnull final Template template,

@Override
protected void extraValidation(final List<Throwable> validationErrors, final Configuration configuration) {
if (this.processorGraph == null) {
validationErrors.add(new ConfigurationException("There are child processors for this processor"));
}

if (this.reportTemplate != null && this.reportKey == null || this.reportTemplate == null && this.reportKey != null) {
validationErrors.add(new ConfigurationException("'reportKey' and 'reportTemplate' must either both be null or both" +
" be non-null. reportKey: " + this.reportKey +
Expand All @@ -215,9 +219,13 @@ protected void extraValidation(final List<Throwable> validationErrors, final Con
attribute.validate(validationErrors, configuration);
}

final Set<Processor<?, ?>> allProcessors = this.processorGraph.getAllProcessors();
for (Processor<?, ?> processor : allProcessors) {
processor.validate(validationErrors, configuration);
if (this.processorGraph == null) {
validationErrors.add(new ConfigurationException("There are no child processors for this processor"));
} else {
final Set<Processor<?, ?>> allProcessors = this.processorGraph.getAllProcessors();
for (Processor<?, ?> processor : allProcessors) {
processor.validate(validationErrors, configuration);
}
}
}

Expand Down

0 comments on commit 0b3214b

Please sign in to comment.