# HG changeset patch # User Ingo Weinzierl # Date 1323943742 0 # Node ID 158b3aabda2c9f98421ea6d1d6bc04c6af0cf650 # Parent 382e38164200bd1cd3748d4d714b27bab643a9f1 Prepare the OutGenerator during the describe() operation of the FLYS Collection to enable the OutGenerator to return an initial Settings object. flys-artifacts/trunk@3422 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 382e38164200 -r 158b3aabda2c flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Thu Dec 15 09:43:54 2011 +0000 +++ b/flys-artifacts/ChangeLog Thu Dec 15 10:09:02 2011 +0000 @@ -1,3 +1,9 @@ +2011-12-15 Ingo Weinzierl + + * src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java: + Prepare the OutGenerator (process each of the Output's Facets) during the + describe() operation to be able to return an initial Settings object. + 2011-12-15 Ingo Weinzierl * src/main/java/de/intevation/flys/exports/BooleanAttribute.java, diff -r 382e38164200 -r 158b3aabda2c flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java --- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java Thu Dec 15 09:43:54 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java Thu Dec 15 10:09:02 2011 +0000 @@ -245,8 +245,21 @@ protected Settings createInitialOutputSettings(CallContext cc, String out) { OutGenerator outGen = getOutGenerator(cc, out, null); - // TODO simulate a real out() process and return finally the Settings - // object retrieved by the OutGenerator. + // XXX NOTE: the outGen is not able to process its generate() operation, + // because it has no OutputStream set! + outGen.init(XMLUtils.newDocument(), null, cc); + prepareMasterArtifact(outGen, cc); + + try { + Document attr = getAttribute(cc, out); + doOut(outGen, out, out, attr, cc); + } + catch (ArtifactDatabaseException adbe) { + log.error(adbe, adbe); + } + catch (IOException ioe) { + log.error(ioe, ioe); + } return outGen.getSettings(); } @@ -291,24 +304,36 @@ } generator.init(format, out, context); + prepareMasterArtifact(generator, context); + try { + Document attr = getAttribute(context, name); + doOut(generator, name, subtype, attr, context); + generator.generate(); + } + catch (ArtifactDatabaseException adbe) { + log.error(adbe, adbe); + } + } + + + /** + * Sets the master Artifact at the given generator. + * + * @param generator The generator that gets a master Artifact. + * @param cc The CallContext. + */ + protected void prepareMasterArtifact(OutGenerator generator, CallContext cc + ) { // Get master artifact. - FLYSArtifact master = getMasterArtifact(context); + FLYSArtifact master = getMasterArtifact(cc); if (master != null) { - log.debug("Will set master Artifact to uuid: " + master.identifier()); + log.debug("Set master Artifact to uuid: " + master.identifier()); generator.setMasterArtifact(master); } else { log.warn("Could not set master artifact."); } - - try { - Document attr = getAttribute(context, name); - doOut(generator, name, subtype, attr, context); - } - catch (ArtifactDatabaseException adbe) { - log.error(adbe, adbe); - } } @@ -376,8 +401,6 @@ catch (ArtifactDatabaseException ade) { log.error(ade, ade); } - - generator.generate(); }