ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1653918 - in /ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin: VaadinClient.java VaadinServlet.java component/ArtifactsPanel.java
Date Thu, 22 Jan 2015 15:52:31 GMT
Author: jawi
Date: Thu Jan 22 15:52:30 2015
New Revision: 1653918

URL: http://svn.apache.org/r1653918
Log:
ACE-444 - AIOOBE in webUI:

- modified code to also accept double valued cache rates.


Modified:
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/ArtifactsPanel.java

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java?rev=1653918&r1=1653917&r2=1653918&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
Thu Jan 22 15:52:30 2015
@@ -187,7 +187,7 @@ public class VaadinClient extends com.va
     private final AssociationHelper m_associations = new AssociationHelper();
     private final AtomicBoolean m_dependenciesResolved = new AtomicBoolean(false);
     // for the artifacts list...
-    private final int m_cacheRate;
+    private final double m_cacheRate;
     private final int m_pageLength;
 
     private ProgressIndicator m_progress;
@@ -214,7 +214,7 @@ public class VaadinClient extends com.va
      * @param userName
      *            the hardcoded username to use when authentication is disabled.
      */
-    public VaadinClient(DependencyManager manager, URL aceHost, URL obrUrl, String repositoryXML,
boolean useAuth, String userName, String password, int cacheRate, int pageLength) {
+    public VaadinClient(DependencyManager manager, URL aceHost, URL obrUrl, String repositoryXML,
boolean useAuth, String userName, String password, double cacheRate, int pageLength) {
         m_manager = manager;
         try {
             m_repository = new URL(aceHost, endpoint);

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java?rev=1653918&r1=1653917&r2=1653918&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java
Thu Jan 22 15:52:30 2015
@@ -66,7 +66,7 @@ public class VaadinServlet extends Abstr
     private static final String DEFAULT_OBR_XML = "repository.xml";
     private static final String DEFAULT_SERVLET_ENDPOINT = "/ace";
     private static final int DEFAULT_SESSION_TIMEOUT = 300; // in seconds.
-    private static final int DEFAULT_CACHE_RATE = 2;
+    private static final double DEFAULT_CACHE_RATE = 1;
     private static final int DEFAULT_PAGE_LENGTH = 100;
 
     static {
@@ -88,7 +88,7 @@ public class VaadinServlet extends Abstr
     private volatile String m_repositoryXML;
     private volatile String m_servletEndpoint;
     private volatile int m_sessionTimeout;
-    private volatile int m_cacheRate;
+    private volatile double m_cacheRate;
     private volatile int m_pageLength;
 
     /**
@@ -117,7 +117,7 @@ public class VaadinServlet extends Abstr
         String repositoryXML = DEFAULT_OBR_XML;
         String servletEndpoint = DEFAULT_SERVLET_ENDPOINT;
         int sessionTimeout = DEFAULT_SESSION_TIMEOUT;
-        int cacheRate = DEFAULT_CACHE_RATE;
+        double cacheRate = DEFAULT_CACHE_RATE;
         int pageLength = DEFAULT_PAGE_LENGTH;
 
         if (dictionary != null) {
@@ -130,14 +130,14 @@ public class VaadinServlet extends Abstr
             servletEndpoint = getOptionalString(dictionary, KEY_SERVLET_ENDPOINT);
             sessionTimeout = getInteger(dictionary, KEY_SESSION_TIMEOUT);
             
-            Integer value = getOptionalInteger(dictionary, KEY_CACHE_RATE);
-            if (value != null) {
-                cacheRate = value.intValue(); 
+            Double doubleValue = getOptionalDouble(dictionary, KEY_CACHE_RATE);
+            if (doubleValue != null) {
+                cacheRate = doubleValue.doubleValue(); 
             }
 
-            value = getOptionalInteger(dictionary, KEY_PAGE_LENGTH);
-            if (value != null) {
-                pageLength = value.intValue(); 
+            Integer intValue = getOptionalInteger(dictionary, KEY_PAGE_LENGTH);
+            if (intValue != null) {
+                pageLength = intValue.intValue(); 
             }
         }
 
@@ -215,6 +215,27 @@ public class VaadinServlet extends Abstr
         return value.intValue();
     }
 
+    private Double getOptionalDouble(Dictionary dictionary, String key) throws ConfigurationException
{
+        Object value = dictionary.get(key);
+        if (value == null) {
+            return null;
+        }
+        if (!(value instanceof Double) && !(value instanceof String)) {
+            throw new ConfigurationException(key, "Invalid value!");
+        }
+        if (value instanceof Double) {
+            return (Double) value;
+        }
+
+        try {
+            String valueStr = ((String) value).trim();
+            return Double.parseDouble(valueStr);
+        }
+        catch (NumberFormatException exception) {
+            throw new ConfigurationException(key, "Invalid value!");
+        }
+    }
+
     private Integer getOptionalInteger(Dictionary dictionary, String key) throws ConfigurationException
{
         Object value = dictionary.get(key);
         if (value == null) {

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/ArtifactsPanel.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/ArtifactsPanel.java?rev=1653918&r1=1653917&r2=1653918&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/ArtifactsPanel.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/ArtifactsPanel.java
Thu Jan 22 15:52:30 2015
@@ -37,7 +37,7 @@ import com.vaadin.data.Item;
  * Provides an object panel for displaying artifacts.
  */
 public abstract class ArtifactsPanel extends BaseObjectPanel<ArtifactObject, ArtifactRepository,
RepositoryObject, FeatureObject> {
-    private final int m_cacheRate;
+    private final double m_cacheRate;
     private final int m_pageLength;
 
     /**
@@ -48,7 +48,7 @@ public abstract class ArtifactsPanel ext
      * @param associationMgr
      *            the helper for creating/removing associations.
      */
-    public ArtifactsPanel(AssociationHelper associations, AssociationManager associationMgr,
int cacheRate, int pageLength) {
+    public ArtifactsPanel(AssociationHelper associations, AssociationManager associationMgr,
double cacheRate, int pageLength) {
         super(associations, associationMgr, "Artifact", UIExtensionFactory.EXTENSION_POINT_VALUE_ARTIFACT,
true, ArtifactObject.class);
 
         m_cacheRate = cacheRate;



Mime
View raw message