Use bookmark database in core.
[Sone.git] / src / main / java / net / pterodactylus / sone / database / memory / MemoryDatabase.java
1 /*
2  * Sone - MemoryDatabase.java - Copyright © 2013 David Roden
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
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.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 package net.pterodactylus.sone.database.memory;
19
20 import static com.google.common.base.Optional.fromNullable;
21 import static com.google.common.base.Preconditions.checkNotNull;
22 import static com.google.common.base.Predicates.not;
23 import static com.google.common.collect.FluentIterable.from;
24 import static java.util.Collections.unmodifiableCollection;
25 import static net.pterodactylus.sone.data.Reply.TIME_COMPARATOR;
26 import static net.pterodactylus.sone.data.Sone.LOCAL_SONE_FILTER;
27 import static net.pterodactylus.sone.data.Sone.toAllAlbums;
28 import static net.pterodactylus.sone.data.Sone.toAllImages;
29
30 import java.util.Collection;
31 import java.util.Comparator;
32 import java.util.HashMap;
33 import java.util.HashSet;
34 import java.util.List;
35 import java.util.Map;
36 import java.util.Set;
37 import java.util.concurrent.locks.ReadWriteLock;
38 import java.util.concurrent.locks.ReentrantReadWriteLock;
39
40 import net.pterodactylus.sone.data.Album;
41 import net.pterodactylus.sone.data.Image;
42 import net.pterodactylus.sone.data.Post;
43 import net.pterodactylus.sone.data.PostReply;
44 import net.pterodactylus.sone.data.Sone;
45 import net.pterodactylus.sone.data.impl.AlbumBuilderImpl;
46 import net.pterodactylus.sone.data.impl.ImageBuilderImpl;
47 import net.pterodactylus.sone.database.AlbumBuilder;
48 import net.pterodactylus.sone.database.Database;
49 import net.pterodactylus.sone.database.DatabaseException;
50 import net.pterodactylus.sone.database.ImageBuilder;
51 import net.pterodactylus.sone.database.PostBuilder;
52 import net.pterodactylus.sone.database.PostDatabase;
53 import net.pterodactylus.sone.database.PostReplyBuilder;
54 import net.pterodactylus.sone.database.SoneBuilder;
55 import net.pterodactylus.sone.database.SoneProvider;
56 import net.pterodactylus.util.config.Configuration;
57 import net.pterodactylus.util.config.ConfigurationException;
58
59 import com.google.common.base.Optional;
60 import com.google.common.base.Predicate;
61 import com.google.common.collect.HashMultimap;
62 import com.google.common.collect.Multimap;
63 import com.google.common.collect.SortedSetMultimap;
64 import com.google.common.collect.TreeMultimap;
65 import com.google.common.util.concurrent.AbstractService;
66 import com.google.inject.Inject;
67 import com.google.inject.Singleton;
68
69 /**
70  * Memory-based {@link PostDatabase} implementation.
71  *
72  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
73  */
74 @Singleton
75 public class MemoryDatabase extends AbstractService implements Database {
76
77         /** The lock. */
78         private final ReadWriteLock lock = new ReentrantReadWriteLock();
79
80         /** The Sone provider. */
81         private final SoneProvider soneProvider;
82
83         /** The configuration. */
84         private final Configuration configuration;
85
86         private final Map<String, Sone> allSones = new HashMap<String, Sone>();
87
88         /** All posts by their ID. */
89         private final Map<String, Post> allPosts = new HashMap<String, Post>();
90
91         /** All posts by their Sones. */
92         private final Multimap<String, Post> sonePosts = HashMultimap.create();
93
94         /** Whether posts are known. */
95         private final Set<String> knownPosts = new HashSet<String>();
96
97         /** All post replies by their ID. */
98         private final Map<String, PostReply> allPostReplies = new HashMap<String, PostReply>();
99
100         /** Replies sorted by Sone. */
101         private final SortedSetMultimap<String, PostReply> sonePostReplies = TreeMultimap.create(new Comparator<String>() {
102
103                 @Override
104                 public int compare(String leftString, String rightString) {
105                         return leftString.compareTo(rightString);
106                 }
107         }, TIME_COMPARATOR);
108
109         /** Whether post replies are known. */
110         private final Set<String> knownPostReplies = new HashSet<String>();
111
112         private final Map<String, Album> allAlbums = new HashMap<String, Album>();
113         private final Multimap<String, Album> soneAlbums = HashMultimap.create();
114
115         private final Map<String, Image> allImages = new HashMap<String, Image>();
116         private final Multimap<String, Image> soneImages = HashMultimap.create();
117
118         private final MemoryBookmarkDatabase memoryBookmarkDatabase =
119                         new MemoryBookmarkDatabase(this);
120
121         /**
122          * Creates a new memory database.
123          *
124          * @param soneProvider
125          *              The Sone provider
126          * @param configuration
127          *              The configuration for loading and saving elements
128          */
129         @Inject
130         public MemoryDatabase(SoneProvider soneProvider, Configuration configuration) {
131                 this.soneProvider = soneProvider;
132                 this.configuration = configuration;
133         }
134
135         //
136         // DATABASE METHODS
137         //
138
139         /**
140          * Saves the database.
141          *
142          * @throws DatabaseException
143          *              if an error occurs while saving
144          */
145         @Override
146         public void save() throws DatabaseException {
147                 saveKnownPosts();
148                 saveKnownPostReplies();
149         }
150
151         //
152         // SERVICE METHODS
153         //
154
155         /** {@inheritDocs} */
156         @Override
157         protected void doStart() {
158                 loadKnownPosts();
159                 loadKnownPostReplies();
160                 notifyStarted();
161         }
162
163         /** {@inheritDocs} */
164         @Override
165         protected void doStop() {
166                 try {
167                         save();
168                         notifyStopped();
169                 } catch (DatabaseException de1) {
170                         notifyFailed(de1);
171                 }
172         }
173
174         @Override
175         public SoneBuilder newSoneBuilder() {
176                 return new MemorySoneBuilder();
177         }
178
179         @Override
180         public void storeSone(Sone sone) {
181                 lock.writeLock().lock();
182                 try {
183                         Collection<Post> removedPosts = sonePosts.removeAll(sone.getId());
184                         for (Post removedPost : removedPosts) {
185                                 allPosts.remove(removedPost.getId());
186                         }
187                         Collection<PostReply> removedPostReplies =
188                                         sonePostReplies.removeAll(sone.getId());
189                         for (PostReply removedPostReply : removedPostReplies) {
190                                 allPostReplies.remove(removedPostReply.getId());
191                         }
192                         Collection<Album> removedAlbums =
193                                         soneAlbums.removeAll(sone.getId());
194                         for (Album removedAlbum : removedAlbums) {
195                                 allAlbums.remove(removedAlbum.getId());
196                         }
197                         Collection<Image> removedImages =
198                                         soneImages.removeAll(sone.getId());
199                         for (Image removedImage : removedImages) {
200                                 allImages.remove(removedImage.getId());
201                         }
202
203                         allSones.put(sone.getId(), sone);
204                         sonePosts.putAll(sone.getId(), sone.getPosts());
205                         for (Post post : sone.getPosts()) {
206                                 allPosts.put(post.getId(), post);
207                         }
208                         sonePostReplies.putAll(sone.getId(), sone.getReplies());
209                         for (PostReply postReply : sone.getReplies()) {
210                                 allPostReplies.put(postReply.getId(), postReply);
211                         }
212                         soneAlbums.putAll(sone.getId(), toAllAlbums.apply(sone));
213                         for (Album album : toAllAlbums.apply(sone)) {
214                                 allAlbums.put(album.getId(), album);
215                         }
216                         soneImages.putAll(sone.getId(), toAllImages.apply(sone));
217                         for (Image image : toAllImages.apply(sone)) {
218                                 allImages.put(image.getId(), image);
219                         }
220                 } finally {
221                         lock.writeLock().unlock();
222                 }
223         }
224
225         @Override
226         public Optional<Sone> getSone(String soneId) {
227                 lock.readLock().lock();
228                 try {
229                         return fromNullable(allSones.get(soneId));
230                 } finally {
231                         lock.readLock().unlock();
232                 }
233         }
234
235         @Override
236         public Collection<Sone> getSones() {
237                 lock.readLock().lock();
238                 try {
239                         return new HashSet<Sone>(allSones.values());
240                 } finally {
241                         lock.readLock().unlock();
242                 }
243         }
244
245         @Override
246         public Collection<Sone> getLocalSones() {
247                 lock.readLock().lock();
248                 try {
249                         return from(allSones.values()).filter(LOCAL_SONE_FILTER).toSet();
250                 } finally {
251                         lock.readLock().unlock();
252                 }
253         }
254
255         @Override
256         public Collection<Sone> getRemoteSones() {
257                 lock.readLock().lock();
258                 try {
259                         return from(allSones.values())
260                                         .filter(not(LOCAL_SONE_FILTER)) .toSet();
261                 } finally {
262                         lock.readLock().unlock();
263                 }
264         }
265
266         //
267         // POSTPROVIDER METHODS
268         //
269
270         /** {@inheritDocs} */
271         @Override
272         public Optional<Post> getPost(String postId) {
273                 lock.readLock().lock();
274                 try {
275                         return fromNullable(allPosts.get(postId));
276                 } finally {
277                         lock.readLock().unlock();
278                 }
279         }
280
281         /** {@inheritDocs} */
282         @Override
283         public Collection<Post> getPosts(String soneId) {
284                 return new HashSet<Post>(getPostsFrom(soneId));
285         }
286
287         /** {@inheritDocs} */
288         @Override
289         public Collection<Post> getDirectedPosts(final String recipientId) {
290                 lock.readLock().lock();
291                 try {
292                         return from(sonePosts.values()).filter(new Predicate<Post>() {
293                                 @Override
294                                 public boolean apply(Post post) {
295                                         return post.getRecipientId().asSet().contains(recipientId);
296                                 }
297                         }).toSet();
298                 } finally {
299                         lock.readLock().unlock();
300                 }
301         }
302
303         //
304         // POSTBUILDERFACTORY METHODS
305         //
306
307         /** {@inheritDocs} */
308         @Override
309         public PostBuilder newPostBuilder() {
310                 return new MemoryPostBuilder(this, soneProvider);
311         }
312
313         //
314         // POSTSTORE METHODS
315         //
316
317         /** {@inheritDocs} */
318         @Override
319         public void storePost(Post post) {
320                 checkNotNull(post, "post must not be null");
321                 lock.writeLock().lock();
322                 try {
323                         allPosts.put(post.getId(), post);
324                         getPostsFrom(post.getSone().getId()).add(post);
325                 } finally {
326                         lock.writeLock().unlock();
327                 }
328         }
329
330         /** {@inheritDocs} */
331         @Override
332         public void removePost(Post post) {
333                 checkNotNull(post, "post must not be null");
334                 lock.writeLock().lock();
335                 try {
336                         allPosts.remove(post.getId());
337                         getPostsFrom(post.getSone().getId()).remove(post);
338                         post.getSone().removePost(post);
339                 } finally {
340                         lock.writeLock().unlock();
341                 }
342         }
343
344         /** {@inheritDocs} */
345         @Override
346         public void storePosts(Sone sone, Collection<Post> posts) throws IllegalArgumentException {
347                 checkNotNull(sone, "sone must not be null");
348                 /* verify that all posts are from the same Sone. */
349                 for (Post post : posts) {
350                         if (!sone.equals(post.getSone())) {
351                                 throw new IllegalArgumentException(String.format("Post from different Sone found: %s", post));
352                         }
353                 }
354
355                 lock.writeLock().lock();
356                 try {
357                         /* remove all posts by the Sone. */
358                         Collection<Post> oldPosts = getPostsFrom(sone.getId());
359                         for (Post post : oldPosts) {
360                                 allPosts.remove(post.getId());
361                         }
362
363                         /* add new posts. */
364                         getPostsFrom(sone.getId()).addAll(posts);
365                         for (Post post : posts) {
366                                 allPosts.put(post.getId(), post);
367                         }
368                 } finally {
369                         lock.writeLock().unlock();
370                 }
371         }
372
373         /** {@inheritDocs} */
374         @Override
375         public void removePosts(Sone sone) {
376                 checkNotNull(sone, "sone must not be null");
377                 lock.writeLock().lock();
378                 try {
379                         /* remove all posts by the Sone. */
380                         getPostsFrom(sone.getId()).clear();
381                         for (Post post : sone.getPosts()) {
382                                 allPosts.remove(post.getId());
383                         }
384                 } finally {
385                         lock.writeLock().unlock();
386                 }
387         }
388
389         //
390         // POSTREPLYPROVIDER METHODS
391         //
392
393         /** {@inheritDocs} */
394         @Override
395         public Optional<PostReply> getPostReply(String id) {
396                 lock.readLock().lock();
397                 try {
398                         return fromNullable(allPostReplies.get(id));
399                 } finally {
400                         lock.readLock().unlock();
401                 }
402         }
403
404         /** {@inheritDocs} */
405         @Override
406         public List<PostReply> getReplies(final String postId) {
407                 lock.readLock().lock();
408                 try {
409                         return from(allPostReplies.values())
410                                         .filter(new Predicate<PostReply>() {
411                                                 @Override
412                                                 public boolean apply(PostReply postReply) {
413                                                         return postReply.getPostId().equals(postId);
414                                                 }
415                                         }).toSortedList(TIME_COMPARATOR);
416                 } finally {
417                         lock.readLock().unlock();
418                 }
419         }
420
421         //
422         // POSTREPLYBUILDERFACTORY METHODS
423         //
424
425         /** {@inheritDocs} */
426         @Override
427         public PostReplyBuilder newPostReplyBuilder() {
428                 return new MemoryPostReplyBuilder(this, soneProvider);
429         }
430
431         //
432         // POSTREPLYSTORE METHODS
433         //
434
435         /** {@inheritDocs} */
436         @Override
437         public void storePostReply(PostReply postReply) {
438                 lock.writeLock().lock();
439                 try {
440                         allPostReplies.put(postReply.getId(), postReply);
441                 } finally {
442                         lock.writeLock().unlock();
443                 }
444         }
445
446         /** {@inheritDocs} */
447         @Override
448         public void storePostReplies(Sone sone, Collection<PostReply> postReplies) {
449                 checkNotNull(sone, "sone must not be null");
450                 /* verify that all posts are from the same Sone. */
451                 for (PostReply postReply : postReplies) {
452                         if (!sone.equals(postReply.getSone())) {
453                                 throw new IllegalArgumentException(String.format("PostReply from different Sone found: %s", postReply));
454                         }
455                 }
456
457                 lock.writeLock().lock();
458                 try {
459                         /* remove all post replies of the Sone. */
460                         for (PostReply postReply : getRepliesFrom(sone.getId())) {
461                                 removePostReply(postReply);
462                         }
463                         for (PostReply postReply : postReplies) {
464                                 allPostReplies.put(postReply.getId(), postReply);
465                                 sonePostReplies.put(postReply.getSone().getId(), postReply);
466                         }
467                 } finally {
468                         lock.writeLock().unlock();
469                 }
470         }
471
472         /** {@inheritDocs} */
473         @Override
474         public void removePostReply(PostReply postReply) {
475                 lock.writeLock().lock();
476                 try {
477                         allPostReplies.remove(postReply.getId());
478                 } finally {
479                         lock.writeLock().unlock();
480                 }
481         }
482
483         /** {@inheritDocs} */
484         @Override
485         public void removePostReplies(Sone sone) {
486                 checkNotNull(sone, "sone must not be null");
487
488                 lock.writeLock().lock();
489                 try {
490                         for (PostReply postReply : sone.getReplies()) {
491                                 removePostReply(postReply);
492                         }
493                 } finally {
494                         lock.writeLock().unlock();
495                 }
496         }
497
498         //
499         // ALBUMPROVDER METHODS
500         //
501
502         @Override
503         public Optional<Album> getAlbum(String albumId) {
504                 lock.readLock().lock();
505                 try {
506                         return fromNullable(allAlbums.get(albumId));
507                 } finally {
508                         lock.readLock().unlock();
509                 }
510         }
511
512         //
513         // ALBUMBUILDERFACTORY METHODS
514         //
515
516         @Override
517         public AlbumBuilder newAlbumBuilder() {
518                 return new AlbumBuilderImpl();
519         }
520
521         //
522         // ALBUMSTORE METHODS
523         //
524
525         @Override
526         public void storeAlbum(Album album) {
527                 lock.writeLock().lock();
528                 try {
529                         allAlbums.put(album.getId(), album);
530                         soneAlbums.put(album.getSone().getId(), album);
531                 } finally {
532                         lock.writeLock().unlock();
533                 }
534         }
535
536         @Override
537         public void removeAlbum(Album album) {
538                 lock.writeLock().lock();
539                 try {
540                         allAlbums.remove(album.getId());
541                         soneAlbums.remove(album.getSone().getId(), album);
542                 } finally {
543                         lock.writeLock().unlock();
544                 }
545         }
546
547         //
548         // IMAGEPROVIDER METHODS
549         //
550
551         @Override
552         public Optional<Image> getImage(String imageId) {
553                 lock.readLock().lock();
554                 try {
555                         return fromNullable(allImages.get(imageId));
556                 } finally {
557                         lock.readLock().unlock();
558                 }
559         }
560
561         //
562         // IMAGEBUILDERFACTORY METHODS
563         //
564
565         @Override
566         public ImageBuilder newImageBuilder() {
567                 return new ImageBuilderImpl();
568         }
569
570         //
571         // IMAGESTORE METHODS
572         //
573
574         @Override
575         public void storeImage(Image image) {
576                 lock.writeLock().lock();
577                 try {
578                         allImages.put(image.getId(), image);
579                         soneImages.put(image.getSone().getId(), image);
580                 } finally {
581                         lock.writeLock().unlock();
582                 }
583         }
584
585         @Override
586         public void removeImage(Image image) {
587                 lock.writeLock().lock();
588                 try {
589                         allImages.remove(image.getId());
590                         soneImages.remove(image.getSone().getId(), image);
591                 } finally {
592                         lock.writeLock().unlock();
593                 }
594         }
595
596         @Override
597         public void bookmarkPost(String postId) {
598                 memoryBookmarkDatabase.bookmarkPost(postId);
599         }
600
601         @Override
602         public void bookmarkPost(Post post) {
603                 memoryBookmarkDatabase.bookmarkPost(post);
604         }
605
606         @Override
607         public void unbookmarkPost(Post post) {
608                 memoryBookmarkDatabase.unbookmarkPost(post);
609         }
610
611         @Override
612         public boolean isPostBookmarked(Post post) {
613                 return memoryBookmarkDatabase.isPostBookmarked(post);
614         }
615
616         @Override
617         public Set<Post> getBookmarkedPosts() {
618                 return memoryBookmarkDatabase.getBookmarkedPosts();
619         }
620
621         //
622         // PACKAGE-PRIVATE METHODS
623         //
624
625         /**
626          * Returns whether the given post is known.
627          *
628          * @param post
629          *              The post
630          * @return {@code true} if the post is known, {@code false} otherwise
631          */
632         boolean isPostKnown(Post post) {
633                 lock.readLock().lock();
634                 try {
635                         return knownPosts.contains(post.getId());
636                 } finally {
637                         lock.readLock().unlock();
638                 }
639         }
640
641         /**
642          * Sets whether the given post is known.
643          *
644          * @param post
645          *              The post
646          * @param known
647          *              {@code true} if the post is known, {@code false} otherwise
648          */
649         void setPostKnown(Post post, boolean known) {
650                 lock.writeLock().lock();
651                 try {
652                         if (known) {
653                                 knownPosts.add(post.getId());
654                         } else {
655                                 knownPosts.remove(post.getId());
656                         }
657                 } finally {
658                         lock.writeLock().unlock();
659                 }
660         }
661
662         /**
663          * Returns whether the given post reply is known.
664          *
665          * @param postReply
666          *              The post reply
667          * @return {@code true} if the given post reply is known, {@code false}
668          *         otherwise
669          */
670         boolean isPostReplyKnown(PostReply postReply) {
671                 lock.readLock().lock();
672                 try {
673                         return knownPostReplies.contains(postReply.getId());
674                 } finally {
675                         lock.readLock().unlock();
676                 }
677         }
678
679         /**
680          * Sets whether the given post reply is known.
681          *
682          * @param postReply
683          *              The post reply
684          * @param known
685          *              {@code true} if the post reply is known, {@code false} otherwise
686          */
687         void setPostReplyKnown(PostReply postReply, boolean known) {
688                 lock.writeLock().lock();
689                 try {
690                         if (known) {
691                                 knownPostReplies.add(postReply.getId());
692                         } else {
693                                 knownPostReplies.remove(postReply.getId());
694                         }
695                 } finally {
696                         lock.writeLock().unlock();
697                 }
698         }
699
700         //
701         // PRIVATE METHODS
702         //
703
704         /**
705          * Gets all posts for the given Sone, creating a new collection if there is
706          * none yet.
707          *
708          * @param soneId
709          *              The ID of the Sone to get the posts for
710          * @return All posts
711          */
712         private Collection<Post> getPostsFrom(String soneId) {
713                 lock.readLock().lock();
714                 try {
715                         return sonePosts.get(soneId);
716                 } finally {
717                         lock.readLock().unlock();
718                 }
719         }
720
721         /** Loads the known posts. */
722         private void loadKnownPosts() {
723                 lock.writeLock().lock();
724                 try {
725                         int postCounter = 0;
726                         while (true) {
727                                 String knownPostId = configuration.getStringValue("KnownPosts/" + postCounter++ + "/ID").getValue(null);
728                                 if (knownPostId == null) {
729                                         break;
730                                 }
731                                 knownPosts.add(knownPostId);
732                         }
733                 } finally {
734                         lock.writeLock().unlock();
735                 }
736         }
737
738         /**
739          * Saves the known posts to the configuration.
740          *
741          * @throws DatabaseException
742          *              if a configuration error occurs
743          */
744         private void saveKnownPosts() throws DatabaseException {
745                 lock.readLock().lock();
746                 try {
747                         int postCounter = 0;
748                         for (String knownPostId : knownPosts) {
749                                 configuration.getStringValue("KnownPosts/" + postCounter++ + "/ID").setValue(knownPostId);
750                         }
751                         configuration.getStringValue("KnownPosts/" + postCounter + "/ID").setValue(null);
752                 } catch (ConfigurationException ce1) {
753                         throw new DatabaseException("Could not save database.", ce1);
754                 } finally {
755                         lock.readLock().unlock();
756                 }
757         }
758
759         /**
760          * Returns all replies by the given Sone.
761          *
762          * @param id
763          *              The ID of the Sone
764          * @return The post replies of the Sone, sorted by time (newest first)
765          */
766         private Collection<PostReply> getRepliesFrom(String id) {
767                 lock.readLock().lock();
768                 try {
769                         return unmodifiableCollection(sonePostReplies.get(id));
770                 } finally {
771                         lock.readLock().unlock();
772                 }
773         }
774
775         /** Loads the known post replies. */
776         private void loadKnownPostReplies() {
777                 lock.writeLock().lock();
778                 try {
779                         int replyCounter = 0;
780                         while (true) {
781                                 String knownReplyId = configuration.getStringValue("KnownReplies/" + replyCounter++ + "/ID").getValue(null);
782                                 if (knownReplyId == null) {
783                                         break;
784                                 }
785                                 knownPostReplies.add(knownReplyId);
786                         }
787                 } finally {
788                         lock.writeLock().unlock();
789                 }
790         }
791
792         /**
793          * Saves the known post replies to the configuration.
794          *
795          * @throws DatabaseException
796          *              if a configuration error occurs
797          */
798         private void saveKnownPostReplies() throws DatabaseException {
799                 lock.readLock().lock();
800                 try {
801                         int replyCounter = 0;
802                         for (String knownReplyId : knownPostReplies) {
803                                 configuration.getStringValue("KnownReplies/" + replyCounter++ + "/ID").setValue(knownReplyId);
804                         }
805                         configuration.getStringValue("KnownReplies/" + replyCounter + "/ID").setValue(null);
806                 } catch (ConfigurationException ce1) {
807                         throw new DatabaseException("Could not save database.", ce1);
808                 } finally {
809                         lock.readLock().unlock();
810                 }
811         }
812
813 }