You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by ps...@apache.org on 2011/11/10 13:42:36 UTC
svn commit: r1200304 - in /incubator/wookie/trunk:
parser/java/src/org/apache/wookie/w3c/ src/org/apache/wookie/ajaxmodel/
src/org/apache/wookie/beans/ src/org/apache/wookie/beans/util/
src/org/apache/wookie/controller/ src/org/apache/wookie/feature/ s...
Author: psharples
Date: Thu Nov 10 12:42:35 2011
New Revision: 1200304
URL: http://svn.apache.org/viewvc?rev=1200304&view=rev
Log:
Removed absolute /wookie paths in code. See WOOKIE-289.
Added:
incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetRuntimeHelper.java (with props)
Removed:
incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/IWidgetRuntimeHelper.java
Modified:
incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IW3CXMLConfiguration.java
incubator/wookie/trunk/src/org/apache/wookie/beans/IWidget.java
incubator/wookie/trunk/src/org/apache/wookie/beans/util/PersistenceManagerFactory.java
incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetInstancesController.java
incubator/wookie/trunk/src/org/apache/wookie/feature/Features.java
incubator/wookie/trunk/src/org/apache/wookie/feature/wave/WaveAPIImpl.java
incubator/wookie/trunk/src/org/apache/wookie/flatpack/FlatpackProcessor.java
incubator/wookie/trunk/src/org/apache/wookie/server/ContextListener.java
incubator/wookie/trunk/src/org/apache/wookie/util/gadgets/GadgetAdapter.java
incubator/wookie/trunk/src/org/apache/wookie/util/html/StartPageProcessor.java
Modified: incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IW3CXMLConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IW3CXMLConfiguration.java?rev=1200304&r1=1200303&r2=1200304&view=diff
==============================================================================
--- incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IW3CXMLConfiguration.java (original)
+++ incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/IW3CXMLConfiguration.java Thu Nov 10 12:42:35 2011
@@ -75,7 +75,6 @@ public interface IW3CXMLConfiguration {
// Other values used
public static final String DEFAULT_WIDGET_VERSION = "1.0";
public static final String UNKNOWN = "unknown";
- public static final String DEFAULT_ICON_PATH = "/wookie/shared/images/cog.gif";
public static final int DEFAULT_HEIGHT_SMALL = 32;
public static final int DEFAULT_WIDTH_SMALL = 32;
public static final int DEFAULT_HEIGHT_LARGE = 300;
Modified: incubator/wookie/trunk/src/org/apache/wookie/beans/IWidget.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/beans/IWidget.java?rev=1200304&r1=1200303&r2=1200304&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/beans/IWidget.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/beans/IWidget.java Thu Nov 10 12:42:35 2011
@@ -16,6 +16,7 @@ package org.apache.wookie.beans;
import java.util.Collection;
+import org.apache.wookie.helpers.WidgetRuntimeHelper;
import org.apache.wookie.util.WidgetFormattingUtils;
import org.apache.wookie.w3c.IW3CXMLConfiguration;
import org.apache.wookie.w3c.util.LocalizationUtils;
@@ -411,6 +412,7 @@ public interface IWidget extends ILocali
return ((startFile != null) ? startFile.getUrl() : null);
}
+
/**
* Get widget icon location for locale.
*
@@ -422,7 +424,7 @@ public interface IWidget extends ILocali
{
IWidgetIcon[] icons = widget.getWidgetIcons().toArray(new IWidgetIcon[widget.getWidgetIcons().size()]);
IWidgetIcon icon = (IWidgetIcon)LocalizationUtils.getLocalizedElement(icons, new String[]{locale}, widget.getDefaultLocale());
- return ((icon != null) ? icon.getSrc() : IW3CXMLConfiguration.DEFAULT_ICON_PATH);
+ return ((icon != null) ? icon.getSrc() : WidgetRuntimeHelper.DEFAULT_ICON_PATH);
}
}
}
Modified: incubator/wookie/trunk/src/org/apache/wookie/beans/util/PersistenceManagerFactory.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/beans/util/PersistenceManagerFactory.java?rev=1200304&r1=1200303&r2=1200304&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/beans/util/PersistenceManagerFactory.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/beans/util/PersistenceManagerFactory.java Thu Nov 10 12:42:35 2011
@@ -27,6 +27,7 @@ import org.apache.wookie.beans.IWidgetDe
import org.apache.wookie.beans.IWidgetIcon;
import org.apache.wookie.beans.IWidgetService;
import org.apache.wookie.beans.IWidgetType;
+import org.apache.wookie.helpers.WidgetRuntimeHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -105,25 +106,25 @@ public class PersistenceManagerFactory
widgetDescription.setContent("This widget is a placeholder for when no corresponding widget is found for a given type");
widget.getDescriptions().add(widgetDescription);
IStartFile widgetStartFile = persistenceManager.newInstance(IStartFile.class);
- widgetStartFile.setUrl("/wookie/wservices/notsupported/index.htm");
+ widgetStartFile.setUrl(WidgetRuntimeHelper.getWebContextPath() + "/wservices/notsupported/index.htm");
widget.getStartFiles().add(widgetStartFile);
IStartFile widgetBUStartFile = persistenceManager.newInstance(IStartFile.class);
- widgetBUStartFile.setUrl("/wookie/wservices/notsupported/locales/bu/index.htm");
+ widgetBUStartFile.setUrl(WidgetRuntimeHelper.getWebContextPath() + "/wservices/notsupported/locales/bu/index.htm");
widgetBUStartFile.setLang("bu");
widget.getStartFiles().add(widgetBUStartFile);
IStartFile widgetFRStartFile = persistenceManager.newInstance(IStartFile.class);
- widgetFRStartFile.setUrl("/wookie/wservices/notsupported/locales/fr/index.htm");
+ widgetFRStartFile.setUrl(WidgetRuntimeHelper.getWebContextPath() + "/wservices/notsupported/locales/fr/index.htm");
widgetFRStartFile.setLang("fr");
widget.getStartFiles().add(widgetFRStartFile);
IStartFile widgetENStartFile = persistenceManager.newInstance(IStartFile.class);
- widgetENStartFile.setUrl("/wookie/wservices/notsupported/locales/en/index.htm");
+ widgetENStartFile.setUrl(WidgetRuntimeHelper.getWebContextPath() + "/wservices/notsupported/locales/en/index.htm");
widgetENStartFile.setLang("en");
widget.getStartFiles().add(widgetENStartFile);
IWidgetType widgetType = persistenceManager.newInstance(IWidgetType.class);
widgetType.setWidgetContext("unsupported");
widget.getWidgetTypes().add(widgetType);
IWidgetIcon widgetIcon = persistenceManager.newInstance(IWidgetIcon.class);
- widgetIcon.setSrc("/wookie/shared/images/defaultwidget.png");
+ widgetIcon.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/shared/images/defaultwidget.png");
widgetIcon.setHeight(80);
widgetIcon.setWidth(80);
widgetIcon.setLang("en");
Modified: incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetInstancesController.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetInstancesController.java?rev=1200304&r1=1200303&r2=1200304&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetInstancesController.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetInstancesController.java Thu Nov 10 12:42:35 2011
@@ -44,6 +44,7 @@ import org.apache.wookie.helpers.Notifie
import org.apache.wookie.helpers.SharedDataHelper;
import org.apache.wookie.helpers.WidgetInstanceFactory;
import org.apache.wookie.helpers.WidgetInstanceHelper;
+import org.apache.wookie.helpers.WidgetRuntimeHelper;
import org.apache.wookie.server.LocaleHandler;
import org.apache.wookie.w3c.util.LocalizationUtils;
@@ -296,7 +297,7 @@ public class WidgetInstancesController e
if (!properties.getString("widget.proxy.hostname").trim().equals("")) serverName = properties.getString("widget.proxy.hostname"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if (!properties.getString("widget.proxy.port").trim().equals("")) serverPort = Integer.parseInt(properties.getString("widget.proxy.port")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
try {
- urlWidgetProxyServer = new URL(scheme,serverName,serverPort,properties.getString("widget.proxy.path"));
+ urlWidgetProxyServer = new URL(scheme, serverName, serverPort, WidgetRuntimeHelper.getWebContextPath() + properties.getString("widget.proxy.path"));
} catch (MalformedURLException e) {
// ignore errors
}
Modified: incubator/wookie/trunk/src/org/apache/wookie/feature/Features.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/feature/Features.java?rev=1200304&r1=1200303&r2=1200304&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/feature/Features.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/feature/Features.java Thu Nov 10 12:42:35 2011
@@ -23,6 +23,7 @@ import java.util.List;
import javax.servlet.ServletContext;
import org.apache.log4j.Logger;
+import org.apache.wookie.helpers.WidgetRuntimeHelper;
import org.apache.wookie.w3c.util.IRIValidator;
import org.jdom.Document;
import org.jdom.Element;
@@ -202,7 +203,12 @@ public class Features {
// and DWR-generated scripts.
//
if (!src.startsWith("/")){
- src = basePath + "/" + src;
+ if(src.startsWith("dwr/")){
+ src = WidgetRuntimeHelper.getWebContextPath() + "/" + src;
+ }
+ else{
+ src = basePath + "/" + src;
+ }
}
scripts[i] = src;
}
Modified: incubator/wookie/trunk/src/org/apache/wookie/feature/wave/WaveAPIImpl.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/feature/wave/WaveAPIImpl.java?rev=1200304&r1=1200303&r2=1200304&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/feature/wave/WaveAPIImpl.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/feature/wave/WaveAPIImpl.java Thu Nov 10 12:42:35 2011
@@ -29,6 +29,7 @@ import org.apache.wookie.beans.util.Pers
import org.apache.wookie.feature.IFeature;
import org.apache.wookie.helpers.Notifier;
import org.apache.wookie.helpers.ParticipantHelper;
+import org.apache.wookie.helpers.WidgetRuntimeHelper;
import org.apache.wookie.server.LocaleHandler;
import org.directwebremoting.WebContextFactory;
@@ -59,7 +60,8 @@ public class WaveAPIImpl implements IFea
}
public String[] scripts() {
- return new String[]{"/wookie/dwr/interface/WaveImpl.js", "/wookie/shared/js/wave.js"};
+ return new String[]{WidgetRuntimeHelper.getWebContextPath() + "/dwr/interface/WaveImpl.js",
+ WidgetRuntimeHelper.getWebContextPath() + "/shared/js/wave.js"};
}
public String[] stylesheets() {
Modified: incubator/wookie/trunk/src/org/apache/wookie/flatpack/FlatpackProcessor.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/flatpack/FlatpackProcessor.java?rev=1200304&r1=1200303&r2=1200304&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/flatpack/FlatpackProcessor.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/flatpack/FlatpackProcessor.java Thu Nov 10 12:42:35 2011
@@ -19,6 +19,7 @@ import java.io.FileWriter;
import org.apache.wookie.feature.Features;
import org.apache.wookie.feature.IFeature;
+import org.apache.wookie.helpers.WidgetRuntimeHelper;
import org.apache.wookie.util.html.HtmlCleaner;
import org.apache.wookie.util.html.IHtmlProcessor;
import org.apache.wookie.w3c.IContentEntity;
@@ -122,7 +123,7 @@ public class FlatpackProcessor implement
for (String script : feature.scripts()) {
// remove the "base" path
// FIXME this is fragile - consider replacing with a better solution
- script = script.replace("/wookie/features/", "");
+ script = script.replace(WidgetRuntimeHelper.getWebContextPath() + "/features/", "");
engine.injectScript(script);
}
}
@@ -139,7 +140,7 @@ public class FlatpackProcessor implement
for (String style : feature.stylesheets()) {
// remove the "base" path
// FIXME this is fragile - consider replacing with a better solution
- style = style.replace("/wookie/features/", "");
+ style = style.replace(WidgetRuntimeHelper.getWebContextPath() + "/features/", "");
engine.injectStylesheet(style);
}
}
Added: incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetRuntimeHelper.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetRuntimeHelper.java?rev=1200304&view=auto
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetRuntimeHelper.java (added)
+++ incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetRuntimeHelper.java Thu Nov 10 12:42:35 2011
@@ -0,0 +1,41 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wookie.helpers;
+/**
+ * Server utililies
+ */
+public class WidgetRuntimeHelper {
+
+ // should be overridden in contextlistener
+ private static String webContextPath = "/wookie";
+ public static String USE_PREFERENCE_INSTANCE_QUEUES = "widget.preferences.useinstancequeues";
+ public static String USE_SHAREDDATA_INSTANCE_QUEUES = "widget.shareddata.useinstancequeues";
+ public static String DWR_SET_PREFERENCE_CALL = getWebContextPath() + "/dwr/call/plaincall/WidgetImpl.setPreferenceForKey.dwr";
+ public static String DWR_SET_SHAREDDATA_CALL = getWebContextPath() + "/dwr/call/plaincall/WookieImpl.setSharedDataForKey.dwr";
+ public static String DWR_APPEND_SHAREDDATA_CALL = getWebContextPath() + "/dwr/call/plaincall/WookieImpl.appendSharedDataForKey.dwr";
+ // The default widget icon
+ public static String DEFAULT_ICON_PATH = getWebContextPath() + "/shared/images/cog.gif";
+ // The default Gadget icon
+ public static String DEFAULT_GADGET_ICON = getWebContextPath() + "/shared/images/defaultwidget.png";
+
+
+ public static String getWebContextPath() {
+ return webContextPath;
+ }
+
+ public static void setWebContextPath(String webContextPath) {
+ WidgetRuntimeHelper.webContextPath = webContextPath;
+ }
+
+}
Propchange: incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetRuntimeHelper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/wookie/trunk/src/org/apache/wookie/server/ContextListener.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/server/ContextListener.java?rev=1200304&r1=1200303&r2=1200304&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/server/ContextListener.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/server/ContextListener.java Thu Nov 10 12:42:35 2011
@@ -29,11 +29,11 @@ import org.apache.commons.configuration.
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.log4j.Logger;
import org.apache.wookie.Messages;
-import org.apache.wookie.ajaxmodel.IWidgetRuntimeHelper;
import org.apache.wookie.beans.util.IPersistenceManager;
import org.apache.wookie.beans.util.PersistenceManagerFactory;
import org.apache.wookie.feature.Features;
import org.apache.wookie.helpers.FlashMessage;
+import org.apache.wookie.helpers.WidgetRuntimeHelper;
import org.apache.wookie.helpers.WidgetFactory;
import org.apache.wookie.util.WgtWatcher;
import org.apache.wookie.util.WidgetFileUtils;
@@ -68,7 +68,7 @@ public class ContextListener implements
public void contextInitialized(ServletContextEvent event) {
try {
ServletContext context = event.getServletContext();
-
+ WidgetRuntimeHelper.setWebContextPath(context.getContextPath());
/*
* load the widgetserver.properties and local.widget.properties file
* and put it into this context as an attribute 'properties' available to all resources
@@ -82,8 +82,8 @@ public class ContextListener implements
context.setAttribute("properties", (Configuration) configuration);
// load these up now so we don't have to do it on every request(i.e. filter) in the future
- usePreferenceInstanceQueues = configuration.getBoolean(IWidgetRuntimeHelper.USE_PREFERENCE_INSTANCE_QUEUES);
- useSharedDataInstanceQueues = configuration.getBoolean(IWidgetRuntimeHelper.USE_SHAREDDATA_INSTANCE_QUEUES);
+ usePreferenceInstanceQueues = configuration.getBoolean(WidgetRuntimeHelper.USE_PREFERENCE_INSTANCE_QUEUES);
+ useSharedDataInstanceQueues = configuration.getBoolean(WidgetRuntimeHelper.USE_SHAREDDATA_INSTANCE_QUEUES);
/*
* Merge in system properties overrides
Modified: incubator/wookie/trunk/src/org/apache/wookie/util/gadgets/GadgetAdapter.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/util/gadgets/GadgetAdapter.java?rev=1200304&r1=1200303&r2=1200304&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/util/gadgets/GadgetAdapter.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/util/gadgets/GadgetAdapter.java Thu Nov 10 12:42:35 2011
@@ -17,6 +17,7 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.List;
+import org.apache.wookie.helpers.WidgetRuntimeHelper;
import org.apache.wookie.w3c.IAccessEntity;
import org.apache.wookie.w3c.IAuthorEntity;
import org.apache.wookie.w3c.IContentEntity;
@@ -54,11 +55,6 @@ public class GadgetAdapter implements W3
private ArrayList<IIconEntity> fIconsList;
private ArrayList<IContentEntity> fContentList;
- /**
- * The default Gadget icon
- */
- private static final String DEFAULT_ICON = "/wookie/shared/images/defaultwidget.png";
-
public GadgetAdapter(JSONObject gadget, String shindig) throws Exception {
if (gadget.has("errors")) throw new Exception("Invalid gadget - Shindig error");
if (!gadget.has("url")) throw new Exception("Invalid gadget - URL missing");
@@ -112,7 +108,7 @@ public class GadgetAdapter implements W3
// Icons
this.fIconsList = new ArrayList<IIconEntity>();
- String icon = getValue(gadget,"thumbnail", DEFAULT_ICON);
+ String icon = getValue(gadget,"thumbnail", WidgetRuntimeHelper.DEFAULT_GADGET_ICON);
IconEntity iconEntity = new IconEntity(icon,null,null);
this.fIconsList.add(iconEntity);
}
Modified: incubator/wookie/trunk/src/org/apache/wookie/util/html/StartPageProcessor.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/util/html/StartPageProcessor.java?rev=1200304&r1=1200303&r2=1200304&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/util/html/StartPageProcessor.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/util/html/StartPageProcessor.java Thu Nov 10 12:42:35 2011
@@ -19,6 +19,7 @@ import java.io.FileWriter;
import org.apache.wookie.feature.Features;
import org.apache.wookie.feature.IFeature;
+import org.apache.wookie.helpers.WidgetRuntimeHelper;
import org.apache.wookie.w3c.IContentEntity;
import org.apache.wookie.w3c.IFeatureEntity;
import org.apache.wookie.w3c.W3CWidget;
@@ -29,10 +30,10 @@ import org.apache.wookie.w3c.IStartPageP
*/
public class StartPageProcessor implements IStartPageProcessor {
- static final String DWR_UTIL_SRC_VALUE = "/wookie/dwr/util.js";
- static final String DWR_ENGINE_SRC_VALUE = "/wookie/dwr/engine.js";
- static final String WIDGET_IMPL_SRC_VALUE = "/wookie/dwr/interface/WidgetImpl.js";
- static final String WOOKIE_WRAPPER_SRC_VALUE = "/wookie/shared/js/wookie-wrapper.js";
+ static final String DWR_UTIL_SRC_VALUE = WidgetRuntimeHelper.getWebContextPath() + "/dwr/util.js";
+ static final String DWR_ENGINE_SRC_VALUE = WidgetRuntimeHelper.getWebContextPath() + "/dwr/engine.js";
+ static final String WIDGET_IMPL_SRC_VALUE = WidgetRuntimeHelper.getWebContextPath() + "/dwr/interface/WidgetImpl.js";
+ static final String WOOKIE_WRAPPER_SRC_VALUE = WidgetRuntimeHelper.getWebContextPath() + "/shared/js/wookie-wrapper.js";
/* (non-Javadoc)
* @see org.apache.wookie.util.html.IStartPageProcessor#processStartFile(java.io.File, org.apache.wookie.w3c.IManifestModel)