/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.forum;
import org.apache.log4j.Logger;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.mail.Mail;
import com.arsdigita.messaging.ThreadedMessage;
import com.arsdigita.notification.BaseSubscription;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
import com.arsdigita.util.Assert;
import com.arsdigita.web.ParameterMap;
import com.arsdigita.web.URL;
/**
* The abstract Subscription class provides the ability for Users
* to sign up for email notifications. Subclasses will specify
* the object to which the notifications apply.
*
* The default implementation provides instant notifications. Subclasses
* should override sendNotification() to alter this behavior.
*
* @author Kevin Scaldeferri (kevin@arsdigita.com)
* @author chrisg23
* @version $Id: Subscription.java 2070 2010-01-28 08:47:41Z pboy $
*/
public abstract class Subscription extends BaseSubscription {
private static final Logger s_log = Logger.getLogger(Subscription.class);
protected static final String HTML_SEPARATOR = "
\n
* Forum : Name
* Subject : Subject
* com.arsdigita.messaging.ThreadedMessageed by: User
*
*
* @return a header to insert at the top of the alert.
*/
public String getHeader(ThreadedMessage msg) {
Assert.isTrue(msg instanceof Post,
"Parameter msg should be a Post");
Post post = (Post)msg;
String author = post.getFrom().getName();
if (author == null) {
author = "Unknown";
}
StringBuffer sb = new StringBuffer();
if (Mail.getConfig().sendHTMLMessageAsHTMLEmail()) {
sb.append("");
sb.append("Forum : ");
sb.append(post.getForum().getDisplayName()).append("\n