comparison artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java @ 269:d9a99b28a847

Added support for the 'type' parameter of artifacts and collections out() call. artifacts/trunk@2030 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 31 May 2011 14:53:36 +0000
parents 4edaf3073109
children 22a90706d32d
comparison
equal deleted inserted replaced
268:4edaf3073109 269:d9a99b28a847
233 /** 233 /**
234 * The persistence wrapper around a living artifact. 234 * The persistence wrapper around a living artifact.
235 */ 235 */
236 protected PersistentArtifact artifact; 236 protected PersistentArtifact artifact;
237 /** 237 /**
238 * The output type.
239 */
240 protected String type;
241 /**
238 * The input document for the artifact's out() call. 242 * The input document for the artifact's out() call.
239 */ 243 */
240 protected Document format; 244 protected Document format;
241 /** 245 /**
242 * The meta information of the artifact's out() call. 246 * The meta information of the artifact's out() call.
257 * @param format The input document for the artifact's out() call. 261 * @param format The input document for the artifact's out() call.
258 * @param callMeta The meta information of the artifact's out() call. 262 * @param callMeta The meta information of the artifact's out() call.
259 */ 263 */
260 public DeferredOutputImpl( 264 public DeferredOutputImpl(
261 PersistentArtifact artifact, 265 PersistentArtifact artifact,
266 String type,
262 Document format, 267 Document format,
263 CallMeta callMeta 268 CallMeta callMeta
264 ) { 269 ) {
265 this.artifact = artifact; 270 this.artifact = artifact;
271 this.type = type;
266 this.format = format; 272 this.format = format;
267 this.callMeta = callMeta; 273 this.callMeta = callMeta;
268 } 274 }
269 275
270 public void write(OutputStream output) throws IOException { 276 public void write(OutputStream output) throws IOException {
274 CallContext.TOUCH, 280 CallContext.TOUCH,
275 callMeta, 281 callMeta,
276 artifact); 282 artifact);
277 283
278 try { 284 try {
279 artifact.getArtifact().out(format, output, cc); 285 artifact.getArtifact().out(type, format, output, cc);
280 } 286 }
281 finally { 287 finally {
282 cc.postCall(); 288 cc.postCall();
283 } 289 }
284 } 290 }
294 { 300 {
295 /** 301 /**
296 * The persistence wrapper around a living collection. 302 * The persistence wrapper around a living collection.
297 */ 303 */
298 protected ArtifactCollection collection; 304 protected ArtifactCollection collection;
305 /**
306 * The output type.
307 */
308 protected String type;
299 /** 309 /**
300 * The input document for the collection's out() call. 310 * The input document for the collection's out() call.
301 */ 311 */
302 protected Document format; 312 protected Document format;
303 /** 313 /**
319 * @param format The input document for the collection's out() call. 329 * @param format The input document for the collection's out() call.
320 * @param callMeta The meta information of the collection's out() call. 330 * @param callMeta The meta information of the collection's out() call.
321 */ 331 */
322 public DeferredCollectionOutputImpl( 332 public DeferredCollectionOutputImpl(
323 ArtifactCollection collection, 333 ArtifactCollection collection,
334 String type,
324 Document format, 335 Document format,
325 CallMeta callMeta 336 CallMeta callMeta
326 ) { 337 ) {
327 this.collection = collection; 338 this.collection = collection;
339 this.type = type;
328 this.format = format; 340 this.format = format;
329 this.callMeta = callMeta; 341 this.callMeta = callMeta;
330 } 342 }
331 343
332 public void write(OutputStream output) throws IOException { 344 public void write(OutputStream output) throws IOException {
336 CallContext.TOUCH, 348 CallContext.TOUCH,
337 callMeta, 349 callMeta,
338 collection); 350 collection);
339 351
340 try { 352 try {
341 collection.out(format, output, cc); 353 collection.out(type, format, output, cc);
342 } 354 }
343 finally { 355 finally {
344 cc.postCall(); 356 cc.postCall();
345 } 357 }
346 } 358 }
748 } 760 }
749 761
750 public DeferredOutput out( 762 public DeferredOutput out(
751 String identifier, 763 String identifier,
752 Document format, 764 Document format,
765 CallMeta callMeta)
766 throws ArtifactDatabaseException
767 {
768 return out(identifier, null, format, callMeta);
769 }
770
771 public DeferredOutput out(
772 String identifier,
773 String type,
774 Document format,
753 CallMeta callMeta 775 CallMeta callMeta
754 ) 776 )
755 throws ArtifactDatabaseException 777 throws ArtifactDatabaseException
756 { 778 {
757 // TODO: Handle background tasks 779 // TODO: Handle background tasks
759 781
760 if (artifact == null) { 782 if (artifact == null) {
761 throw new ArtifactDatabaseException(NO_SUCH_ARTIFACT); 783 throw new ArtifactDatabaseException(NO_SUCH_ARTIFACT);
762 } 784 }
763 785
764 return new DeferredOutputImpl(artifact, format, callMeta); 786 return new DeferredOutputImpl(artifact, type, format, callMeta);
765 } 787 }
766 788
767 public Document exportArtifact(String artifact, CallMeta callMeta) 789 public Document exportArtifact(String artifact, CallMeta callMeta)
768 throws ArtifactDatabaseException 790 throws ArtifactDatabaseException
769 { 791 {
1461 result.appendChild(root); 1483 result.appendChild(root);
1462 1484
1463 return result; 1485 return result;
1464 } 1486 }
1465 1487
1466 public DeferredOutput outCollection(String collectionId, 1488 public DeferredOutput outCollection(
1467 Document format, CallMeta callMeta) 1489 String collectionId,
1468 throws ArtifactDatabaseException 1490 Document format,
1491 CallMeta callMeta)
1492 throws ArtifactDatabaseException
1493 {
1494 return outCollection(collectionId, null, format, callMeta);
1495 }
1496
1497 public DeferredOutput outCollection(
1498 String collectionId,
1499 String type,
1500 Document format,
1501 CallMeta callMeta)
1502 throws ArtifactDatabaseException
1469 { 1503 {
1470 ArtifactCollectionFactory acf = getArtifactCollectionFactory(); 1504 ArtifactCollectionFactory acf = getArtifactCollectionFactory();
1471 1505
1472 if (acf == null) { 1506 if (acf == null) {
1473 throw new ArtifactDatabaseException(NO_SUCH_FACTORY); 1507 throw new ArtifactDatabaseException(NO_SUCH_FACTORY);
1491 CallContext.NOTHING, 1525 CallContext.NOTHING,
1492 callMeta, 1526 callMeta,
1493 c); 1527 c);
1494 1528
1495 try { 1529 try {
1496 return new DeferredCollectionOutputImpl(c, format, callMeta); 1530 return new DeferredCollectionOutputImpl(c, type, format, callMeta);
1497 } 1531 }
1498 finally { 1532 finally {
1499 cc.postCall(); 1533 cc.postCall();
1500 } 1534 }
1501 } 1535 }

http://dive4elements.wald.intevation.org