From 69db9eac8f76a66210b8eb7308c9e5fc84eff977 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Thu, 5 Mar 2015 11:35:19 +0200 Subject: Update @since for 7.4.1 Change-Id: I61233d704eae50447d3ccb5a5c485fe3ef98c436 --- .../vaadin/server/communication/AtmospherePushConnection.java | 2 +- server/src/com/vaadin/ui/Flash.java | 10 +++++----- server/src/com/vaadin/ui/Grid.java | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'server/src') diff --git a/server/src/com/vaadin/server/communication/AtmospherePushConnection.java b/server/src/com/vaadin/server/communication/AtmospherePushConnection.java index ab45fcfe89..357278f411 100644 --- a/server/src/com/vaadin/server/communication/AtmospherePushConnection.java +++ b/server/src/com/vaadin/server/communication/AtmospherePushConnection.java @@ -311,7 +311,7 @@ public class AtmospherePushConnection implements PushConnection { /** * Called when the connection to the client has been lost. * - * @since + * @since 7.4.1 */ public void connectionLost() { resource = null; diff --git a/server/src/com/vaadin/ui/Flash.java b/server/src/com/vaadin/ui/Flash.java index cd7c00087e..2d0f188b84 100644 --- a/server/src/com/vaadin/ui/Flash.java +++ b/server/src/com/vaadin/ui/Flash.java @@ -97,7 +97,7 @@ public class Flash extends AbstractEmbedded { * Returns the codebase. * * @see #setCodebase(String) - * @since 7.4 + * @since 7.4.1 * @return Current codebase. */ public String getCodebase() { @@ -126,7 +126,7 @@ public class Flash extends AbstractEmbedded { * Returns the current codetype. * * @see #setCodetype(String) - * @since 7.4 + * @since 7.4.1 * @return Current codetype. */ public String getCodetype() { @@ -157,7 +157,7 @@ public class Flash extends AbstractEmbedded { * Returns current archive. * * @see #setArchive(String) - * @since 7.4 + * @since 7.4.1 * @return Current archive. */ public String getArchive() { @@ -181,7 +181,7 @@ public class Flash extends AbstractEmbedded { /** * Returns standby. * - * @since + * @since 7.4.1 * @return Standby string. */ public String getStandby() { @@ -247,7 +247,7 @@ public class Flash extends AbstractEmbedded { * * @see #setParameter(String, String) * @see #getParameter(String) - * @since 7.4 + * @since 7.4.1 * @return An iterable with declared parameter names. */ public Iterable getParameterNames() { diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java index 6ab6c6b1a4..ee7da1e36c 100644 --- a/server/src/com/vaadin/ui/Grid.java +++ b/server/src/com/vaadin/ui/Grid.java @@ -5088,7 +5088,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier, * but this method can be used to force recalculation in situations when * grid does not recalculate automatically. * - * @since + * @since 7.4.1 */ public void recalculateColumnWidths() { getRpcProxy(GridClientRpc.class).recalculateColumnWidths(); -- cgit v1.2.3 From 4db0b55aefd83d149e62a7fad2b14fb232d976c8 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 6 Mar 2015 09:09:27 +0000 Subject: Revert "Encode filenames to UTF-8 in Content-Disposition header. (#16556)" Breaks AppResource404, BrowserFrameIsVisible and FlashIsVisible This reverts commit af6dd56e89db8ea8c88f607c4214abcde50dfc94. Change-Id: I82fc9ef4c9d08dc8aa48e0fa137fae5782701389 --- server/src/com/vaadin/server/DownloadStream.java | 30 ++++++---------- server/src/com/vaadin/server/FileDownloader.java | 6 ++++ .../src/com/vaadin/server/FileDownloaderTests.java | 41 ---------------------- 3 files changed, 16 insertions(+), 61 deletions(-) delete mode 100644 server/tests/src/com/vaadin/server/FileDownloaderTests.java (limited to 'server/src') diff --git a/server/src/com/vaadin/server/DownloadStream.java b/server/src/com/vaadin/server/DownloadStream.java index 8b2b933bcc..681c438967 100644 --- a/server/src/com/vaadin/server/DownloadStream.java +++ b/server/src/com/vaadin/server/DownloadStream.java @@ -20,8 +20,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.Serializable; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -282,9 +280,16 @@ public class DownloadStream implements Serializable { } } - // Content-Disposition: attachment generally forces download - response.setHeader("Content-Disposition", - getContentDispositionValue()); + // suggest local filename from DownloadStream if + // Content-Disposition + // not explicitly set + String contentDispositionValue = getParameter("Content-Disposition"); + if (contentDispositionValue == null) { + contentDispositionValue = "filename=\"" + getFileName() + + "\""; + response.setHeader("Content-Disposition", + contentDispositionValue); + } int bufferSize = getBufferSize(); if (bufferSize <= 0 || bufferSize > Constants.MAX_BUFFER_SIZE) { @@ -312,21 +317,6 @@ public class DownloadStream implements Serializable { } } - private String getContentDispositionValue() - throws UnsupportedEncodingException { - String contentDispositionValue = getParameter("Content-Disposition"); - - if (contentDispositionValue == null) { - String encodedFilename = URLEncoder.encode(getFileName(), "utf-8"); - - contentDispositionValue = String.format( - "attachment; filename=\"%s\"; filename*=utf-8''%s", - encodedFilename, encodedFilename); - } - - return contentDispositionValue; - } - /** * Helper method that tries to close an output stream and ignores any * exceptions. diff --git a/server/src/com/vaadin/server/FileDownloader.java b/server/src/com/vaadin/server/FileDownloader.java index bea9922c50..42c2f76e1a 100644 --- a/server/src/com/vaadin/server/FileDownloader.java +++ b/server/src/com/vaadin/server/FileDownloader.java @@ -141,6 +141,12 @@ public class FileDownloader extends AbstractExtension { } stream = ((ConnectorResource) resource).getStream(); + if (stream.getParameter("Content-Disposition") == null) { + // Content-Disposition: attachment generally forces download + stream.setParameter("Content-Disposition", + "attachment; filename=\"" + stream.getFileName() + "\""); + } + // Content-Type to block eager browser plug-ins from hijacking // the file if (isOverrideContentType()) { diff --git a/server/tests/src/com/vaadin/server/FileDownloaderTests.java b/server/tests/src/com/vaadin/server/FileDownloaderTests.java deleted file mode 100644 index 4e9478c570..0000000000 --- a/server/tests/src/com/vaadin/server/FileDownloaderTests.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.vaadin.server; - -import static org.mockito.Matchers.contains; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URLEncoder; - -import org.junit.Before; -import org.junit.Test; - -public class FileDownloaderTests { - private String filename = "日本語.png"; - private DownloadStream stream; - - @Before - public void setup() { - stream = new DownloadStream(mock(InputStream.class), "", filename); - } - - @Test - public void contentDispositionFilenameIsUtf8Encoded() throws IOException { - VaadinResponse response = mock(VaadinResponse.class); - - stream.writeResponse(mock(VaadinRequest.class), response); - - verify(response).setHeader(eq("Content-Disposition"), - contains("attachment;")); - String encodedFileName = URLEncoder.encode(filename, "utf-8"); - verify(response).setHeader(eq("Content-Disposition"), - contains(String.format("filename=\"%s\";", encodedFileName))); - verify(response) - .setHeader( - eq("Content-Disposition"), - contains(String.format("filename*=utf-8''%s", - encodedFileName))); - } -} -- cgit v1.2.3 From 789995e01e79944d45797d31b640b42fa34b115c Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 6 Mar 2015 14:24:00 +0200 Subject: Ensure refresh message is sent on invalid CSRF (#17042) If we create an AtmospherePushConnection and a broadcaster like before we would need to suspend the connection to ensure the AtmosphereResource is actually added to the broadcaster Change-Id: I7265ac0594b7a4da2c7a49fa34ebfbb27e1abdff --- .../com/vaadin/server/communication/PushHandler.java | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'server/src') diff --git a/server/src/com/vaadin/server/communication/PushHandler.java b/server/src/com/vaadin/server/communication/PushHandler.java index 22eee70aa0..c570d22086 100644 --- a/server/src/com/vaadin/server/communication/PushHandler.java +++ b/server/src/com/vaadin/server/communication/PushHandler.java @@ -470,23 +470,9 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter { */ private static void sendRefreshAndDisconnect(AtmosphereResource resource) throws IOException { - if (resource instanceof AtmosphereResourceImpl - && !((AtmosphereResourceImpl) resource).isInScope()) { - // The resource is no longer valid so we should not write - // anything to it - getLogger() - .fine("sendRefreshAndDisconnect called for resource no longer in scope"); - return; - } - - AtmospherePushConnection connection = new AtmospherePushConnection(null); - connection.connect(resource); - try { - connection.sendMessage(VaadinService - .createCriticalNotificationJSON(null, null, null, null)); - } finally { - connection.disconnect(); - } + sendNotificationAndDisconnect(resource, + VaadinService.createCriticalNotificationJSON(null, null, null, + null)); } /** -- cgit v1.2.3 From 9086245a6d2052fe813b3ef4296c686aad82b244 Mon Sep 17 00:00:00 2001 From: Alexey Fansky Date: Wed, 4 Mar 2015 13:23:42 -0800 Subject: Using ComponentFactory in DesignContext.getDefaultInstance() (#16990) Change-Id: I0bb3e7975f2b48cdc589de740cb07ac893b13461 --- .../com/vaadin/ui/declarative/DesignContext.java | 21 +++++++++--------- .../vaadin/tests/design/ComponentFactoryTest.java | 25 ++++++++++++++++++++++ 2 files changed, 36 insertions(+), 10 deletions(-) (limited to 'server/src') diff --git a/server/src/com/vaadin/ui/declarative/DesignContext.java b/server/src/com/vaadin/ui/declarative/DesignContext.java index 09fefd0a6b..218774c72d 100644 --- a/server/src/com/vaadin/ui/declarative/DesignContext.java +++ b/server/src/com/vaadin/ui/declarative/DesignContext.java @@ -278,16 +278,8 @@ public class DesignContext implements Serializable { Class componentClass) { Component instance = instanceCache.get(componentClass); if (instance == null) { - try { - instance = componentClass.newInstance(); - instanceCache.put(componentClass, instance); - } catch (InstantiationException e) { - throw new RuntimeException("Could not instantiate " - + componentClass.getName()); - } catch (IllegalAccessException e) { - throw new RuntimeException("Could not instantiate " - + componentClass.getName()); - } + instance = instantiateClass(componentClass.getName()); + instanceCache.put(componentClass, instance); } return instance; } @@ -484,6 +476,15 @@ public class DesignContext implements Serializable { // Extract the package and class names. String qualifiedClassName = tagNameToClassName(node); + return instantiateClass(qualifiedClassName); + } + + /** + * Instantiates given class via ComponentFactory. + * @param qualifiedClassName class name to instantiate + * @return instance of a given class + */ + private Component instantiateClass(String qualifiedClassName) { ComponentFactory factory = Design.getComponentFactory(); Component component = factory.createComponent(qualifiedClassName, this); diff --git a/server/tests/src/com/vaadin/tests/design/ComponentFactoryTest.java b/server/tests/src/com/vaadin/tests/design/ComponentFactoryTest.java index a5f1d288a2..4115872fb7 100644 --- a/server/tests/src/com/vaadin/tests/design/ComponentFactoryTest.java +++ b/server/tests/src/com/vaadin/tests/design/ComponentFactoryTest.java @@ -19,6 +19,8 @@ import java.io.ByteArrayInputStream; import java.util.ArrayList; import java.util.List; +import com.vaadin.ui.AbstractComponent; +import com.vaadin.ui.TextField; import org.junit.After; import org.junit.Assert; import org.junit.Test; @@ -109,9 +111,32 @@ public class ComponentFactoryTest { Design.read(new ByteArrayInputStream("".getBytes())); } + @Test + public void testGetDefaultInstanceUsesComponentFactory() { + final List classes = new ArrayList(); + currentComponentFactory.set(new ComponentFactory() { + @Override + public Component createComponent(String fullyQualifiedClassName, + DesignContext context) { + classes.add(fullyQualifiedClassName); + return defaultFactory.createComponent(fullyQualifiedClassName, + context); + } + }); + + DesignContext designContext = new DesignContext(); + designContext.getDefaultInstance(new DefaultInstanceTestComponent()); + + Assert.assertEquals("There should be one class requests", 1, classes.size()); + Assert.assertEquals("First class should be DefaultInstanceTestComponent", + DefaultInstanceTestComponent.class.getName(), classes.get(0)); + } + @After public void cleanup() { currentComponentFactory.remove(); } + public static class DefaultInstanceTestComponent extends AbstractComponent { + } } -- cgit v1.2.3 From 21c73437439539276c6f4152fa149c201db94d95 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 10 Mar 2015 15:19:27 +0200 Subject: Update Atmosphere to 2.2.4.vaadin5 (#17074) Change-Id: I85618f66effbf647856d9c152b3e66a6454001d9 --- push/build.xml | 2 +- push/ivy.xml | 2 +- server/src/com/vaadin/server/Constants.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'server/src') diff --git a/push/build.xml b/push/build.xml index 519dc81ed2..336c3629aa 100644 --- a/push/build.xml +++ b/push/build.xml @@ -18,7 +18,7 @@ location="${result.dir}/js/VAADIN/vaadinPush.debug.js" /> - + diff --git a/push/ivy.xml b/push/ivy.xml index c285bfd4aa..605f5d1a05 100644 --- a/push/ivy.xml +++ b/push/ivy.xml @@ -1,7 +1,7 @@ - + ]> diff --git a/server/src/com/vaadin/server/Constants.java b/server/src/com/vaadin/server/Constants.java index b9a43a98de..b7c2a1ff3e 100644 --- a/server/src/com/vaadin/server/Constants.java +++ b/server/src/com/vaadin/server/Constants.java @@ -67,7 +67,7 @@ public interface Constants { // Keep the version number in sync with push/build.xml and other locations // listed in that file - static final String REQUIRED_ATMOSPHERE_RUNTIME_VERSION = "2.2.4.vaadin4"; + static final String REQUIRED_ATMOSPHERE_RUNTIME_VERSION = "2.2.4.vaadin5"; static final String INVALID_ATMOSPHERE_VERSION_WARNING = "\n" + "=================================================================\n" -- cgit v1.2.3 From 155ffa7560e6445557ad2d04d2f83411c391debb Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Wed, 25 Feb 2015 23:19:30 +0200 Subject: Use Math.floor instead of casting to int when trimming decimals. (#16926) Change-Id: I02802b910d0dc90221483fedbf05be48958d8dcc --- server/src/com/vaadin/ui/Slider.java | 2 +- .../src/com/vaadin/tests/server/component/slider/SliderTest.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'server/src') diff --git a/server/src/com/vaadin/ui/Slider.java b/server/src/com/vaadin/ui/Slider.java index dad4d295bf..fab6e33cae 100644 --- a/server/src/com/vaadin/ui/Slider.java +++ b/server/src/com/vaadin/ui/Slider.java @@ -267,7 +267,7 @@ public class Slider extends AbstractField { if (resolution > 0) { // Round up to resolution - newValue = (int) (v * Math.pow(10, resolution)); + newValue = Math.floor(v * Math.pow(10, resolution)); newValue = newValue / Math.pow(10, resolution); if (getMin() > newValue || getMax() < newValue) { throw new ValueOutOfBoundsException(newValue); diff --git a/server/tests/src/com/vaadin/tests/server/component/slider/SliderTest.java b/server/tests/src/com/vaadin/tests/server/component/slider/SliderTest.java index 48bba8a853..d2e2654cbc 100644 --- a/server/tests/src/com/vaadin/tests/server/component/slider/SliderTest.java +++ b/server/tests/src/com/vaadin/tests/server/component/slider/SliderTest.java @@ -65,6 +65,15 @@ public class SliderTest { } catch (Slider.ValueOutOfBoundsException e) { // TODO: handle exception } + } + + @Test + public void valueCanHaveLargePrecision() { + Slider slider = new Slider(); + slider.setResolution(20); + + slider.setValue(99.01234567891234567890123456789); + assertThat(slider.getValue(), is(99.01234567891234567890123456789)); } } -- cgit v1.2.3