1 31 32 package org.opencms.workplace.tools.workplace.broadcast; 33 34 import org.opencms.jsp.CmsJspActionElement; 35 import org.opencms.main.CmsSessionInfo; 36 import org.opencms.main.OpenCms; 37 import org.opencms.util.CmsStringUtil; 38 import org.opencms.workplace.CmsWidgetDialog; 39 import org.opencms.workplace.CmsWorkplaceSettings; 40 import org.opencms.workplace.list.CmsHtmlList; 41 42 import java.util.ArrayList ; 43 import java.util.Iterator ; 44 import java.util.List ; 45 46 import javax.servlet.http.HttpServletRequest ; 47 48 57 public abstract class A_CmsMessageDialog extends CmsWidgetDialog { 58 59 60 public static final String [] PAGES = {"page1"}; 61 62 63 public static final String PARAM_SESSIONIDS = "sessionids"; 64 65 66 protected CmsMessageInfo m_msgInfo; 67 68 69 private String m_paramSessionids; 70 71 76 public A_CmsMessageDialog(CmsJspActionElement jsp) { 77 78 super(jsp); 79 } 80 81 86 public String getParamSessionids() { 87 88 return m_paramSessionids; 89 } 90 91 96 public void setParamSessionids(String sessionIds) { 97 98 m_paramSessionids = sessionIds; 99 } 100 101 104 protected String [] getPageArray() { 105 106 return PAGES; 107 } 108 109 114 protected String getToNames() { 115 116 List users = new ArrayList (); 117 Iterator itIds = idsList().iterator(); 118 while (itIds.hasNext()) { 119 String id = itIds.next().toString(); 120 CmsSessionInfo session = OpenCms.getSessionManager().getSessionInfo(id); 121 if (session != null) { 122 String userName = session.getUser().getFullName(); 123 if (!users.contains(userName)) { 124 users.add(userName); 125 } 126 } 127 } 128 StringBuffer result = new StringBuffer (256); 129 Iterator itUsers = users.iterator(); 130 while (itUsers.hasNext()) { 131 result.append(itUsers.next().toString()); 132 if (itUsers.hasNext()) { 133 result.append("; "); 134 } 135 } 136 return result.toString(); 137 } 138 139 144 protected List idsList() { 145 146 if (!isForAll()) { 147 return CmsStringUtil.splitAsList(getParamSessionids(), CmsHtmlList.ITEM_SEPARATOR); 148 } 149 List ids = new ArrayList (); 150 Iterator itSessions = OpenCms.getSessionManager().getSessionInfos().iterator(); 151 while (itSessions.hasNext()) { 152 ids.add(((CmsSessionInfo)itSessions.next()).getSessionId()); 153 } 154 return ids; 155 } 156 157 160 protected void initMessageObject() { 161 162 Object o = null; 163 164 try { 165 o = getDialogObject(); 167 m_msgInfo = (CmsMessageInfo)o; 168 m_msgInfo.getTo(); 170 } catch (Exception e) { 171 m_msgInfo = new CmsMessageInfo(); 173 } 174 m_msgInfo.setFrom(getCms().getRequestContext().currentUser().getFullName()); 175 m_msgInfo.setTo(getToNames()); 176 } 177 178 181 protected void initMessages() { 182 183 addMessages(Messages.get().getBundleName()); 185 addMessages(org.opencms.workplace.tools.workplace.Messages.get().getBundleName()); 186 super.initMessages(); 188 } 189 190 193 protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) { 194 195 super.initWorkplaceRequestValues(settings, request); 197 198 setDialogObject(m_msgInfo); 200 } 201 202 207 protected boolean isForAll() { 208 209 return CmsStringUtil.isEmptyOrWhitespaceOnly(getParamSessionids()); 210 } 211 } | Popular Tags |