| VerifyBlogsTrackbacks.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 2.1 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 */
14
15 package com.liferay.portal.verify;
16
17 import com.liferay.portal.kernel.log.Log;
18 import com.liferay.portal.kernel.log.LogFactoryUtil;
19 import com.liferay.portlet.blogs.model.BlogsEntry;
20 import com.liferay.portlet.blogs.service.BlogsEntryLocalServiceUtil;
21 import com.liferay.portlet.blogs.util.TrackbackVerifierUtil;
22 import com.liferay.portlet.messageboards.model.MBDiscussion;
23 import com.liferay.portlet.messageboards.model.MBMessage;
24 import com.liferay.portlet.messageboards.service.MBMessageLocalServiceUtil;
25
26 import java.util.List;
27
28 /**
29 * <a href="VerifyBlogsTrackbacks.java.html"><b><i>View Source</i></b></a>
30 *
31 * <p>
32 * This class looks at every blog comment to see if it is a trackback and
33 * verifies that the source URL is a valid URL. Do not run this unless you want
34 * to do this.
35 * </p>
36 *
37 * @author Alexander Chow
38 */
39 public class VerifyBlogsTrackbacks extends VerifyProcess {
40
41 protected void doVerify() throws Exception {
42 List<MBDiscussion> discussions =
43 MBMessageLocalServiceUtil.getDiscussions(
44 BlogsEntry.class.getName());
45
46 for (MBDiscussion discussion : discussions) {
47 long entryId = discussion.getClassPK();
48 long threadId = discussion.getThreadId();
49
50 try {
51 BlogsEntry entry = BlogsEntryLocalServiceUtil.getBlogsEntry(
52 entryId);
53
54 List<MBMessage> messages =
55 MBMessageLocalServiceUtil.getThreadMessages(threadId);
56
57 for (MBMessage message : messages) {
58 TrackbackVerifierUtil.verifyPost(entry, message);
59 }
60 }
61 catch (Exception e) {
62 _log.error(e, e);
63 }
64 }
65 }
66
67 private static Log _log = LogFactoryUtil.getLog(
68 VerifyBlogsTrackbacks.class);
69
70 }