1 23 24 package org.infoglue.cms.applications.managementtool.actions; 25 26 import java.util.ArrayList ; 27 import java.util.List ; 28 29 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction; 30 import org.infoglue.cms.entities.management.Chat; 31 import org.infoglue.cms.entities.management.Message; 32 import org.infoglue.cms.util.CmsSessionContextListener; 33 34 39 40 public class ViewMessageCenterAction extends InfoGlueAbstractAction 41 { 42 private static final long serialVersionUID = 1L; 43 44 private static Chat systemMessagesChat = new Chat(); 45 private static Chat chat = new Chat(); 46 private Integer lastId; 47 private String userName; 48 private String message; 49 private boolean isSystemMessage = false; 50 private List messages; 51 52 private Integer INDEX_MESSAGE_TYPE = new Integer (-1); 53 private Integer SYSTEM_MESSAGE_TYPE = new Integer (0); 54 private Integer CHAT_MESSAGE_TYPE = new Integer (10); 55 56 57 public String doExecute() throws Exception  58 { 59 return "success"; 60 } 61 62 public String doStandaloneChat() throws Exception  63 { 64 return "successStandaloneChat"; 65 } 66 67 public String doGetMessages() throws Exception  68 { 69 if(lastId == null || lastId.intValue() == -1) 70 messages = chat.getMessages(); 71 else 72 messages = chat.getMessages(lastId.intValue()); 73 74 return "successGetMessages"; 75 } 76 77 public String doGetSystemMessages() throws Exception  78 { 79 if(lastId == null || lastId.intValue() == -1) 80 { 81 Message message = new Message(systemMessagesChat.getMessageId(), "administrator", INDEX_MESSAGE_TYPE, "Undefined"); 82 messages = new ArrayList (); 83 messages.add(message); 84 } 85 else 86 messages = systemMessagesChat.getMessages(lastId.intValue()); 87 88 return "successGetSystemMessages"; 89 } 90 91 public String doSendMessage() throws Exception  92 { 93 95 chat.addMessage(this.getUserName(), CHAT_MESSAGE_TYPE, this.message); 96 if(this.isSystemMessage) 98 systemMessagesChat.addMessage(this.getUserName(), SYSTEM_MESSAGE_TYPE, "openChat('" + this.message + "');"); 99 100 return "successMessageSent"; 101 } 102 103 public List getSessionInfoBeanList() 104 { 105 return CmsSessionContextListener.getSessionInfoBeanList(); 106 } 107 108 public String getMessage() 109 { 110 return message; 111 } 112 113 public void setMessage(String message) 114 { 115 this.message = message; 116 } 117 118 public List getMessages() 119 { 120 return messages; 121 } 122 123 public Integer getLastId() 124 { 125 return lastId; 126 } 127 128 public void setLastId(Integer lastId) 129 { 130 this.lastId = lastId; 131 } 132 133 public void setIsSystemMessage(boolean isSystemMessage) 134 { 135 this.isSystemMessage = isSystemMessage; 136 } 137 } 138 | Popular Tags |