1 13 82 89 90 package org.jahia.params; 91 92 import java.io.IOException ; 93 import java.io.ObjectInputStream ; 94 import java.io.ObjectOutputStream ; 95 import java.io.Serializable ; 96 import java.util.ArrayList ; 97 import java.util.Locale ; 98 99 import javax.servlet.http.HttpServletRequest ; 100 101 import org.jahia.bin.Jahia; 102 import org.jahia.exceptions.JahiaException; 103 import org.jahia.exceptions.JahiaPageNotFoundException; 104 import org.jahia.exceptions.JahiaSessionExpirationException; 105 import org.jahia.exceptions.JahiaSiteNotFoundException; 106 import org.jahia.services.applications.ServletIncludeRequestWrapper; 107 import org.jahia.services.sites.JahiaSite; 108 import org.jahia.services.usermanager.JahiaUser; 109 import org.jahia.services.version.EntryLoadRequest; 110 111 115 public class SerializableParamBean extends ParamBean implements Serializable { 116 117 private DummyServletRequestWrapper dummyRequest; 118 119 private String operationMode = ParamBean.EDIT; 120 121 private Locale locale; 122 123 124 128 public SerializableParamBean() 129 { 130 } 132 133 142 public SerializableParamBean(ParamBean jParams) 143 throws JahiaPageNotFoundException, JahiaSessionExpirationException, 144 JahiaSiteNotFoundException, JahiaException 145 { 146 super(null, null, Jahia.getStaticServletConfig().getServletContext(), 147 Jahia.getSettings(), System.currentTimeMillis(), 148 ParamBean.POST_METHOD, jParams.getSite(), jParams.getUser(), jParams.getContentPage()); 149 this.dummyRequest = new DummyServletRequestWrapper(jParams.getUser()); 150 this.operationMode = jParams.getOperationMode(); 151 entryLoadRequest = new EntryLoadRequest(jParams.getEntryLoadRequest()); 152 this.locale = (Locale )jParams.getLocale().clone(); 153 } 154 155 public HttpServletRequest getRequest(){ 156 return this.dummyRequest; 157 } 158 159 public ServletIncludeRequestWrapper getRequestWrapper() { 160 return null; 161 } 162 public HttpServletRequest getRealRequest(){ 163 return this.dummyRequest; 164 } 165 166 167 177 public static SerializableParamBean getInstance(ParamBean jParams) 178 throws JahiaPageNotFoundException, JahiaSessionExpirationException, 179 JahiaSiteNotFoundException, JahiaException { 180 return new SerializableParamBean(jParams); 181 } 182 183 public void changeLanguage (Locale theLocale) 184 throws JahiaSessionExpirationException, JahiaException { 185 } 186 187 public ArrayList getLocales () 188 throws JahiaException { 189 return new ArrayList (); 190 } 191 192 public ArrayList getLocales (boolean allowMixLanguages) 193 throws JahiaException { 194 return new ArrayList (); 195 } 196 197 public String getSiteURL (int pageID, boolean withSessionID, boolean withOperationMode) { 198 return null; 199 } 200 201 public String getOperationMode() { 202 return operationMode; 203 } 204 205 public void setOperationMode(String theOperationMode) { 206 this.operationMode = theOperationMode; 207 } 208 209 public Locale getLocale() { 210 return locale; 211 } 212 213 public void setLocale(Locale theLocale) { 214 this.locale = theLocale; 215 } 216 217 public String toString() { 218 return "SerializableParamBean{siteId: " 219 + getSiteID() 220 + "; locale: " 221 + locale 222 + "; user: " 223 + getUser() 224 + "}"; 225 } 226 227 private void writeObject(ObjectOutputStream out) throws IOException 228 { 229 out.defaultWriteObject(); 230 out.writeObject(getSite()); 231 out.writeObject(getUser()); 232 out.writeObject(entryLoadRequest); 233 } 234 235 private void readObject(ObjectInputStream in) 236 throws IOException , ClassNotFoundException 237 { 238 in.defaultReadObject(); 239 JahiaSite site = (JahiaSite)in.readObject(); 240 JahiaUser user = (JahiaUser)in.readObject(); 241 entryLoadRequest = (EntryLoadRequest)in.readObject(); 242 setData(site, user); 243 } 244 245 } 246 | Popular Tags |