1 | | - | /* |
2 | | - | * Tigase Jabber/XMPP Publish Subscribe Component |
3 | | - | * Copyright (C) 2007 "Bartosz M. Małkowski" <bartosz.malkowski@tigase.org> |
4 | | - | * |
5 | | - | * This program is free software: you can redistribute it and/or modify |
6 | | - | * it under the terms of the GNU General Public License as published by |
7 | | - | * the Free Software Foundation, either version 3 of the License. |
8 | | - | * |
9 | | - | * This program is distributed in the hope that it will be useful, |
10 | | - | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | | - | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | | - | * GNU General Public License for more details. |
13 | | - | * |
14 | | - | * You should have received a copy of the GNU General Public License |
15 | | - | * along with this program. Look for COPYING file in the top folder. |
16 | | - | * If not, see http://www.gnu.org/licenses/. |
17 | | - | * |
18 | | - | * $Rev$ |
19 | | - | * Last modified by $Author$ |
20 | | - | * $Date$ |
21 | | - | */ |
22 | | - | package tigase.pubsub.repository.inmemory; |
23 | | - | |
24 | | - | import java.util.ArrayList; |
25 | | - | import java.util.Date; |
26 | | - | import java.util.HashMap; |
27 | | - | import java.util.List; |
28 | | - | import java.util.logging.Level; |
29 | | - | import java.util.logging.Logger; |
30 | | - | |
31 | | - | import tigase.pubsub.AbstractNodeConfig; |
32 | | - | import tigase.pubsub.Affiliation; |
33 | | - | import tigase.pubsub.NodeType; |
34 | | - | import tigase.pubsub.PubSubConfig; |
35 | | - | import tigase.pubsub.Subscription; |
36 | | - | import tigase.pubsub.repository.IPubSubDAO; |
37 | | - | import tigase.pubsub.repository.IPubSubRepository; |
38 | | - | import tigase.pubsub.repository.PubSubDAO; |
39 | | - | import tigase.pubsub.repository.PubSubRepositoryListener; |
40 | | - | import tigase.pubsub.repository.RepositoryException; |
41 | | - | import tigase.xml.Element; |
42 | | - | |
43 | | - | public class InMemoryPubSubRepository implements IPubSubRepository { |
44 | | - | |
45 | | - | public final static String CREATION_DATE_KEY = "creation-date"; |
46 | | - | |
47 | | - | protected static final String NODE_TYPE_KEY = "pubsub#node_type"; |
48 | | - | |
49 | | - | protected static final String NODES_KEY = "nodes/"; |
50 | | - | |
51 | | - | private final List<PubSubRepositoryListener> listeners = new ArrayList<PubSubRepositoryListener>(); |
52 | | - | |
53 | | - | protected Logger log = Logger.getLogger(this.getClass().getName()); |
54 | | - | |
55 | | - | private final HashMap<String, Entry> nodes = new HashMap<String, Entry>(); |
56 | | - | |
57 | | - | private final PubSubDAO pubSubDB; |
58 | | - | |
59 | | - | public InMemoryPubSubRepository(PubSubDAO pubSubDB, PubSubConfig pubSubConfig) { |
60 | | - | this.pubSubDB = pubSubDB; |
61 | | - | } |
62 | | - | |
63 | | - | /* |
64 | | - | * (non-Javadoc) |
65 | | - | * |
66 | | - | * @see |
67 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#addListener(tigase |
68 | | - | * .pubsub.repository.PubSubRepositoryListener) |
69 | | - | */ |
70 | | - | public void addListener(PubSubRepositoryListener listener) { |
71 | | - | this.listeners.add(listener); |
72 | | - | } |
73 | | - | |
74 | | - | /* |
75 | | - | * (non-Javadoc) |
76 | | - | * |
77 | | - | * @see |
78 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#addSubscriberJid( |
79 | | - | * java.lang.String, java.lang.String, tigase.pubsub.Affiliation, |
80 | | - | * tigase.pubsub.Subscription) |
81 | | - | */ |
82 | | - | public String addSubscriberJid(String nodeName, String jid, Affiliation affiliation, Subscription subscription) |
83 | | - | throws RepositoryException { |
84 | | - | Entry entry = readNodeEntry(nodeName); |
85 | | - | String subid = this.pubSubDB.addSubscriberJid(nodeName, jid, affiliation, subscription); |
86 | | - | Subscriber subscriber = new Subscriber(jid, subid, subscription); |
87 | | - | NodeAffiliation nodeAffiliation = new NodeAffiliation(jid, affiliation); |
88 | | - | entry.add(subscriber); |
89 | | - | entry.add(nodeAffiliation); |
90 | | - | return subid; |
91 | | - | } |
92 | | - | |
93 | | - | private Date asDate(String d) { |
94 | | - | Long x = Long.valueOf(d); |
95 | | - | return new Date(x.longValue()); |
96 | | - | } |
97 | | - | |
98 | | - | /* |
99 | | - | * (non-Javadoc) |
100 | | - | * |
101 | | - | * @see |
102 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#changeAffiliation |
103 | | - | * (java.lang.String, java.lang.String, tigase.pubsub.Affiliation) |
104 | | - | */ |
105 | | - | public void changeAffiliation(String nodeName, String jid, Affiliation affiliation) throws RepositoryException { |
106 | | - | Entry entry = readNodeEntry(nodeName); |
107 | | - | this.pubSubDB.changeAffiliation(nodeName, jid, affiliation); |
108 | | - | entry.changeAffiliation(jid, affiliation); |
109 | | - | } |
110 | | - | |
111 | | - | /* |
112 | | - | * (non-Javadoc) |
113 | | - | * |
114 | | - | * @see |
115 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#changeSubscription |
116 | | - | * (java.lang.String, java.lang.String, tigase.pubsub.Subscription) |
117 | | - | */ |
118 | | - | public void changeSubscription(String nodeName, String jid, Subscription subscription) throws RepositoryException { |
119 | | - | Entry entry = readNodeEntry(nodeName); |
120 | | - | this.pubSubDB.changeSubscription(nodeName, jid, subscription); |
121 | | - | entry.changeSubscription(jid, subscription); |
122 | | - | } |
123 | | - | |
124 | | - | /* |
125 | | - | * (non-Javadoc) |
126 | | - | * |
127 | | - | * @see |
128 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#createNode(java.lang |
129 | | - | * .String, java.lang.String, tigase.pubsub.AbstractNodeConfig, |
130 | | - | * tigase.pubsub.NodeType, java.lang.String) |
131 | | - | */ |
132 | | - | public void createNode(String nodeName, String ownerJid, AbstractNodeConfig nodeConfig, NodeType nodeType, String collection) |
133 | | - | throws RepositoryException { |
134 | | - | this.pubSubDB.createNode(nodeName, ownerJid, nodeConfig, nodeType, collection); |
135 | | - | Entry cnf = readNodeEntry(nodeName); |
136 | | - | if (!"".equals(cnf.getConfig().getCollection())) { |
137 | | - | fireNewNodeCollection(nodeName, null, collection); |
138 | | - | } |
139 | | - | } |
140 | | - | |
141 | | - | /* |
142 | | - | * (non-Javadoc) |
143 | | - | * |
144 | | - | * @see |
145 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#deleteItem(java.lang |
146 | | - | * .String, java.lang.String) |
147 | | - | */ |
148 | | - | public void deleteItem(String nodeName, String id) throws RepositoryException { |
149 | | - | this.pubSubDB.deleteItem(nodeName, id); |
150 | | - | Entry entry = readNodeEntry(nodeName); |
151 | | - | entry.deleteItem(id); |
152 | | - | } |
153 | | - | |
154 | | - | /* |
155 | | - | * (non-Javadoc) |
156 | | - | * |
157 | | - | * @see |
158 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#deleteNode(java.lang |
159 | | - | * .String) |
160 | | - | */ |
161 | | - | public void deleteNode(String nodeName) throws RepositoryException { |
162 | | - | this.pubSubDB.deleteNode(nodeName); |
163 | | - | this.nodes.remove(nodeName); |
164 | | - | } |
165 | | - | |
166 | | - | private void fireNewNodeCollection(String nodeName, String oldCollectionName, String newCollectionName) { |
167 | | - | for (PubSubRepositoryListener listener : this.listeners) { |
168 | | - | listener.onChangeCollection(nodeName, oldCollectionName, newCollectionName); |
169 | | - | } |
170 | | - | } |
171 | | - | |
172 | | - | /* |
173 | | - | * (non-Javadoc) |
174 | | - | * |
175 | | - | * @see |
176 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#forgetConfiguration |
177 | | - | * (java.lang.String) |
178 | | - | */ |
179 | | - | public void forgetConfiguration(String nodeName) throws RepositoryException { |
180 | | - | this.nodes.remove(nodeName); |
181 | | - | readNodeEntry(nodeName); |
182 | | - | } |
183 | | - | |
184 | | - | /* |
185 | | - | * (non-Javadoc) |
186 | | - | * |
187 | | - | * @see |
188 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#getAffiliations(java |
189 | | - | * .lang.String) |
190 | | - | */ |
191 | | - | public NodeAffiliation[] getAffiliations(final String nodeName) throws RepositoryException { |
192 | | - | Entry entry = readNodeEntry(nodeName); |
193 | | - | return entry.getAffiliations(); |
194 | | - | } |
195 | | - | |
196 | | - | /* |
197 | | - | * (non-Javadoc) |
198 | | - | * |
199 | | - | * @see |
200 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#getBuddyGroups(java |
201 | | - | * .lang.String, java.lang.String) |
202 | | - | */ |
203 | | - | public String[] getBuddyGroups(String owner, String bareJid) throws RepositoryException { |
204 | | - | return this.pubSubDB.getBuddyGroups(owner, bareJid); |
205 | | - | } |
206 | | - | |
207 | | - | /* |
208 | | - | * (non-Javadoc) |
209 | | - | * |
210 | | - | * @see |
211 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#getBuddySubscription |
212 | | - | * (java.lang.String, java.lang.String) |
213 | | - | */ |
214 | | - | public String getBuddySubscription(String owner, String buddy) throws RepositoryException { |
215 | | - | return this.pubSubDB.getBuddySubscription(owner, buddy); |
216 | | - | } |
217 | | - | |
218 | | - | /* |
219 | | - | * (non-Javadoc) |
220 | | - | * |
221 | | - | * @see |
222 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#getItem(java.lang |
223 | | - | * .String, java.lang.String) |
224 | | - | */ |
225 | | - | public Element getItem(String nodeName, String id) throws RepositoryException { |
226 | | - | Entry entry = readNodeEntry(nodeName); |
227 | | - | Item item = entry.getItemData(id); |
228 | | - | return item != null ? item.getData() : null; |
229 | | - | } |
230 | | - | |
231 | | - | /* |
232 | | - | * (non-Javadoc) |
233 | | - | * |
234 | | - | * @see |
235 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#getItemCreationDate |
236 | | - | * (java.lang.String, java.lang.String) |
237 | | - | */ |
238 | | - | public Date getItemCreationDate(String nodeName, String id) throws RepositoryException { |
239 | | - | Entry entry = readNodeEntry(nodeName); |
240 | | - | if (entry == null) |
241 | | - | return null; |
242 | | - | return entry.getItemCreationDate(id); |
243 | | - | } |
244 | | - | |
245 | | - | /* |
246 | | - | * (non-Javadoc) |
247 | | - | * |
248 | | - | * @see |
249 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#getItemsIds(java. |
250 | | - | * lang.String) |
251 | | - | */ |
252 | | - | public String[] getItemsIds(String nodeName) throws RepositoryException { |
253 | | - | Entry entry = readNodeEntry(nodeName); |
254 | | - | return entry == null ? null : entry.getSortedItemsId(); |
255 | | - | } |
256 | | - | |
257 | | - | @Override |
258 | | - | public Date getItemUpdateDate(String nodeName, String id) throws RepositoryException { |
259 | | - | return this.pubSubDB.getItemUpdateDate(nodeName, id); |
260 | | - | } |
261 | | - | |
262 | | - | /* |
263 | | - | * (non-Javadoc) |
264 | | - | * |
265 | | - | * @see |
266 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#getNodeConfig(java |
267 | | - | * .lang.String) |
268 | | - | */ |
269 | | - | public AbstractNodeConfig getNodeConfig(String nodeName) throws RepositoryException { |
270 | | - | Entry entry = readNodeEntry(nodeName); |
271 | | - | return entry == null ? null : entry.getConfig(); |
272 | | - | } |
273 | | - | |
274 | | - | /* |
275 | | - | * (non-Javadoc) |
276 | | - | * |
277 | | - | * @see tigase.pubsub.repository.inmemory.IPubSubRepository#getNodesList() |
278 | | - | */ |
279 | | - | public String[] getNodesList() throws RepositoryException { |
280 | | - | return this.pubSubDB.getNodesList(); |
281 | | - | } |
282 | | - | |
283 | | - | /* |
284 | | - | * (non-Javadoc) |
285 | | - | * |
286 | | - | * @see tigase.pubsub.repository.inmemory.IPubSubRepository#getPubSubDAO() |
287 | | - | */ |
288 | | - | public IPubSubDAO getPubSubDAO() { |
289 | | - | return this.pubSubDB; |
290 | | - | } |
291 | | - | |
292 | | - | /* |
293 | | - | * (non-Javadoc) |
294 | | - | * |
295 | | - | * @see |
296 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#getSubscriberAffiliation |
297 | | - | * (java.lang.String, java.lang.String) |
298 | | - | */ |
299 | | - | public NodeAffiliation getSubscriberAffiliation(String nodeName, String jid) throws RepositoryException { |
300 | | - | Entry entry = readNodeEntry(nodeName); |
301 | | - | return entry.getSubscriberAffiliation(jid); |
302 | | - | } |
303 | | - | |
304 | | - | /* |
305 | | - | * (non-Javadoc) |
306 | | - | * |
307 | | - | * @see |
308 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#getSubscription(java |
309 | | - | * .lang.String, java.lang.String) |
310 | | - | */ |
311 | | - | public Subscription getSubscription(String nodeName, String jid) throws RepositoryException { |
312 | | - | Entry entry = readNodeEntry(nodeName); |
313 | | - | if (entry == null) |
314 | | - | return Subscription.none; |
315 | | - | return entry.getSubscriberSubscription(jid); |
316 | | - | } |
317 | | - | |
318 | | - | /* |
319 | | - | * (non-Javadoc) |
320 | | - | * |
321 | | - | * @see |
322 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#getSubscriptionId |
323 | | - | * (java.lang.String, java.lang.String) |
324 | | - | */ |
325 | | - | public String getSubscriptionId(String nodeName, String jid) throws RepositoryException { |
326 | | - | Entry entry = readNodeEntry(nodeName); |
327 | | - | return entry.getSubscriptionId(jid); |
328 | | - | } |
329 | | - | |
330 | | - | /* |
331 | | - | * (non-Javadoc) |
332 | | - | * |
333 | | - | * @see |
334 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#getSubscriptions( |
335 | | - | * java.lang.String) |
336 | | - | */ |
337 | | - | public Subscriber[] getSubscriptions(String nodeName) throws RepositoryException { |
338 | | - | Entry entry = readNodeEntry(nodeName); |
339 | | - | return entry == null ? null : entry.getSubscribersJid(); |
340 | | - | } |
341 | | - | |
342 | | - | /* |
343 | | - | * (non-Javadoc) |
344 | | - | * |
345 | | - | * @see |
346 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#getUserRoster(java |
347 | | - | * .lang.String) |
348 | | - | */ |
349 | | - | public String[] getUserRoster(String owner) throws RepositoryException { |
350 | | - | return this.pubSubDB.getUserRoster(owner); |
351 | | - | } |
352 | | - | |
353 | | - | /* |
354 | | - | * (non-Javadoc) |
355 | | - | * |
356 | | - | * @see tigase.pubsub.repository.inmemory.IPubSubRepository#init() |
357 | | - | */ |
358 | | - | public void init() { |
359 | | - | try { |
360 | | - | log.config("InMemory PS Repository initializing..."); |
361 | | - | this.nodes.clear(); |
362 | | - | String[] nodes = this.pubSubDB.getNodesList(); |
363 | | - | if (nodes != null) |
364 | | - | for (String nodeName : nodes) { |
365 | | - | readNodeEntry(nodeName); |
366 | | - | } |
367 | | - | } catch (Exception e) { |
368 | | - | log.log(Level.SEVERE, "Can't initialize InMemory PS!", e); |
369 | | - | throw new RuntimeException("Can't initialize InMemory PS!", e); |
370 | | - | } |
371 | | - | } |
372 | | - | |
373 | | - | protected List<Item> readItems(String nodeName) throws RepositoryException { |
374 | | - | String[] ids = this.pubSubDB.getItemsIds(nodeName); |
375 | | - | if (ids != null) { |
376 | | - | List<Item> result = new ArrayList<Item>(); |
377 | | - | for (String id : ids) { |
378 | | - | final Element data = this.pubSubDB.getItem(nodeName, id); |
379 | | - | final Date creationDate = this.pubSubDB.getItemCreationDate(nodeName, id); |
380 | | - | final Date updateDate = this.pubSubDB.getItemUpdateDate(nodeName, id); |
381 | | - | final String pubslisher = this.pubSubDB.getItemPublisher(nodeName, id); |
382 | | - | Item item = new Item(id, data, creationDate, updateDate, pubslisher); |
383 | | - | result.add(item); |
384 | | - | } |
385 | | - | return result; |
386 | | - | } |
387 | | - | return null; |
388 | | - | } |
389 | | - | |
390 | | - | protected List<NodeAffiliation> readNodeAffiliations(final String nodeName) throws RepositoryException { |
391 | | - | String[] jids = this.pubSubDB.getAffiliations(nodeName); |
392 | | - | List<NodeAffiliation> result = new ArrayList<NodeAffiliation>(); |
393 | | - | if (jids != null) { |
394 | | - | for (String jid : jids) { |
395 | | - | Affiliation affiliation = this.pubSubDB.getSubscriberAffiliation(nodeName, jid); |
396 | | - | NodeAffiliation na = new NodeAffiliation(jid, affiliation); |
397 | | - | result.add(na); |
398 | | - | } |
399 | | - | } |
400 | | - | return result; |
401 | | - | } |
402 | | - | |
403 | | - | protected AbstractNodeConfig readNodeConfig(final String nodeName) throws RepositoryException { |
404 | | - | return this.pubSubDB.getNodeConfig(nodeName); |
405 | | - | } |
406 | | - | |
407 | | - | protected Entry readNodeEntry(final String nodeName) throws RepositoryException { |
408 | | - | Entry entry = this.nodes.get(nodeName); |
409 | | - | if (entry == null) { |
410 | | - | log.fine("Reading '" + nodeName + "' node entry..."); |
411 | | - | AbstractNodeConfig cnf = readNodeConfig(nodeName); |
412 | | - | if (cnf == null) |
413 | | - | return null; |
414 | | - | Date creationDate = this.pubSubDB.getNodeCreationDate(nodeName); |
415 | | - | |
416 | | - | List<Subscriber> subscribers = readSubscribers(nodeName); |
417 | | - | List<NodeAffiliation> affiliations = readNodeAffiliations(nodeName); |
418 | | - | List<Item> items = readItems(nodeName); |
419 | | - | entry = new Entry(nodeName, creationDate, cnf, subscribers, affiliations, items); |
420 | | - | this.nodes.put(nodeName, entry); |
421 | | - | } |
422 | | - | return entry; |
423 | | - | } |
424 | | - | |
425 | | - | protected List<Subscriber> readSubscribers(final String nodeName) throws RepositoryException { |
426 | | - | String[] jids = this.pubSubDB.getSubscriptions(nodeName); |
427 | | - | List<Subscriber> result = new ArrayList<Subscriber>(); |
428 | | - | if (jids != null) |
429 | | - | for (String jid : jids) { |
430 | | - | String subId = this.pubSubDB.getSubscriptionId(nodeName, jid); |
431 | | - | Subscription subscription = this.pubSubDB.getSubscription(nodeName, jid); |
432 | | - | Subscriber s = new Subscriber(jid, subId, subscription); |
433 | | - | result.add(s); |
434 | | - | } |
435 | | - | |
436 | | - | return result; |
437 | | - | } |
438 | | - | |
439 | | - | /* |
440 | | - | * (non-Javadoc) |
441 | | - | * |
442 | | - | * @see |
443 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#removeListener(tigase |
444 | | - | * .pubsub.repository.PubSubRepositoryListener) |
445 | | - | */ |
446 | | - | public void removeListener(PubSubRepositoryListener listener) { |
447 | | - | this.listeners.remove(listener); |
448 | | - | } |
449 | | - | |
450 | | - | /* |
451 | | - | * (non-Javadoc) |
452 | | - | * |
453 | | - | * @see |
454 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#removeSubscriber( |
455 | | - | * java.lang.String, java.lang.String) |
456 | | - | */ |
457 | | - | public void removeSubscriber(String nodeName, String jid) throws RepositoryException { |
458 | | - | this.pubSubDB.removeSubscriber(nodeName, jid); |
459 | | - | Entry entry = readNodeEntry(nodeName); |
460 | | - | entry.removeSubscriber(jid); |
461 | | - | } |
462 | | - | |
463 | | - | /* |
464 | | - | * (non-Javadoc) |
465 | | - | * |
466 | | - | * @see |
467 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#setNewNodeCollection |
468 | | - | * (java.lang.String, java.lang.String) |
469 | | - | */ |
470 | | - | public void setNewNodeCollection(String nodeName, String collectionNew) throws RepositoryException { |
471 | | - | Entry entry = readNodeEntry(nodeName); |
472 | | - | this.pubSubDB.setNewNodeCollection(nodeName, collectionNew); |
473 | | - | final String oldCollectionName = entry.getConfig().getCollection(); |
474 | | - | entry.getConfig().setCollection(collectionNew); |
475 | | - | fireNewNodeCollection(nodeName, oldCollectionName, collectionNew); |
476 | | - | } |
477 | | - | |
478 | | - | /* |
479 | | - | * (non-Javadoc) |
480 | | - | * |
481 | | - | * @see |
482 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#update(java.lang. |
483 | | - | * String, tigase.pubsub.AbstractNodeConfig) |
484 | | - | */ |
485 | | - | public void update(String nodeName, AbstractNodeConfig nodeConfig) throws RepositoryException { |
486 | | - | Entry entry = readNodeEntry(nodeName); |
487 | | - | final String oldCollectionName = entry.getConfig().getCollection(); |
488 | | - | this.pubSubDB.update(nodeName, nodeConfig); |
489 | | - | entry.getConfig().copyFrom(nodeConfig); |
490 | | - | final String newCollectionName = entry.getConfig().getCollection(); |
491 | | - | if (!oldCollectionName.equals(newCollectionName)) { |
492 | | - | fireNewNodeCollection(nodeName, oldCollectionName, newCollectionName); |
493 | | - | } |
494 | | - | |
495 | | - | } |
496 | | - | |
497 | | - | /* |
498 | | - | * (non-Javadoc) |
499 | | - | * |
500 | | - | * @see |
501 | | - | * tigase.pubsub.repository.inmemory.IPubSubRepository#writeItem(java.lang |
502 | | - | * .String, long, java.lang.String, java.lang.String, tigase.xml.Element) |
503 | | - | */ |
504 | | - | public void writeItem(String nodeName, long timeInMilis, String id, String publisher, Element item) throws RepositoryException { |
505 | | - | this.pubSubDB.writeItem(nodeName, timeInMilis, id, publisher, item); |
506 | | - | Item it = new Item(id, item, new Date(timeInMilis), new Date(timeInMilis), publisher); |
507 | | - | Entry entry = readNodeEntry(nodeName); |
508 | | - | entry.add(it); |
509 | | - | } |
510 | | - | |
511 | | - | } |
512 | | - | |