Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollectionFactory.java @ 168:f70977cf2faf
Avoid Nullpointer exception in listCollections() when no creation time of the collection is returned.
artifacts/trunk@1393 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 04 Mar 2011 09:13:18 +0000 |
parents | db0d20440b92 |
children | ac0f8bd97277 |
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 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import org.apache.log4j.Logger; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import org.w3c.dom.Document; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import org.w3c.dom.Node; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.artifacts.ArtifactCollection; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.artifacts.ArtifactCollectionFactory; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 /** |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 * The default implementation of a ArtifactCollectionFactory. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 * |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 * @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
|
23 */ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 public class DefaultArtifactCollectionFactory |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 implements ArtifactCollectionFactory |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 /** 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
|
28 private static Logger logger = |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 Logger.getLogger(DefaultArtifactCollectionFactory.class); |
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 /** 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
|
32 public static final String XPATH_TTL = "@ttl"; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 /** 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
|
35 public static final String XPATH_NAME = "@name"; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 /** 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
|
38 public static final String XPATH_DESCRIPTION = "@description"; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 |
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 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
|
42 * by this factory. |
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 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
|
45 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 /** |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 * 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
|
48 * configuration. |
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 public static final String DEFAULT_DESCRIPTION = |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 "No description available"; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 |
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 * 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
|
55 */ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 public static final String DEFAULT_ARTIFACTCOLLECTION = |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 "de.intevation.artifactdatabase.DefaultArtifact"; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 |
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 /** The name of the factory.*/ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 protected String name; |
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 /** The description of the factory.*/ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 protected String description; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 /** 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
|
67 protected Class clazz; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 /** 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
|
70 protected Long ttl; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 |
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 /** |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 * The default constructor. |
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 public DefaultArtifactCollectionFactory() { |
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 |
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 /** |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 * The short name of this factory. |
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 * @return the name of this factory. |
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 public String getName() { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 return name; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 } |
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 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 /** |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 * Description of this factory. |
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 * @return description of the factory. |
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 public String getDescription() { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 return description; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 } |
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 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 /** |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 * 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
|
102 * |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 * @param artifact |
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 public Long timeToLiveUntouched( |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 ArtifactCollection collection, |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 Object context) |
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 return ttl; |
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 |
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 * 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
|
115 * an identifier. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 * @param context a context from the ArtifactDatabase. |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 * @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
|
118 * @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
|
119 * @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
|
120 */ |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 public ArtifactCollection createCollection( |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
122 String identifier, |
159
db0d20440b92
Added code to create collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
122
diff
changeset
|
123 String name, |
db0d20440b92
Added code to create collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
122
diff
changeset
|
124 Document data, |
db0d20440b92
Added code to create collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
122
diff
changeset
|
125 Object context |
db0d20440b92
Added code to create collections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
122
diff
changeset
|
126 ) { |
122
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
127 try { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
128 ArtifactCollection collection = |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
129 (ArtifactCollection) clazz.newInstance(); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
130 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 collection.setup(identifier, this, context, data); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 return collection; |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
135 catch (InstantiationException ie) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
136 logger.error(ie.getLocalizedMessage(), ie); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
137 } |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
138 catch (IllegalAccessException iae) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
139 logger.error(iae.getLocalizedMessage(), iae); |
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 (ClassCastException cce) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
142 logger.error(cce.getLocalizedMessage(), cce); |
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 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 return null; |
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 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
148 /** |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
149 * Setup the factory with a given configuration |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
150 * @param config the configuration |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
151 * @param factoryNode the ConfigurationNode of this Factory |
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 public void setup(Document config, Node factoryNode) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 String ttlString = Config.getStringXPath(factoryNode, XPATH_TTL); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 if (ttlString != null) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 try { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 ttl = Long.valueOf(ttlString); |
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 catch (NumberFormatException nfe) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
160 logger.warn("'" + ttlString + "' is not an integer."); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
161 } |
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 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
164 description = Config.getStringXPath( |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
165 factoryNode, XPATH_DESCRIPTION, DEFAULT_DESCRIPTION); |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
166 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 name = Config.getStringXPath(factoryNode, XPATH_NAME, toString()); |
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 String artifactCollection = Config.getStringXPath( |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 factoryNode, XPATH_ARTIFACTCOLLECTION, DEFAULT_ARTIFACTCOLLECTION); |
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 try { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
173 clazz = Class.forName(artifactCollection); |
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 catch (ClassNotFoundException cnfe) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
176 logger.error(cnfe.getLocalizedMessage(), cnfe); |
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 |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 if (clazz == null) { |
c9cf5f33a230
Added a default implementation of an ArtifactCollectionFactory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
180 clazz = DefaultArtifactCollection.class; |
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 } |
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |