Closed tarrox closed 6 years ago
Maybe something like:
if (item.get("@drsFile") != null && url == "") {
// use @drsFile
} else {
// use url
}
So streams does apparently not allow to create an empty or null url by setting the property to an empty string.
What I came up with was setting -Ddrsfile=file:
and using:
@Override
public void init(ProcessContext processContext) throws Exception {
if (url != null) {
if (!url.getPath().equals("")) {
try {
loadDrsData(url);
} catch (Exception e) {
log.error("Could not load .drs file specified in the url.");
throw new RuntimeException(e.getMessage());
}
} else {
url = null;
}
}
}
But I don't really like it. Anybody got a better idea?
Another option would be to switch the url to a string and convert it if needed. That way we could set it as empty. Although this wouldn't be a good solution either, i would even say worse.
Another way would be to skip the whole init function and simply load the url if needed in the process function, basically taking @drsfile
and if not given use the url parameter, if this fails, just abort as usual. That way we wouldn't need to check for an empty path as a way to check which method to use. Instead the drskey is always used if given.
I think this option would be the cleanest.
simply load the url if needed in the process function
The checking is done by streams at the xml Parsing level. The only thing would be make it a string and convert to url.
The checking is done by streams at the xml Parsing level. The only thing would be make it a string and convert to url.
We would set the url to -Ddrsfile=file:
or -Ddrsfile=file:whatever
but wouldn't bother checking it in any special way, as we would priorities the information from the @drsfile
and if that isn't given we load the url which would fail, which would be fine as no correct drs information was given, which should result in a failure.
Currently the
DrsCalibration
in thecalibration.xml
uses theurl="${drsfile}"
method of getting the drs file, which makes the xml incompatible with the use ofFactFileMultistream
. I think it would be nice if it would work with it, as it means one can just reuse it.There are two options I can think of to make this work:
ulr=${drsfile}
and have a processor that injects the${drsfile}
into the datastream as the@drsFile
item.DrsCalibration
-Processor switches to the@drsFile
option if the given url can't be read (For example because the string is empty or because it couldn't be read).