diff artifacts/src/main/java/de/intevation/artifacts/ArtifactCollection.java @ 115:a1200c6ed048

Initial interfaces to handle with Collections and Users. artifacts/trunk@1338 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 01 Mar 2011 12:17:00 +0000
parents
children 2707b7ec273f
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/de/intevation/artifacts/ArtifactCollection.java	Tue Mar 01 12:17:00 2011 +0000
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2011 by Intevation GmbH
+ *
+ * This program is free software under the LGPL (>=v2.1)
+ * Read the file LGPL.txt coming with the software for details
+ * or visit http://www.gnu.org/licenses/ if it does not exist.
+ */
+
+package de.intevation.artifacts;
+
+import org.w3c.dom.Document;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Serializable;
+
+public interface ArtifactCollection
+extends          Serializable
+{
+    /**
+     * Set a new identifier for this collection.
+     * @param identifier New identifier for this collection.
+     */
+    void setIdentifier(String identifier);
+
+    /**
+     * Identify this collection.
+     * @return Returns unique string to identify this collection globally.
+     */
+    String identifier();
+
+    /**
+     * Set a new owner of this collection.
+     * @param user New owner for this collection.
+     */
+    void setUser(User user);
+
+    /**
+     * Identify the owner of the collection.
+     * @return Returns owner of the collection.
+     */
+    User getUser(); // FIXME: Is ArtifactCollectionFactory needed?
+
+    /**
+     * When created by a factory this method is called to
+     * initialize the collection.
+     * @param identifier The identifier from collection database
+     * @param factory    The factory which created this collection.
+     * @param context    The global context of the runtime system.
+     * @param data       The data which can be use to setup a collection with
+     *                   more details.
+     */
+    void setup(
+        String                    identifier,
+        ArtifactCollectionFactory factory,
+        Object                    context,
+        Document                  data);
+
+    //TODO: create LifeCycle interface
+    /**
+     * Called from artifact database when an artifact is
+     * going to be removed from system.
+     * @param context The global context of the runtime system.
+     */
+    void endOfLife(Object context);
+
+    /**
+     * Internal hash of this collection.
+     * @return Returns hash that should stay the same if the internal
+     *         value has not changed. Useful for caching
+     */
+    String hash();
+
+
+    /**
+     * Called from artifact database before an artifact is
+     * going to be exported as xml document.
+     * @param context The global context of the runtime system.
+     */
+    void cleanup(Object context);
+
+
+    void addArtifact(Artifact artifact, Document attributes);
+
+    void removeArtifact(Artifact artifact);
+
+    Artifact [] getArtifacts();
+
+    Document getAttribute(Artifact artifact);
+
+    void setAtribute(Artifact artifact, Document document);
+
+    /**
+     * Produce output for this collection.
+     * @param format Specifies the format of the output.
+     * @param out Stream to write the result data to.
+     * @param context The global context of the runtime system.
+     * @throws IOException Thrown if an I/O occurs.
+     */
+    void out(
+        Document     format,
+        OutputStream out,
+        CallContext  context)
+    throws IOException;
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org