source: extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/service/impl/CommentServiceImpl.java @ 10505

Last change on this file since 10505 was 10505, checked in by anthony43, 13 years ago

huge refactoring to introduce JiwigoException : a generic exception encapsulating low level exceptions (IOException, ProxyAuthentication, etc...)
The aim is to have, on the consumer side, just one exception to catch them all.
this refactoring may need a code review to check the changes.

File size: 2.0 KB
Line 
1package fr.mael.jiwigo.service.impl;
2
3import java.io.IOException;
4import java.util.List;
5
6import org.slf4j.Logger;
7import org.slf4j.LoggerFactory;
8
9import fr.mael.jiwigo.dao.CommentDao;
10import fr.mael.jiwigo.om.Comment;
11import fr.mael.jiwigo.service.CommentService;
12import fr.mael.jiwigo.transverse.exception.JiwigoException;
13import 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 */
31public 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}
Note: See TracBrowser for help on using the repository browser.