From 473d53980a0b6e57114b1ff5135636f2a45266b9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petter=20Holmstr=C3=B6m?= Date: Wed, 4 Nov 2009 07:14:23 +0000 Subject: [PATCH] More refactorings. svn changeset:9609/svn branch:portlet_2.0 --- .../server/AbstractApplicationPortlet.java | 472 +++++++++++++++--- .../server/AbstractApplicationServlet.java | 50 +- .../server/AbstractCommunicationManager.java | 33 +- .../gwt/server/ApplicationPortlet.java | 4 + .../vaadin/terminal/gwt/server/Constants.java | 59 +++ .../terminal/gwt/server/JsonPaintTarget.java | 12 +- .../gwt/server/PortletApplicationContext.java | 5 +- .../server/PortletCommunicationManager.java | 4 +- 8 files changed, 498 insertions(+), 141 deletions(-) create mode 100644 src/com/vaadin/terminal/gwt/server/Constants.java diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java index 325cda3434..b4157d4f12 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java @@ -5,7 +5,12 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.Serializable; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.net.MalformedURLException; +import java.security.GeneralSecurityException; import java.util.Collection; import java.util.Date; import java.util.Enumeration; @@ -17,6 +22,7 @@ import java.util.Properties; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import javax.portlet.GenericPortlet; +import javax.portlet.MimeResponse; import javax.portlet.PortletConfig; import javax.portlet.PortletContext; import javax.portlet.PortletException; @@ -32,30 +38,25 @@ import javax.portlet.ResourceURL; import javax.servlet.http.HttpServletResponse; import com.vaadin.Application; +import com.vaadin.Application.SystemMessages; import com.vaadin.external.org.apache.commons.fileupload.portlet.PortletFileUpload; +import com.vaadin.terminal.Terminal; +import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.ui.Window; -public abstract class AbstractApplicationPortlet extends GenericPortlet { +/** + * TODO Document me! + * + * @author peholmst + */ +public abstract class AbstractApplicationPortlet extends GenericPortlet + implements Constants { - // TODO Move some (all?) of the constants to a separate interface (shared with servlet) - - private static final String ERROR_NO_WINDOW_FOUND = "No window found. Did you remember to setMainWindow()?"; - - static final String THEME_DIRECTORY_PATH = "VAADIN/themes/"; - - private static final String WIDGETSET_DIRECTORY_PATH = "VAADIN/widgetsets/"; - - private static final String DEFAULT_WIDGETSET = "com.vaadin.terminal.gwt.DefaultWidgetSet"; - - private static final String DEFAULT_THEME_NAME = "reindeer"; - - private static final String URL_PARAMETER_REPAINT_ALL = "repaintAll"; - - private static final String URL_PARAMETER_RESTART_APPLICATION = "restartApplication"; - - private static final String URL_PARAMETER_CLOSE_APPLICATION = "closeApplication"; - - private static final int DEFAULT_BUFFER_SIZE = 32 * 1024; + /* + * TODO Big parts of this class are directly copy-pasted from + * AbstractApplicationServlet. On the long term, it would probably be wise + * to try to integrate the common parts into a shared super class. + */ // TODO Close application when portlet window is closed @@ -63,10 +64,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet { private Properties applicationProperties; - @Override - public void destroy() { - // TODO Auto-generated method stub - } + private boolean productionMode = false; @SuppressWarnings("unchecked") @Override @@ -89,8 +87,119 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet { applicationProperties.setProperty(name, context .getInitParameter(name)); } - // TODO Check production mode - // TODO Check cross site protection + checkProductionMode(); + checkCrossSiteProtection(); + } + + private void checkCrossSiteProtection() { + if (getApplicationOrSystemProperty( + SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION, "false").equals( + "true")) { + /* + * Print an information/warning message about running with xsrf + * protection disabled + */ + System.err.println(WARNING_XSRF_PROTECTION_DISABLED); + } + } + + private void checkProductionMode() { + // Check if the application is in production mode. + // We are in production mode if Debug=false or productionMode=true + if (getApplicationOrSystemProperty(SERVLET_PARAMETER_DEBUG, "true") + .equals("false")) { + // "Debug=true" is the old way and should no longer be used + productionMode = true; + } else if (getApplicationOrSystemProperty( + SERVLET_PARAMETER_PRODUCTION_MODE, "false").equals("true")) { + // "productionMode=true" is the real way to do it + productionMode = true; + } + + if (!productionMode) { + /* Print an information/warning message about running in debug mode */ + // TODO Maybe we need a different message for portlets? + System.err.println(NOT_PRODUCTION_MODE_INFO); + } + } + + /** + * Gets an application property value. + * + * @param parameterName + * the Name or the parameter. + * @return String value or null if not found + */ + protected String getApplicationProperty(String parameterName) { + + String val = applicationProperties.getProperty(parameterName); + if (val != null) { + return val; + } + + // Try lower case application properties for backward compatibility with + // 3.0.2 and earlier + val = applicationProperties.getProperty(parameterName.toLowerCase()); + + return val; + } + + /** + * Gets an system property value. + * + * @param parameterName + * the Name or the parameter. + * @return String value or null if not found + */ + protected String getSystemProperty(String parameterName) { + String val = null; + + String pkgName; + final Package pkg = getClass().getPackage(); + if (pkg != null) { + pkgName = pkg.getName(); + } else { + final String className = getClass().getName(); + pkgName = new String(className.toCharArray(), 0, className + .lastIndexOf('.')); + } + val = System.getProperty(pkgName + "." + parameterName); + if (val != null) { + return val; + } + + // Try lowercased system properties + val = System.getProperty(pkgName + "." + parameterName.toLowerCase()); + return val; + } + + /** + * Gets an application or system property value. + * + * @param parameterName + * the Name or the parameter. + * @param defaultValue + * the Default to be used. + * @return String value or default if not found + */ + private String getApplicationOrSystemProperty(String parameterName, + String defaultValue) { + + String val = null; + + // Try application properties + val = getApplicationProperty(parameterName); + if (val != null) { + return val; + } + + // Try system properties + val = getSystemProperty(parameterName); + if (val != null) { + return val; + } + + return defaultValue; } enum RequestType { @@ -131,14 +240,25 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet { return PortletFileUpload.isMultipartContent(request); } + /** + * Returns true if the servlet is running in production mode. Production + * mode disables all debug facilities. + * + * @return true if in production mode, false if in debug mode + */ + public boolean isProductionMode() { + return productionMode; + } + protected void handleRequest(PortletRequest request, PortletResponse response) throws PortletException, IOException { - System.out.println("AbstractApplicationPortlet.handleRequest() " + System.currentTimeMillis()); + // System.out.println("AbstractApplicationPortlet.handleRequest() " + + // System.currentTimeMillis()); RequestType requestType = getRequestType(request); - System.out.println(" RequestType: " + requestType); - System.out.println(" WindowID: " + request.getWindowID()); + // System.out.println(" RequestType: " + requestType); + // System.out.println(" WindowID: " + request.getWindowID()); if (requestType == RequestType.UNKNOWN) { System.out.println("Unknown request type"); @@ -228,9 +348,13 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet { writeAjaxPage((RenderRequest) request, (RenderResponse) response, window, application); } + } catch (final SessionExpired e) { + // Session has expired, notify user + handleServiceSessionExpired(request, response); + } catch (final GeneralSecurityException e) { + handleServiceSecurityException(request, response); } catch (final Throwable e) { - // TODO Handle exceptions - e.printStackTrace(); + handleServiceException(request, response, application, e); } finally { // Notifies transaction end if (application != null) { @@ -240,15 +364,12 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet { } } - // TODO Vaadin resources cannot be loaded, try to load other resources using - // the portlet context - private void serveStaticResources(ResourceRequest request, ResourceResponse response) throws IOException, PortletException { final String resourceID = request.getResourceID(); final PortletContext pc = getPortletContext(); - System.out.println("Trying to load resource [" + resourceID + "]"); +// System.out.println("Trying to load resource [" + resourceID + "]"); InputStream is = pc.getResourceAsStream(resourceID); if (is != null) { @@ -263,31 +384,31 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet { os.write(buffer, 0, bytes); } } else { - System.err.println("Requested resource [" + resourceID - + "] could not be found"); - response.setProperty(ResourceResponse.HTTP_STATUS_CODE, Integer - .toString(HttpServletResponse.SC_NOT_FOUND)); + System.err.println("Requested resource [" + resourceID + + "] could not be found"); + response.setProperty(ResourceResponse.HTTP_STATUS_CODE, Integer + .toString(HttpServletResponse.SC_NOT_FOUND)); } } @Override public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { - System.out.println("AbstractApplicationPortlet.processAction()"); + // System.out.println("AbstractApplicationPortlet.processAction()"); handleRequest(request, response); } @RenderMode(name = "VIEW") public void doRender(RenderRequest request, RenderResponse response) throws PortletException, IOException { - System.out.println("AbstractApplicationPortlet.render()"); + // System.out.println("AbstractApplicationPortlet.render()"); handleRequest(request, response); } @Override public void serveResource(ResourceRequest request, ResourceResponse response) throws PortletException, IOException { - System.out.println("AbstractApplicationPortlet.serveResource()"); + // System.out.println("AbstractApplicationPortlet.serveResource()"); handleRequest(request, response); } @@ -430,19 +551,18 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet { RenderResponse response, Window window, Application application) throws IOException, MalformedURLException, PortletException { - System.out.println("AbstractApplicationPortlet.writeAjaxPage()"); +// System.out.println("AbstractApplicationPortlet.writeAjaxPage()"); response.setContentType("text/html"); final BufferedWriter page = new BufferedWriter(new OutputStreamWriter( response.getPortletOutputStream(), "UTF-8")); - ; // TODO The widgetset URL is currently hard-corded for LifeRay - String widgetsetURL = "/html/" + WIDGETSET_DIRECTORY_PATH + DEFAULT_WIDGETSET - + "/" + DEFAULT_WIDGETSET + ".nocache.js?" + String widgetsetURL = "/html/" + WIDGETSET_DIRECTORY_PATH + + DEFAULT_WIDGETSET + "/" + DEFAULT_WIDGETSET + ".nocache.js?" + new Date().getTime(); - + String themeURI = "/html/" + THEME_DIRECTORY_PATH + DEFAULT_THEME_NAME; page.write("\n"); - - //if (themeName != null) { - // Custom theme's stylesheet, load only once, in different - // script - // tag to be dominate styles injected by widget - // set - page.write("\n"); - //} - + + // if (themeName != null) { + // Custom theme's stylesheet, load only once, in different + // script + // tag to be dominate styles injected by widget + // set + page.write("\n"); + // } + // TODO Warn if widgetset has not been loaded after 15 seconds /*- Add classnames; @@ -549,4 +672,219 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet { // TODO Add support for custom class loader return getClass().getClassLoader(); } + + private boolean isOnUnloadRequest(PortletRequest request) { + return request.getParameter(ApplicationConnection.PARAM_UNLOADBURST) != null; + } + + /** + * Get system messages from the current application class + * + * @return + */ + protected SystemMessages getSystemMessages() { + try { + Class appCls = getApplicationClass(); + Method m = appCls.getMethod("getSystemMessages", (Class[]) null); + return (Application.SystemMessages) m.invoke(null, (Object[]) null); + } catch (ClassNotFoundException e) { + // This should never happen + throw new SystemMessageException(e); + } catch (SecurityException e) { + throw new SystemMessageException( + "Application.getSystemMessage() should be static public", e); + } catch (NoSuchMethodException e) { + // This is completely ok and should be silently ignored + } catch (IllegalArgumentException e) { + // This should never happen + throw new SystemMessageException(e); + } catch (IllegalAccessException e) { + throw new SystemMessageException( + "Application.getSystemMessage() should be static public", e); + } catch (InvocationTargetException e) { + // This should never happen + throw new SystemMessageException(e); + } + return Application.getSystemMessages(); + } + + void handleServiceSessionExpired(PortletRequest request, + PortletResponse response) throws IOException, PortletException { + + if (isOnUnloadRequest(request)) { + /* + * Request was an unload request (e.g. window close event) and the + * client expects no response if it fails. + */ + return; + } + + try { + Application.SystemMessages ci = getSystemMessages(); + if (getRequestType(request) != RequestType.UIDL) { + // 'plain' http req - e.g. browser reload; + // just go ahead redirect the browser + if (response instanceof ActionResponse) { + ((ActionResponse) response).sendRedirect(ci + .getSessionExpiredURL()); + } else { + // TODO What to do if we are e.g. rendering? + } + } else { + /* + * Session must be invalidated before criticalNotification as it + * commits the response. + */ + request.getPortletSession().invalidate(); + + // send uidl redirect + criticalNotification(request, (ResourceResponse) response, ci + .getSessionExpiredCaption(), ci + .getSessionExpiredMessage(), null, ci + .getSessionExpiredURL()); + + } + } catch (SystemMessageException ee) { + throw new PortletException(ee); + } + + } + + private void handleServiceSecurityException(PortletRequest request, + PortletResponse response) throws IOException, PortletException { + if (isOnUnloadRequest(request)) { + /* + * Request was an unload request (e.g. window close event) and the + * client expects no response if it fails. + */ + return; + } + + try { + Application.SystemMessages ci = getSystemMessages(); + if (getRequestType(request) != RequestType.UIDL) { + // 'plain' http req - e.g. browser reload; + // just go ahead redirect the browser + if (response instanceof ActionResponse) { + ((ActionResponse) response).sendRedirect(ci + .getCommunicationErrorURL()); + } else { + // TODO What to do if we are e.g. rendering? + } + } else { + // send uidl redirect + criticalNotification(request, (ResourceResponse) response, ci + .getCommunicationErrorCaption(), ci + .getCommunicationErrorMessage(), + INVALID_SECURITY_KEY_MSG, ci.getCommunicationErrorURL()); + /* + * Invalidate session. Portal integration will fail otherwise + * since the session is not created by the portal. + */ + request.getPortletSession().invalidate(); + } + } catch (SystemMessageException ee) { + throw new PortletException(ee); + } + } + + private void handleServiceException(PortletRequest request, + PortletResponse response, Application application, Throwable e) + throws IOException, PortletException { + // if this was an UIDL request, response UIDL back to client + if (getRequestType(request) == RequestType.UIDL) { + Application.SystemMessages ci = getSystemMessages(); + criticalNotification(request, (ResourceResponse) response, ci + .getInternalErrorCaption(), ci.getInternalErrorMessage(), + null, ci.getInternalErrorURL()); + if (application != null) { + application.getErrorHandler() + .terminalError(new RequestError(e)); + } else { + throw new PortletException(e); + } + } else { + // Re-throw other exceptions + throw new PortletException(e); + } + + } + + @SuppressWarnings("serial") + public class RequestError implements Terminal.ErrorEvent, Serializable { + + private final Throwable throwable; + + public RequestError(Throwable throwable) { + this.throwable = throwable; + } + + public Throwable getThrowable() { + return throwable; + } + + } + + /** + * Send notification to client's application. Used to notify client of + * critical errors and session expiration due to long inactivity. Server has + * no knowledge of what application client refers to. + * + * @param request + * the Portlet request instance. + * @param response + * the Portlet response to write to. + * @param caption + * for the notification + * @param message + * for the notification + * @param details + * a detail message to show in addition to the passed message. + * Currently shown directly but could be hidden behind a details + * drop down. + * @param url + * url to load after message, null for current page + * @throws IOException + * if the writing failed due to input/output error. + */ + void criticalNotification(PortletRequest request, MimeResponse response, + String caption, String message, String details, String url) + throws IOException { + + // clients JS app is still running, but server application either + // no longer exists or it might fail to perform reasonably. + // send a notification to client's application and link how + // to "restart" application. + + if (caption != null) { + caption = "\"" + caption + "\""; + } + if (details != null) { + if (message == null) { + message = details; + } else { + message += "

" + details; + } + } + if (message != null) { + message = "\"" + message + "\""; + } + if (url != null) { + url = "\"" + url + "\""; + } + + // Set the response type + response.setContentType("application/json; charset=UTF-8"); + final OutputStream out = response.getPortletOutputStream(); + final PrintWriter outWriter = new PrintWriter(new BufferedWriter( + new OutputStreamWriter(out, "UTF-8"))); + outWriter.print("for(;;);[{\"changes\":[], \"meta\" : {" + + "\"appError\": {" + "\"caption\":" + caption + "," + + "\"message\" : " + message + "," + "\"url\" : " + url + + "}}, \"resources\": {}, \"locales\":[]}]"); + outWriter.flush(); + outWriter.close(); + out.flush(); + } + } diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index 9430d1d276..57e414652f 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@ -57,7 +57,7 @@ import com.vaadin.ui.Window; */ @SuppressWarnings("serial") -public abstract class AbstractApplicationServlet extends HttpServlet { +public abstract class AbstractApplicationServlet extends HttpServlet implements Constants { // TODO Move some (all?) of the constants to a separate interface (shared with portlet) @@ -139,56 +139,8 @@ public abstract class AbstractApplicationServlet extends HttpServlet { private Properties applicationProperties; - private static final String NOT_PRODUCTION_MODE_INFO = "" - + "=================================================================\n" - + "Vaadin is running in DEBUG MODE.\nAdd productionMode=true to web.xml " - + "to disable debug features.\nTo show debug window, add ?debug to " - + "your application URL.\n" - + "================================================================="; - - private static final String WARNING_XSRF_PROTECTION_DISABLED = "" - + "===========================================================\n" - + "WARNING: Cross-site request forgery protection is disabled!\n" - + "==========================================================="; - private boolean productionMode = false; - private static final String URL_PARAMETER_RESTART_APPLICATION = "restartApplication"; - private static final String URL_PARAMETER_CLOSE_APPLICATION = "closeApplication"; - private static final String URL_PARAMETER_REPAINT_ALL = "repaintAll"; - protected static final String URL_PARAMETER_THEME = "theme"; - - private static final String SERVLET_PARAMETER_DEBUG = "Debug"; - private static final String SERVLET_PARAMETER_PRODUCTION_MODE = "productionMode"; - static final String SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION = "disable-xsrf-protection"; - - // Configurable parameter names - private static final String PARAMETER_VAADIN_RESOURCES = "Resources"; - - private static final int DEFAULT_BUFFER_SIZE = 32 * 1024; - - private static final int MAX_BUFFER_SIZE = 64 * 1024; - - private static final String AJAX_UIDL_URI = "/UIDL"; - - static final String THEME_DIRECTORY_PATH = "VAADIN/themes/"; - - private static final int DEFAULT_THEME_CACHETIME = 1000 * 60 * 60 * 24; - - static final String WIDGETSET_DIRECTORY_PATH = "VAADIN/widgetsets/"; - - // Name of the default widget set, used if not specified in web.xml - private static final String DEFAULT_WIDGETSET = "com.vaadin.terminal.gwt.DefaultWidgetSet"; - - // Widget set parameter name - private static final String PARAMETER_WIDGETSET = "widgetset"; - - private static final String ERROR_NO_WINDOW_FOUND = "No window found. Did you remember to setMainWindow()?"; - - private static final String DEFAULT_THEME_NAME = "reindeer"; - - private static final String INVALID_SECURITY_KEY_MSG = "Invalid security key."; - private String resourcePath = null; /** diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index cfd5beb50b..71fa1eff2e 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -306,7 +306,7 @@ public abstract class AbstractCommunicationManager implements synchronized (application) { handleChangeVariablesError(application, uploadComponent, e, - new HashMap()); + new HashMap()); } } } @@ -557,8 +557,9 @@ public abstract class AbstractCommunicationManager implements } }); - for (final Iterator i = paintables.iterator(); i.hasNext();) { - final Paintable p = (Paintable) i.next(); + for (final Iterator i = paintables.iterator(); i + .hasNext();) { + final Paintable p = i.next(); // TODO CLEAN if (p instanceof Window) { @@ -692,8 +693,8 @@ public abstract class AbstractCommunicationManager implements // TODO We should only precache the layouts that are not // cached already (plagiate from usedPaintableTypes) int resourceIndex = 0; - for (final Iterator i = paintTarget.getUsedResources().iterator(); i - .hasNext();) { + for (final Iterator i = paintTarget.getUsedResources() + .iterator(); i.hasNext();) { final String resource = (String) i.next(); InputStream is = null; try { @@ -827,13 +828,13 @@ public abstract class AbstractCommunicationManager implements final VariableOwner owner = (VariableOwner) idPaintableMap .get(variable[VAR_PID]); if (owner != null && owner.isEnabled()) { - Map m; + Map m; if (nextVariable != null && variable[VAR_PID] .equals(nextVariable[VAR_PID])) { // we have more than one value changes in row for // one variable owner, collect em in HashMap - m = new HashMap(); + m = new HashMap(); m.put(variable[VAR_NAME], convertVariableValue( variable[VAR_TYPE].charAt(0), variable[VAR_VALUE])); @@ -973,7 +974,7 @@ public abstract class AbstractCommunicationManager implements } private void handleChangeVariablesError(Application application, - Component owner, Exception e, Map m) { + Component owner, Exception e, Map m) { boolean handled = false; ChangeVariablesErrorEvent errorEvent = new ChangeVariablesErrorEvent( owner, e, m); @@ -1429,9 +1430,9 @@ public abstract class AbstractCommunicationManager implements return value.equals(v); } - public Set entrySet() { - final Set s = new HashSet(); - s.add(new Map.Entry() { + public Set> entrySet() { + final Set> s = new HashSet>(); + s.add(new Map.Entry() { public Object getKey() { return name; @@ -1459,8 +1460,8 @@ public abstract class AbstractCommunicationManager implements return false; } - public Set keySet() { - final Set s = new HashSet(); + public Set keySet() { + final Set s = new HashSet(); s.add(name); return s; } @@ -1469,7 +1470,7 @@ public abstract class AbstractCommunicationManager implements throw new UnsupportedOperationException(); } - public void putAll(Map t) { + public void putAll(Map t) { throw new UnsupportedOperationException(); } @@ -1481,8 +1482,8 @@ public abstract class AbstractCommunicationManager implements return 1; } - public Collection values() { - final LinkedList s = new LinkedList(); + public Collection values() { + final LinkedList s = new LinkedList(); s.add(value); return s; diff --git a/src/com/vaadin/terminal/gwt/server/ApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/ApplicationPortlet.java index f363fcfddb..e7e2bb3cfb 100644 --- a/src/com/vaadin/terminal/gwt/server/ApplicationPortlet.java +++ b/src/com/vaadin/terminal/gwt/server/ApplicationPortlet.java @@ -19,6 +19,10 @@ import javax.portlet.RenderResponse; import com.liferay.portal.kernel.util.PropsUtil; import com.vaadin.Application; +/** + * @deprecated Use Portlet 2.0 class {@link ApplicationPortlet2} instead. + */ +@Deprecated @SuppressWarnings("serial") public class ApplicationPortlet implements Portlet, Serializable { // portlet configuration parameters diff --git a/src/com/vaadin/terminal/gwt/server/Constants.java b/src/com/vaadin/terminal/gwt/server/Constants.java new file mode 100644 index 0000000000..1a91cc885c --- /dev/null +++ b/src/com/vaadin/terminal/gwt/server/Constants.java @@ -0,0 +1,59 @@ +package com.vaadin.terminal.gwt.server; + +/** + * TODO Document me! + * + * @author peholmst + * + */ +public interface Constants { + + static final String NOT_PRODUCTION_MODE_INFO = "" + + "=================================================================\n" + + "Vaadin is running in DEBUG MODE.\nAdd productionMode=true to web.xml " + + "to disable debug features.\nTo show debug window, add ?debug to " + + "your application URL.\n" + + "================================================================="; + + static final String WARNING_XSRF_PROTECTION_DISABLED = "" + + "===========================================================\n" + + "WARNING: Cross-site request forgery protection is disabled!\n" + + "==========================================================="; + + static final String URL_PARAMETER_RESTART_APPLICATION = "restartApplication"; + static final String URL_PARAMETER_CLOSE_APPLICATION = "closeApplication"; + static final String URL_PARAMETER_REPAINT_ALL = "repaintAll"; + static final String URL_PARAMETER_THEME = "theme"; + + static final String SERVLET_PARAMETER_DEBUG = "Debug"; + static final String SERVLET_PARAMETER_PRODUCTION_MODE = "productionMode"; + static final String SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION = "disable-xsrf-protection"; + + // Configurable parameter names + static final String PARAMETER_VAADIN_RESOURCES = "Resources"; + + static final int DEFAULT_BUFFER_SIZE = 32 * 1024; + + static final int MAX_BUFFER_SIZE = 64 * 1024; + + static final String AJAX_UIDL_URI = "/UIDL"; + + final String THEME_DIRECTORY_PATH = "VAADIN/themes/"; + + static final int DEFAULT_THEME_CACHETIME = 1000 * 60 * 60 * 24; + + static final String WIDGETSET_DIRECTORY_PATH = "VAADIN/widgetsets/"; + + // Name of the default widget set, used if not specified in web.xml + static final String DEFAULT_WIDGETSET = "com.vaadin.terminal.gwt.DefaultWidgetSet"; + + // Widget set parameter name + static final String PARAMETER_WIDGETSET = "widgetset"; + + static final String ERROR_NO_WINDOW_FOUND = "No window found. Did you remember to setMainWindow()?"; + + static final String DEFAULT_THEME_NAME = "reindeer"; + + static final String INVALID_SECURITY_KEY_MSG = "Invalid security key."; + +} diff --git a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java index d5c4ffcdd2..4dc87aa08a 100644 --- a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java +++ b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java @@ -869,11 +869,11 @@ public class JsonPaintTarget implements PaintTarget { class JsonTag implements Serializable { boolean firstField = false; - Vector variables = new Vector(); + Vector variables = new Vector(); - Vector children = new Vector(); + Vector children = new Vector(); - Vector attr = new Vector(); + Vector attr = new Vector(); StringBuilder data = new StringBuilder(); @@ -945,7 +945,7 @@ public class JsonPaintTarget implements PaintTarget { public String getData() { final StringBuilder buf = new StringBuilder(); - final Iterator it = children.iterator(); + final Iterator it = children.iterator(); while (it.hasNext()) { buf.append(startField()); buf.append(it.next()); @@ -961,7 +961,7 @@ public class JsonPaintTarget implements PaintTarget { final StringBuilder buf = new StringBuilder(); buf.append(startField()); buf.append("{"); - for (final Iterator iter = attr.iterator(); iter.hasNext();) { + for (final Iterator iter = attr.iterator(); iter.hasNext();) { final String element = (String) iter.next(); buf.append(element); if (iter.hasNext()) { @@ -984,7 +984,7 @@ public class JsonPaintTarget implements PaintTarget { final StringBuilder buf = new StringBuilder(); buf.append(startField()); buf.append("\"v\":{"); - final Iterator iter = variables.iterator(); + final Iterator iter = variables.iterator(); while (iter.hasNext()) { final Variable element = (Variable) iter.next(); buf.append(element.getJsonPresentation()); diff --git a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java index 6aabc34906..621ef1b246 100644 --- a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java +++ b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java @@ -35,9 +35,10 @@ import com.vaadin.Application; /** * @author marc - * + * @deprecated Use Portlet 2.0 class {@link PortletApplicationContext2} instead. */ -@SuppressWarnings("serial") +@SuppressWarnings({"serial", "unchecked"}) +@Deprecated public class PortletApplicationContext extends WebApplicationContext implements Serializable { diff --git a/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java index 5d36373fc9..f4e0853fe2 100644 --- a/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java @@ -138,7 +138,9 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { public void criticalNotification(Request request, Response response, String cap, String msg, String details, String outOfSyncURL) throws IOException { - // TODO Implement me! + portlet.criticalNotification((PortletRequest) request + .getWrappedRequest(), (MimeResponse) response + .getWrappedResponse(), cap, msg, details, outOfSyncURL); } public String getRequestPathInfo(Request request) { -- 2.39.5