Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollectionFactory.java @ 442:fc92e44a9a0e
Merged.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 17 Oct 2012 22:26:06 +0200 |
parents | f367be55dd35 |
children |
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 public Long timeToLiveUntouched( |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 ArtifactCollection collection, |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 Object context) |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 return ttl; |
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 |
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 * 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
|
117 * an identifier. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 * @param context a context from the ArtifactDatabase. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 * @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
|
120 * @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
|
121 * @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
|
122 */ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
123 public ArtifactCollection createCollection( |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
124 String identifier, |
159
db0d20440b92
Added code to create collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
122
diff
changeset
|
125 String name, |
170
ac0f8bd97277
Fix parameter propagation of creation time ond collection names.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
159
diff
changeset
|
126 Date creationTime, |
281
942a54670a72
Made the TTL of a Collection retrievable via getter method.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
207
diff
changeset
|
127 long ttl, |
159
db0d20440b92
Added code to create collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
122
diff
changeset
|
128 Document data, |
db0d20440b92
Added code to create collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
122
diff
changeset
|
129 Object context |
db0d20440b92
Added code to create collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
122
diff
changeset
|
130 ) { |
122
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 try { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 ArtifactCollection collection = |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 (ArtifactCollection) clazz.newInstance(); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 |
367
6431b7efe240
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
281
diff
changeset
|
135 collection.setup(identifier, |
6431b7efe240
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
281
diff
changeset
|
136 name, |
6431b7efe240
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
281
diff
changeset
|
137 creationTime, |
6431b7efe240
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
281
diff
changeset
|
138 ttl, |
6431b7efe240
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
281
diff
changeset
|
139 this, |
6431b7efe240
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
281
diff
changeset
|
140 context, |
6431b7efe240
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
281
diff
changeset
|
141 data); |
122
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
142 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
143 return collection; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
144 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 catch (InstantiationException ie) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
146 logger.error(ie.getLocalizedMessage(), ie); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
147 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
148 catch (IllegalAccessException iae) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
149 logger.error(iae.getLocalizedMessage(), iae); |
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 catch (ClassCastException cce) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
152 logger.error(cce.getLocalizedMessage(), cce); |
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 return null; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 |
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 * Setup the factory with a given configuration |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
160 * @param config the configuration |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
161 * @param factoryNode the ConfigurationNode of this Factory |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
162 */ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
163 public void setup(Document config, Node factoryNode) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
164 String ttlString = Config.getStringXPath(factoryNode, XPATH_TTL); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
165 if (ttlString != null) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
166 try { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 ttl = Long.valueOf(ttlString); |
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 catch (NumberFormatException nfe) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 logger.warn("'" + ttlString + "' is not an integer."); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 } |
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 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
174 description = Config.getStringXPath( |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
175 factoryNode, XPATH_DESCRIPTION, DEFAULT_DESCRIPTION); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
176 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
177 name = Config.getStringXPath(factoryNode, XPATH_NAME, toString()); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
178 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 String artifactCollection = Config.getStringXPath( |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
180 factoryNode, XPATH_ARTIFACTCOLLECTION, DEFAULT_ARTIFACTCOLLECTION); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
181 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
182 try { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
183 clazz = Class.forName(artifactCollection); |
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 catch (ClassNotFoundException cnfe) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
186 logger.error(cnfe.getLocalizedMessage(), cnfe); |
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 if (clazz == null) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
190 clazz = DefaultArtifactCollection.class; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
191 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
192 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
193 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
194 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |