Browse Source

This is the implementation of the server-side logging feature

 - Changed some loglevels according to review
 - Don't log unecessary stacktraces in portlets
 - printStackTrace:s replaced with JUL logging
 - System.out and System.errs replaced with JUL logging

svn changeset:15493/svn branch:6.5
tags/6.7.0.beta1
Jonatan Kronqvist 13 years ago
parent
commit
7e59116879

+ 8
- 4
src/com/vaadin/Application.java View File

import java.util.LinkedList; import java.util.LinkedList;
import java.util.Locale; import java.util.Locale;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;


import com.vaadin.service.ApplicationContext; import com.vaadin.service.ApplicationContext;
import com.vaadin.terminal.ApplicationResource; import com.vaadin.terminal.ApplicationResource;
public abstract class Application implements URIHandler, public abstract class Application implements URIHandler,
Terminal.ErrorListener, Serializable { Terminal.ErrorListener, Serializable {


private final static Logger logger = Logger.getLogger(Application.class
.getName());

/** /**
* Id use for the next window that is opened. Access to this must be * Id use for the next window that is opened. Access to this must be
* synchronized. * synchronized.
final Throwable t = event.getThrowable(); final Throwable t = event.getThrowable();
if (t instanceof SocketException) { if (t instanceof SocketException) {
// Most likely client browser closed socket // Most likely client browser closed socket
System.err
.println("Warning: SocketException in CommunicationManager."
+ " Most likely client (browser) closed socket.");
logger.warning("SocketException in CommunicationManager."
+ " Most likely client (browser) closed socket.");
return; return;
} }


} }


// also print the error on console // also print the error on console
t.printStackTrace();
logger.log(Level.SEVERE, "Terminal error:", t);
} }


/** /**

+ 6
- 4
src/com/vaadin/data/util/MethodProperty.java View File

import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;


import com.vaadin.data.Property; import com.vaadin.data.Property;
import com.vaadin.util.SerializerHelper; import com.vaadin.util.SerializerHelper;
public class MethodProperty<T> implements Property, public class MethodProperty<T> implements Property,
Property.ValueChangeNotifier, Property.ReadOnlyStatusChangeNotifier { Property.ValueChangeNotifier, Property.ReadOnlyStatusChangeNotifier {


private static final Logger logger = Logger.getLogger(MethodProperty.class
.getName());
/** /**
* The object that includes the property the MethodProperty is bound to. * The object that includes the property the MethodProperty is bound to.
*/ */
getMethod = null; getMethod = null;
} }
} catch (SecurityException e) { } catch (SecurityException e) {
System.err.println("Internal deserialization error");
e.printStackTrace();
logger.log(Level.SEVERE, "Internal deserialization error", e);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
System.err.println("Internal deserialization error");
e.printStackTrace();
logger.log(Level.SEVERE, "Internal deserialization error", e);
} }
}; };



+ 10
- 7
src/com/vaadin/event/ListenerMethod.java View File

import java.util.Arrays; import java.util.Arrays;
import java.util.EventListener; import java.util.EventListener;
import java.util.EventObject; import java.util.EventObject;
import java.util.logging.Level;
import java.util.logging.Logger;


/** /**
* <p> * <p>
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class ListenerMethod implements EventListener, Serializable { public class ListenerMethod implements EventListener, Serializable {


private static final Logger logger = Logger.getLogger(ListenerMethod.class
.getName());

/** /**
* Type of the event that should trigger this listener. Also the subclasses * Type of the event that should trigger this listener. Also the subclasses
* of this class are accepted to trigger the listener. * of this class are accepted to trigger the listener.
/** /**
* The object containing the trigger method. * The object containing the trigger method.
*/ */
private Object object;
private final Object object;


/** /**
* The trigger method to call when an event passing the given criteria * The trigger method to call when an event passing the given criteria
out.writeObject(name); out.writeObject(name);
out.writeObject(paramTypes); out.writeObject(paramTypes);
} catch (NotSerializableException e) { } catch (NotSerializableException e) {
System.err
.println("Fatal error in serialization of the application: Class "
+ object.getClass().getName()
+ " must implement serialization.");
logger.severe("Fatal error in serialization of the application: Class "
+ object.getClass().getName()
+ " must implement serialization.");
throw e; throw e;
} }


// inner classes // inner classes
method = findHighestMethod(object.getClass(), name, paramTypes); method = findHighestMethod(object.getClass(), name, paramTypes);
} catch (SecurityException e) { } catch (SecurityException e) {
System.err.println("Internal deserialization error");
e.printStackTrace();
logger.log(Level.SEVERE, "Internal deserialization error", e);
} }
}; };



+ 12
- 10
src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java View File

import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;


import javax.portlet.ActionRequest; import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse; import javax.portlet.ActionResponse;
public abstract class AbstractApplicationPortlet extends GenericPortlet public abstract class AbstractApplicationPortlet extends GenericPortlet
implements Constants { implements Constants {


private static final Logger logger = Logger
.getLogger(AbstractApplicationPortlet.class.getName());

/** /**
* This portlet parameter is used to add styles to the main element. E.g * This portlet parameter is used to add styles to the main element. E.g
* "height:500px" generates a style="height:500px" to the main element. * "height:500px" generates a style="height:500px" to the main element.
* Print an information/warning message about running with xsrf * Print an information/warning message about running with xsrf
* protection disabled * protection disabled
*/ */
System.err.println(WARNING_XSRF_PROTECTION_DISABLED);
logger.warning(WARNING_XSRF_PROTECTION_DISABLED);
} }
} }


if (!productionMode) { if (!productionMode) {
/* Print an information/warning message about running in debug mode */ /* Print an information/warning message about running in debug mode */
// TODO Maybe we need a different message for portlets? // TODO Maybe we need a different message for portlets?
System.err.println(NOT_PRODUCTION_MODE_INFO);
logger.warning(NOT_PRODUCTION_MODE_INFO);
} }
} }


} catch (final SessionExpiredException e) { } catch (final SessionExpiredException e) {
// TODO Figure out a better way to deal with // TODO Figure out a better way to deal with
// SessionExpiredExceptions // SessionExpiredExceptions
System.err.println("Session has expired");
e.printStackTrace(System.err);
logger.finest("A user session has expired");
} catch (final GeneralSecurityException e) { } catch (final GeneralSecurityException e) {
// TODO Figure out a better way to deal with // TODO Figure out a better way to deal with
// GeneralSecurityExceptions // GeneralSecurityExceptions
System.err
.println("General security exception, should never happen");
e.printStackTrace(System.err);
logger.finest("General security exception, the security key was probably incorrect.");
} catch (final Throwable e) { } catch (final Throwable e) {
handleServiceException(request, response, application, e); handleServiceException(request, response, application, e);
} finally { } finally {


private void handleUnknownRequest(PortletRequest request, private void handleUnknownRequest(PortletRequest request,
PortletResponse response) { PortletResponse response) {
System.err.println("Unknown request type");
logger.warning("Unknown request type");
} }


/** /**
os.write(buffer, 0, bytes); os.write(buffer, 0, bytes);
} }
} else { } else {
System.err.println("Requested resource [" + resourceID
logger.warning("Requested resource [" + resourceID
+ "] could not be found"); + "] could not be found");
response.setProperty(ResourceResponse.HTTP_STATUS_CODE, response.setProperty(ResourceResponse.HTTP_STATUS_CODE,
Integer.toString(HttpServletResponse.SC_NOT_FOUND)); Integer.toString(HttpServletResponse.SC_NOT_FOUND));
appClass += getApplicationClass().getSimpleName(); appClass += getApplicationClass().getSimpleName();
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
appClass += "unknown"; appClass += "unknown";
e.printStackTrace();
logger.log(Level.SEVERE, "Could not find application class", e);
} }
String themeClass = "v-theme-" String themeClass = "v-theme-"
+ themeName.replaceAll("[^a-zA-Z0-9]", ""); + themeName.replaceAll("[^a-zA-Z0-9]", "");

+ 19
- 11
src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java View File

import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;


import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.ServletException; import javax.servlet.ServletException;
// TODO Move some (all?) of the constants to a separate interface (shared // TODO Move some (all?) of the constants to a separate interface (shared
// with portlet) // with portlet)


private static final Logger logger = Logger
.getLogger(AbstractApplicationServlet.class.getName());

/** /**
* The version number of this release. For example "6.2.0". Always in the * The version number of this release. For example "6.2.0". Always in the
* format "major.minor.revision[.build]". The build part is optional. All of * format "major.minor.revision[.build]". The build part is optional. All of
* Print an information/warning message about running with xsrf * Print an information/warning message about running with xsrf
* protection disabled * protection disabled
*/ */
System.err.println(WARNING_XSRF_PROTECTION_DISABLED);
logger.warning(WARNING_XSRF_PROTECTION_DISABLED);
} }
} }




if (!productionMode) { if (!productionMode) {
/* Print an information/warning message about running in debug mode */ /* Print an information/warning message about running in debug mode */
System.err.println(NOT_PRODUCTION_MODE_INFO);
logger.warning(NOT_PRODUCTION_MODE_INFO);
} }


} }
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
// Default is 1h // Default is 1h
resourceCacheTime = 3600; resourceCacheTime = 3600;
System.err.println(WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC);
logger.warning(WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC);
} }
} }


resultPath = url.getFile(); resultPath = url.getFile();
} catch (final Exception e) { } catch (final Exception e) {
// FIXME: Handle exception // FIXME: Handle exception
e.printStackTrace();
logger.log(Level.WARNING, "Could not find resource path "
+ path, e);
} }
} }
return resultPath; return resultPath;


if (resourceUrl == null) { if (resourceUrl == null) {
// cannot serve requested file // cannot serve requested file
System.err
.println("Requested resource ["
+ filename
+ "] not found from filesystem or through class loader."
+ " Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.");
logger.severe("Requested resource ["
+ filename
+ "] not found from filesystem or through class loader."
+ " Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.");
response.setStatus(HttpServletResponse.SC_NOT_FOUND); response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return; return;
} }
} }
} catch (Exception e) { } catch (Exception e) {
// Failed to find out last modified timestamp. Continue without it. // Failed to find out last modified timestamp. Continue without it.
e.printStackTrace();
logger.log(
Level.FINEST,
"Failed to find out last modified timestamp. Continuing without it.",
e);
} }


// Set type mime type if we can determine it based on the filename // Set type mime type if we can determine it based on the filename
try { try {
return getApplicationClass().getSimpleName(); return getApplicationClass().getSimpleName();
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
e.printStackTrace();
logger.log(Level.FINER, "getApplicationCSSClassName failed", e);
return "unknown"; return "unknown";
} }
} }

+ 28
- 20
src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java View File

import java.util.Set; import java.util.Set;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;


import javax.portlet.PortletRequest; import javax.portlet.PortletRequest;
import javax.portlet.PortletResponse; import javax.portlet.PortletResponse;
public abstract class AbstractCommunicationManager implements public abstract class AbstractCommunicationManager implements
Paintable.RepaintRequestListener, Serializable { Paintable.RepaintRequestListener, Serializable {


private static final Logger logger = Logger
.getLogger(AbstractCommunicationManager.class.getName());

/** /**
* Generic interface of a (HTTP or Portlet) request to the application. * Generic interface of a (HTTP or Portlet) request to the application.
* *
if (window == null) { if (window == null) {
// This should not happen, no windows exists but // This should not happen, no windows exists but
// application is still open. // application is still open.
System.err
.println("Warning, could not get window for application with request ID "
+ request.getRequestID());
logger.severe("Warning, could not get window for application with request ID "
+ request.getRequestID());
return; return;
} }
} else { } else {
// FIXME: Handle exception // FIXME: Handle exception
// Not critical, but something is still wrong; print // Not critical, but something is still wrong; print
// stacktrace // stacktrace
e2.printStackTrace();
logger.log(Level.WARNING,
"getSystemMessages() failed - continuing", e2);
} }
if (ci != null) { if (ci != null) {
String msg = ci.getOutOfSyncMessage(); String msg = ci.getOutOfSyncMessage();
"getSystemMessages", (Class[]) null); "getSystemMessages", (Class[]) null);
ci = (Application.SystemMessages) m.invoke(null, ci = (Application.SystemMessages) m.invoke(null,
(Object[]) null); (Object[]) null);
} catch (NoSuchMethodException e1) {
e1.printStackTrace();
} catch (NoSuchMethodException e) {
logger.log(Level.WARNING,
"getSystemMessages() failed - continuing", e);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
e.printStackTrace();
logger.log(Level.WARNING,
"getSystemMessages() failed - continuing", e);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace();
logger.log(Level.WARNING,
"getSystemMessages() failed - continuing", e);
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
e.printStackTrace();
logger.log(Level.WARNING,
"getSystemMessages() failed - continuing", e);
} }


// meta instruction for client to enable auto-forward to // meta instruction for client to enable auto-forward to
is = callback.getThemeResourceAsStream(themeName, resource); is = callback.getThemeResourceAsStream(themeName, resource);
} catch (final Exception e) { } catch (final Exception e) {
// FIXME: Handle exception // FIXME: Handle exception
e.printStackTrace();
logger.log(Level.FINER,
"Failed to get theme resource stream.", e);
} }
if (is != null) { if (is != null) {


r.close(); r.close();
} catch (final java.io.IOException e) { } catch (final java.io.IOException e) {
// FIXME: Handle exception // FIXME: Handle exception
System.err.println("Resource transfer failed: "
+ request.getRequestID() + ". ("
+ e.getMessage() + ")");
logger.log(Level.SEVERE, "Resource transfer failed: "
+ request.getRequestID() + ".", e);
} }
outWriter.print("\"" outWriter.print("\""
+ JsonPaintTarget.escapeJSON(layout.toString()) + JsonPaintTarget.escapeJSON(layout.toString())
+ "\""); + "\"");
} else { } else {
// FIXME: Handle exception // FIXME: Handle exception
System.err.println("CustomLayout not found: " + resource);
logger.severe("CustomLayout not found: " + resource);
} }
} }
outWriter.print("}"); outWriter.print("}");
+ variable[VAR_PID]; + variable[VAR_PID];
success = false; success = false;
} }
System.err.println(msg);
logger.warning(msg);
continue; continue;
} }
} }
DateFormat dateFormat = DateFormat.getDateTimeInstance( DateFormat dateFormat = DateFormat.getDateTimeInstance(
DateFormat.SHORT, DateFormat.SHORT, l); DateFormat.SHORT, DateFormat.SHORT, l);
if (!(dateFormat instanceof SimpleDateFormat)) { if (!(dateFormat instanceof SimpleDateFormat)) {
System.err
.println("Unable to get default date pattern for locale "
+ l.toString());
logger.warning("Unable to get default date pattern for locale "
+ l.toString());
dateFormat = new SimpleDateFormat(); dateFormat = new SimpleDateFormat();
} }
final String df = ((SimpleDateFormat) dateFormat).toPattern(); final String df = ((SimpleDateFormat) dateFormat).toPattern();
} }
} }


private HashMap<Class<? extends Paintable>, Integer> typeToKey = new HashMap<Class<? extends Paintable>, Integer>();
private final HashMap<Class<? extends Paintable>, Integer> typeToKey = new HashMap<Class<? extends Paintable>, Integer>();
private int nextTypeKey = 0; private int nextTypeKey = 0;


String getTagForType(Class<? extends Paintable> class1) { String getTagForType(Class<? extends Paintable> class1) {
*/ */
class OpenWindowCache implements Serializable { class OpenWindowCache implements Serializable {


private Set<Object> res = new HashSet<Object>();
private final Set<Object> res = new HashSet<Object>();


/** /**
* *

+ 7
- 2
src/com/vaadin/terminal/gwt/server/AbstractWebApplicationContext.java View File

import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;


import javax.servlet.http.HttpSessionBindingEvent; import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener; import javax.servlet.http.HttpSessionBindingListener;
public abstract class AbstractWebApplicationContext implements public abstract class AbstractWebApplicationContext implements
ApplicationContext, HttpSessionBindingListener, Serializable { ApplicationContext, HttpSessionBindingListener, Serializable {


private static final Logger logger = Logger
.getLogger(AbstractWebApplicationContext.class.getName());

protected Collection<TransactionListener> listeners = Collections protected Collection<TransactionListener> listeners = Collections
.synchronizedList(new LinkedList<TransactionListener>()); .synchronizedList(new LinkedList<TransactionListener>());


// remove same application here. Possible if you got e.g. session // remove same application here. Possible if you got e.g. session
// lifetime 1 min but socket write may take longer than 1 min. // lifetime 1 min but socket write may take longer than 1 min.
// FIXME: Handle exception // FIXME: Handle exception
System.err.println("Could not remove application, leaking memory.");
e.printStackTrace();
logger.log(Level.SEVERE,
"Could not remove application, leaking memory.", e);
} }
} }



+ 10
- 2
src/com/vaadin/terminal/gwt/server/ApplicationRunnerServlet.java View File

import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;


import javax.servlet.ServletConfig; import javax.servlet.ServletConfig;
import javax.servlet.ServletException; import javax.servlet.ServletException;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class ApplicationRunnerServlet extends AbstractApplicationServlet { public class ApplicationRunnerServlet extends AbstractApplicationServlet {


private static final Logger logger = Logger
.getLogger(ApplicationRunnerServlet.class.getName());

/** /**
* The name of the application class currently used. Only valid within one * The name of the application class currently used. Only valid within one
* request. * request.
*/ */
private String[] defaultPackages; private String[] defaultPackages;
private ThreadLocal<HttpServletRequest> request = new ThreadLocal<HttpServletRequest>();
private final ThreadLocal<HttpServletRequest> request = new ThreadLocal<HttpServletRequest>();


@Override @Override
public void init(ServletConfig servletConfig) throws ServletException { public void init(ServletConfig servletConfig) throws ServletException {
// Ignore as this is expected for many packages // Ignore as this is expected for many packages
} catch (Exception e2) { } catch (Exception e2) {
// TODO: handle exception // TODO: handle exception
e2.printStackTrace();
logger.log(
Level.FINER,
"Failed to find application class in the default package.",
e2);
} }
if (appClass != null) { if (appClass != null) {
return appClass; return appClass;

+ 15
- 7
src/com/vaadin/terminal/gwt/server/ComponentSizeValidator.java View File

import java.util.Map; import java.util.Map;
import java.util.Stack; import java.util.Stack;
import java.util.Vector; import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;


import com.vaadin.terminal.Sizeable; import com.vaadin.terminal.Sizeable;
import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.AbstractOrderedLayout;
@SuppressWarnings({ "serial", "deprecation" }) @SuppressWarnings({ "serial", "deprecation" })
public class ComponentSizeValidator implements Serializable { public class ComponentSizeValidator implements Serializable {


private final static Logger logger = Logger
.getLogger(ComponentSizeValidator.class.getName());

private final static int LAYERS_SHOWN = 4; private final static int LAYERS_SHOWN = 4;


/** /**


return parentCanDefineHeight(component); return parentCanDefineHeight(component);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
logger.log(Level.FINER,
"An exception occurred while validating sizes.", e);
return true; return true;
} }
} }


return parentCanDefineWidth(component); return parentCanDefineWidth(component);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
logger.log(Level.FINER,
"An exception occurred while validating sizes.", e);
return true; return true;
} }
} }


public static class InvalidLayout implements Serializable { public static class InvalidLayout implements Serializable {


private Component component;
private final Component component;


private boolean invalidHeight;
private boolean invalidWidth;
private final boolean invalidHeight;
private final boolean invalidWidth;


private Vector<InvalidLayout> subErrors = new Vector<InvalidLayout>();
private final Vector<InvalidLayout> subErrors = new Vector<InvalidLayout>();


public InvalidLayout(Component component, boolean height, boolean width) { public InvalidLayout(Component component, boolean height, boolean width) {
this.component = component; this.component = component;
return; return;
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace();
logger.log(Level.FINER,
"An exception occurred while validating sizes.", e);
} }


} }

+ 3
- 3
src/com/vaadin/terminal/gwt/server/Constants.java View File

*/ */
public interface Constants { public interface Constants {


static final String NOT_PRODUCTION_MODE_INFO = ""
static final String NOT_PRODUCTION_MODE_INFO = "\n"
+ "=================================================================\n" + "=================================================================\n"
+ "Vaadin is running in DEBUG MODE.\nAdd productionMode=true to web.xml " + "Vaadin is running in DEBUG MODE.\nAdd productionMode=true to web.xml "
+ "to disable debug features.\nTo show debug window, add ?debug to " + "to disable debug features.\nTo show debug window, add ?debug to "
+ "your application URL.\n" + "your application URL.\n"
+ "================================================================="; + "=================================================================";


static final String WARNING_XSRF_PROTECTION_DISABLED = ""
static final String WARNING_XSRF_PROTECTION_DISABLED = "\n"
+ "===========================================================\n" + "===========================================================\n"
+ "WARNING: Cross-site request forgery protection is disabled!\n" + "WARNING: Cross-site request forgery protection is disabled!\n"
+ "==========================================================="; + "===========================================================";


static final String WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC = ""
static final String WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC = "\n"
+ "===========================================================\n" + "===========================================================\n"
+ "WARNING: resourceCacheTime has been set to a non integer value " + "WARNING: resourceCacheTime has been set to a non integer value "
+ "in web.xml. The default of 1h will be used.\n" + "in web.xml. The default of 1h will be used.\n"

+ 7
- 4
src/com/vaadin/terminal/gwt/server/DragAndDropService.java View File



import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.Map; import java.util.Map;
import java.util.logging.Logger;


import com.vaadin.event.Transferable; import com.vaadin.event.Transferable;
import com.vaadin.event.TransferableImpl; import com.vaadin.event.TransferableImpl;


public class DragAndDropService implements VariableOwner { public class DragAndDropService implements VariableOwner {


private static final Logger logger = Logger
.getLogger(DragAndDropService.class.getName());

private int lastVisitId; private int lastVisitId;


private boolean lastVisitAccepted = false; private boolean lastVisitAccepted = false;


// Validate drop handler owner // Validate drop handler owner
if (!(owner instanceof DropTarget)) { if (!(owner instanceof DropTarget)) {
System.err.println("DropHandler owner " + owner
logger.severe("DropHandler owner " + owner
+ " must implement DropTarget"); + " must implement DropTarget");
return; return;
} }
DropHandler dropHandler = (dropTarget).getDropHandler(); DropHandler dropHandler = (dropTarget).getDropHandler();
if (dropHandler == null) { if (dropHandler == null) {
// No dropHandler returned so no drop can be performed. // No dropHandler returned so no drop can be performed.
System.err
.println("DropTarget.getDropHandler() returned null for owner: "
+ dropTarget);
logger.fine("DropTarget.getDropHandler() returned null for owner: "
+ dropTarget);
return; return;
} }



+ 13
- 19
src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java View File

import java.io.NotSerializableException; import java.io.NotSerializableException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;


import javax.servlet.ServletException; import javax.servlet.ServletException;
log.severe("DeadlineExceeded for " + session.getId()); log.severe("DeadlineExceeded for " + session.getId());
sendDeadlineExceededNotification(request, response); sendDeadlineExceededNotification(request, response);
} catch (NotSerializableException e) { } catch (NotSerializableException e) {
log.severe("NotSerializableException: " + getStackTraceAsString(e));
log.log(Level.SEVERE, "Not serializable!", e);


// TODO this notification is usually not shown - should we redirect // TODO this notification is usually not shown - should we redirect
// in some other way - can we? // in some other way - can we?
sendNotSerializableNotification(request, response); sendNotSerializableNotification(request, response);
} catch (Exception e) { } catch (Exception e) {
log.severe(e + ": " + getStackTraceAsString(e));
log.log(Level.SEVERE,
"An exception occurred while servicing request.", e);


sendCriticalErrorNotification(request, response); sendCriticalErrorNotification(request, response);
} finally { } finally {
session.setAttribute(WebApplicationContext.class.getName(), session.setAttribute(WebApplicationContext.class.getName(),
applicationContext); applicationContext);
} catch (IOException e) { } catch (IOException e) {
log.warning("Could not de-serialize ApplicationContext for "
+ session.getId() + " A new one will be created. "
+ getStackTraceAsString(e));
log.log(Level.WARNING,
"Could not de-serialize ApplicationContext for "
+ session.getId()
+ " A new one will be created. ", e);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
log.warning("Could not de-serialize ApplicationContext for "
+ session.getId() + " A new one will be created. "
+ getStackTraceAsString(e));
log.log(Level.WARNING,
"Could not de-serialize ApplicationContext for "
+ session.getId()
+ " A new one will be created. ", e);
} }
} }
// will create new context if the above did not // will create new context if the above did not
} }
} }
} catch (Exception e) { } catch (Exception e) {
log.warning("Exception while cleaning: " + getStackTraceAsString(e));
log.log(Level.WARNING, "Exception while cleaning.", e);
} }
} }

