Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/DatacageBackendListener.java @ 1002:db86c665ab6e
Datacage: Pass global context to datacage if calls come from backend listener.
flys-artifacts/trunk@2442 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 01 Aug 2011 16:34:48 +0000 |
parents | a640944b5dd7 |
children | 52949da92f7a |
comparison
equal
deleted
inserted
replaced
1001:a640944b5dd7 | 1002:db86c665ab6e |
---|---|
22 | 22 |
23 public DatacageBackendListener() { | 23 public DatacageBackendListener() { |
24 log.debug("new DatacageBackendListener"); | 24 log.debug("new DatacageBackendListener"); |
25 } | 25 } |
26 | 26 |
27 protected BackendListener getListener() { | 27 protected Datacage getDatacage() { |
28 Object listener = context.get(Datacage.DATACAGE_KEY); | 28 Object listener = context.get(Datacage.DATACAGE_KEY); |
29 return listener instanceof BackendListener | 29 return listener instanceof Datacage |
30 ? (BackendListener)listener | 30 ? (Datacage)listener |
31 : null; | 31 : null; |
32 } | 32 } |
33 | 33 |
34 @Override | 34 @Override |
35 public void setup(GlobalContext context) { | 35 public void setup(GlobalContext context) { |
36 log.debug("setup"); | 36 log.debug("setup"); |
37 this.context = context; | 37 this.context = context; |
38 BackendListener l = getListener(); | 38 Datacage l = getDatacage(); |
39 if (l != null) { | 39 if (l != null) { |
40 l.setup(context); | 40 l.setup(context); |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 @Override | 44 @Override |
45 public void createdArtifact(Artifact artifact, Backend backend) { | 45 public void createdArtifact(Artifact artifact, Backend backend) { |
46 log.debug("createdArtifact"); | 46 log.debug("createdArtifact"); |
47 BackendListener l = getListener(); | 47 Datacage l = getDatacage(); |
48 if (l != null) { | 48 if (l != null) { |
49 l.createdArtifact(artifact, backend); | 49 l.createdArtifact(artifact, backend, context); |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 @Override | 53 @Override |
54 public void storedArtifact(Artifact artifact, Backend backend) { | 54 public void storedArtifact(Artifact artifact, Backend backend) { |
55 log.debug("storedArtifact"); | 55 log.debug("storedArtifact"); |
56 BackendListener l = getListener(); | 56 Datacage l = getDatacage(); |
57 if (l != null) { | 57 if (l != null) { |
58 l.storedArtifact(artifact, backend); | 58 l.storedArtifact(artifact, backend, context); |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 @Override | 62 @Override |
63 public void createdUser(User user, Backend backend) { | 63 public void createdUser(User user, Backend backend) { |
64 log.debug("createdUser"); | 64 log.debug("createdUser"); |
65 BackendListener l = getListener(); | 65 Datacage l = getDatacage(); |
66 if (l != null) { | 66 if (l != null) { |
67 l.createdUser(user, backend); | 67 l.createdUser(user, backend, context); |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 @Override | 71 @Override |
72 public void deletedUser(String identifier, Backend backend) { | 72 public void deletedUser(String identifier, Backend backend) { |
73 log.debug("deletedUser"); | 73 log.debug("deletedUser"); |
74 BackendListener l = getListener(); | 74 Datacage l = getDatacage(); |
75 if (l != null) { | 75 if (l != null) { |
76 l.deletedUser(identifier, backend); | 76 l.deletedUser(identifier, backend, context); |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 @Override | 80 @Override |
81 public void createdCollection( | 81 public void createdCollection( |
82 ArtifactCollection collection, | 82 ArtifactCollection collection, |
83 Backend backend | 83 Backend backend |
84 ) { | 84 ) { |
85 log.debug("createdCollection"); | 85 log.debug("createdCollection"); |
86 BackendListener l = getListener(); | 86 Datacage l = getDatacage(); |
87 if (l != null) { | 87 if (l != null) { |
88 l.createdCollection(collection, backend); | 88 l.createdCollection(collection, backend, context); |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 @Override | 92 @Override |
93 public void deletedCollection(String identifier, Backend backend) { | 93 public void deletedCollection(String identifier, Backend backend) { |
94 log.debug("deletedCollection"); | 94 log.debug("deletedCollection"); |
95 BackendListener l = getListener(); | 95 Datacage l = getDatacage(); |
96 if (l != null) { | 96 if (l != null) { |
97 l.deletedCollection(identifier, backend); | 97 l.deletedCollection(identifier, backend, context); |
98 } | 98 } |
99 } | 99 } |
100 | 100 |
101 @Override | 101 @Override |
102 public void changedCollectionAttribute( | 102 public void changedCollectionAttribute( |
103 String identifier, | 103 String identifier, |
104 Document document, | 104 Document document, |
105 Backend backend | 105 Backend backend |
106 ) { | 106 ) { |
107 log.debug("changedCollectionAttribute"); | 107 log.debug("changedCollectionAttribute"); |
108 BackendListener l = getListener(); | 108 Datacage l = getDatacage(); |
109 if (l != null) { | 109 if (l != null) { |
110 l.changedCollectionAttribute(identifier, document, backend); | 110 l.changedCollectionAttribute( |
111 identifier, document, backend, context); | |
111 } | 112 } |
112 } | 113 } |
113 | 114 |
114 @Override | 115 @Override |
115 public void changedCollectionItemAttribute( | 116 public void changedCollectionItemAttribute( |
117 String artifactId, | 118 String artifactId, |
118 Document document, | 119 Document document, |
119 Backend backend | 120 Backend backend |
120 ) { | 121 ) { |
121 log.debug("changedCollectionItemAttribute"); | 122 log.debug("changedCollectionItemAttribute"); |
122 BackendListener l = getListener(); | 123 Datacage l = getDatacage(); |
123 if (l != null) { | 124 if (l != null) { |
124 l.changedCollectionItemAttribute( | 125 l.changedCollectionItemAttribute( |
125 collectionId, artifactId, document, backend); | 126 collectionId, artifactId, document, backend, context); |
126 } | 127 } |
127 } | 128 } |
128 | 129 |
129 @Override | 130 @Override |
130 public void addedArtifactToCollection( | 131 public void addedArtifactToCollection( |
131 String artifactId, | 132 String artifactId, |
132 String collectionId, | 133 String collectionId, |
133 Backend backend | 134 Backend backend |
134 ) { | 135 ) { |
135 log.debug("addedArtifactToCollection"); | 136 log.debug("addedArtifactToCollection"); |
136 BackendListener l = getListener(); | 137 Datacage l = getDatacage(); |
137 if (l != null) { | 138 if (l != null) { |
138 l.addedArtifactToCollection( | 139 l.addedArtifactToCollection( |
139 artifactId, collectionId, backend); | 140 artifactId, collectionId, backend, context); |
140 } | 141 } |
141 } | 142 } |
142 | 143 |
143 @Override | 144 @Override |
144 public void removedArtifactFromCollection( | 145 public void removedArtifactFromCollection( |
145 String artifactId, | 146 String artifactId, |
146 String collectionId, | 147 String collectionId, |
147 Backend backend | 148 Backend backend |
148 ) { | 149 ) { |
149 log.debug("removedArtifactFromCollection"); | 150 log.debug("removedArtifactFromCollection"); |
150 BackendListener l = getListener(); | 151 Datacage l = getDatacage(); |
151 if (l != null) { | 152 if (l != null) { |
152 l.removedArtifactFromCollection( | 153 l.removedArtifactFromCollection( |
153 artifactId, collectionId, backend); | 154 artifactId, collectionId, backend, context); |
154 } | 155 } |
155 } | 156 } |
156 | 157 |
157 @Override | 158 @Override |
158 public void setCollectionName( | 159 public void setCollectionName( |
159 String collectionId, | 160 String collectionId, |
160 String name | 161 String name |
161 ) { | 162 ) { |
162 log.debug("setCollectionName"); | 163 log.debug("setCollectionName"); |
163 BackendListener l = getListener(); | 164 Datacage l = getDatacage(); |
164 if (l != null) { | 165 if (l != null) { |
165 l.setCollectionName(collectionId, name); | 166 l.setCollectionName(collectionId, name, context); |
166 } | 167 } |
167 } | 168 } |
168 } | 169 } |
169 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 170 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |