1 | package fr.mael.jiwigo.service.impl; |
---|
2 | |
---|
3 | import java.io.IOException; |
---|
4 | import java.util.List; |
---|
5 | |
---|
6 | import org.slf4j.Logger; |
---|
7 | import org.slf4j.LoggerFactory; |
---|
8 | |
---|
9 | import fr.mael.jiwigo.dao.CommentDao; |
---|
10 | import fr.mael.jiwigo.om.Comment; |
---|
11 | import fr.mael.jiwigo.service.CommentService; |
---|
12 | import fr.mael.jiwigo.transverse.exception.JiwigoException; |
---|
13 | import fr.mael.jiwigo.transverse.exception.ProxyAuthenticationException; |
---|
14 | |
---|
15 | /* |
---|
16 | * jiwigo-ws-api Piwigo webservice access Api |
---|
17 | * Copyright (c) 2010-2011 Mael mael@le-guevel.com |
---|
18 | * All Rights Reserved |
---|
19 | * |
---|
20 | * This library is free software. It comes without any warranty, to |
---|
21 | * the extent permitted by applicable law. You can redistribute it |
---|
22 | * and/or modify it under the terms of the Do What The Fuck You Want |
---|
23 | * To Public License, Version 2, as published by Sam Hocevar. See |
---|
24 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
25 | */ |
---|
26 | /** |
---|
27 | |
---|
28 | * @author mael |
---|
29 | * |
---|
30 | */ |
---|
31 | public class CommentServiceImpl implements CommentService { |
---|
32 | /** |
---|
33 | * Logger |
---|
34 | */ |
---|
35 | private final Logger LOG = LoggerFactory.getLogger(CommentServiceImpl.class); |
---|
36 | |
---|
37 | private CommentDao dao; |
---|
38 | |
---|
39 | /** |
---|
40 | * Lists all comments for an image |
---|
41 | * @param imageId the id of the image |
---|
42 | * @return the list of comments |
---|
43 | * @throws IOException |
---|
44 | * @throws ProxyAuthenticationException |
---|
45 | */ |
---|
46 | public List<Comment> list(Integer imageId) throws JiwigoException { |
---|
47 | return dao.list(imageId); |
---|
48 | } |
---|
49 | |
---|
50 | /** |
---|
51 | * Creates a comment for an image |
---|
52 | * @param content the comment |
---|
53 | * @param imageId the id of the image |
---|
54 | * @param auteur the author of the comment |
---|
55 | * @return true if successful |
---|
56 | * @throws IOException |
---|
57 | * @throws ProxyAuthenticationException |
---|
58 | */ |
---|
59 | public boolean create(String content, Integer imageId, String auteur) throws JiwigoException { |
---|
60 | Comment comment = new Comment(); |
---|
61 | comment.setContent(content); |
---|
62 | comment.setImageId(imageId); |
---|
63 | comment.setAuthor(auteur); |
---|
64 | return dao.create(comment); |
---|
65 | } |
---|
66 | |
---|
67 | public CommentDao getDao() { |
---|
68 | return dao; |
---|
69 | } |
---|
70 | |
---|
71 | public void setDao(CommentDao dao) { |
---|
72 | this.dao = dao; |
---|
73 | } |
---|
74 | |
---|
75 | } |
---|