private String getStackTraceAsString(Throwable t) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
t.printStackTrace(pw);
return sw.toString();
}

} }

+ 21
- 14
src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java View File

import java.util.Set; import java.util.Set;
import java.util.Stack; import java.util.Stack;
import java.util.Vector; import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;


import com.vaadin.Application; import com.vaadin.Application;
import com.vaadin.terminal.ApplicationResource; import com.vaadin.terminal.ApplicationResource;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class JsonPaintTarget implements PaintTarget { public class JsonPaintTarget implements PaintTarget {


private static final Logger logger = Logger.getLogger(JsonPaintTarget.class
.getName());

/* Document type declarations */ /* Document type declarations */


private final static String UIDL_ARG_NAME = "name"; private final static String UIDL_ARG_NAME = "name";


private int changes = 0; private int changes = 0;


private Set<Object> usedResources = new HashSet<Object>();
private final Set<Object> usedResources = new HashSet<Object>();


private boolean customLayoutArgumentsOpen = false; private boolean customLayoutArgumentsOpen = false;




private boolean cacheEnabled = false; private boolean cacheEnabled = false;


private Collection<Paintable> paintedComponents = new HashSet<Paintable>();
private final Collection<Paintable> paintedComponents = new HashSet<Paintable>();


private Collection<Paintable> identifiersCreatedDueRefPaint; private Collection<Paintable> identifiersCreatedDueRefPaint;


private Collection<Class<? extends Paintable>> usedPaintableTypes = new LinkedList<Class<? extends Paintable>>();
private final Collection<Class<? extends Paintable>> usedPaintableTypes = new LinkedList<Class<? extends Paintable>>();


/** /**
* Creates a new XMLPrintWriter, without automatic line flushing. * Creates a new XMLPrintWriter, without automatic line flushing.
&& Paintable.class.isAssignableFrom(superclass)) { && Paintable.class.isAssignableFrom(superclass)) {
class1 = (Class<? extends Paintable>) superclass; class1 = (Class<? extends Paintable>) superclass;
} else { } else {
System.out
.append("Warning: no superclass of "
+ paintable.getClass().getName()
+ " has a @ClientWidget"
+ " annotation. Component will not be mapped correctly on client side.");
logger.warning("No superclass of "
+ paintable.getClass().getName()
+ " has a @ClientWidget"
+ " annotation. Component will not be mapped correctly on client side.");
break; break;
} }
} }
// TODO could optize to quit at the end attribute // TODO could optize to quit at the end attribute
} }
} catch (IOException e1) { } catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
logger.log(
Level.SEVERE,
"An error occurred while finding widget mapping.",
e1);
} finally { } finally {
try { try {
bufferedReader.close(); bufferedReader.close();
} catch (IOException e1) { } catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
logger.log(Level.SEVERE, "Could not close reader.",
e1);
} }
} }


} catch (Throwable e2) { } catch (Throwable e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
logger.log(Level.SEVERE,
"An error occurred while finding widget mapping.",
e2);
} }


return false; return false;

+ 14
- 5
src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java View File

import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;


import javax.portlet.ActionRequest; import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse; import javax.portlet.ActionResponse;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class PortletApplicationContext2 extends AbstractWebApplicationContext { public class PortletApplicationContext2 extends AbstractWebApplicationContext {


private static final Logger logger = Logger
.getLogger(PortletApplicationContext2.class.getName());

protected Map<Application, Set<PortletListener>> portletListeners = new HashMap<Application, Set<PortletListener>>(); protected Map<Application, Set<PortletListener>> portletListeners = new HashMap<Application, Set<PortletListener>>();


protected transient PortletSession session; protected transient PortletSession session;


private PortletResponse response; private PortletResponse response;


private Map<String, QName> eventActionDestinationMap = new HashMap<String, QName>();
private Map<String, Serializable> eventActionValueMap = new HashMap<String, Serializable>();
private final Map<String, QName> eventActionDestinationMap = new HashMap<String, QName>();
private final Map<String, Serializable> eventActionValueMap = new HashMap<String, Serializable>();


private Map<String, String> sharedParameterActionNameMap = new HashMap<String, String>();
private Map<String, String> sharedParameterActionValueMap = new HashMap<String, String>();
private final Map<String, String> sharedParameterActionNameMap = new HashMap<String, String>();
private final Map<String, String> sharedParameterActionValueMap = new HashMap<String, String>();


public File getBaseDirectory() { public File getBaseDirectory() {
String resultPath = session.getPortletContext().getRealPath("/"); String resultPath = session.getPortletContext().getRealPath("/");
return new File(url.getFile()); return new File(url.getFile());
} catch (final Exception e) { } catch (final Exception e) {
// FIXME: Handle exception // FIXME: Handle exception
e.printStackTrace();
logger.log(
Level.FINE,
"Cannot access base directory, possible security issue "
+ "with Application Server or Servlet Container",
e);
} }
} }
return null; return null;

+ 7
- 8
src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java View File

} catch (MalformedURLException e) { } catch (MalformedURLException e) {
// should never happen as based on an existing URL, // should never happen as based on an existing URL,
// only changing end of file name/path part // only changing end of file name/path part
e.printStackTrace();
logger.log(Level.SEVERE,
"This should never happen!", e);
} }
} }
} }
} }
} }
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
logger.log(Level.FINEST, "Failed to inspect JAR file", e);
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
logger.log(Level.FINEST, "Failed to inspect JAR file", e);
} }


return false; return false;
} catch (LinkageError e) { } catch (LinkageError e) {
// NOP // NOP
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
logger.log(Level.FINEST, "Could not add class: " + fullclassName, e);
} }
} }


try { try {
return new URL("file://" + directory.getCanonicalPath()); return new URL("file://" + directory.getCanonicalPath());
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
e.printStackTrace();
logger.log(Level.FINEST, "Ignoring exception", e);
// ignore: continue to the next classpath entry // ignore: continue to the next classpath entry
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace();
logger.log(Level.FINEST, "Ignoring exception", e);
// ignore: continue to the next classpath entry // ignore: continue to the next classpath entry
} }
} }

+ 8
- 2
src/com/vaadin/tools/WidgetsetCompiler.java View File

package com.vaadin.tools; package com.vaadin.tools;


import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;


import com.vaadin.terminal.gwt.widgetsetutils.WidgetSetBuilder; import com.vaadin.terminal.gwt.widgetsetutils.WidgetSetBuilder;


*/ */
public class WidgetsetCompiler { public class WidgetsetCompiler {


private static final Logger logger = Logger
.getLogger(WidgetsetCompiler.class.getName());

/** /**
* @param args * @param args
* same arguments as for com.google.gwt.dev.Compiler * same arguments as for com.google.gwt.dev.Compiler
String[].class); String[].class);
method.invoke(null, new Object[] { args }); method.invoke(null, new Object[] { args });
} catch (Throwable thr) { } catch (Throwable thr) {
thr.printStackTrace();
logger.log(Level.SEVERE,
"Widgetset compilation failed", thr);
} }
} }
}; };
runThread.join(); runThread.join();
System.out.println("Widgetset compilation finished"); System.out.println("Widgetset compilation finished");
} catch (Throwable thr) { } catch (Throwable thr) {
thr.printStackTrace();
logger.log(Level.SEVERE, "Widgetset compilation failed", thr);
} }
} }
} }

+ 13
- 6
src/com/vaadin/ui/Table.java View File

import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;


import com.vaadin.data.Container; import com.vaadin.data.Container;
import com.vaadin.data.Item; import com.vaadin.data.Item;
Container.Ordered, Container.Sortable, ItemClickSource, DragSource, Container.Ordered, Container.Sortable, ItemClickSource, DragSource,
DropTarget { DropTarget {


private static final Logger logger = Logger
.getLogger(Table.class.getName());

/** /**
* Modes that Table support as drag sourse. * Modes that Table support as drag sourse.
*/ */
.get("lastToBeRendered")).intValue(); .get("lastToBeRendered")).intValue();
} catch (Exception e) { } catch (Exception e) {
// FIXME: Handle exception // FIXME: Handle exception
e.printStackTrace();
logger.log(Level.FINER,
"Could not parse the first and/or last rows.", e);
} }


