Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java @ 228:dd977fb7552e
Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
artifacts/trunk@1630 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 31 Mar 2011 08:42:53 +0000 |
parents | 98695dc6d94d |
children | fbd57d2eeaef |
comparison
equal
deleted
inserted
replaced
227:4bb6bfaca393 | 228:dd977fb7552e |
---|---|
282 cc.postCall(); | 282 cc.postCall(); |
283 } | 283 } |
284 } | 284 } |
285 } // class DeferredOutputImpl | 285 } // class DeferredOutputImpl |
286 | 286 |
287 | |
288 /** | |
289 * This inner class allows the deferral of writing the output | |
290 * of the artifact's out() call. | |
291 */ | |
292 public class DeferredCollectionOutputImpl | |
293 implements DeferredOutput | |
294 { | |
295 /** | |
296 * The persistence wrapper around a living collection. | |
297 */ | |
298 protected ArtifactCollection collection; | |
299 /** | |
300 * The input document for the collection's out() call. | |
301 */ | |
302 protected Document format; | |
303 /** | |
304 * The meta information of the collection's out() call. | |
305 */ | |
306 protected CallMeta callMeta; | |
307 | |
308 /** | |
309 * Default constructor. | |
310 */ | |
311 public DeferredCollectionOutputImpl() { | |
312 } | |
313 | |
314 /** | |
315 * Constructor to create a deferred execution unit for | |
316 * the collection's out() call given a collection, an input document | |
317 * an the meta information. | |
318 * @param collection The collection. | |
319 * @param format The input document for the collection's out() call. | |
320 * @param callMeta The meta information of the collection's out() call. | |
321 */ | |
322 public DeferredCollectionOutputImpl( | |
323 ArtifactCollection collection, | |
324 Document format, | |
325 CallMeta callMeta | |
326 ) { | |
327 this.collection = collection; | |
328 this.format = format; | |
329 this.callMeta = callMeta; | |
330 } | |
331 | |
332 public void write(OutputStream output) throws IOException { | |
333 | |
334 CollectionCallContext cc = new CollectionCallContext( | |
335 ArtifactDatabaseImpl.this, | |
336 CallContext.TOUCH, | |
337 callMeta, | |
338 context, | |
339 collection); | |
340 | |
341 try { | |
342 collection.out(format, output, cc); | |
343 } | |
344 finally { | |
345 cc.postCall(); | |
346 } | |
347 } | |
348 } // class DeferredCollectionOutputImpl | |
349 | |
287 /** | 350 /** |
288 * List of name/description pairs needed for | 351 * List of name/description pairs needed for |
289 * {@link #artifactFactoryNamesAndDescriptions() }. | 352 * {@link #artifactFactoryNamesAndDescriptions() }. |
290 */ | 353 */ |
291 protected String [][] factoryNamesAndDescription; | 354 protected String [][] factoryNamesAndDescription; |
1352 return result; | 1415 return result; |
1353 } | 1416 } |
1354 | 1417 |
1355 public DeferredOutput outCollection(String collectionId, | 1418 public DeferredOutput outCollection(String collectionId, |
1356 Document format, CallMeta callMeta) | 1419 Document format, CallMeta callMeta) |
1357 throws ArtifactDatabaseException{ | 1420 throws ArtifactDatabaseException |
1358 throw new ArtifactDatabaseException("Not implemented, yet!"); | 1421 { |
1422 ArtifactCollectionFactory acf = getArtifactCollectionFactory(); | |
1423 | |
1424 if (acf == null) { | |
1425 throw new ArtifactDatabaseException(NO_SUCH_FACTORY); | |
1426 } | |
1427 | |
1428 UserFactory uf = getUserFactory(); | |
1429 if (uf == null) { | |
1430 throw new ArtifactDatabaseException(NO_SUCH_FACTORY); | |
1431 } | |
1432 | |
1433 ArtifactCollection c = backend.getCollection( | |
1434 collectionId, acf, uf, context); | |
1435 | |
1436 if (c == null) { | |
1437 logger.warn("No collection found with identifier: " + collectionId); | |
1438 throw new ArtifactDatabaseException(NO_SUCH_COLLECTION); | |
1439 } | |
1440 | |
1441 CallContext cc = new CollectionCallContext( | |
1442 ArtifactDatabaseImpl.this, | |
1443 CallContext.NOTHING, | |
1444 callMeta, | |
1445 context, | |
1446 c); | |
1447 | |
1448 return new DeferredCollectionOutputImpl(c, format, callMeta); | |
1359 } | 1449 } |
1360 } | 1450 } |
1361 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 1451 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |