001/* 002 * (C) Copyright 2007-2008 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nuxeo - initial API and implementation 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.ecm.platform.ec.notification; 023 024import org.nuxeo.ecm.platform.notification.api.Notification; 025 026/** 027 * A notification that a user can subscribe to. 028 * <p> 029 * It has: 030 * <ul> 031 * <li>a name 032 * <li>a channel - for now only email is supported 033 * <li>a subject - as a fixed string or a template to customize subject notifications 034 * <li>a template - so the notifications that the user will receive can be customized 035 * </ul> 036 * 037 * @author <a href="mailto:npaslaru@nuxeo.com">Narcis Paslaru</a> 038 * @author <a href="mailto:tmartins@nuxeo.com">Thierry Martins</a> 039 */ 040public class NotificationImpl implements Notification { 041 042 private static final long serialVersionUID = 6550698875484943882L; 043 044 private final String name; 045 046 private final String template; 047 048 private final String subjectTemplate; 049 050 private final String subject; 051 052 private final String channel; 053 054 private final boolean autoSubscribed; 055 056 private final String availableIn; 057 058 private final String label; 059 060 private boolean enabled; 061 062 private String templateExpr; 063 064 public NotificationImpl(String name, String template, String channel, String subjectTemplate, 065 boolean autoSubscribed, String subject, String availableIn, String label) { 066 this.name = name; 067 this.template = template; 068 this.channel = channel; 069 this.subjectTemplate = subjectTemplate; 070 this.autoSubscribed = autoSubscribed; 071 this.subject = subject; 072 this.availableIn = availableIn; 073 this.label = label; 074 } 075 076 /** 077 * @since 5.6 078 */ 079 public void setTemplateExpr(String templateExpr) { 080 this.templateExpr = templateExpr; 081 } 082 083 @Override 084 public String getName() { 085 return name; 086 } 087 088 @Override 089 public String getChannel() { 090 return channel; 091 } 092 093 @Override 094 public String getTemplate() { 095 return template; 096 } 097 098 @Override 099 public boolean getAutoSubscribed() { 100 return autoSubscribed; 101 } 102 103 @Override 104 public String getSubject() { 105 return subject; 106 } 107 108 @Override 109 public String getSubjectTemplate() { 110 return subjectTemplate; 111 } 112 113 @Override 114 public String getAvailableIn() { 115 return availableIn; 116 } 117 118 @Override 119 public String getLabel() { 120 return label; 121 } 122 123 @Override 124 public boolean equals(Object obj) { 125 if (obj == this) { 126 return true; 127 } 128 if (obj instanceof NotificationImpl) { 129 NotificationImpl other = (NotificationImpl) obj; 130 return name.equals(other.name); 131 } 132 return false; 133 } 134 135 @Override 136 public int hashCode() { 137 return name.hashCode(); 138 } 139 140 @Override 141 public boolean getEnabled() { 142 return enabled; 143 } 144 145 public void setEnabled(boolean enabled) { 146 this.enabled = enabled; 147 } 148 149 @Override 150 public String getTemplateExpr() { 151 return templateExpr; 152 } 153 154}