// respect suggested rows only if table is not otherwise updated // respect suggested rows only if table is not otherwise updated
} }
} catch (final Exception e) { } catch (final Exception e) {
// FIXME: Handle exception // FIXME: Handle exception
e.printStackTrace();
logger.log(Level.FINER,
"Could not determine column collapsing state", e);
} }
clientNeedsContentRefresh = true; clientNeedsContentRefresh = true;
} }
setColumnOrder(idsTemp); setColumnOrder(idsTemp);
} catch (final Exception e) { } catch (final Exception e) {
// FIXME: Handle exception // FIXME: Handle exception
e.printStackTrace();
logger.log(Level.FINER,
"Could not determine column reordering state", e);
} }
clientNeedsContentRefresh = true; clientNeedsContentRefresh = true;
} }
} }


// The property id of the column which header was pressed // The property id of the column which header was pressed
private Object columnPropertyId;
private final Object columnPropertyId;


public HeaderClickEvent(Component source, Object propertyId, public HeaderClickEvent(Component source, Object propertyId,
MouseEventDetails details) { MouseEventDetails details) {
} }


// The property id of the column which header was pressed // The property id of the column which header was pressed
private Object columnPropertyId;
private final Object columnPropertyId;


/** /**
* Constructor * Constructor

Loading…
Cancel
Save