[jbosstools-commits] JBoss Tools SVN: r24494 - trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/preferences.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri Aug 27 08:17:17 EDT 2010


Author: adietish
Date: 2010-08-27 08:17:16 -0400 (Fri, 27 Aug 2010)
New Revision: 24494

Modified:
   trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/preferences/GlobalUsageReportingSettings.java
Log:
[JBIDE-6880] defaults implemented (in case page to reachable)

Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/preferences/GlobalUsageReportingSettings.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/preferences/GlobalUsageReportingSettings.java	2010-08-27 12:05:10 UTC (rev 24493)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/preferences/GlobalUsageReportingSettings.java	2010-08-27 12:17:16 UTC (rev 24494)
@@ -11,7 +11,6 @@
 package org.jboss.tools.usage.preferences;
 
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.util.Map;
 
 import org.eclipse.core.runtime.Plugin;
@@ -24,45 +23,60 @@
  */
 public class GlobalUsageReportingSettings extends HttpResourceMap {
 
+	private static final String REPORT_ENABLEMENT_ENABLEDVALUE = "ENABLED"; //$NON-NLS-1$
+
 	private static final String REPORTING_ENABLEMENT_URL = "http://community.jboss.org/wiki/JBossToolsJBossDeveloperStudioUsageReportingEnablement"; //$NON-NLS-1$
 
-	public static final String KEY_REPORT_ENABLEMENT = "Usage Reporting is ";
-	public static final String KEY_DUMMY_VALUE = "Dummy Value is ";
-	public static final String KEY_INTEGER_VALUE = "Integer Value is ";
+	public static final String REPORT_ENABLEMENT_KEY = "Usage Reporting is "; //$NON-NLS-1$
+	private static final boolean REPORT_ENABLEMENT_DEFAULT = true;
 
+	public static final String DUMMY_VALUE_KEY = "Dummy Value is "; //$NON-NLS-1$
+	public static final String INTEGER_VALUE_KEY = "Integer Value is "; //$NON-NLS-1$
+
+	/* the delimiter that delimits the value */
 	private static final char VALUE_DELIMITER = '<';
 
-
 	public GlobalUsageReportingSettings(Plugin plugin) throws IOException {
 		super(REPORTING_ENABLEMENT_URL
 				, VALUE_DELIMITER
 				, plugin
-				, KEY_REPORT_ENABLEMENT
-				, KEY_DUMMY_VALUE
-				, KEY_INTEGER_VALUE);
+				, REPORT_ENABLEMENT_KEY
+				, DUMMY_VALUE_KEY
+				, INTEGER_VALUE_KEY);
 
 		this.plugin = plugin;
 		this.urlConnection = createURLConnection(REPORTING_ENABLEMENT_URL);
 	}
 
-	public boolean isEnabled() throws UnsupportedEncodingException, IOException {
-		Map<String, String> valueMap = getValueMap();
-		String isEnabled = valueMap.get(KEY_REPORT_ENABLEMENT);
-		return isEnabled != null && "ENABLED".equals(isEnabled.toUpperCase());
+	public boolean isEnabled() {
+		try {
+			Map<String, String> valueMap = getValueMap();
+			String isEnabled = valueMap.get(REPORT_ENABLEMENT_KEY);
+			return isEnabled != null && REPORT_ENABLEMENT_ENABLEDVALUE.equals(isEnabled.toUpperCase());
+		} catch (Exception e) {
+			return REPORT_ENABLEMENT_DEFAULT;
+		}
 	}
 
-	public String getStringValue() throws UnsupportedEncodingException, IOException {
-		Map<String, String> valueMap = getValueMap();
-		return valueMap.get(KEY_DUMMY_VALUE);
+	public String getStringValue() {
+		try {
+			Map<String, String> valueMap = getValueMap();
+			return valueMap.get(DUMMY_VALUE_KEY);
+		} catch (Exception e) {
+			return "";
+		}
 	}
 
-	public Integer getIntegerValue() throws UnsupportedEncodingException, IOException {
-		Map<String, String> valueMap = getValueMap();
-		String integerValue = valueMap.get(KEY_INTEGER_VALUE);
-		if(integerValue != null) {
-			return Integer.parseInt(integerValue);
-		} else {
-			return null;
+	public Integer getIntegerValue() {
+		Integer returnValue = null;
+		try {
+			Map<String, String> valueMap = getValueMap();
+			String integerValue = valueMap.get(INTEGER_VALUE_KEY);
+			if (integerValue != null) {
+				returnValue = Integer.parseInt(integerValue);
+			}
+		} catch (Exception e) {
 		}
+		return returnValue;
 	}
 }



More information about the jbosstools-commits mailing list