Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java @ 77:48d1a9a082c2 0.5
Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
to make the sources to be able to be formatted with jalopy (http://jalopy.sourceforge.net).
artifacts/trunk@695 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 21 Feb 2010 23:05:32 +0000 |
parents | d4c4c23847f5 |
children | f69e5b87f05f |
rev | line source |
---|---|
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.artifactdatabase; |
0d6badf6af42
Added not yet working backend to artifact database.
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:
70
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:
70
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:
70
diff
changeset
|
5 import java.util.ArrayList; |
d4c4c23847f5
Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents:
70
diff
changeset
|
6 import java.util.HashMap; |
d4c4c23847f5
Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents:
70
diff
changeset
|
7 import java.util.HashSet; |
d4c4c23847f5
Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents:
70
diff
changeset
|
8 import java.util.List; |
d4c4c23847f5
Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents:
70
diff
changeset
|
9 |
d4c4c23847f5
Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents:
70
diff
changeset
|
10 import org.apache.log4j.Logger; |
d4c4c23847f5
Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents:
70
diff
changeset
|
11 import org.w3c.dom.Document; |
d4c4c23847f5
Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents:
70
diff
changeset
|
12 |
70
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
13 import de.intevation.artifactdatabase.Backend.PersistentArtifact; |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
14 import de.intevation.artifacts.Artifact; |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
15 import de.intevation.artifacts.ArtifactDatabase; |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
16 import de.intevation.artifacts.ArtifactDatabaseException; |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
17 import de.intevation.artifacts.ArtifactFactory; |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
18 import de.intevation.artifacts.CallContext; |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
19 import de.intevation.artifacts.CallMeta; |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
20 import de.intevation.artifacts.Service; |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
21 import de.intevation.artifacts.ServiceFactory; |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
22 |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 /** |
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 * @author Sascha L. Teichmann |
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 */ |
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 public class ArtifactDatabaseImpl |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
36
diff
changeset
|
27 implements ArtifactDatabase, Id.Filter, Backend.FactoryLookup |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 { |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
29 private static Logger logger = |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
30 Logger.getLogger(ArtifactDatabaseImpl.class); |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
32 public static final String NO_SUCH_FACTORY = |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
33 "No such factory"; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
34 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
35 public static final String NO_SUCH_ARTIFACT = |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
36 "No such artifact"; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
37 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
38 public static final String NOT_IN_BACKGROUND = |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
39 "Not in background"; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
40 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
41 public static final String INVALID_CALL_STATE = |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
42 "Invalid after call state"; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
43 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
44 public static final String CREATION_FAILED = |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
45 "Creation of artifact failed"; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
46 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
47 public static final String INTERNAL_ERROR = |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
48 "Creation of artifact failed"; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
49 |
70
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
50 public static final String NO_SUCH_SERVICE = |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
51 "No such service"; |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
52 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
53 public class CallContextImpl |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
54 implements CallContext |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
55 { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
56 protected PersistentArtifact artifact; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
57 protected int action; |
48
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
58 protected CallMeta callMeta; |
58
39fec7d714dc
Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
55
diff
changeset
|
59 protected HashMap customValues; |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
60 |
48
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
61 public CallContextImpl( |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
62 PersistentArtifact artifact, |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
63 int action, |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
64 CallMeta callMeta |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
65 ) { |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
66 this.artifact = artifact; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
67 this.action = action; |
48
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
68 this.callMeta = callMeta; |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
69 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
70 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
71 public void afterCall(int action) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
72 this.action = action; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
73 if (action == BACKGROUND) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
74 addIdToBackground(artifact.getId()); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
75 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
76 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
77 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
78 public void afterBackground(int action) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
79 if (this.action != BACKGROUND) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
80 throw new IllegalStateException(NOT_IN_BACKGROUND); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
81 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
82 fromBackground(artifact, action); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
83 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
84 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
85 public Object globalContext() { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
86 return context; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
87 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
88 |
66
89e3de0ee05f
Implemented some methods to get access to ArtifactFactories which are stored in the ArtifactDatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
58
diff
changeset
|
89 public ArtifactDatabase getDatabase() { |
89e3de0ee05f
Implemented some methods to get access to ArtifactFactories which are stored in the ArtifactDatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
58
diff
changeset
|
90 return ArtifactDatabaseImpl.this; |
89e3de0ee05f
Implemented some methods to get access to ArtifactFactories which are stored in the ArtifactDatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
58
diff
changeset
|
91 } |
89e3de0ee05f
Implemented some methods to get access to ArtifactFactories which are stored in the ArtifactDatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
58
diff
changeset
|
92 |
48
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
93 public CallMeta getMeta() { |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
94 return callMeta; |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
95 } |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
96 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
97 public void postCall() { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
98 switch (action) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
99 case NOTHING: |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
100 break; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
101 case TOUCH: |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
102 artifact.touch(); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
103 break; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
104 case STORE: |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
105 artifact.store(); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
106 break; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
107 case BACKGROUND: |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
108 logger.warn("BACKGROUND processing is not fully implemented, yet!"); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
109 artifact.store(); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
110 break; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
111 default: |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
112 logger.error(INVALID_CALL_STATE + ": " + action); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
113 throw new IllegalStateException(INVALID_CALL_STATE); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
114 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
115 } |
58
39fec7d714dc
Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
55
diff
changeset
|
116 |
39fec7d714dc
Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
55
diff
changeset
|
117 public Object getContextValue(Object key) { |
39fec7d714dc
Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
55
diff
changeset
|
118 return customValues != null |
39fec7d714dc
Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
55
diff
changeset
|
119 ? customValues.get(key) |
39fec7d714dc
Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
55
diff
changeset
|
120 : null; |
39fec7d714dc
Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
55
diff
changeset
|
121 } |
39fec7d714dc
Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
55
diff
changeset
|
122 |
39fec7d714dc
Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
55
diff
changeset
|
123 public Object putContextValue(Object key, Object value) { |
39fec7d714dc
Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
55
diff
changeset
|
124 if (customValues == null) { |
39fec7d714dc
Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
55
diff
changeset
|
125 customValues = new HashMap(); |
39fec7d714dc
Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
55
diff
changeset
|
126 } |
39fec7d714dc
Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
55
diff
changeset
|
127 return customValues.put(key, value); |
39fec7d714dc
Added a real artifact proxy class to be more flexible with artifact replacements
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
55
diff
changeset
|
128 } |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
129 } // class CallContextImpl |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
130 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
131 public class DeferredOutputImpl |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
132 implements DeferredOutput |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
133 { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
134 protected PersistentArtifact artifact; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
135 protected Document format; |
48
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
136 protected CallMeta callMeta; |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
137 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
138 public DeferredOutputImpl() { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
139 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
140 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
141 public DeferredOutputImpl( |
47
4ae4dc99127d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
41
diff
changeset
|
142 PersistentArtifact artifact, |
48
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
143 Document format, |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
144 CallMeta callMeta |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
145 ) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
146 this.artifact = artifact; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
147 this.format = format; |
48
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
148 this.callMeta = callMeta; |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
149 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
150 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
151 public void write(OutputStream output) throws IOException { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
152 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
153 CallContextImpl cc = new CallContextImpl( |
48
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
154 artifact, CallContext.TOUCH, callMeta); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
155 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
156 try { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
157 artifact.getArtifact().out(format, output, cc); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
158 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
159 finally { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
160 cc.postCall(); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
161 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
162 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
163 } // class DeferredOutputImpl |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
164 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
165 protected String [][] factoryNamesAndDescription; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
166 protected HashMap name2factory; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
167 |
70
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
168 protected String [][] serviceNamesAndDescription; |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
169 protected HashMap name2service; |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
170 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
171 protected Backend backend; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
172 protected Object context; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
173 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
174 protected HashSet backgroundIds; |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
175 |
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
176 public ArtifactDatabaseImpl() { |
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
177 } |
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
178 |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
36
diff
changeset
|
179 public ArtifactDatabaseImpl(FactoryBootstrap bootstrap) { |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
36
diff
changeset
|
180 this(bootstrap, null); |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
36
diff
changeset
|
181 } |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
36
diff
changeset
|
182 |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
183 public ArtifactDatabaseImpl(FactoryBootstrap bootstrap, Backend backend) { |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
184 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
185 backgroundIds = new HashSet(); |
70
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
186 |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
187 setupArtifactFactories(bootstrap); |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
188 setupServices(bootstrap); |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
189 |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
190 context = bootstrap.getContext(); |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
191 |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
192 wireWithBackend(backend); |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
193 } |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
194 |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
195 protected void setupArtifactFactories(FactoryBootstrap bootstrap) { |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
196 name2factory = new HashMap(); |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
197 |
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
198 ArtifactFactory [] factories = bootstrap.getArtifactFactories(); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
199 factoryNamesAndDescription = new String[factories.length][]; |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
200 |
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
201 for (int i = 0; i < factories.length; ++i) { |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
202 |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
203 ArtifactFactory factory = factories[i]; |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
204 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
205 String name = factory.getName(); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
206 String description = factory.getDescription(); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
207 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
208 factoryNamesAndDescription[i] = |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
209 new String [] { name, description }; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
210 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
211 name2factory.put(name, factory); |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
212 } |
70
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
213 } |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
214 |
70
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
215 protected void setupServices(FactoryBootstrap bootstrap) { |
26
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
216 |
70
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
217 name2service = new HashMap(); |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
218 |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
219 ServiceFactory [] serviceFactories = |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
220 bootstrap.getServiceFactories(); |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
221 |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
222 serviceNamesAndDescription = |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
223 new String[serviceFactories.length][]; |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
224 |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
225 for (int i = 0; i < serviceFactories.length; ++i) { |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
226 ServiceFactory factory = serviceFactories[i]; |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
227 |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
228 String name = factory.getName(); |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
229 String description = factory.getDescription(); |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
230 |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
231 serviceNamesAndDescription[i] = |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
232 new String [] { name, description }; |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
233 |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
234 name2service.put( |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
235 name, |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
236 factory.createService(bootstrap.getContext())); |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
237 } |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
238 |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
36
diff
changeset
|
239 } |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
36
diff
changeset
|
240 |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
36
diff
changeset
|
241 public void wireWithBackend(Backend backend) { |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
36
diff
changeset
|
242 if (backend != null) { |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
36
diff
changeset
|
243 this.backend = backend; |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
36
diff
changeset
|
244 backend.setFactoryLookup(this); |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
36
diff
changeset
|
245 } |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
246 } |
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
247 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
248 protected void fromBackground(PersistentArtifact artifact, int action) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
249 logger.warn("BACKGROUND processing is not fully implemented, yet!"); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
250 switch (action) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
251 case CallContext.NOTHING: |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
252 break; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
253 case CallContext.TOUCH: |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
254 artifact.touch(); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
255 break; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
256 case CallContext.STORE: |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
257 artifact.store(); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
258 break; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
259 default: |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
260 logger.warn("operation not allowed in fromBackground"); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
261 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
262 removeIdFromBackground(artifact.getId()); |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
263 } |
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
264 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
265 protected void removeIdFromBackground(int id) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
266 synchronized (backgroundIds) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
267 backgroundIds.remove(Integer.valueOf(id)); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
268 } |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
269 } |
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
270 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
271 protected void addIdToBackground(int id) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
272 synchronized (backgroundIds) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
273 backgroundIds.add(Integer.valueOf(id)); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
274 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
275 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
276 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
277 public List filterIds(List ids) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
278 int N = ids.size(); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
279 ArrayList out = new ArrayList(N); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
280 synchronized (backgroundIds) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
281 for (int i = 0; i < N; ++i) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
282 Id id = (Id)ids.get(i); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
283 if (!backgroundIds.contains(Integer.valueOf(id.getId()))) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
284 out.add(id); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
285 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
286 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
287 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
288 return out; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
289 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
290 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
291 public String [][] artifactFactoryNamesAndDescriptions() { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
292 return factoryNamesAndDescription; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
293 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
294 |
66
89e3de0ee05f
Implemented some methods to get access to ArtifactFactories which are stored in the ArtifactDatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
58
diff
changeset
|
295 public ArtifactFactory getInternalArtifactFactory(String factoryName) { |
89e3de0ee05f
Implemented some methods to get access to ArtifactFactories which are stored in the ArtifactDatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
58
diff
changeset
|
296 return getArtifactFactory(factoryName); |
89e3de0ee05f
Implemented some methods to get access to ArtifactFactories which are stored in the ArtifactDatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
58
diff
changeset
|
297 } |
89e3de0ee05f
Implemented some methods to get access to ArtifactFactories which are stored in the ArtifactDatabase.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
58
diff
changeset
|
298 |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
36
diff
changeset
|
299 public ArtifactFactory getArtifactFactory(String factoryName) { |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
36
diff
changeset
|
300 return (ArtifactFactory)name2factory.get(factoryName); |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
36
diff
changeset
|
301 } |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
36
diff
changeset
|
302 |
48
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
303 public Document createArtifactWithFactory( |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
304 String factoryName, |
75
d4c4c23847f5
Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents:
70
diff
changeset
|
305 CallMeta callMeta, |
d4c4c23847f5
Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents:
70
diff
changeset
|
306 Document data |
48
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
307 ) |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
308 throws ArtifactDatabaseException |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
309 { |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
36
diff
changeset
|
310 ArtifactFactory factory = getArtifactFactory(factoryName); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
311 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
312 if (factory == null) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
313 throw new ArtifactDatabaseException(NO_SUCH_FACTORY); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
314 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
315 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
316 Artifact artifact = factory.createArtifact( |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
317 backend.newIdentifier(), |
75
d4c4c23847f5
Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents:
70
diff
changeset
|
318 context, |
d4c4c23847f5
Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents:
70
diff
changeset
|
319 data); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
320 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
321 if (artifact == null) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
322 throw new ArtifactDatabaseException(CREATION_FAILED); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
323 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
324 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
325 PersistentArtifact persistentArtifact; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
326 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
327 try { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
328 persistentArtifact = backend.storeInitially( |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
329 artifact, |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
36
diff
changeset
|
330 factory, |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
331 factory.timeToLiveUntouched(artifact, context)); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
332 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
333 catch (Exception e) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
334 logger.error(e.getLocalizedMessage(), e); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
335 throw new ArtifactDatabaseException(CREATION_FAILED); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
336 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
337 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
338 CallContextImpl cc = new CallContextImpl( |
48
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
339 persistentArtifact, CallContext.NOTHING, callMeta); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
340 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
341 try { |
55
9a29899b31e5
describe() in REST interface is also handled as POST to pass
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
48
diff
changeset
|
342 return artifact.describe(null, cc); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
343 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
344 finally { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
345 cc.postCall(); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
346 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
347 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
348 |
55
9a29899b31e5
describe() in REST interface is also handled as POST to pass
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
48
diff
changeset
|
349 public Document describe(String identifier, Document data, CallMeta callMeta) |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
350 throws ArtifactDatabaseException |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
351 { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
352 // TODO: Handle background tasks |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
353 PersistentArtifact artifact = backend.getArtifact(identifier); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
354 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
355 if (artifact == null) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
356 throw new ArtifactDatabaseException(NO_SUCH_ARTIFACT); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
357 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
358 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
359 CallContextImpl cc = new CallContextImpl( |
48
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
360 artifact, CallContext.TOUCH, callMeta); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
361 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
362 try { |
55
9a29899b31e5
describe() in REST interface is also handled as POST to pass
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
48
diff
changeset
|
363 return artifact.getArtifact().describe(data, cc); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
364 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
365 finally { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
366 cc.postCall(); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
367 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
368 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
369 |
48
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
370 public Document advance(String identifier, Document target, CallMeta callMeta) |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
371 throws ArtifactDatabaseException |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
372 { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
373 // TODO: Handle background tasks |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
374 PersistentArtifact artifact = backend.getArtifact(identifier); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
375 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
376 if (artifact == null) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
377 throw new ArtifactDatabaseException(NO_SUCH_ARTIFACT); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
378 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
379 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
380 CallContextImpl cc = new CallContextImpl( |
48
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
381 artifact, CallContext.STORE, callMeta); |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
382 |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
383 try { |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
384 return artifact.getArtifact().advance(target, cc); |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
385 } |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
386 finally { |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
387 cc.postCall(); |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
388 } |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
389 } |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
390 |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
391 public Document feed(String identifier, Document data, CallMeta callMeta) |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
392 throws ArtifactDatabaseException |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
393 { |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
394 // TODO: Handle background tasks |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
395 PersistentArtifact artifact = backend.getArtifact(identifier); |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
396 |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
397 if (artifact == null) { |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
398 throw new ArtifactDatabaseException(NO_SUCH_ARTIFACT); |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
399 } |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
400 |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
401 CallContextImpl cc = new CallContextImpl( |
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
402 artifact, CallContext.STORE, callMeta); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
403 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
404 try { |
36
f7d2cd59a0d5
Bugfix done. Now the feed Method works fine
Tim Englich <tim.englich@intevation.de>
parents:
32
diff
changeset
|
405 return artifact.getArtifact().feed(data, cc); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
406 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
407 finally { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
408 cc.postCall(); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
409 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
410 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
411 |
48
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
412 public DeferredOutput out(String identifier, Document format, CallMeta callMeta) |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
413 throws ArtifactDatabaseException |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
414 { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
415 // TODO: Handle background tasks |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
416 PersistentArtifact artifact = backend.getArtifact(identifier); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
417 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
418 if (artifact == null) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
419 throw new ArtifactDatabaseException(NO_SUCH_ARTIFACT); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
420 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
26
diff
changeset
|
421 |
48
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
422 return new DeferredOutputImpl(artifact, format, callMeta); |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
423 } |
68
541814404822
Added interfaces for XML processing services. TODO: Implement them!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
66
diff
changeset
|
424 |
541814404822
Added interfaces for XML processing services. TODO: Implement them!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
66
diff
changeset
|
425 public String [][] serviceNamesAndDescriptions() { |
70
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
426 return serviceNamesAndDescription; |
68
541814404822
Added interfaces for XML processing services. TODO: Implement them!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
66
diff
changeset
|
427 } |
541814404822
Added interfaces for XML processing services. TODO: Implement them!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
66
diff
changeset
|
428 |
70
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
429 public Document process( |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
430 String serviceName, |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
431 Document input, |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
432 CallMeta callMeta |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
433 ) |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
434 throws ArtifactDatabaseException |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
435 { |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
436 Service service = (Service)name2service.get(serviceName); |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
437 |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
438 if (service == null) { |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
439 throw new ArtifactDatabaseException(NO_SUCH_SERVICE); |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
440 } |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
441 |
ce488c1d3fc4
Serve services over artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
68
diff
changeset
|
442 return service.process(input, context, callMeta); |
68
541814404822
Added interfaces for XML processing services. TODO: Implement them!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
66
diff
changeset
|
443 } |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
444 } |
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
445 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: |