source: ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rss/RssCreatorComments.java @ 5549

Last change on this file since 5549 was 5549, checked in by olhsha@mpi.nl, 10 years ago

Added group service. Tested via the tomcat on loclahots (test URI and postman), old unit tests are adjusted and work well. Todo: retest on localhost tomcat, look at run-time exceptions, add new unit tests, adjust front-end

File size: 2.1 KB
Line 
1package clarin.cmdi.componentregistry.rss;
2
3import clarin.cmdi.componentregistry.DatesHelper;
4import clarin.cmdi.componentregistry.model.Comment;
5import java.util.Comparator;
6import java.util.List;
7
8/**
9 *
10 * @author olhsha
11 */
12public class RssCreatorComments extends RssCreator<Comment> {
13
14    /**
15     *
16     * @param isPrivate if "true" then profiles and components from the user's
17     * workspace, otherwise -- public (uri-parameter)
18     * @param baseURI where the database is located
19     * @param limit number of items to be displayed (uri-parameter)
20     * @param descriptionId Id of the profile/component whose comments are
21     * considered
22     * @param descriptionName Name of the profile/component whose comments are
23     * considered
24     * @param descriptionType "profile" or "component"
25     * @param comms the list of comments from which the list of rss-items for
26     * the channel will be created
27     * @param comparator compare comments by dates
28     */
29    public RssCreatorComments(boolean isPrivate, String baseURI, int limit,
30            String descriptionId, String descriptionName, String descriptionType, List<Comment> comms, Comparator<Comment> comparator) {
31        super(isPrivate, baseURI, limit, comms);
32        setChannelLink(baseURI + "?item=" + descriptionId + ((isPrivate) ? "&space=user" : "") + "&browserview=comments");
33        setChannelTitle((isPrivate ? "Private " : "Public ") + descriptionType + " \"" + descriptionName + "\"");
34        setChannelDescription(String.format("Comments feed for the %s \"%s\"", descriptionType, descriptionName));
35        setComparator(comparator);
36    }
37
38    @Override
39    protected RssItem fromArgToRssItem(Comment comm) {
40        final String itemLink = getChannelLink() + "&commentId=" + comm.getId();
41        RssItem retval = new RssItem();
42        retval.setDescription(comm.getComment());
43        retval.setGuid(makeGuid(itemLink));
44        retval.setLink(itemLink);
45        retval.setPubDate(DatesHelper.getRFCDateTime(comm.getCommentDate()));
46        retval.setTitle(String.format("Comment %1$s\nby %2$s", comm.getId(), comm.getUserName()));
47        return retval;
48    }
49}
Note: See TracBrowser for help on using the repository browser.