annotate artifact-database/src/main/java/org/dive4elements/artifactdatabase/ArtifactDatabaseImpl.java @ 562:05caf2e731d0

Allow to add additional restful services via configuration.
author gernotbelger
date Wed, 10 Oct 2018 20:07:58 +0200
parents 68f01f10624e
children
rev   line source
100
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 94
diff changeset
1 /*
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 94
diff changeset
2 * Copyright (c) 2010 by Intevation GmbH
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 94
diff changeset
3 *
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 94
diff changeset
4 * This program is free software under the LGPL (>=v2.1)
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 94
diff changeset
5 * Read the file LGPL.txt coming with the software for details
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 94
diff changeset
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 94
diff changeset
7 */
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 94
diff changeset
8
475
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
9 package org.dive4elements.artifactdatabase;
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
10
475
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
11 import org.dive4elements.artifacts.common.utils.XMLUtils;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
12 import org.dive4elements.artifacts.common.utils.StringUtils;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
13
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
14 import org.dive4elements.artifactdatabase.Backend.PersistentArtifact;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
15
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
16 import org.dive4elements.artifacts.Artifact;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
17 import org.dive4elements.artifacts.ArtifactCollection;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
18 import org.dive4elements.artifacts.ArtifactCollectionFactory;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
19 import org.dive4elements.artifacts.ArtifactDatabase;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
20 import org.dive4elements.artifacts.ArtifactDatabaseException;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
21 import org.dive4elements.artifacts.ArtifactFactory;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
22 import org.dive4elements.artifacts.ArtifactNamespaceContext;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
23 import org.dive4elements.artifacts.ArtifactSerializer;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
24 import org.dive4elements.artifacts.CallContext;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
25 import org.dive4elements.artifacts.CallMeta;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
26 import org.dive4elements.artifacts.CollectionItem;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
27 import org.dive4elements.artifacts.GlobalContext;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
28 import org.dive4elements.artifacts.Hook;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
29 import org.dive4elements.artifacts.Message;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
30 import org.dive4elements.artifacts.Service;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
31 import org.dive4elements.artifacts.ServiceFactory;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
32 import org.dive4elements.artifacts.User;
415df0fc4fa1 Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents: 473
diff changeset
33 import org.dive4elements.artifacts.UserFactory;
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
34
75
d4c4c23847f5 Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents: 70
diff changeset
35 import java.io.IOException;
d4c4c23847f5 Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents: 70
diff changeset
36 import java.io.OutputStream;
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
37
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
38 import java.security.MessageDigest;
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
39 import java.security.NoSuchAlgorithmException;
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
40
80
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
41 import java.util.Arrays;
168
f70977cf2faf Avoid Nullpointer exception in listCollections() when no creation time of the collection is returned.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 167
diff changeset
42 import java.util.Date;
75
d4c4c23847f5 Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents: 70
diff changeset
43 import java.util.HashMap;
d4c4c23847f5 Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents: 70
diff changeset
44 import java.util.HashSet;
331
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
45 import java.util.LinkedList;
292
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
46 import java.util.List;
331
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
47 import java.util.Map;
230
fbd57d2eeaef Changed semantics of locked artifact ids.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 228
diff changeset
48 import java.util.Set;
75
d4c4c23847f5 Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents: 70
diff changeset
49
160
dc687827439f Enabled the artifact database to store and load roles of users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 159
diff changeset
50 import javax.xml.xpath.XPathConstants;
dc687827439f Enabled the artifact database to store and load roles of users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 159
diff changeset
51
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
52 import org.apache.commons.codec.binary.Base64;
80
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
53 import org.apache.commons.codec.binary.Hex;
75
d4c4c23847f5 Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents: 70
diff changeset
54
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
55 import org.apache.log4j.Logger;
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
56
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
57 import org.w3c.dom.Document;
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
58 import org.w3c.dom.Element;
160
dc687827439f Enabled the artifact database to store and load roles of users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 159
diff changeset
59 import org.w3c.dom.Node;
70
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
60
13
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 /**
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
62 * The core implementation of artifact database. This layer exposes
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
63 * the needed methods to the artifact runtime system which e.g. may
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
64 * expose them via REST. The concrete persistent representation of the
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
65 * artifacts is handled by the {@link Backend backend}.
80
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
66 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
13
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67 */
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 public class ArtifactDatabaseImpl
233
16cd059945e5 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 230
diff changeset
69 implements ArtifactDatabase,
230
fbd57d2eeaef Changed semantics of locked artifact ids.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 228
diff changeset
70 DatabaseCleaner.LockedIdsProvider,
fbd57d2eeaef Changed semantics of locked artifact ids.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 228
diff changeset
71 Backend.FactoryLookup
13
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72 {
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
73 private static Logger logger =
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
74 Logger.getLogger(ArtifactDatabaseImpl.class);
13
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75
293
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
76 /** The key under which the artifact database is stored in the global
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
77 * context.*/
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
78 public static final String GLOBAL_CONTEXT_KEY = "global.artifact.database";
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
79
153
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
80 /** Message that is returned if an operation was successful.*/
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
81 public static final String OPERATION_SUCCESSFUL =
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
82 "SUCCESS";
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
83
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
84 /** Message that is returned if an operation failed.*/
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
85 public static final String OPERATION_FAILURE =
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
86 "FAILURE";
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
87
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
88 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
89 * Error message issued if a requested artifact factory
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
90 * is not registered to this database.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
91 */
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
92 public static final String NO_SUCH_FACTORY =
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
93 "No such factory";
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
94
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
95 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
96 * Error message issued if a requested artifact is not found
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
97 * in this database.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
98 */
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
99 public static final String NO_SUCH_ARTIFACT =
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
100 "No such artifact";
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
101
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
102 /**
222
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
103 * Error message issued if a requested artifact is not found
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
104 * in this database.
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
105 */
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
106 public static final String NO_SUCH_COLLECTION =
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
107 "No such collection";
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
108
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
109 /**
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
110 * Error message issued if the creation of an artifact failed.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
111 */
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
112 public static final String CREATION_FAILED =
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
113 "Creation of artifact failed";
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
114
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
115 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
116 * Error message if an severe internal error occurred.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
117 */
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
118 public static final String INTERNAL_ERROR =
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
119 "Creation of artifact failed";
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
120
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
121 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
122 * Error message issued if a requested service is not
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
123 * offered by this database.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
124 */
70
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
125 public static final String NO_SUCH_SERVICE =
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
126 "No such service";
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
127
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
128 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
129 * Default digest hash to be used while im-/exporting artifacts.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
130 */
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
131 public static final String DIGEST_ALGORITHM =
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
132 "SHA-1";
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
133
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
134 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
135 * XPath to get the checksum from an XML representation of
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
136 * an exported artifact.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
137 */
80
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
138 public static final String XPATH_IMPORT_CHECKSUM =
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
139 "/art:action/art:data/@checksum";
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
140
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
141 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
142 * XPath to get the name of the factory which should be
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
143 * used to revive an antrifact that is going to be imported.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
144 */
80
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
145 public static final String XPATH_IMPORT_FACTORY =
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
146 "/art:action/art:data/@factory";
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
147
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
148 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
149 * XPath to get the base64 encoded data of an artifact
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
150 * that is going to be imported.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
151 */
80
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
152 public static final String XPATH_IMPORT_DATA =
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
153 "/art:action/art:data/text()";
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
154
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
155 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
156 * Error message issued if the checksum of an
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
157 * artifact to be imported has an invalid syntax.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
158 */
80
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
159 public static final String INVALID_CHECKSUM =
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
160 "Invalid checksum";
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
161
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
162 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
163 * Error message issued the checksum validation
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
164 * of an artifact to be imported fails.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
165 */
80
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
166 public static final String CHECKSUM_MISMATCH =
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
167 "Mismatching checksum";
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
168
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
169 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
170 * Error message issued if an artifact to be imported
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
171 * does not have any data.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
172 */
80
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
173 public static final String NO_DATA =
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
174 "No data";
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
175
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
176 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
177 * Error message issued if the deserialization of
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
178 * an artifact to be imported fails.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
179 */
80
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
180 public static final String INVALID_ARTIFACT =
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
181 "Invalid artifact";
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
182
149
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
183
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
184 // User constants
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
185
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
186 /**
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
187 * Error message issued if the creation of a user failed.
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
188 */
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
189 public static final String USER_CREATION_FAILED =
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
190 "Creation of user failed.";
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
191
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
192 /** XPath to figure out the name of a new user.*/
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
193 public static final String XPATH_USERNAME =
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
194 "/art:action/art:user/@name";
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
195
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
196 /** XPath to figure out the role of a new user.*/
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
197 public static final String XPATH_USERROLE =
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
198 "/art:action/art:user/art:role";
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
199
415
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
200 /** XPath to figure out the account of a new user.*/
411
20f12944c710 Add user account information when creating a user in the artifact database
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 395
diff changeset
201 public static final String XPATH_USERACCOUNT =
20f12944c710 Add user account information when creating a user in the artifact database
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 395
diff changeset
202 "/art:action/art:user/art:account/@name";
20f12944c710 Add user account information when creating a user in the artifact database
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 395
diff changeset
203
415
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
204 /** XPath to figure out the account of when searching for a user .*/
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
205 public static final String XPATH_USERACCOUNT_FIND =
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
206 "/art:action/art:account/@name";
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
207
152
7e5619115d5b Implemented the deleteUser() method in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 150
diff changeset
208 /** Error message if a specified user does not exist.*/
7e5619115d5b Implemented the deleteUser() method in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 150
diff changeset
209 public static final String NO_SUCH_USER =
7e5619115d5b Implemented the deleteUser() method in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 150
diff changeset
210 "No such user";
7e5619115d5b Implemented the deleteUser() method in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 150
diff changeset
211
149
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
212 /** Error message if no username is given for user creation.*/
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
213 public static final String NO_USERNAME =
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
214 "Invalid username";
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
215
411
20f12944c710 Add user account information when creating a user in the artifact database
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 395
diff changeset
216 /** Error message if no user account is given for user creation.*/
20f12944c710 Add user account information when creating a user in the artifact database
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 395
diff changeset
217 public static final String NO_USERACCOUNT =
20f12944c710 Add user account information when creating a user in the artifact database
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 395
diff changeset
218 "Invalid user account name";
20f12944c710 Add user account information when creating a user in the artifact database
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 395
diff changeset
219
158
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
220 // Collection constants
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
221
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
222 /**
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
223 * Error message issued if the creation of a collection failed.
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
224 */
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
225 public static final String COLLECTION_CREATION_FAILED =
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
226 "Creation of collection failed";
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
227
162
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
228 /**
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
229 * XPath to figure out the name of a collection described in the incoming
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
230 * document.
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
231 */
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
232 public static final String XPATH_COLLECTION_NAME =
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
233 "/art:action/art:type/art:collection/@name";
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
234
189
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
235 /**
198
6370369412e9 Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 196
diff changeset
236 * XPath to figure out the attributes for a collection.
6370369412e9 Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 196
diff changeset
237 */
6370369412e9 Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 196
diff changeset
238 public static final String XPATH_COLLECTION_ATTRIBUTE =
6370369412e9 Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 196
diff changeset
239 "/art:action/art:type/art:collection/art:attribute";
6370369412e9 Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 196
diff changeset
240
6370369412e9 Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 196
diff changeset
241 /**
189
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
242 * XPath to figure out the attributes for an artifact that is put into a
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
243 * collection.
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
244 */
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
245 public static final String XPATH_COLLECTION_ITEM_ATTRIBUTE =
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
246 "/art:action/art:type/art:artifact/art:attribute";
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
247
273
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
248 /**
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
249 * XPath to figure out the time to live value for setting a new TTL.
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
250 */
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
251 public static final String XPATH_COLLECTION_TTL =
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
252 "/art:action/art:type/art:ttl/@value";
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
253
149
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
254
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
255 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
256 * This inner class allows the deferral of writing the output
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
257 * of the artifact's out() call.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
258 */
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
259 public class DeferredOutputImpl
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
260 implements DeferredOutput
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
261 {
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
262 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
263 * The persistence wrapper around a living artifact.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
264 */
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
265 protected PersistentArtifact artifact;
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
266 /**
269
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
267 * The output type.
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
268 */
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
269 protected String type;
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
270 /**
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
271 * The input document for the artifact's out() call.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
272 */
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
273 protected Document format;
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
274 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
275 * The meta information of the artifact's out() call.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
276 */
48
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
277 protected CallMeta callMeta;
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
278
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
279 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
280 * Default constructor.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
281 */
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
282 public DeferredOutputImpl() {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
283 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
284
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
285 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
286 * Constructor to create a deferred execution unit for
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
287 * the artifact's out() call given an artifact, an input document
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
288 * an the meta information.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
289 * @param artifact The persistence wrapper around a living artifact.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
290 * @param format The input document for the artifact's out() call.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
291 * @param callMeta The meta information of the artifact's out() call.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
292 */
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
293 public DeferredOutputImpl(
47
4ae4dc99127d Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 41
diff changeset
294 PersistentArtifact artifact,
269
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
295 String type,
48
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
296 Document format,
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
297 CallMeta callMeta
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
298 ) {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
299 this.artifact = artifact;
269
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
300 this.type = type;
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
301 this.format = format;
48
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
302 this.callMeta = callMeta;
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
303 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
304
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
305 public void write(OutputStream output) throws IOException {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
306
219
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
307 ArtifactCallContext cc = new ArtifactCallContext(
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
308 ArtifactDatabaseImpl.this,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
309 CallContext.TOUCH,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
310 callMeta,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
311 artifact);
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
312
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
313 try {
269
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
314 artifact.getArtifact().out(type, format, output, cc);
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
315 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
316 finally {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
317 cc.postCall();
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
318 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
319 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
320 } // class DeferredOutputImpl
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
321
228
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
322
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
323 /**
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
324 * This inner class allows the deferral of writing the output
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
325 * of the artifact's out() call.
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
326 */
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
327 public class DeferredCollectionOutputImpl
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
328 implements DeferredOutput
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
329 {
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
330 /**
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
331 * The persistence wrapper around a living collection.
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
332 */
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
333 protected ArtifactCollection collection;
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
334 /**
269
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
335 * The output type.
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
336 */
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
337 protected String type;
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
338 /**
228
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
339 * The input document for the collection's out() call.
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
340 */
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
341 protected Document format;
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
342 /**
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
343 * The meta information of the collection's out() call.
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
344 */
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
345 protected CallMeta callMeta;
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
346
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
347 /**
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
348 * Default constructor.
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
349 */
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
350 public DeferredCollectionOutputImpl() {
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
351 }
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
352
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
353 /**
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
354 * Constructor to create a deferred execution unit for
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
355 * the collection's out() call given a collection, an input document
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
356 * an the meta information.
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
357 * @param collection The collection.
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
358 * @param format The input document for the collection's out() call.
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
359 * @param callMeta The meta information of the collection's out() call.
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
360 */
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
361 public DeferredCollectionOutputImpl(
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
362 ArtifactCollection collection,
269
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
363 String type,
228
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
364 Document format,
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
365 CallMeta callMeta
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
366 ) {
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
367 this.collection = collection;
269
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
368 this.type = type;
228
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
369 this.format = format;
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
370 this.callMeta = callMeta;
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
371 }
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
372
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
373 public void write(OutputStream output) throws IOException {
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
374
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
375 CollectionCallContext cc = new CollectionCallContext(
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
376 ArtifactDatabaseImpl.this,
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
377 CallContext.TOUCH,
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
378 callMeta,
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
379 collection);
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
380
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
381 try {
269
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
382 collection.out(type, format, output, cc);
228
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
383 }
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
384 finally {
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
385 cc.postCall();
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
386 }
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
387 }
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
388 } // class DeferredCollectionOutputImpl
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
389
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
390 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
391 * List of name/description pairs needed for
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
392 * {@link #artifactFactoryNamesAndDescriptions() }.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
393 */
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
394 protected String [][] factoryNamesAndDescription;
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
395 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
396 * Map to access artifact factories by there name.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
397 */
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
398 protected HashMap name2factory;
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
399
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
400 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
401 * List of name/description pairs needed for
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
402 * {@link #serviceNamesAndDescriptions() }.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
403 */
70
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
404 protected String [][] serviceNamesAndDescription;
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
405 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
406 * Map to access services by there name.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
407 */
70
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
408 protected HashMap name2service;
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
409
562
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
410 private Map<String, Class<?>> restServices;
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
411
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
412 /**
155
f797093c60bd Made a (single one) artifact collection factory configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 154
diff changeset
413 * The factory that is used to create new artifact collections.
f797093c60bd Made a (single one) artifact collection factory configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 154
diff changeset
414 */
f797093c60bd Made a (single one) artifact collection factory configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 154
diff changeset
415 protected ArtifactCollectionFactory collectionFactory;
f797093c60bd Made a (single one) artifact collection factory configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 154
diff changeset
416
f797093c60bd Made a (single one) artifact collection factory configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 154
diff changeset
417 /**
127
0245a87df368 Made the user factory available in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
418 * The factory that is used to create and list users.
0245a87df368 Made the user factory available in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
419 */
0245a87df368 Made the user factory available in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
420 protected UserFactory userFactory;
0245a87df368 Made the user factory available in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
421
0245a87df368 Made the user factory available in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
422 /**
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
423 * Reference to the storage backend.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
424 */
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
425 protected Backend backend;
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
426 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
427 * Reference of the global context of the artifact runtime system.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
428 */
293
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
429 protected GlobalContext context;
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
430
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
431 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
432 * The signing secret to be used for ex-/importing artifacts.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
433 */
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
434 protected byte [] exportSecret;
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
435
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
436 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
437 * A set of ids of artifact which currently running in background.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
438 * This artifacts should not be removed from the database by the
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
439 * database cleaner.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
440 */
331
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
441 protected HashSet<Integer> backgroundIds;
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
442
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
443 /**
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
444 * A list of background messages for Artifacts and Collections.
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
445 */
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
446 protected Map<String, LinkedList<Message>> backgroundMsgs;
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
447
13
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
448
247
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
449 protected CallContext.Listener callContextListener;
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
450
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
451 /**
292
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
452 * Hooks that are executed after an artifact has been fed.
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
453 */
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
454 protected List<Hook> postFeedHooks;
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
455
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
456 /**
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
457 * Hooks that are executed after an artifact has advanced.
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
458 */
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
459 protected List<Hook> postAdvanceHooks;
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
460
348
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
461 /**
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
462 * Hooks that are executed after an artifact's describe() operation was
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
463 * called.
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
464 */
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
465 protected List<Hook> postDescribeHooks;
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
466
304
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
467 protected List<LifetimeListener> lifetimeListeners;
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
468
562
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
469 private String serverAddress;
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
470
292
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
471 /**
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
472 * Default constructor.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
473 */
13
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
474 public ArtifactDatabaseImpl() {
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
475 }
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
476
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
477 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
478 * Constructor to create a artifact database with the given
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
479 * bootstrap parameters like artifact- and service factories et. al.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
480 * Created this way the artifact database has no backend.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
481 * @param bootstrap The parameters to start this artifact database.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
482 */
41
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 36
diff changeset
483 public ArtifactDatabaseImpl(FactoryBootstrap bootstrap) {
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 36
diff changeset
484 this(bootstrap, null);
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 36
diff changeset
485 }
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 36
diff changeset
486
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
487 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
488 * Constructor to create a artifact database with the a given
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
489 * backend and
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
490 * bootstrap parameters like artifact- and service factories et. al.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
491 * @param bootstrap The parameters to start this artifact database.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
492 * @param backend The storage backend.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
493 */
13
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
494 public ArtifactDatabaseImpl(FactoryBootstrap bootstrap, Backend backend) {
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
495
313
ddc35c950e97 Backend: Handle forgotten store/create event source.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 311
diff changeset
496 logger.debug("new ArtifactDatabaseImpl");
ddc35c950e97 Backend: Handle forgotten store/create event source.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 311
diff changeset
497
331
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
498 backgroundIds = new HashSet<Integer>();
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
499 backgroundMsgs = new HashMap<String, LinkedList<Message>>();
562
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
500
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
501 this.serverAddress = bootstrap.getHTTPServer().getServerAddress();
70
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
502
155
f797093c60bd Made a (single one) artifact collection factory configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 154
diff changeset
503 setupArtifactCollectionFactory(bootstrap);
70
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
504 setupArtifactFactories(bootstrap);
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
505 setupServices(bootstrap);
562
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
506 setupRestServices(bootstrap);
127
0245a87df368 Made the user factory available in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
507 setupUserFactory(bootstrap);
249
c47a640cfdae Enhanced the bootstrap - the CallContext.Listener is initialized (if configured).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 247
diff changeset
508 setupCallContextListener(bootstrap);
292
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
509 setupHooks(bootstrap);
304
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
510 setupLifetimeListeners(bootstrap);
70
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
511
293
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
512 context = bootstrap.getContext();
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
513 context.put(GLOBAL_CONTEXT_KEY, this);
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
514
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
515 exportSecret = bootstrap.getExportSecret();
70
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
516
313
ddc35c950e97 Backend: Handle forgotten store/create event source.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 311
diff changeset
517 wireWithBackend(backend, bootstrap);
70
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
518 }
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
519
247
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
520 public CallContext.Listener getCallContextListener() {
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
521 return callContextListener;
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
522 }
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
523
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
524 public void setCallContextListener(
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
525 CallContext.Listener callContextListener
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
526 ) {
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
527 this.callContextListener = callContextListener;
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
528 }
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
529
292
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
530
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
531 public void setPostFeedHook(List<Hook> postFeedHooks) {
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
532 this.postFeedHooks = postFeedHooks;
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
533 }
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
534
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
535 public void setPostAdvanceHook(List<Hook> postAdvanceHooks) {
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
536 this.postAdvanceHooks = postAdvanceHooks;
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
537 }
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
538
348
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
539 public void setPostDescribeHook(List<Hook> postDescribeHooks) {
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
540 this.postDescribeHooks = postDescribeHooks;
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
541 }
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
542
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
543 /**
155
f797093c60bd Made a (single one) artifact collection factory configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 154
diff changeset
544 * Used to extract the artifact collection factory from bootstrap.
f797093c60bd Made a (single one) artifact collection factory configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 154
diff changeset
545 *
f797093c60bd Made a (single one) artifact collection factory configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 154
diff changeset
546 * @param bootstrap The bootstrap parameters.
f797093c60bd Made a (single one) artifact collection factory configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 154
diff changeset
547 */
f797093c60bd Made a (single one) artifact collection factory configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 154
diff changeset
548 protected void setupArtifactCollectionFactory(FactoryBootstrap bootstrap) {
f797093c60bd Made a (single one) artifact collection factory configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 154
diff changeset
549 collectionFactory = bootstrap.getArtifactCollectionFactory();
f797093c60bd Made a (single one) artifact collection factory configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 154
diff changeset
550 }
f797093c60bd Made a (single one) artifact collection factory configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 154
diff changeset
551
f797093c60bd Made a (single one) artifact collection factory configurable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 154
diff changeset
552 /**
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
553 * Used to extract the artifact factories from the bootstrap
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
554 * parameters and building the internal lookup tables.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
555 * @param bootstrap The bootstrap parameters.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
556 */
70
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
557 protected void setupArtifactFactories(FactoryBootstrap bootstrap) {
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
558 name2factory = new HashMap();
13
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
559
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
560 ArtifactFactory [] factories = bootstrap.getArtifactFactories();
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
561 factoryNamesAndDescription = new String[factories.length][];
13
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
562
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
563 for (int i = 0; i < factories.length; ++i) {
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
564
13
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
565 ArtifactFactory factory = factories[i];
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
566
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
567 String name = factory.getName();
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
568 String description = factory.getDescription();
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
569
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
570 factoryNamesAndDescription[i] =
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
571 new String [] { name, description };
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
572
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
573 name2factory.put(name, factory);
13
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
574 }
70
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
575 }
13
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
576
249
c47a640cfdae Enhanced the bootstrap - the CallContext.Listener is initialized (if configured).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 247
diff changeset
577 /**
c47a640cfdae Enhanced the bootstrap - the CallContext.Listener is initialized (if configured).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 247
diff changeset
578 * Used to extract the callContextListener from the bootstrap.
c47a640cfdae Enhanced the bootstrap - the CallContext.Listener is initialized (if configured).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 247
diff changeset
579 *
c47a640cfdae Enhanced the bootstrap - the CallContext.Listener is initialized (if configured).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 247
diff changeset
580 * @param bootstrap The bootstrap parameters.
c47a640cfdae Enhanced the bootstrap - the CallContext.Listener is initialized (if configured).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 247
diff changeset
581 */
c47a640cfdae Enhanced the bootstrap - the CallContext.Listener is initialized (if configured).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 247
diff changeset
582 protected void setupCallContextListener(FactoryBootstrap bootstrap) {
c47a640cfdae Enhanced the bootstrap - the CallContext.Listener is initialized (if configured).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 247
diff changeset
583 setCallContextListener(bootstrap.getCallContextListener());
c47a640cfdae Enhanced the bootstrap - the CallContext.Listener is initialized (if configured).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 247
diff changeset
584 }
127
0245a87df368 Made the user factory available in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
585
292
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
586
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
587 protected void setupHooks(FactoryBootstrap bootstrap) {
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
588 setPostFeedHook(bootstrap.getPostFeedHooks());
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
589 setPostAdvanceHook(bootstrap.getPostAdvanceHooks());
348
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
590 setPostDescribeHook(bootstrap.getPostDescribeHooks());
292
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
591 }
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
592
311
1d517e051e95 Made backend listeners loadable at boot time.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 308
diff changeset
593 protected void setupBackendListeners(FactoryBootstrap bootstrap) {
313
ddc35c950e97 Backend: Handle forgotten store/create event source.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 311
diff changeset
594 logger.debug("setupBackendListeners");
311
1d517e051e95 Made backend listeners loadable at boot time.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 308
diff changeset
595 List<BackendListener> bls = bootstrap.getBackendListeners();
313
ddc35c950e97 Backend: Handle forgotten store/create event source.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 311
diff changeset
596 if (bls != null && !bls.isEmpty()) {
311
1d517e051e95 Made backend listeners loadable at boot time.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 308
diff changeset
597 for (BackendListener listener: bls) {
1d517e051e95 Made backend listeners loadable at boot time.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 308
diff changeset
598 listener.setup(context);
1d517e051e95 Made backend listeners loadable at boot time.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 308
diff changeset
599 }
1d517e051e95 Made backend listeners loadable at boot time.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 308
diff changeset
600 backend.addAllListeners(bls);
1d517e051e95 Made backend listeners loadable at boot time.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 308
diff changeset
601 }
1d517e051e95 Made backend listeners loadable at boot time.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 308
diff changeset
602 }
1d517e051e95 Made backend listeners loadable at boot time.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 308
diff changeset
603
304
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
604 protected void setupLifetimeListeners(FactoryBootstrap bootstrap) {
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
605 this.lifetimeListeners = bootstrap.getLifetimeListeners();
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
606 }
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
607
127
0245a87df368 Made the user factory available in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
608 /**
0245a87df368 Made the user factory available in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
609 * Used to extract the user factory from the bootstrap.
0245a87df368 Made the user factory available in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
610 */
0245a87df368 Made the user factory available in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
611 protected void setupUserFactory(FactoryBootstrap bootstrap) {
0245a87df368 Made the user factory available in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
612 userFactory = bootstrap.getUserFactory();
0245a87df368 Made the user factory available in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
613 }
0245a87df368 Made the user factory available in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 118
diff changeset
614
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
615 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
616 * Used to extract the service factories from the bootstrap
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
617 * parameters, setting up the services and building the internal
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
618 * lookup tables.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
619 * @param bootstrap The bootstrap parameters.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
620 */
70
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
621 protected void setupServices(FactoryBootstrap bootstrap) {
26
83a059c204f8 Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 13
diff changeset
622
70
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
623 name2service = new HashMap();
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
624
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
625 ServiceFactory [] serviceFactories =
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
626 bootstrap.getServiceFactories();
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
627
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
628 serviceNamesAndDescription =
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
629 new String[serviceFactories.length][];
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
630
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
631 for (int i = 0; i < serviceFactories.length; ++i) {
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
632 ServiceFactory factory = serviceFactories[i];
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
633
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
634 String name = factory.getName();
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
635 String description = factory.getDescription();
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
636
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
637 serviceNamesAndDescription[i] =
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
638 new String [] { name, description };
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
639
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
640 name2service.put(
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
641 name,
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
642 factory.createService(bootstrap.getContext()));
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
643 }
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
644
41
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 36
diff changeset
645 }
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 36
diff changeset
646
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
647 /**
562
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
648 * Used to extract the service factories from the bootstrap
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
649 * parameters, setting up the services and building the internal
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
650 * lookup tables.
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
651 * @param bootstrap The bootstrap parameters.
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
652 */
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
653 private void setupRestServices(FactoryBootstrap bootstrap) {
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
654
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
655 restServices = new HashMap<String,Class<?>>(bootstrap.getRestServiceNames());
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
656 }
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
657
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
658 /**
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
659 * Wires a storage backend to this artifact database and
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
660 * establishes a callback to be able to revive artifacts
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
661 * via the serializers of this artifact factories.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
662 * @param backend The backend to be wired with this artifact database.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
663 */
313
ddc35c950e97 Backend: Handle forgotten store/create event source.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 311
diff changeset
664 public void wireWithBackend(Backend backend, FactoryBootstrap bootstrap) {
ddc35c950e97 Backend: Handle forgotten store/create event source.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 311
diff changeset
665 logger.debug("wireWithBackend");
41
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 36
diff changeset
666 if (backend != null) {
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 36
diff changeset
667 this.backend = backend;
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 36
diff changeset
668 backend.setFactoryLookup(this);
313
ddc35c950e97 Backend: Handle forgotten store/create event source.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 311
diff changeset
669 setupBackendListeners(bootstrap);
41
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 36
diff changeset
670 }
13
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
671 }
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
672
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
673 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
674 * Called after an backgrounded artifact signals its
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
675 * will to be written back to the backend.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
676 * @param artifact The persistence wrapper around
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
677 * the backgrounded artifact.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
678 * @param action The action to be performed.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
679 */
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
680 protected void fromBackground(PersistentArtifact artifact, int action) {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
681 logger.warn("BACKGROUND processing is not fully implemented, yet!");
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
682 switch (action) {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
683 case CallContext.NOTHING:
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
684 break;
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
685 case CallContext.TOUCH:
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
686 artifact.touch();
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
687 break;
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
688 case CallContext.STORE:
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
689 artifact.store();
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
690 break;
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
691 default:
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
692 logger.warn("operation not allowed in fromBackground");
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
693 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
694 removeIdFromBackground(artifact.getId());
331
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
695 removeBackgroundMessages(artifact.getArtifact().identifier());
13
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
696 }
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
697
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
698 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
699 * Removes an artifact's database id from the set of backgrounded
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
700 * artifacts. The database cleaner is now able to remove it safely
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
701 * from the database again.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
702 * @param id The database id of the artifact.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
703 */
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
704 protected void removeIdFromBackground(int id) {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
705 synchronized (backgroundIds) {
230
fbd57d2eeaef Changed semantics of locked artifact ids.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 228
diff changeset
706 backgroundIds.remove(id);
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
707 }
13
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
708 }
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
709
331
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
710
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
711 /**
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
712 * Removes all messages that have been added to the <i>backgroundMsgs</i>
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
713 * list.
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
714 *
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
715 * @param uuid The UUID of an artifact or collection.
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
716 */
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
717 protected void removeBackgroundMessages(String uuid) {
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
718 logger.debug("Remove background messages for: " + uuid);
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
719
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
720 synchronized (backgroundMsgs) {
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
721 backgroundMsgs.remove(uuid);
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
722 }
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
723 }
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
724
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
725 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
726 * Adds an artifact's database id to the set of artifacts
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
727 * running in backgroound. To be in this set prevents the
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
728 * artifact to be removed from the database by the database cleaner.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
729 * @param id The database id of the artifact to be protected
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
730 * from being removed from the database.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
731 */
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
732 protected void addIdToBackground(int id) {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
733 synchronized (backgroundIds) {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
734 backgroundIds.add(Integer.valueOf(id));
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
735 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
736 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
737
331
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
738 /**
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
739 * Adds a <i>Message</i> to the background messages list of the Artifact or
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
740 * Collection.
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
741 *
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
742 * @param uuid The UUID of the Artifact or Collection.
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
743 * @param msg The message that should be added to the background messages
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
744 * list.
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
745 */
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
746 public void addBackgroundMessage(String uuid, Message msg) {
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
747 logger.debug("Add new background messsage for: " + uuid);
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
748
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
749 synchronized (backgroundMsgs) {
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
750 LinkedList<Message> messages = backgroundMsgs.get(uuid);
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
751
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
752 if (messages == null) {
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
753 messages = new LinkedList<Message>();
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
754 backgroundMsgs.put(uuid, messages);
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
755 }
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
756
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
757 messages.addLast(msg);
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
758 }
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
759 }
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
760
230
fbd57d2eeaef Changed semantics of locked artifact ids.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 228
diff changeset
761 public Set<Integer> getLockedIds() {
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
762 synchronized (backgroundIds) {
230
fbd57d2eeaef Changed semantics of locked artifact ids.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 228
diff changeset
763 return new HashSet<Integer>(backgroundIds);
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
764 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
765 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
766
331
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
767 /**
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
768 * Returns the background <i>Message</i>s for a specific Artifact or
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
769 * Collection.
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
770 *
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
771 * @param uuid The Artifact's or Collection's UUID.
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
772 *
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
773 * @return a <i>List</i> of <i>Message</i>s or null if no messages are
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
774 * existing.
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
775 */
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
776 public LinkedList<Message> getBackgroundMessages(String uuid) {
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
777 logger.debug("Retrieve background message for: " + uuid);
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
778
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
779 synchronized (backgroundMsgs) {
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
780 return backgroundMsgs.get(uuid);
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
781 }
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
782 }
089c6f7794b5 Integrated a messaging system for Artifacts and Collections that started background threads.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 328
diff changeset
783
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
784 public String [][] artifactFactoryNamesAndDescriptions() {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
785 return factoryNamesAndDescription;
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
786 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
787
66
89e3de0ee05f Implemented some methods to get access to ArtifactFactories which are stored in the ArtifactDatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 58
diff changeset
788 public ArtifactFactory getInternalArtifactFactory(String factoryName) {
89e3de0ee05f Implemented some methods to get access to ArtifactFactories which are stored in the ArtifactDatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 58
diff changeset
789 return getArtifactFactory(factoryName);
89e3de0ee05f Implemented some methods to get access to ArtifactFactories which are stored in the ArtifactDatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 58
diff changeset
790 }
89e3de0ee05f Implemented some methods to get access to ArtifactFactories which are stored in the ArtifactDatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 58
diff changeset
791
41
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 36
diff changeset
792 public ArtifactFactory getArtifactFactory(String factoryName) {
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 36
diff changeset
793 return (ArtifactFactory)name2factory.get(factoryName);
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 36
diff changeset
794 }
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 36
diff changeset
795
149
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
796 public UserFactory getUserFactory() {
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
797 return userFactory;
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
798 }
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
799
158
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
800 public ArtifactCollectionFactory getArtifactCollectionFactory() {
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
801 return collectionFactory;
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
802 }
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
803
48
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
804 public Document createArtifactWithFactory(
86
b2e0cb83631c Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 84
diff changeset
805 String factoryName,
75
d4c4c23847f5 Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents: 70
diff changeset
806 CallMeta callMeta,
d4c4c23847f5 Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents: 70
diff changeset
807 Document data
48
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
808 )
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
809 throws ArtifactDatabaseException
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
810 {
343
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
811 logger.debug("ArtifactDatabaseImpl.createArtifactWithFactory "
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
812 + factoryName);
41
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 36
diff changeset
813 ArtifactFactory factory = getArtifactFactory(factoryName);
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
814
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
815 if (factory == null) {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
816 throw new ArtifactDatabaseException(NO_SUCH_FACTORY);
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
817 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
818
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
819 Artifact artifact = factory.createArtifact(
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
820 backend.newIdentifier(),
75
d4c4c23847f5 Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents: 70
diff changeset
821 context,
297
694d818e99b2 Adapted the signature of Artifact.setup() - a parameter of type CallMeta has been added.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 294
diff changeset
822 callMeta,
75
d4c4c23847f5 Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents: 70
diff changeset
823 data);
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
824
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
825 if (artifact == null) {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
826 throw new ArtifactDatabaseException(CREATION_FAILED);
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
827 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
828
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
829 PersistentArtifact persistentArtifact;
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
830
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
831 try {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
832 persistentArtifact = backend.storeInitially(
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
833 artifact,
41
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 36
diff changeset
834 factory,
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
835 factory.timeToLiveUntouched(artifact, context));
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
836 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
837 catch (Exception e) {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
838 logger.error(e.getLocalizedMessage(), e);
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
839 throw new ArtifactDatabaseException(CREATION_FAILED);
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
840 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
841
219
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
842 ArtifactCallContext cc = new ArtifactCallContext(
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
843 ArtifactDatabaseImpl.this,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
844 CallContext.NOTHING,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
845 callMeta,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
846 persistentArtifact);
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
847
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
848 try {
496
090f08a64b59 Execute postDescribeHooks after initial describe and creation
Andre Heinecke <aheinecke@intevation.de>
parents: 475
diff changeset
849 Document res = artifact.describe(data, cc);
090f08a64b59 Execute postDescribeHooks after initial describe and creation
Andre Heinecke <aheinecke@intevation.de>
parents: 475
diff changeset
850
090f08a64b59 Execute postDescribeHooks after initial describe and creation
Andre Heinecke <aheinecke@intevation.de>
parents: 475
diff changeset
851 if (postDescribeHooks != null) {
090f08a64b59 Execute postDescribeHooks after initial describe and creation
Andre Heinecke <aheinecke@intevation.de>
parents: 475
diff changeset
852 for (Hook hook: postDescribeHooks) {
090f08a64b59 Execute postDescribeHooks after initial describe and creation
Andre Heinecke <aheinecke@intevation.de>
parents: 475
diff changeset
853 hook.execute(artifact, cc, res);
090f08a64b59 Execute postDescribeHooks after initial describe and creation
Andre Heinecke <aheinecke@intevation.de>
parents: 475
diff changeset
854 }
090f08a64b59 Execute postDescribeHooks after initial describe and creation
Andre Heinecke <aheinecke@intevation.de>
parents: 475
diff changeset
855 }
090f08a64b59 Execute postDescribeHooks after initial describe and creation
Andre Heinecke <aheinecke@intevation.de>
parents: 475
diff changeset
856 return res;
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
857 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
858 finally {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
859 cc.postCall();
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
860 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
861 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
862
293
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
863
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
864 public Artifact getRawArtifact(String identifier)
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
865 throws ArtifactDatabaseException
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
866 {
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
867 PersistentArtifact artifact = backend.getArtifact(identifier);
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
868
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
869 if (artifact == null) {
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
870 throw new ArtifactDatabaseException(NO_SUCH_ARTIFACT);
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
871 }
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
872
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
873 return artifact.getArtifact();
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
874 }
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
875
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 292
diff changeset
876
94
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 92
diff changeset
877 public Document describe(
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 92
diff changeset
878 String identifier,
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 92
diff changeset
879 Document data,
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 92
diff changeset
880 CallMeta callMeta
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 92
diff changeset
881 )
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 92
diff changeset
882 throws ArtifactDatabaseException
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
883 {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
884 // TODO: Handle background tasks
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
885 PersistentArtifact artifact = backend.getArtifact(identifier);
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
886
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
887 if (artifact == null) {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
888 throw new ArtifactDatabaseException(NO_SUCH_ARTIFACT);
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
889 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
890
219
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
891 ArtifactCallContext cc = new ArtifactCallContext(
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
892 ArtifactDatabaseImpl.this,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
893 CallContext.TOUCH,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
894 callMeta,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
895 artifact);
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
896
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
897 try {
348
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
898 Artifact art = artifact.getArtifact();
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
899 Document res = art.describe(data, cc);
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
900
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
901 if (postDescribeHooks != null) {
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
902 for (Hook hook: postDescribeHooks) {
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
903 hook.execute(art, cc, res);
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
904 }
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
905 }
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
906
f2277458823e Enabled 'post-describe' hooks for Artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
907 return res;
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
908 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
909 finally {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
910 cc.postCall();
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
911 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
912 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
913
94
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 92
diff changeset
914 public Document advance(
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 92
diff changeset
915 String identifier,
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 92
diff changeset
916 Document target,
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 92
diff changeset
917 CallMeta callMeta
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 92
diff changeset
918 )
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 92
diff changeset
919 throws ArtifactDatabaseException
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
920 {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
921 // TODO: Handle background tasks
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
922 PersistentArtifact artifact = backend.getArtifact(identifier);
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
923
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
924 if (artifact == null) {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
925 throw new ArtifactDatabaseException(NO_SUCH_ARTIFACT);
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
926 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
927
219
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
928 ArtifactCallContext cc = new ArtifactCallContext(
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
929 ArtifactDatabaseImpl.this,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
930 CallContext.STORE,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
931 callMeta,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
932 artifact);
48
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
933
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
934 try {
292
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
935 Artifact art = artifact.getArtifact();
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
936 Document res = art.advance(target, cc);
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
937
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
938 if (postAdvanceHooks != null) {
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
939 for (Hook hook: postAdvanceHooks) {
294
b530e83acf2e Adapted the signature of Hook.execute() which now retrieves a Document as third parameter.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 293
diff changeset
940 hook.execute(art, cc, res);
292
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
941 }
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
942 }
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
943
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
944 return res;
48
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
945 }
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
946 finally {
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
947 cc.postCall();
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
948 }
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
949 }
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
950
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
951 public Document feed(String identifier, Document data, CallMeta callMeta)
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
952 throws ArtifactDatabaseException
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
953 {
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
954 // TODO: Handle background tasks
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
955 PersistentArtifact artifact = backend.getArtifact(identifier);
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
956
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
957 if (artifact == null) {
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
958 throw new ArtifactDatabaseException(NO_SUCH_ARTIFACT);
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
959 }
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
960
219
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
961 ArtifactCallContext cc = new ArtifactCallContext(
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
962 ArtifactDatabaseImpl.this,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
963 CallContext.STORE,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
964 callMeta,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
965 artifact);
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
966
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
967 try {
292
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
968 Artifact art = artifact.getArtifact();
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
969 Document res = art.feed(data, cc);
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
970
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
971 if (postFeedHooks != null) {
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
972 for (Hook hook: postFeedHooks) {
294
b530e83acf2e Adapted the signature of Hook.execute() which now retrieves a Document as third parameter.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 293
diff changeset
973 hook.execute(art, cc, res);
292
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
974 }
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
975 }
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
976
39c0ff00d188 Introduced a hook concept - currently used for 'post-feed' and 'post-advance'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
977 return res;
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
978 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
979 finally {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
980 cc.postCall();
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
981 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
982 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
983
94
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 92
diff changeset
984 public DeferredOutput out(
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 92
diff changeset
985 String identifier,
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 92
diff changeset
986 Document format,
269
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
987 CallMeta callMeta)
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
988 throws ArtifactDatabaseException
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
989 {
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
990 return out(identifier, null, format, callMeta);
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
991 }
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
992
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
993 public DeferredOutput out(
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
994 String identifier,
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
995 String type,
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
996 Document format,
94
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 92
diff changeset
997 CallMeta callMeta
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 92
diff changeset
998 )
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 92
diff changeset
999 throws ArtifactDatabaseException
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
1000 {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
1001 // TODO: Handle background tasks
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
1002 PersistentArtifact artifact = backend.getArtifact(identifier);
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
1003
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
1004 if (artifact == null) {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
1005 throw new ArtifactDatabaseException(NO_SUCH_ARTIFACT);
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
1006 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 26
diff changeset
1007
269
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
1008 return new DeferredOutputImpl(artifact, type, format, callMeta);
13
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1009 }
68
541814404822 Added interfaces for XML processing services. TODO: Implement them!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 66
diff changeset
1010
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1011 public Document exportArtifact(String artifact, CallMeta callMeta)
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1012 throws ArtifactDatabaseException
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1013 {
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1014 final String [] factoryName = new String[1];
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1015
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1016 byte [] bytes = (byte [])backend.loadArtifact(
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1017 artifact,
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1018 new Backend.ArtifactLoader() {
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1019 public Object load(
86
b2e0cb83631c Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 84
diff changeset
1020 ArtifactFactory factory,
84
72e2dd4feb31 Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 82
diff changeset
1021 Long ttl,
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1022 byte [] bytes,
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1023 int id
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1024 ) {
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1025 factoryName[0] = factory.getName();
82
efe752c4f8b2 Call cleanup method to remove special data stored by an 'out'-target before exporting an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 81
diff changeset
1026
efe752c4f8b2 Call cleanup method to remove special data stored by an 'out'-target before exporting an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 81
diff changeset
1027 ArtifactSerializer serializer = factory.getSerializer();
efe752c4f8b2 Call cleanup method to remove special data stored by an 'out'-target before exporting an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 81
diff changeset
1028
efe752c4f8b2 Call cleanup method to remove special data stored by an 'out'-target before exporting an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 81
diff changeset
1029 Artifact artifact = serializer.fromBytes(bytes);
efe752c4f8b2 Call cleanup method to remove special data stored by an 'out'-target before exporting an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 81
diff changeset
1030 artifact.cleanup(context);
efe752c4f8b2 Call cleanup method to remove special data stored by an 'out'-target before exporting an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 81
diff changeset
1031
efe752c4f8b2 Call cleanup method to remove special data stored by an 'out'-target before exporting an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 81
diff changeset
1032 return serializer.toBytes(artifact);
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1033 }
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1034 });
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1035
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1036 if (bytes == null) {
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1037 throw new ArtifactDatabaseException(NO_SUCH_ARTIFACT);
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1038 }
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1039
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1040 return createExportDocument(
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1041 factoryName[0],
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1042 bytes,
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1043 exportSecret);
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1044 }
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1045
92
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
1046 /**
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
1047 * Creates an exteral XML representation of an artifact.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
1048 * @param factoryName The name of the factory which is responsible
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
1049 * for the serialized artifact.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
1050 * @param artifact The byte data of the artifact itself.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
1051 * @param secret The signing secret.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
1052 * @return An XML document containing the external representation
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
1053 * of the artifact.
73d0ebae81d7 Last bunch of javadoc
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
1054 */
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1055 protected static Document createExportDocument(
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1056 String factoryName,
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1057 byte [] artifact,
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1058 byte [] secret
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1059 ) {
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1060 Document document = XMLUtils.newDocument();
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1061
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1062 MessageDigest md;
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1063 try {
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1064 md = MessageDigest.getInstance(DIGEST_ALGORITHM);
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1065 }
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1066 catch (NoSuchAlgorithmException nsae) {
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1067 logger.error(nsae.getLocalizedMessage(), nsae);
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1068 return document;
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1069 }
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1070
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1071 md.update(artifact);
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1072 md.update(secret);
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1073
80
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1074 String checksum = Hex.encodeHexString(md.digest());
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1075
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1076 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1077 document,
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1078 ArtifactNamespaceContext.NAMESPACE_URI,
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1079 ArtifactNamespaceContext.NAMESPACE_PREFIX);
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1080
80
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1081 Element root = ec.create("action");
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1082 document.appendChild(root);
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1083
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1084 Element type = ec.create("type");
183
9b8923043a38 Repaired the namespaces of the xml element attributes in the collecton context of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 176
diff changeset
1085 ec.addAttr(type, "name", "export", true);
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1086 root.appendChild(type);
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1087
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1088 Element data = ec.create("data");
183
9b8923043a38 Repaired the namespaces of the xml element attributes in the collecton context of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 176
diff changeset
1089 ec.addAttr(data, "checksum", checksum, true);
9b8923043a38 Repaired the namespaces of the xml element attributes in the collecton context of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 176
diff changeset
1090 ec.addAttr(data, "factory", factoryName, true);
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1091 data.setTextContent(Base64.encodeBase64String(artifact));
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1092
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1093 root.appendChild(data);
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1094
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1095 return document;
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1096 }
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1097
80
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1098 public Document importArtifact(Document input, CallMeta callMeta)
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1099 throws ArtifactDatabaseException
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1100 {
80
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1101 String factoryName = XMLUtils.xpathString(
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1102 input,
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1103 XPATH_IMPORT_FACTORY,
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1104 ArtifactNamespaceContext.INSTANCE);
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1105
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1106 ArtifactFactory factory;
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1107
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1108 if (factoryName == null
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1109 || (factoryName = factoryName.trim()).length() == 0
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1110 || (factory = getArtifactFactory(factoryName)) == null) {
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1111 throw new ArtifactDatabaseException(NO_SUCH_FACTORY);
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1112 }
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1113
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1114 String checksumString = XMLUtils.xpathString(
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1115 input,
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1116 XPATH_IMPORT_CHECKSUM,
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1117 ArtifactNamespaceContext.INSTANCE);
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1118
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1119 byte [] checksum;
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1120
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1121 if (checksumString == null
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1122 || (checksumString = checksumString.trim()).length() == 0
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1123 || (checksum = StringUtils.decodeHex(checksumString)) == null
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1124 ) {
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1125 throw new ArtifactDatabaseException(INVALID_CHECKSUM);
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1126 }
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1127
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1128 checksumString = null;
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1129
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1130 String dataString = XMLUtils.xpathString(
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1131 input,
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1132 XPATH_IMPORT_DATA,
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1133 ArtifactNamespaceContext.INSTANCE);
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1134
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1135 if (dataString == null
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1136 || (dataString = dataString.trim()).length() == 0) {
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1137 throw new ArtifactDatabaseException(NO_DATA);
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1138 }
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1139
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1140 byte [] data = Base64.decodeBase64(dataString);
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1141
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1142 dataString = null;
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1143
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1144 MessageDigest md;
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1145 try {
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1146 md = MessageDigest.getInstance(DIGEST_ALGORITHM);
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1147 }
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1148 catch (NoSuchAlgorithmException nsae) {
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1149 logger.error(nsae.getLocalizedMessage(), nsae);
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1150 return XMLUtils.newDocument();
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1151 }
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1152
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1153 md.update(data);
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1154 md.update(exportSecret);
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1155
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1156 byte [] digest = md.digest();
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1157
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1158 if (!Arrays.equals(checksum, digest)) {
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1159 throw new ArtifactDatabaseException(CHECKSUM_MISMATCH);
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1160 }
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1161
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1162 ArtifactSerializer serializer = factory.getSerializer();
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1163
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1164 Artifact artifact = serializer.fromBytes(data); data = null;
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1165
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1166 if (artifact == null) {
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1167 throw new ArtifactDatabaseException(INVALID_ARTIFACT);
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1168 }
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1169
81
e9c80fdfee13 Set new identifiers on artifacts after an artifact import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 80
diff changeset
1170 artifact.setIdentifier(backend.newIdentifier());
80
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1171 PersistentArtifact persistentArtifact;
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1172
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1173 try {
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1174 persistentArtifact = backend.storeOrReplace(
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1175 artifact,
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1176 factory,
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1177 factory.timeToLiveUntouched(artifact, context));
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1178 }
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1179 catch (Exception e) {
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1180 logger.error(e.getLocalizedMessage(), e);
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1181 throw new ArtifactDatabaseException(CREATION_FAILED);
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1182 }
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1183
219
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1184 ArtifactCallContext cc = new ArtifactCallContext(
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1185 ArtifactDatabaseImpl.this,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1186 CallContext.NOTHING,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1187 callMeta,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1188 persistentArtifact);
80
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1189
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1190 try {
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1191 return artifact.describe(input, cc);
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1192 }
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1193 finally {
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1194 cc.postCall();
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 79
diff changeset
1195 }
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1196 }
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
1197
68
541814404822 Added interfaces for XML processing services. TODO: Implement them!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 66
diff changeset
1198 public String [][] serviceNamesAndDescriptions() {
70
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
1199 return serviceNamesAndDescription;
68
541814404822 Added interfaces for XML processing services. TODO: Implement them!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 66
diff changeset
1200 }
541814404822 Added interfaces for XML processing services. TODO: Implement them!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 66
diff changeset
1201
380
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 348
diff changeset
1202 public Service.Output process(
86
b2e0cb83631c Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 84
diff changeset
1203 String serviceName,
70
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
1204 Document input,
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
1205 CallMeta callMeta
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
1206 )
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
1207 throws ArtifactDatabaseException
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
1208 {
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
1209 Service service = (Service)name2service.get(serviceName);
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
1210
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
1211 if (service == null) {
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
1212 throw new ArtifactDatabaseException(NO_SUCH_SERVICE);
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
1213 }
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
1214
ce488c1d3fc4 Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 68
diff changeset
1215 return service.process(input, context, callMeta);
68
541814404822 Added interfaces for XML processing services. TODO: Implement them!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 66
diff changeset
1216 }
117
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1217
118
0e0c27bc0b90 Added creation time to collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 117
diff changeset
1218 // User API
117
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1219
395
b77465617071 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 394
diff changeset
1220 /** Returns user(s) elements. */
117
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1221 public Document listUsers(CallMeta callMeta)
150
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1222 throws ArtifactDatabaseException
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1223 {
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1224 UserFactory factory = getUserFactory();
117
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1225
150
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1226 if (factory == null) {
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1227 throw new ArtifactDatabaseException(NO_SUCH_FACTORY);
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1228 }
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1229
157
6e6965873a48 Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 155
diff changeset
1230 User [] users = backend.getUsers(factory, context);
150
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1231
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1232 if (users != null) {
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1233 logger.debug(users.length + " users found in the backend.");
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1234 }
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1235
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1236 Document result = XMLUtils.newDocument();
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1237
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1238 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1239 result,
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1240 ArtifactNamespaceContext.NAMESPACE_URI,
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1241 ArtifactNamespaceContext.NAMESPACE_PREFIX);
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1242
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1243 Element root = ec.create("users");
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1244 result.appendChild(root);
418
8d8aed23c323 Remove spaces and newline
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 417
diff changeset
1245
417
410a1bfb9590 Fix for NPE on empty user database
Christian Lins <christian.lins@intevation.de>
parents: 415
diff changeset
1246 if(users != null) {
410a1bfb9590 Fix for NPE on empty user database
Christian Lins <christian.lins@intevation.de>
parents: 415
diff changeset
1247 for (User user: users) {
410a1bfb9590 Fix for NPE on empty user database
Christian Lins <christian.lins@intevation.de>
parents: 415
diff changeset
1248 Element ue = ec.create("user");
410a1bfb9590 Fix for NPE on empty user database
Christian Lins <christian.lins@intevation.de>
parents: 415
diff changeset
1249 ec.addAttr(ue, "uuid", user.identifier(), true);
410a1bfb9590 Fix for NPE on empty user database
Christian Lins <christian.lins@intevation.de>
parents: 415
diff changeset
1250 ec.addAttr(ue, "name", user.getName(), true);
410a1bfb9590 Fix for NPE on empty user database
Christian Lins <christian.lins@intevation.de>
parents: 415
diff changeset
1251 Element ua = ec.create("account");
410a1bfb9590 Fix for NPE on empty user database
Christian Lins <christian.lins@intevation.de>
parents: 415
diff changeset
1252 ec.addAttr(ua, "name", user.getAccount(), true);
410a1bfb9590 Fix for NPE on empty user database
Christian Lins <christian.lins@intevation.de>
parents: 415
diff changeset
1253 ue.appendChild(ua);
150
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1254
417
410a1bfb9590 Fix for NPE on empty user database
Christian Lins <christian.lins@intevation.de>
parents: 415
diff changeset
1255 Document role = user.getRole();
150
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1256
417
410a1bfb9590 Fix for NPE on empty user database
Christian Lins <christian.lins@intevation.de>
parents: 415
diff changeset
1257 if (role != null) {
410a1bfb9590 Fix for NPE on empty user database
Christian Lins <christian.lins@intevation.de>
parents: 415
diff changeset
1258 ue.appendChild(result.importNode(role.getFirstChild(), true));
410a1bfb9590 Fix for NPE on empty user database
Christian Lins <christian.lins@intevation.de>
parents: 415
diff changeset
1259 }
160
dc687827439f Enabled the artifact database to store and load roles of users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 159
diff changeset
1260
417
410a1bfb9590 Fix for NPE on empty user database
Christian Lins <christian.lins@intevation.de>
parents: 415
diff changeset
1261 root.appendChild(ue);
160
dc687827439f Enabled the artifact database to store and load roles of users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 159
diff changeset
1262 }
150
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1263 }
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1264
78a27a6b3f1f Implemented the listUsers() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 149
diff changeset
1265 return result;
117
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1266 }
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1267
415
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1268 /** Search for a user. */
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1269 public Document findUser(Document data, CallMeta callMeta)
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1270 throws ArtifactDatabaseException
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1271 {
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1272 UserFactory factory = getUserFactory();
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1273
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1274 if (factory == null) {
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1275 throw new ArtifactDatabaseException(NO_SUCH_FACTORY);
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1276 }
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1277
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1278 String account = XMLUtils.xpathString(
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1279 data, XPATH_USERACCOUNT_FIND, ArtifactNamespaceContext.INSTANCE);
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1280
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1281 if (account == null || account.length() == 0) {
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1282 logger.warn("Can't find user without account!");
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1283 throw new ArtifactDatabaseException(NO_USERACCOUNT);
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1284 }
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1285
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1286 User user = backend.findUser(account, factory, context);
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1287
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1288 Document result = XMLUtils.newDocument();
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1289
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1290 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1291 result,
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1292 ArtifactNamespaceContext.NAMESPACE_URI,
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1293 ArtifactNamespaceContext.NAMESPACE_PREFIX);
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1294
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1295 Element ue = ec.create("user");
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1296
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1297 if (user != null) {
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1298 logger.debug(user + " user found in the backend.");
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1299
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1300 ec.addAttr(ue, "uuid", user.identifier(), true);
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1301 ec.addAttr(ue, "name", user.getName(), true);
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1302 Element ua = ec.create("account");
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1303 ec.addAttr(ua, "name", user.getAccount(), true);
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1304 ue.appendChild(ua);
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1305
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1306 Document role = user.getRole();
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1307
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1308 if (role != null) {
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1309 ue.appendChild(result.importNode(role.getFirstChild(), true));
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1310 }
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1311 }
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1312
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1313 result.appendChild(ue);
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1314
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1315 return result;
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1316 }
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1317
117
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1318 public Document createUser(Document data, CallMeta callMeta)
149
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1319 throws ArtifactDatabaseException
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1320 {
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1321 UserFactory factory = getUserFactory();
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1322
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1323 if (factory == null) {
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1324 throw new ArtifactDatabaseException(NO_SUCH_FACTORY);
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1325 }
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1326
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1327 String name = XMLUtils.xpathString(
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1328 data, XPATH_USERNAME, ArtifactNamespaceContext.INSTANCE);
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1329
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1330 if (name == null || name.length() == 0) {
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1331 logger.warn("User without username not accepted!");
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1332 throw new ArtifactDatabaseException(NO_USERNAME);
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1333 }
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1334
411
20f12944c710 Add user account information when creating a user in the artifact database
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 395
diff changeset
1335 String account = XMLUtils.xpathString(
20f12944c710 Add user account information when creating a user in the artifact database
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 395
diff changeset
1336 data, XPATH_USERACCOUNT, ArtifactNamespaceContext.INSTANCE);
20f12944c710 Add user account information when creating a user in the artifact database
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 395
diff changeset
1337
415
d4a846ee35b8 Implement ArtifactDatabase findUser method
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 412
diff changeset
1338 if (account == null || account.length() == 0) {
411
20f12944c710 Add user account information when creating a user in the artifact database
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 395
diff changeset
1339 logger.warn("User without account not accepted!");
20f12944c710 Add user account information when creating a user in the artifact database
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 395
diff changeset
1340 throw new ArtifactDatabaseException(NO_USERACCOUNT);
20f12944c710 Add user account information when creating a user in the artifact database
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 395
diff changeset
1341 }
20f12944c710 Add user account information when creating a user in the artifact database
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 395
diff changeset
1342
160
dc687827439f Enabled the artifact database to store and load roles of users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 159
diff changeset
1343 Node tmp = (Node) XMLUtils.xpath(
dc687827439f Enabled the artifact database to store and load roles of users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 159
diff changeset
1344 data,
dc687827439f Enabled the artifact database to store and load roles of users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 159
diff changeset
1345 XPATH_USERROLE,
dc687827439f Enabled the artifact database to store and load roles of users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 159
diff changeset
1346 XPathConstants.NODE,
dc687827439f Enabled the artifact database to store and load roles of users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 159
diff changeset
1347 ArtifactNamespaceContext.INSTANCE);
dc687827439f Enabled the artifact database to store and load roles of users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 159
diff changeset
1348
149
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1349 Document role = XMLUtils.newDocument();
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1350
160
dc687827439f Enabled the artifact database to store and load roles of users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 159
diff changeset
1351 if (tmp != null) {
dc687827439f Enabled the artifact database to store and load roles of users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 159
diff changeset
1352 Node clone = role.importNode(tmp, true);
dc687827439f Enabled the artifact database to store and load roles of users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 159
diff changeset
1353 role.appendChild(clone);
dc687827439f Enabled the artifact database to store and load roles of users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 159
diff changeset
1354 }
dc687827439f Enabled the artifact database to store and load roles of users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 159
diff changeset
1355
149
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1356 User newUser = null;
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1357
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1358 try {
411
20f12944c710 Add user account information when creating a user in the artifact database
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 395
diff changeset
1359 newUser = backend.createUser(name, account, role, userFactory, context);
149
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1360 }
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1361 catch (Exception e) {
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1362 logger.error(e.getMessage(), e);
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1363 throw new ArtifactDatabaseException(USER_CREATION_FAILED);
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1364 }
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1365
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1366 Document result = XMLUtils.newDocument();
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1367
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1368 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1369 result,
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1370 ArtifactNamespaceContext.NAMESPACE_URI,
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1371 ArtifactNamespaceContext.NAMESPACE_PREFIX);
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1372
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1373 Element root = ec.create("result");
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1374
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1375 if (newUser != null) {
153
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
1376 root.setTextContent(OPERATION_SUCCESSFUL);
149
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1377 }
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1378 else {
153
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
1379 root.setTextContent(OPERATION_FAILURE);
149
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1380 }
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1381
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1382 result.appendChild(root);
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1383
c69abd07bdd0 Implemented the createUser() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
1384 return result;
117
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1385 }
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1386
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1387 public Document deleteUser(String userId, CallMeta callMeta)
152
7e5619115d5b Implemented the deleteUser() method in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 150
diff changeset
1388 throws ArtifactDatabaseException
7e5619115d5b Implemented the deleteUser() method in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 150
diff changeset
1389 {
153
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
1390 logger.debug("Delete user: " + userId);
152
7e5619115d5b Implemented the deleteUser() method in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 150
diff changeset
1391
153
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
1392 Document result = XMLUtils.newDocument();
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
1393
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
1394 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
1395 result,
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
1396 ArtifactNamespaceContext.NAMESPACE_URI,
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
1397 ArtifactNamespaceContext.NAMESPACE_PREFIX);
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
1398
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
1399 Element root = ec.create("result");
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
1400 result.appendChild(root);
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
1401
157
6e6965873a48 Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 155
diff changeset
1402 boolean success = backend.deleteUser(userId);
154
1a72f08ce8d7 Propagate delete user errors correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 153
diff changeset
1403
1a72f08ce8d7 Propagate delete user errors correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 153
diff changeset
1404 root.setTextContent(success ? OPERATION_SUCCESSFUL: OPERATION_FAILURE);
152
7e5619115d5b Implemented the deleteUser() method in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 150
diff changeset
1405
153
bf596b83d984 Adjusted method signatures for deleting users in the UserFactory and in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 152
diff changeset
1406 return result;
117
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1407 }
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1408
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1409
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1410 // Collection API
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1411
343
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1412 public Document getCollectionsMasterArtifact(
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1413 String collectionId,
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1414 CallMeta meta)
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1415 throws ArtifactDatabaseException
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1416 {
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1417 Document result = XMLUtils.newDocument();
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1418 String masterUUID = backend.getMasterArtifact(collectionId);
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1419
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1420 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1421 result,
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1422 ArtifactNamespaceContext.NAMESPACE_URI,
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1423 ArtifactNamespaceContext.NAMESPACE_PREFIX);
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1424
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1425 ArtifactCollectionFactory acf = getArtifactCollectionFactory();
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1426
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1427 if (acf == null) {
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1428 throw new ArtifactDatabaseException(NO_SUCH_FACTORY);
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1429 }
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1430
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1431 UserFactory uf = getUserFactory();
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1432 if (uf == null) {
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1433 throw new ArtifactDatabaseException(NO_SUCH_FACTORY);
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1434 }
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1435
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1436 ArtifactCollection c = backend.getCollection(
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1437 collectionId, acf, uf, context);
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1438
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1439 if (c == null) {
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1440 logger.warn("No collection found with identifier: " + collectionId);
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1441 throw new ArtifactDatabaseException(NO_SUCH_COLLECTION);
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1442 }
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1443
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1444 Element root = ec.create("artifact-collection");
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1445 ec.addAttr(root, "name", c.getName(), true);
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1446 ec.addAttr(root, "uuid", c.identifier(), true);
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1447 ec.addAttr(root, "ttl", String.valueOf(c.getTTL()), true);
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1448
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1449 Date creationTime = c.getCreationTime();
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1450 String creation = creationTime != null
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1451 ? Long.toString(creationTime.getTime())
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1452 : "";
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1453
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1454 ec.addAttr(root, "creation", creation, true);
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1455 result.appendChild(root);
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1456
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1457 if (masterUUID == null || masterUUID.length() == 0) {
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1458 logger.debug("No master for the collection existing.");
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1459 return result;
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1460 }
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1461
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1462 Element master = ec.create("artifact");
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1463 ec.addAttr(master, "uuid", masterUUID, true);
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1464
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1465 root.appendChild(master);
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1466
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1467 return result;
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1468 }
542caebea773 Add functionality to get 'oldest' artifact of a collection.'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 334
diff changeset
1469
117
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1470 public Document listCollections(String userId, CallMeta callMeta)
164
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1471 throws ArtifactDatabaseException
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1472 {
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1473 ArtifactCollectionFactory acf = getArtifactCollectionFactory();
167
c9c27aca2f70 Added code to list collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 166
diff changeset
1474 UserFactory uf = getUserFactory();
164
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1475
167
c9c27aca2f70 Added code to list collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 166
diff changeset
1476 if (acf == null || uf == null) {
164
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1477 throw new ArtifactDatabaseException(NO_SUCH_FACTORY);
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1478 }
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1479
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1480 logger.debug("Fetch the list of collection for user: " + userId);
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1481
167
c9c27aca2f70 Added code to list collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 166
diff changeset
1482 ArtifactCollection [] ac = backend.listCollections(
c9c27aca2f70 Added code to list collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 166
diff changeset
1483 userId,
c9c27aca2f70 Added code to list collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 166
diff changeset
1484 null, // XXX: fetch from REST
c9c27aca2f70 Added code to list collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 166
diff changeset
1485 acf, uf,
c9c27aca2f70 Added code to list collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 166
diff changeset
1486 context);
164
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1487
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1488 Document result = XMLUtils.newDocument();
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1489
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1490 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1491 result,
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1492 ArtifactNamespaceContext.NAMESPACE_URI,
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1493 ArtifactNamespaceContext.NAMESPACE_PREFIX);
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1494
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1495 Element root = ec.create("artifact-collections");
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1496 result.appendChild(root);
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1497
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1498 if (ac == null || ac.length == 0) {
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1499 logger.debug("No collections for the user existing.");
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1500
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1501 return result;
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1502 }
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1503
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1504 logger.debug("Found " + ac.length + " collections of the user.");
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1505
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1506 for (ArtifactCollection c: ac) {
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1507 Element collection = ec.create("artifact-collection");
183
9b8923043a38 Repaired the namespaces of the xml element attributes in the collecton context of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 176
diff changeset
1508 ec.addAttr(collection, "name", c.getName(), true);
9b8923043a38 Repaired the namespaces of the xml element attributes in the collecton context of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 176
diff changeset
1509 ec.addAttr(collection, "uuid", c.identifier(), true);
282
d15f09d5b89d Put the ttl of each collection into the document that contains the user collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 275
diff changeset
1510 ec.addAttr(collection, "ttl", String.valueOf(c.getTTL()), true);
168
f70977cf2faf Avoid Nullpointer exception in listCollections() when no creation time of the collection is returned.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 167
diff changeset
1511
f70977cf2faf Avoid Nullpointer exception in listCollections() when no creation time of the collection is returned.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 167
diff changeset
1512 Date creationTime = c.getCreationTime();
f70977cf2faf Avoid Nullpointer exception in listCollections() when no creation time of the collection is returned.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 167
diff changeset
1513 String creation = creationTime != null
f70977cf2faf Avoid Nullpointer exception in listCollections() when no creation time of the collection is returned.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 167
diff changeset
1514 ? Long.toString(creationTime.getTime())
f70977cf2faf Avoid Nullpointer exception in listCollections() when no creation time of the collection is returned.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 167
diff changeset
1515 : "";
f70977cf2faf Avoid Nullpointer exception in listCollections() when no creation time of the collection is returned.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 167
diff changeset
1516
183
9b8923043a38 Repaired the namespaces of the xml element attributes in the collecton context of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 176
diff changeset
1517 ec.addAttr(collection, "creation", creation, true);
164
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1518
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1519 root.appendChild(collection);
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1520 }
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1521
268c2972d4a7 Implemented the interface method listCollections() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 162
diff changeset
1522 return result;
117
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1523 }
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1524
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1525 public Document createCollection(String ownerId, Document data,
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1526 CallMeta callMeta)
158
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1527 throws ArtifactDatabaseException
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1528 {
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1529 ArtifactCollectionFactory acf = getArtifactCollectionFactory();
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1530
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1531 if (acf == null) {
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1532 throw new ArtifactDatabaseException(NO_SUCH_FACTORY);
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1533 }
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1534
162
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1535 String name = XMLUtils.xpathString(
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1536 data, XPATH_COLLECTION_NAME, ArtifactNamespaceContext.INSTANCE);
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1537
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1538 logger.debug("Create new collection with name: " + name);
159
db0d20440b92 Added code to create collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 158
diff changeset
1539
254
6cf9560bd249 Bugfix: do not write empty xml documents into database any longer - caused exceptions while serialization/deserialization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 253
diff changeset
1540 Document attr = null;
198
6370369412e9 Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 196
diff changeset
1541
6370369412e9 Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 196
diff changeset
1542 Node attrNode = (Node) XMLUtils.xpath(
6370369412e9 Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 196
diff changeset
1543 data,
6370369412e9 Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 196
diff changeset
1544 XPATH_COLLECTION_ATTRIBUTE,
6370369412e9 Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 196
diff changeset
1545 XPathConstants.NODE,
6370369412e9 Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 196
diff changeset
1546 ArtifactNamespaceContext.INSTANCE);
6370369412e9 Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 196
diff changeset
1547
6370369412e9 Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 196
diff changeset
1548 if (attrNode != null) {
254
6cf9560bd249 Bugfix: do not write empty xml documents into database any longer - caused exceptions while serialization/deserialization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 253
diff changeset
1549 attr = XMLUtils.newDocument();
198
6370369412e9 Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 196
diff changeset
1550 attr.appendChild(attr.importNode(attrNode, true));
6370369412e9 Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 196
diff changeset
1551 }
6370369412e9 Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 196
diff changeset
1552
158
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1553 ArtifactCollection ac = backend.createCollection(
198
6370369412e9 Parse the collection attribute of the incoming document of a create-collection call and store this in the Backend.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 196
diff changeset
1554 ownerId, name, acf, attr, context);
158
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1555
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1556 if (ac == null) {
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1557 throw new ArtifactDatabaseException(COLLECTION_CREATION_FAILED);
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1558 }
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1559
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1560 Document result = XMLUtils.newDocument();
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1561
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1562 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1563 result,
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1564 ArtifactNamespaceContext.NAMESPACE_URI,
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1565 ArtifactNamespaceContext.NAMESPACE_PREFIX);
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1566
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1567 Element root = ec.create("result");
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1568 result.appendChild(root);
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1569
169
2f575d594fdb The document returned by the createCollection() method will now contain the uuid of the created collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 168
diff changeset
1570 Element acElement = ec.create("artifact-collection");
183
9b8923043a38 Repaired the namespaces of the xml element attributes in the collecton context of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 176
diff changeset
1571 ec.addAttr(acElement, "uuid", ac.identifier(), true);
284
084d68974d4a The ttl is now contained in the document that is returned after a collection has been created.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 282
diff changeset
1572 ec.addAttr(acElement, "ttl", String.valueOf(ac.getTTL()), true);
169
2f575d594fdb The document returned by the createCollection() method will now contain the uuid of the created collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 168
diff changeset
1573
2f575d594fdb The document returned by the createCollection() method will now contain the uuid of the created collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 168
diff changeset
1574 root.appendChild(acElement);
158
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1575
d718a4d55662 Implemented the createCollection() method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 157
diff changeset
1576 return result;
117
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1577 }
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1578
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1579 public Document deleteCollection(String collectionId, CallMeta callMeta)
162
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1580 throws ArtifactDatabaseException
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1581 {
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1582 logger.debug("Delete collection: " + collectionId);
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1583
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1584 Document result = XMLUtils.newDocument();
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1585
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1586 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1587 result,
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1588 ArtifactNamespaceContext.NAMESPACE_URI,
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1589 ArtifactNamespaceContext.NAMESPACE_PREFIX);
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1590
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1591 Element root = ec.create("result");
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1592 result.appendChild(root);
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1593
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1594 boolean success = backend.deleteCollection(collectionId);
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1595
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1596 root.setTextContent(success ? OPERATION_SUCCESSFUL: OPERATION_FAILURE);
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1597
4ac91485b4e0 Implemented the deleteCollection() interface method in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 160
diff changeset
1598 return result;
117
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1599 }
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1600
196
171b6200d26d Added a describe() action for collections - the implementation in the artifact server is currently just a stub that throws an not implemented exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 192
diff changeset
1601 public Document describeCollection(String collectionId, CallMeta callMeta)
171b6200d26d Added a describe() action for collections - the implementation in the artifact server is currently just a stub that throws an not implemented exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 192
diff changeset
1602 throws ArtifactDatabaseException
171b6200d26d Added a describe() action for collections - the implementation in the artifact server is currently just a stub that throws an not implemented exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 192
diff changeset
1603 {
171b6200d26d Added a describe() action for collections - the implementation in the artifact server is currently just a stub that throws an not implemented exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 192
diff changeset
1604 logger.debug("Describe collection: " + collectionId);
219
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1605 ArtifactCollectionFactory acf = getArtifactCollectionFactory();
196
171b6200d26d Added a describe() action for collections - the implementation in the artifact server is currently just a stub that throws an not implemented exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 192
diff changeset
1606
219
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1607 if (acf == null) {
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1608 throw new ArtifactDatabaseException(NO_SUCH_FACTORY);
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1609 }
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1610
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1611 UserFactory uf = getUserFactory();
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1612 if (uf == null) {
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1613 throw new ArtifactDatabaseException(NO_SUCH_FACTORY);
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1614 }
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1615
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1616 ArtifactCollection c = backend.getCollection(
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1617 collectionId, acf, uf, context);
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1618
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1619 if (c == null) {
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1620 logger.warn("No collection found with identifier: " + collectionId);
222
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
1621 throw new ArtifactDatabaseException(NO_SUCH_COLLECTION);
219
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1622 }
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1623
246
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 233
diff changeset
1624 CollectionCallContext cc = new CollectionCallContext(
219
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1625 ArtifactDatabaseImpl.this,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1626 CallContext.NOTHING,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1627 callMeta,
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1628 c);
cabe4c02ab64 Refactored the CallContextImpl - there are two concrete classes for Artifacts and ArtifactCollections now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
1629
246
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 233
diff changeset
1630 try {
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 233
diff changeset
1631 return c.describe(cc);
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 233
diff changeset
1632 }
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 233
diff changeset
1633 finally {
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 233
diff changeset
1634 cc.postCall();
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 233
diff changeset
1635 }
253
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1636 }
246
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 233
diff changeset
1637
253
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1638
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1639 public Document getCollectionAttribute(String collectionId, CallMeta meta)
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1640 throws ArtifactDatabaseException
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1641 {
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1642 logger.debug("Fetch collection attribute for: " + collectionId);
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1643
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1644 return backend.getCollectionAttribute(collectionId);
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1645 }
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1646
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1647
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1648 public Document setCollectionAttribute(
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1649 String collectionId,
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1650 CallMeta meta,
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1651 Document attribute)
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1652 throws ArtifactDatabaseException
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1653 {
268
4edaf3073109 Repaired the setting of a new attribute for a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 254
diff changeset
1654 logger.debug("Set new attribute for the collection: " + collectionId);
253
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1655
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1656 Document result = XMLUtils.newDocument();
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1657
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1658 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1659 result,
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1660 ArtifactNamespaceContext.NAMESPACE_URI,
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1661 ArtifactNamespaceContext.NAMESPACE_PREFIX);
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1662
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1663 Element root = ec.create("result");
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1664 result.appendChild(root);
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1665
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1666 boolean success = backend.setCollectionAttribute(
268
4edaf3073109 Repaired the setting of a new attribute for a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 254
diff changeset
1667 collectionId, attribute);
253
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1668
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1669 root.setTextContent(success ? OPERATION_SUCCESSFUL: OPERATION_FAILURE);
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1670
a2df2b48d2aa Enabled the artifact database to handle requests specific to collection attributes and collection item attributes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 252
diff changeset
1671 return result;
196
171b6200d26d Added a describe() action for collections - the implementation in the artifact server is currently just a stub that throws an not implemented exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 192
diff changeset
1672 }
171b6200d26d Added a describe() action for collections - the implementation in the artifact server is currently just a stub that throws an not implemented exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 192
diff changeset
1673
252
6de74b0b878e Changed the method names to get and set the attributes of collection items.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 250
diff changeset
1674 public Document getCollectionItemAttribute(String collectionId, String artifactId,
192
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1675 CallMeta callMeta) throws ArtifactDatabaseException
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1676 {
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1677 logger.debug("Fetch the attribute for the artifact: " + artifactId);
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1678
252
6de74b0b878e Changed the method names to get and set the attributes of collection items.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 250
diff changeset
1679 return backend.getCollectionItemAttribute(collectionId, artifactId);
117
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1680 }
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1681
252
6de74b0b878e Changed the method names to get and set the attributes of collection items.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 250
diff changeset
1682 public Document setCollectionItemAttribute(String collectionId, String artifactId,
192
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1683 Document source, CallMeta callMeta)
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1684 throws ArtifactDatabaseException
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1685 {
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1686 logger.debug("Set the attribute for the artifact: " + artifactId);
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1687
254
6cf9560bd249 Bugfix: do not write empty xml documents into database any longer - caused exceptions while serialization/deserialization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 253
diff changeset
1688 Document attribute = null;
192
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1689
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1690 Node attr = (Node) XMLUtils.xpath(
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1691 source,
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1692 XPATH_COLLECTION_ITEM_ATTRIBUTE,
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1693 XPathConstants.NODE,
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1694 ArtifactNamespaceContext.INSTANCE);
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1695
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1696 if (attr != null) {
254
6cf9560bd249 Bugfix: do not write empty xml documents into database any longer - caused exceptions while serialization/deserialization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 253
diff changeset
1697 attribute = XMLUtils.newDocument();
192
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1698 attribute.appendChild(attribute.importNode(attr, true));
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1699 }
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1700
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1701 Document result = XMLUtils.newDocument();
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1702
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1703 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1704 result,
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1705 ArtifactNamespaceContext.NAMESPACE_URI,
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1706 ArtifactNamespaceContext.NAMESPACE_PREFIX);
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1707
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1708 Element root = ec.create("result");
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1709 result.appendChild(root);
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1710
252
6de74b0b878e Changed the method names to get and set the attributes of collection items.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 250
diff changeset
1711 boolean success = backend.setCollectionItemAttribute(
192
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1712 collectionId, artifactId, attribute);
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1713
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1714 root.setTextContent(success ? OPERATION_SUCCESSFUL: OPERATION_FAILURE);
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1715
dad6071c9072 Implemented the getCollectionAttribute() and setCollectionAttribute() methods.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 190
diff changeset
1716 return result;
117
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1717 }
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1718
189
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1719 public Document addCollectionArtifact(
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1720 String collectionId,
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1721 String artifactId,
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1722 Document input,
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1723 CallMeta callMeta)
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1724 throws ArtifactDatabaseException
166
89db80380f7f Implemented the method addCollectionArtifact() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 164
diff changeset
1725 {
89db80380f7f Implemented the method addCollectionArtifact() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 164
diff changeset
1726 logger.debug(
89db80380f7f Implemented the method addCollectionArtifact() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 164
diff changeset
1727 "Add artifact '" + artifactId + "' collection '" +collectionId+"'");
89db80380f7f Implemented the method addCollectionArtifact() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 164
diff changeset
1728
189
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1729 Document attr = XMLUtils.newDocument();
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1730
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1731 Node attrNode = (Node) XMLUtils.xpath(
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1732 input,
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1733 XPATH_COLLECTION_ITEM_ATTRIBUTE,
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1734 XPathConstants.NODE,
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1735 ArtifactNamespaceContext.INSTANCE);
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1736
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1737 if (attrNode != null) {
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1738 attr.appendChild(attr.importNode(attrNode, true));
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1739 }
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1740
166
89db80380f7f Implemented the method addCollectionArtifact() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 164
diff changeset
1741 boolean success = backend.addCollectionArtifact(
176
a0eff2227588 Added code to add artifacts to collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 169
diff changeset
1742 collectionId,
a0eff2227588 Added code to add artifacts to collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 169
diff changeset
1743 artifactId,
189
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1744 attr);
166
89db80380f7f Implemented the method addCollectionArtifact() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 164
diff changeset
1745
222
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
1746 if (!success) {
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
1747 Document result = XMLUtils.newDocument();
166
89db80380f7f Implemented the method addCollectionArtifact() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 164
diff changeset
1748
222
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
1749 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
1750 result,
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
1751 ArtifactNamespaceContext.NAMESPACE_URI,
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
1752 ArtifactNamespaceContext.NAMESPACE_PREFIX);
166
89db80380f7f Implemented the method addCollectionArtifact() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 164
diff changeset
1753
222
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
1754 Element root = ec.create("result");
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
1755 result.appendChild(root);
166
89db80380f7f Implemented the method addCollectionArtifact() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 164
diff changeset
1756
222
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
1757 root.setTextContent(OPERATION_FAILURE);
166
89db80380f7f Implemented the method addCollectionArtifact() in the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 164
diff changeset
1758
222
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
1759 return result;
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
1760 }
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
1761
98695dc6d94d The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 219
diff changeset
1762 return describeCollection(collectionId, callMeta);
117
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1763 }
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1764
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1765 public Document removeCollectionArtifact(String collectionId, String artifactId,
190
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1766 CallMeta callMeta) throws ArtifactDatabaseException
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1767 {
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1768 logger.debug(
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1769 "Remove artifact '" + artifactId + "' from collection '" +
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1770 collectionId + "'");
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1771
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1772 Document attr = XMLUtils.newDocument();
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1773
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1774 boolean success = backend.removeCollectionArtifact(
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1775 collectionId,
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1776 artifactId);
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1777
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1778 Document result = XMLUtils.newDocument();
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1779
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1780 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1781 result,
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1782 ArtifactNamespaceContext.NAMESPACE_URI,
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1783 ArtifactNamespaceContext.NAMESPACE_PREFIX);
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1784
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1785 Element root = ec.create("result");
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1786 result.appendChild(root);
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1787
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1788 root.setTextContent(success ? OPERATION_SUCCESSFUL: OPERATION_FAILURE);
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1789
7acf4a325bfe Implemented removeCollectionArtifact() method of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 189
diff changeset
1790 return result;
117
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1791 }
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1792
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1793 public Document listCollectionArtifacts(String collectionId,
189
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1794 CallMeta callMeta) throws ArtifactDatabaseException
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1795 {
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1796 CollectionItem[] items = backend.listCollectionArtifacts(collectionId);
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1797
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1798 Document result = XMLUtils.newDocument();
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1799
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1800 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1801 result,
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1802 ArtifactNamespaceContext.NAMESPACE_URI,
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1803 ArtifactNamespaceContext.NAMESPACE_PREFIX);
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1804
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1805 Element root = ec.create("result");
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1806 Element ac = ec.create("artifact-collection");
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1807 ec.addAttr(ac, "uuid", collectionId, true);
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1808
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1809 for (CollectionItem item: items) {
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1810 Element i = ec.create("collection-item");
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1811 Element attr = ec.create("attribute");
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1812 ec.addAttr(i, "uuid", item.getArtifactIdentifier(), true);
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1813
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1814 Document attribute = item.getAttribute();
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1815 if (attribute != null) {
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1816 Node firstChild = attribute.getFirstChild();
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1817 attr.appendChild(result.importNode(firstChild, true));
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1818 }
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1819 else {
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1820 logger.debug("No attributes for the collection item!");
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1821 }
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1822
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1823 i.appendChild(attr);
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1824 ac.appendChild(i);
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1825 }
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1826
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1827 root.appendChild(ac);
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1828 result.appendChild(root);
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1829
fbaeb5931d10 Implemented addCollectionArtifact() and listCollectionArtifacts() of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 183
diff changeset
1830 return result;
117
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1831 }
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1832
273
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1833 public Document setCollectionTTL(String uuid, Document doc, CallMeta meta)
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1834 throws ArtifactDatabaseException
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1835 {
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1836 Document result = XMLUtils.newDocument();
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1837 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1838 result,
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1839 ArtifactNamespaceContext.NAMESPACE_URI,
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1840 ArtifactNamespaceContext.NAMESPACE_PREFIX);
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1841
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1842 Element root = ec.create("result");
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1843 result.appendChild(root);
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1844
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1845 String tmp = XMLUtils.xpathString(
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1846 doc, XPATH_COLLECTION_TTL, ArtifactNamespaceContext.INSTANCE);
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1847
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1848 logger.info("Set TTL of artifact collection '" + uuid + "' to: " + tmp);
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1849
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1850 if (tmp == null || tmp.length() == 0) {
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1851 logger.warn("No ttl for this collection specified.");
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1852 root.setTextContent(OPERATION_FAILURE);
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1853
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1854 return result;
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1855 }
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1856
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1857 Long ttl = null;
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1858 if ((tmp = tmp.toUpperCase()).equals("INF")) {
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1859 ttl = null;
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1860 }
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1861 else if (tmp.equals("DEFAULT")) {
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1862 ArtifactCollectionFactory acf = getArtifactCollectionFactory();
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1863 ttl = acf.timeToLiveUntouched(null, context);
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1864 }
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1865 else {
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1866 try {
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1867 ttl = Long.valueOf(tmp);
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1868
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1869 if (ttl < 0) {
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1870 throw new NumberFormatException("Negative value.");
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1871 }
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1872 }
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1873 catch (NumberFormatException nfe) {
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1874 logger.error("Could not determine TTL", nfe);
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1875 root.setTextContent(OPERATION_FAILURE);
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1876 return result;
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1877 }
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1878 }
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1879
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1880 boolean success = backend.setCollectionTTL(uuid, ttl);
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1881 root.setTextContent(success ? OPERATION_SUCCESSFUL: OPERATION_FAILURE);
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1882
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1883 return result;
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1884 }
22a90706d32d Enables the artifact server to set the TTL of a specific collection via REST call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 269
diff changeset
1885
275
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1886
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1887 public Document setCollectionName(String uuid, Document doc, CallMeta meta)
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1888 throws ArtifactDatabaseException
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1889 {
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1890 Document result = XMLUtils.newDocument();
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1891 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1892 result,
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1893 ArtifactNamespaceContext.NAMESPACE_URI,
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1894 ArtifactNamespaceContext.NAMESPACE_PREFIX);
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1895
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1896 Element root = ec.create("result");
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1897 result.appendChild(root);
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1898
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1899 String name = XMLUtils.xpathString(
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1900 doc, XPATH_COLLECTION_NAME, ArtifactNamespaceContext.INSTANCE);
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1901
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1902 logger.info("Set name of collection '" + uuid + "' to: " + name);
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1903
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1904 if (name == null || name.length() == 0) {
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1905 logger.warn("The new name is emtpy. No new name set!");
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1906 root.setTextContent(OPERATION_FAILURE);
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1907 return result;
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1908 }
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1909
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1910 boolean success = backend.setCollectionName(uuid, name);
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1911 root.setTextContent(success ? OPERATION_SUCCESSFUL: OPERATION_FAILURE);
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1912
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1913 return result;
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1914 }
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1915
e92d5944fe4b Enabled the artifact database to retrieve requests to change the name of a specific collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 273
diff changeset
1916
269
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
1917 public DeferredOutput outCollection(
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
1918 String collectionId,
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
1919 Document format,
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
1920 CallMeta callMeta)
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
1921 throws ArtifactDatabaseException
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
1922 {
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
1923 return outCollection(collectionId, null, format, callMeta);
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
1924 }
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
1925
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
1926 public DeferredOutput outCollection(
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
1927 String collectionId,
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
1928 String type,
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
1929 Document format,
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
1930 CallMeta callMeta)
d9a99b28a847 Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 268
diff changeset
1931 throws ArtifactDatabaseException
228
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1932 {
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1933 ArtifactCollectionFactory acf = getArtifactCollectionFactory();
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1934
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1935 if (acf == null) {
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1936 throw new ArtifactDatabaseException(NO_SUCH_FACTORY);
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1937 }
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1938
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1939 UserFactory uf = getUserFactory();
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1940 if (uf == null) {
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1941 throw new ArtifactDatabaseException(NO_SUCH_FACTORY);
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1942 }
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1943
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1944 ArtifactCollection c = backend.getCollection(
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1945 collectionId, acf, uf, context);
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1946
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1947 if (c == null) {
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1948 logger.warn("No collection found with identifier: " + collectionId);
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1949 throw new ArtifactDatabaseException(NO_SUCH_COLLECTION);
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1950 }
dd977fb7552e Added an implementation of DeferredOutput for ArtifactCollections and implemented the out() operation of ArtifactCollections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
1951
328
1eb7863136f4 ArtifactDatabase: Called context listeners too early.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 313
diff changeset
1952 return new DeferredCollectionOutputImpl(c, type, format, callMeta);
246
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 233
diff changeset
1953 }
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 233
diff changeset
1954
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 233
diff changeset
1955 protected void initCallContext(CallContext cc) {
247
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
1956 logger.debug("initCallContext");
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
1957 if (callContextListener != null) {
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
1958 callContextListener.init(cc);
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
1959 }
246
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 233
diff changeset
1960 }
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 233
diff changeset
1961
a8a06bbe306c Added calls to call init/close for call contextes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 233
diff changeset
1962 protected void closeCallContext(CallContext cc) {
247
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
1963 logger.debug("closeCallContext");
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
1964 if (callContextListener != null) {
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
1965 callContextListener.close(cc);
3a1209f214f5 Added instance variable to hold a call context listener.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 246
diff changeset
1966 }
117
4d725248f8d1 Added external API for users and collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
1967 }
303
190aa68ae7a8 Added method to artifact database to load all artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 301
diff changeset
1968
190aa68ae7a8 Added method to artifact database to load all artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 301
diff changeset
1969 @Override
394
c40729bfe06d Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
1970 public void loadAllArtifacts(ArtifactLoadedCallback callback)
303
190aa68ae7a8 Added method to artifact database to load all artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 301
diff changeset
1971 throws ArtifactDatabaseException
190aa68ae7a8 Added method to artifact database to load all artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 301
diff changeset
1972 {
190aa68ae7a8 Added method to artifact database to load all artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 301
diff changeset
1973 logger.debug("loadAllArtifacts");
190aa68ae7a8 Added method to artifact database to load all artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 301
diff changeset
1974 boolean success = backend.loadAllArtifacts(callback);
190aa68ae7a8 Added method to artifact database to load all artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 301
diff changeset
1975 if (!success) {
190aa68ae7a8 Added method to artifact database to load all artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 301
diff changeset
1976 throw new ArtifactDatabaseException(INTERNAL_ERROR);
190aa68ae7a8 Added method to artifact database to load all artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 301
diff changeset
1977 }
190aa68ae7a8 Added method to artifact database to load all artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 301
diff changeset
1978 }
304
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1979
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1980 public void start() {
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1981 if (lifetimeListeners == null || lifetimeListeners.isEmpty()) {
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1982 return;
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1983 }
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1984
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1985 for (LifetimeListener ltl: lifetimeListeners) {
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1986 ltl.systemUp(context);
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1987 }
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1988
308
a077bb098eb4 Fixed broken SQL statement. Added debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 304
diff changeset
1989 logger.debug("all lifetime listeners started");
a077bb098eb4 Fixed broken SQL statement. Added debug output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 304
diff changeset
1990
304
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1991 Runtime.getRuntime().addShutdownHook(new Thread() {
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1992 @Override
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1993 public void run() {
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1994 for (LifetimeListener ltl: lifetimeListeners) {
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1995 ltl.systemDown(context);
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1996 }
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1997 }
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1998 });
40b64b4aafce Added lifetime listeners to be called when system is up and is going down.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 303
diff changeset
1999 }
550
68f01f10624e Introduced helper for finding the user name for a given artifact
gernotbelger
parents: 496
diff changeset
2000
68f01f10624e Introduced helper for finding the user name for a given artifact
gernotbelger
parents: 496
diff changeset
2001 @Override
68f01f10624e Introduced helper for finding the user name for a given artifact
gernotbelger
parents: 496
diff changeset
2002 public String findArtifactUser(final String artifactIdentifier) {
68f01f10624e Introduced helper for finding the user name for a given artifact
gernotbelger
parents: 496
diff changeset
2003 return backend.findUserName(artifactIdentifier);
68f01f10624e Introduced helper for finding the user name for a given artifact
gernotbelger
parents: 496
diff changeset
2004 }
562
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
2005
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
2006 @Override
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
2007 public String getServerAddress() {
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
2008 return this.serverAddress;
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
2009 }
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
2010
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
2011 @Override
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
2012 public Map<String, Class<?>> getRestServices() {
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
2013 return restServices;
05caf2e731d0 Allow to add additional restful services via configuration.
gernotbelger
parents: 550
diff changeset
2014 }
13
0d6badf6af42 Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2015 }
79
f69e5b87f05f Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 75
diff changeset
2016 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org