Permalink
Browse files

Version 2.0.3 - added error message if not licensed appropriately

  • Loading branch information...
1 parent e3ed5d4 commit bb9dfe1dbb191437423e66770a8c895561349e19 sappling committed Feb 9, 2012
View
@@ -9,7 +9,7 @@ info {
name = 'Weather'
description = 'Periodically imports weather data from a selectable weather service into one or more locations '+
'for use in views and logic programming.'
- version = '2.0.2' // Pre-release '+new Date().format('yyyy/MM/dd kk:mm:ss')
+ version = '2.0.3' // Pre-release '+new Date().format('yyyy/MM/dd kk:mm:ss')
vendor = 'ALC Labs'
}
@@ -0,0 +1,16 @@
+package com.controlj.addon.weather;
+
+import com.controlj.green.addonsupport.LicensedFeatures;
+
+/**
+ *
+ */
+public class Licensing {
+ private static final boolean licensed = LicensedFeatures.hasFeature(LicensedFeatures.FeaturePackage.Enterprise);
+
+ public static boolean isLicensed()
+ {
+ return licensed;
+ }
+
+}
@@ -25,6 +25,7 @@
import com.controlj.addon.weather.config.ConfigDataFactory;
import com.controlj.addon.weather.config.WeatherConfigEntry;
import com.controlj.addon.weather.util.Logging;
+import com.controlj.green.addonsupport.LicensedFeatures;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
@@ -51,6 +52,9 @@
*/
//@Override
public synchronized void contextInitialized(ServletContextEvent sce) {
+ if (!Licensing.isLicensed()) {
+ return;
+ }
ref.set(this);
scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
@@ -22,6 +22,8 @@
package com.controlj.addon.weather.servlets;
+import com.controlj.addon.weather.Licensing;
+import com.controlj.addon.weather.ScheduledWeatherLookup;
import com.controlj.addon.weather.WeatherLookup;
import com.controlj.addon.weather.config.ConfigData;
import com.controlj.addon.weather.config.ConfigDataFactory;
@@ -105,24 +107,29 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws S
}
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- ConfigData configData = getConfigData(req);
ResponseWriter writer = new ResponseWriter(resp);
-
- String action = req.getParameter(ACTION_PARAM_NAME);
- if (ACTION_INIT.equals(action)) {
- retrieveData(configData, writer);
- retrieveUI(configData, writer);
- } else if (ACTION_UPDATE.equals(action)) {
- retrieveData(configData, writer);
- } else if (ACTION_SHOWDATA.equals(action)) {
- retrieveData(configData, writer);
- showData(configData, writer, req);
- } else if (ACTION_UI.equals(action)) {
- uiAction(configData, writer, req);
+ if (!Licensing.isLicensed()) {
+ writer.putString("error","ERROR: This add-on requires the Enterprise license option.");
} else {
- String message = "Unknown action \"" + action + "\" specified for controller";
- writer.addError(message);
- Logging.println("ERROR:" + message);
+
+ ConfigData configData = getConfigData(req);
+
+ String action = req.getParameter(ACTION_PARAM_NAME);
+ if (ACTION_INIT.equals(action)) {
+ retrieveData(configData, writer);
+ retrieveUI(configData, writer);
+ } else if (ACTION_UPDATE.equals(action)) {
+ retrieveData(configData, writer);
+ } else if (ACTION_SHOWDATA.equals(action)) {
+ retrieveData(configData, writer);
+ showData(configData, writer, req);
+ } else if (ACTION_UI.equals(action)) {
+ uiAction(configData, writer, req);
+ } else {
+ String message = "Unknown action \"" + action + "\" specified for controller";
+ writer.addError(message);
+ Logging.println("ERROR:" + message);
+ }
}
writer.write();
}
@@ -207,6 +207,11 @@ function handleResultData(data) {
Adds the parts of the UI contributed by the WeatherServiceUI
*/
function handleUIResults(data) {
+ if (data.error) { // currently just used for licensing error
+ $("#errortext").text(data.error);
+ $("#error").css("display","block")
+ return;
+ }
$("#adddialog").html(data.adddialog)
$("#serviceconfig").html(data.serviceconfig)

0 comments on commit bb9dfe1

Please sign in to comment.