Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollectionFactory.java @ 357:1d11a0531242
Added artifact parameter to facets getDataProviderKeys.
artifacts/trunk@3380 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 09 Dec 2011 16:03:19 +0000 |
parents | 942a54670a72 |
children | 6431b7efe240 |
rev | line source |
---|---|
122
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 /* |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 * Copyright (c) 2011 by Intevation GmbH |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 * |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 * This program is free software under the LGPL (>=v2.1) |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 * Read the file LGPL.txt coming with the software for details |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 * or visit http://www.gnu.org/licenses/ if it does not exist. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 */ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 package de.intevation.artifactdatabase; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
207
b2115f484edb
Move Config and XMLUtils totally to commons package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
170
diff
changeset
|
10 import de.intevation.artifacts.common.utils.Config; |
b2115f484edb
Move Config and XMLUtils totally to commons package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
170
diff
changeset
|
11 |
122
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import org.apache.log4j.Logger; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import org.w3c.dom.Document; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import org.w3c.dom.Node; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.artifacts.ArtifactCollection; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.artifacts.ArtifactCollectionFactory; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
170
ac0f8bd97277
Fix parameter propagation of creation time ond collection names.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
159
diff
changeset
|
20 import java.util.Date; |
ac0f8bd97277
Fix parameter propagation of creation time ond collection names.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
159
diff
changeset
|
21 |
122
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 /** |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 * The default implementation of a ArtifactCollectionFactory. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 * |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 */ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 public class DefaultArtifactCollectionFactory |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 implements ArtifactCollectionFactory |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 /** The logger that is used in this factory.*/ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 private static Logger logger = |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 Logger.getLogger(DefaultArtifactCollectionFactory.class); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 /** XPath to access the TTL of this artifact.*/ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 public static final String XPATH_TTL = "@ttl"; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 /** XPath to access the name of this factory.*/ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 public static final String XPATH_NAME = "@name"; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 /** XPath to access the description of this artifact factory.*/ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 public static final String XPATH_DESCRIPTION = "@description"; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 /** |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 * XPath to access the class name of the artifacts to be build |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 * by this factory. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 */ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 public static final String XPATH_ARTIFACTCOLLECTION = "@artifact-collection"; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 /** |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 * Default description of this factory if none is given by the |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 * configuration. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 */ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 public static final String DEFAULT_DESCRIPTION = |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 "No description available"; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 /** |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 * Class to load if no artifact class is given in the configuration. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 */ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 public static final String DEFAULT_ARTIFACTCOLLECTION = |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 "de.intevation.artifactdatabase.DefaultArtifact"; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 /** The name of the factory.*/ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 protected String name; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 /** The description of the factory.*/ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 protected String description; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 /** The class that is used to instantiate new ArtifactCollection.*/ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 protected Class clazz; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 /** The time to live of the artifact collection build by this factory.*/ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 protected Long ttl; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 /** |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 * The default constructor. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 */ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 public DefaultArtifactCollectionFactory() { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 /** |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 * The short name of this factory. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 * |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 * @return the name of this factory. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 */ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 public String getName() { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 return name; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 /** |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 * Description of this factory. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 * |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 * @return description of the factory. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 */ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 public String getDescription() { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 return description; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 /** |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
105 * Returns the time to live of the given artifact. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 * |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 * @param artifact |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 */ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 public Long timeToLiveUntouched( |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 ArtifactCollection collection, |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 Object context) |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 return ttl; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
115 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 /** |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 * Create a new artifact of certain type, given a general purpose context and |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 * an identifier. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 * @param context a context from the ArtifactDatabase. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 * @param identifier unique identifer for the new artifact |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
122 * @param data the data containing more details for the setup of an Artifact. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
123 * @return a new {@linkplain de.intevation.artifacts.ArtifactCollection ArtifactCollection} |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
124 */ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
125 public ArtifactCollection createCollection( |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 String identifier, |
159
db0d20440b92
Added code to create collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
122
diff
changeset
|
127 String name, |
170
ac0f8bd97277
Fix parameter propagation of creation time ond collection names.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
159
diff
changeset
|
128 Date creationTime, |
281
942a54670a72
Made the TTL of a Collection retrievable via getter method.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
207
diff
changeset
|
129 long ttl, |
159
db0d20440b92
Added code to create collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
122
diff
changeset
|
130 Document data, |
db0d20440b92
Added code to create collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
122
diff
changeset
|
131 Object context |
db0d20440b92
Added code to create collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
122
diff
changeset
|
132 ) { |
122
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 try { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 ArtifactCollection collection = |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
135 (ArtifactCollection) clazz.newInstance(); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
136 |
281
942a54670a72
Made the TTL of a Collection retrievable via getter method.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
207
diff
changeset
|
137 collection.setup(identifier, name, creationTime, ttl, this, context, data); |
122
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
138 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
139 return collection; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
140 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
141 catch (InstantiationException ie) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
142 logger.error(ie.getLocalizedMessage(), ie); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
143 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
144 catch (IllegalAccessException iae) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 logger.error(iae.getLocalizedMessage(), iae); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
146 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
147 catch (ClassCastException cce) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
148 logger.error(cce.getLocalizedMessage(), cce); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
149 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
150 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
151 return null; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
152 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
153 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 /** |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 * Setup the factory with a given configuration |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 * @param config the configuration |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 * @param factoryNode the ConfigurationNode of this Factory |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
158 */ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
159 public void setup(Document config, Node factoryNode) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
160 String ttlString = Config.getStringXPath(factoryNode, XPATH_TTL); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
161 if (ttlString != null) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
162 try { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
163 ttl = Long.valueOf(ttlString); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
164 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
165 catch (NumberFormatException nfe) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
166 logger.warn("'" + ttlString + "' is not an integer."); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
168 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
169 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 description = Config.getStringXPath( |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 factoryNode, XPATH_DESCRIPTION, DEFAULT_DESCRIPTION); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
172 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
173 name = Config.getStringXPath(factoryNode, XPATH_NAME, toString()); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
174 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
175 String artifactCollection = Config.getStringXPath( |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
176 factoryNode, XPATH_ARTIFACTCOLLECTION, DEFAULT_ARTIFACTCOLLECTION); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
177 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
178 try { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 clazz = Class.forName(artifactCollection); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
180 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
181 catch (ClassNotFoundException cnfe) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
182 logger.error(cnfe.getLocalizedMessage(), cnfe); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
183 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
184 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
185 if (clazz == null) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
186 clazz = DefaultArtifactCollection.class; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
187 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
188 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
189 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
190 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |