Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java @ 83:8c4638abd518
Installed a SLF4J bridge to route incoming jul logs (used by restlet) to log4j.
artifacts/trunk@820 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 22 Mar 2010 15:54:06 +0000 |
parents | efe752c4f8b2 |
children | b2e0cb83631c |
rev | line source |
---|---|
10
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.artifactdatabase; |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
75
d4c4c23847f5
Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents:
55
diff
changeset
|
3 import java.io.IOException; |
d4c4c23847f5
Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents:
55
diff
changeset
|
4 import java.io.OutputStream; |
d4c4c23847f5
Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents:
55
diff
changeset
|
5 |
d4c4c23847f5
Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents:
55
diff
changeset
|
6 import org.apache.log4j.Logger; |
10
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 import org.w3c.dom.Document; |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.artifacts.Artifact; |
24
d5dc2900392f
* Added callback parameter to Artifact.setup()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
18
diff
changeset
|
10 import de.intevation.artifacts.ArtifactFactory; |
75
d4c4c23847f5
Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents:
55
diff
changeset
|
11 import de.intevation.artifacts.CallContext; |
31
c4d85a8532d1
Artifact.out() is now called with an java.io.Outpustream
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
12 |
10
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 /** |
77
48d1a9a082c2
Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
75
diff
changeset
|
14 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> |
10
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 */ |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 public class DefaultArtifact |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 implements Artifact |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 { |
17
5a6b6a3debc7
Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
10
diff
changeset
|
19 private static Logger logger = Logger.getLogger(DefaultArtifact.class); |
47
4ae4dc99127d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
42
diff
changeset
|
20 |
10
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 protected String identifier; |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 public DefaultArtifact() { |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 } |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 |
81
e9c80fdfee13
Set new identifiers on artifacts after an artifact import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
77
diff
changeset
|
26 |
e9c80fdfee13
Set new identifiers on artifacts after an artifact import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
77
diff
changeset
|
27 public void setIdentifier(String identifier) { |
e9c80fdfee13
Set new identifiers on artifacts after an artifact import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
77
diff
changeset
|
28 if (logger.isDebugEnabled()) { |
e9c80fdfee13
Set new identifiers on artifacts after an artifact import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
77
diff
changeset
|
29 logger.debug("Change identifier: " |
e9c80fdfee13
Set new identifiers on artifacts after an artifact import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
77
diff
changeset
|
30 + this.identifier + " -> " + identifier); |
e9c80fdfee13
Set new identifiers on artifacts after an artifact import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
77
diff
changeset
|
31 } |
e9c80fdfee13
Set new identifiers on artifacts after an artifact import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
77
diff
changeset
|
32 this.identifier = identifier; |
e9c80fdfee13
Set new identifiers on artifacts after an artifact import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
77
diff
changeset
|
33 } |
e9c80fdfee13
Set new identifiers on artifacts after an artifact import.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
77
diff
changeset
|
34 |
10
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 public String identifier() { |
42
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
36 if (logger.isDebugEnabled()) { |
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
37 logger.debug("DefaultArtifact.identifier: " + identifier); |
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
38 } |
10
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 return this.identifier; |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 } |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 public String hash() { |
42
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
43 String hash = String.valueOf(hashCode()); |
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
44 if (logger.isDebugEnabled()) { |
47
4ae4dc99127d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
42
diff
changeset
|
45 logger.debug("DefaultArtifact.hashCode: " |
42
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
46 + identifier + " (" + hash + ")"); |
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
47 } |
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
48 return hash; |
10
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 } |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 |
55
9a29899b31e5
describe() in REST interface is also handled as POST to pass
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
51 public Document describe(Document data, CallContext context) { |
42
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
52 if (logger.isDebugEnabled()) { |
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
53 logger.debug("DefaultArtifact.describe: " + identifier); |
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
54 } |
26
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
55 return XMLUtils.newDocument(); |
10
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 } |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
58 public Document advance(Document target, CallContext context) { |
42
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
59 if (logger.isDebugEnabled()) { |
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
60 logger.debug("DefaultArtifact.advance: " + identifier); |
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
61 } |
26
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
62 return XMLUtils.newDocument(); |
10
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 } |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
65 public Document feed(Document target, CallContext context) { |
42
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
66 if (logger.isDebugEnabled()) { |
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
67 logger.debug("DefaultArtifact.feed: " + identifier); |
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
68 } |
26
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
69 return XMLUtils.newDocument(); |
10
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 } |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 |
31
c4d85a8532d1
Artifact.out() is now called with an java.io.Outpustream
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
72 public void out( |
c4d85a8532d1
Artifact.out() is now called with an java.io.Outpustream
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
73 Document format, |
c4d85a8532d1
Artifact.out() is now called with an java.io.Outpustream
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
74 OutputStream out, |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
75 CallContext context |
31
c4d85a8532d1
Artifact.out() is now called with an java.io.Outpustream
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
76 ) |
c4d85a8532d1
Artifact.out() is now called with an java.io.Outpustream
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
77 throws IOException |
c4d85a8532d1
Artifact.out() is now called with an java.io.Outpustream
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
78 { |
42
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
79 if (logger.isDebugEnabled()) { |
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
80 logger.debug("DefaultArtifact.out: " + identifier); |
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
81 } |
10
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 } |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 |
75
d4c4c23847f5
Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents:
55
diff
changeset
|
84 public void setup(String identifier, ArtifactFactory factory, |
d4c4c23847f5
Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents:
55
diff
changeset
|
85 Object context, Document data) { |
42
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
86 if (logger.isDebugEnabled()) { |
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
87 logger.debug("DefaultArtifact.setup: " + identifier); |
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
88 } |
10
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 this.identifier = identifier; |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 } |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 public void endOfLife(Object context) { |
42
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
93 if (logger.isDebugEnabled()) { |
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
94 logger.debug("DefaultArtifact.endOfLife: " + identifier); |
5fbd8e65bdf5
Added debug output to DefaultArtifact tracing of artifact lifecyle easier.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
95 } |
10
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 } |
82
efe752c4f8b2
Call cleanup method to remove special data stored by an 'out'-target before exporting an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
81
diff
changeset
|
97 |
efe752c4f8b2
Call cleanup method to remove special data stored by an 'out'-target before exporting an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
81
diff
changeset
|
98 public void cleanup(Object context) { |
efe752c4f8b2
Call cleanup method to remove special data stored by an 'out'-target before exporting an artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
81
diff
changeset
|
99 } |
10
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 } |
e8626caac353
* Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: |