001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software GmbH & Co. KG, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.main; 029 030import org.opencms.file.CmsUser; 031 032/** 033 * A single broadcast message, send from one OpenCms user to another.<p> 034 * 035 * To addess a broadcast to another user, it must be placed in the 036 * broadcast queue of that user using for example 037 * {@link org.opencms.main.CmsSessionManager#sendBroadcast(CmsUser, String, CmsUser)}.<p> 038 * 039 * @since 6.0.0 040 */ 041public class CmsBroadcast { 042 043 public static long DISPLAY_AGAIN_TIME = 60 * 1000; 044 045 /** The broadcast content. */ 046 private String m_message; 047 048 /** The sender of the broadcast. */ 049 private CmsUser m_sender; 050 051 /** Time the broadcast was send. */ 052 private long m_sendTime; 053 054 /**The last display time. */ 055 private long m_lastDisplay; 056 057 private boolean m_repeat; 058 059 /** 060 * Creates a new broadcast, with the current system time set as send time.<p> 061 * 062 * @param sender the sender of the broadcast 063 * @param message the message to send 064 */ 065 public CmsBroadcast(CmsUser sender, String message) { 066 067 this(sender, message, System.currentTimeMillis(), 0L, false); 068 } 069 070 /** 071 * Creates a new broadcast, with the current system time set as send time.<p> 072 * 073 * @param sender the sender of the broadcast 074 * @param message the message to send 075 */ 076 public CmsBroadcast(CmsUser sender, String message, boolean repeat) { 077 078 this(sender, message, System.currentTimeMillis(), 0L, repeat); 079 } 080 081 /** 082 * Creates a new broadcast, with the current system time set as send time.<p> 083 * 084 * @param sender the sender of the broadcast 085 * @param message the message to send 086 * @param sendTime time when broadcast initaly was send 087 * @param lastDisplay last display time 088 */ 089 public CmsBroadcast(CmsUser sender, String message, long sendTime, long lastDisplay, boolean repeat) { 090 091 m_sender = sender; 092 m_message = message; 093 m_sendTime = sendTime; 094 m_lastDisplay = lastDisplay; 095 m_repeat = repeat; 096 } 097 098 public long getLastDisplay() { 099 100 return m_lastDisplay; 101 } 102 103 /** 104 * Returns the broadcast message content.<p> 105 * 106 * @return the broadcast message content 107 */ 108 public String getMessage() { 109 110 return m_message; 111 } 112 113 /** 114 * Returns the time this broadcast was send.<p> 115 * 116 * @return the time this broadcast was send 117 */ 118 public long getSendTime() { 119 120 return m_sendTime; 121 } 122 123 /** 124 * Returns the user that was the sender of this broadcast.<p> 125 * 126 * It could be <code>null</code> to signalize a system message.<p> 127 * 128 * @return the user that was the sender of this broadcast 129 */ 130 public CmsUser getUser() { 131 132 return m_sender; 133 } 134 135 public boolean isRepeat() { 136 137 return m_repeat; 138 } 139}