You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by ja...@apache.org on 2011/06/30 16:26:20 UTC

svn commit: r1141550 - in /incubator/rave/trunk/rave-portal/src: main/java/org/apache/rave/portal/util/ main/java/org/apache/rave/portal/web/controller/ main/java/org/apache/rave/portal/web/util/ main/java/org/apache/rave/util/ main/resources/ main/web...

Author: jasha
Date: Thu Jun 30 14:26:19 2011
New Revision: 1141550

URL: http://svn.apache.org/viewvc?rev=1141550&view=rev
Log:
RAVE-45 Portal host/ip configuration (Non-localhost support)

Added:
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util/OpenSocialEnvironment.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/util/OverridablePropertyPlaceholderConfigurer.java
    incubator/rave/trunk/rave-portal/src/main/resources/applicationContext-properties.xml
    incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/util/OverridablePropertyPlaceholderConfigurerTest.java
    incubator/rave/trunk/rave-portal/src/test/resources/applicationContext-test.xml
    incubator/rave/trunk/rave-portal/src/test/resources/portal-test.properties
Modified:
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/HomeController.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
    incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/applicationContext.xml
    incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp
    incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/web.xml

Added: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util/OpenSocialEnvironment.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util/OpenSocialEnvironment.java?rev=1141550&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util/OpenSocialEnvironment.java (added)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util/OpenSocialEnvironment.java Thu Jun 30 14:26:19 2011
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.rave.portal.util;
+
+/**
+ * Environment variables for OpenSocial calls from the portal (to Shindig)
+ */
+public class OpenSocialEnvironment {
+    /**
+     * Protocol for the opensocial engine (http, https)
+     */
+    private String engineProtocol;
+    /**
+     * Root location of the opensocial engine (localhost:8080, www.example.com)
+     */
+    private String engineRoot;
+    /**
+     * Path after the root for gadgets (gadgets)
+     */
+    private String engineGadgetPath;
+
+
+    public void setEngineProtocol(String engineProtocol) {
+        this.engineProtocol = engineProtocol;
+    }
+
+    public String getEngineProtocol() {
+        return engineProtocol;
+    }
+
+    public void setEngineRoot(String engineRoot) {
+        this.engineRoot = engineRoot;
+    }
+
+    public String getEngineRoot() {
+        return engineRoot;
+    }
+
+    public void setEngineGadgetPath(String engineGadgetPath) {
+        this.engineGadgetPath = engineGadgetPath;
+    }
+
+    public String getEngineGadgetPath() {
+        return engineGadgetPath;
+    }
+}

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/HomeController.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/HomeController.java?rev=1141550&r1=1141549&r2=1141550&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/HomeController.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/controller/HomeController.java Thu Jun 30 14:26:19 2011
@@ -22,6 +22,7 @@ import org.apache.rave.portal.model.Page
 import org.apache.rave.portal.model.User;
 import org.apache.rave.portal.service.PageService;
 import org.apache.rave.portal.service.UserService;
+import org.apache.rave.portal.util.OpenSocialEnvironment;
 import org.apache.rave.portal.web.util.ModelKeys;
 import org.apache.rave.portal.web.util.ViewNames;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -42,6 +43,9 @@ public class HomeController {
     private UserService userService;
 
     @Autowired
+    private OpenSocialEnvironment openSocialEnvironment;
+
+    @Autowired
     public HomeController(PageService pageService, UserService userService) {
         this.pageService = pageService;
         this.userService = userService;
@@ -52,6 +56,7 @@ public class HomeController {
         User user = userService.getAuthenticatedUser();
         List<Page> pages = pageService.getAllPages(user.getUserId());
         model.addAttribute(ModelKeys.PAGES, pages);
+        model.addAttribute(ModelKeys.OPENSOCIAL_ENVIRONMENT, openSocialEnvironment);
         return ViewNames.HOME;
     }
 }
\ No newline at end of file

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java?rev=1141550&r1=1141549&r2=1141550&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java (original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java Thu Jun 30 14:26:19 2011
@@ -24,9 +24,10 @@ package org.apache.rave.portal.web.util;
  */
 public class ModelKeys {
     private ModelKeys() {}
-    public final static String PAGES = "pages"; // a list of pages available for the current user
-    public final static String ERROR_MESSAGE = "errorMessage"; // an error message to be reported to the user
+    public static final String PAGES = "pages"; // a list of pages available for the current user
+    public static final String ERROR_MESSAGE = "errorMessage"; // an error message to be reported to the user
     public static final String WIDGETS = "widgets"; // a list of widget objects
     public static final String WIDGET = "widget";
     public static final String REFERRING_PAGE_ID = "referringPageId";
+    public static final String OPENSOCIAL_ENVIRONMENT = "openSocialEnv";
 }
\ No newline at end of file

Added: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/util/OverridablePropertyPlaceholderConfigurer.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/util/OverridablePropertyPlaceholderConfigurer.java?rev=1141550&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/util/OverridablePropertyPlaceholderConfigurer.java (added)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/util/OverridablePropertyPlaceholderConfigurer.java Thu Jun 30 14:26:19 2011
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.rave.util;
+
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.core.io.Resource;
+
+/**
+ * Reads property from the default location unless a system property {@literal portal.override.properties} is set
+ */
+public class OverridablePropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer {
+
+    private static final String PORTAL_OVERRIDE_PROPERTIES = "portal.override.properties";
+    private static final String CLASSPATH = "classpath:";
+
+    @Override
+    public void setLocation(Resource location) {
+        Resource locationResource;
+        final String overrideProperty = System.getProperty(PORTAL_OVERRIDE_PROPERTIES);
+        
+        if (StringUtils.isBlank(overrideProperty)) {
+            locationResource = location;
+        } else if (overrideProperty.startsWith(CLASSPATH)) {
+            locationResource = new ClassPathResource(overrideProperty.substring(CLASSPATH.length()));
+        } else {
+            locationResource = new FileSystemResource(overrideProperty);
+        }
+        super.setLocation(locationResource);
+    }
+
+}

Added: incubator/rave/trunk/rave-portal/src/main/resources/applicationContext-properties.xml
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/resources/applicationContext-properties.xml?rev=1141550&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/resources/applicationContext-properties.xml (added)
+++ incubator/rave/trunk/rave-portal/src/main/resources/applicationContext-properties.xml Thu Jun 30 14:26:19 2011
@@ -0,0 +1,29 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+    <!-- make the the portal.properties props available to autowire injectors, location of the properties can
+     be overridden by setting a system property "portal.override.properties" -->
+    <bean id="portalPropertyPlaceholder" class="org.apache.rave.util.OverridablePropertyPlaceholderConfigurer">
+        <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
+        <property name="location" value="classpath:portal.properties"/>
+    </bean>
+</beans>

Modified: incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/applicationContext.xml
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/applicationContext.xml?rev=1141550&r1=1141549&r2=1141550&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/applicationContext.xml (original)
+++ incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/applicationContext.xml Thu Jun 30 14:26:19 2011
@@ -34,9 +34,6 @@
         http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd
         http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
 
-    <!-- make the the portal.properties props available to autowire injectors -->
-    <context:property-placeholder location="classpath:portal.properties"/>
-
     <context:component-scan base-package="org.apache.rave" annotation-config="true" />
 
     <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
@@ -92,4 +89,11 @@
             </list>
         </property>
     </bean>
+
+    <!-- Environment variables for opensocial calls from the portal -->
+    <bean id="openSocialEnvironment" class="org.apache.rave.portal.util.OpenSocialEnvironment">
+        <property name="engineProtocol" value="${portal.opensocial_engine.protocol}"/>
+        <property name="engineRoot" value="${portal.opensocial_engine.root}"/>
+        <property name="engineGadgetPath" value="${portal.opensocial_engine.gadget_path}"/>
+    </bean>
 </beans>
\ No newline at end of file

Modified: incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp?rev=1141550&r1=1141549&r2=1141550&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp (original)
+++ incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp Thu Jun 30 14:26:19 2011
@@ -25,11 +25,9 @@
 <%@ taglib prefix="portal" uri="http://www.apache.org/rave/tags" %>
 <%@ taglib tagdir="/WEB-INF/tags" prefix="rave"%>
 <jsp:useBean id="pages" type="java.util.List<org.apache.rave.portal.model.Page>" scope="request"/>
-<fmt:setBundle basename="portal" var="portal"/>
-<fmt:message bundle="${portal}" key="portal.opensocial_engine.protocol" var="osProtocol"/>
-<fmt:message bundle="${portal}" key="portal.opensocial_engine.root" var="osRoot"/>
-<fmt:message bundle="${portal}" key="portal.opensocial_engine.gadget_path" var="osGadget"/>
-<c:set var="opensocial_engine_url" value="${osProtocol}://${osRoot}${osGadget}"/>
+<jsp:useBean id="openSocialEnv" scope="request" type="org.apache.rave.portal.util.OpenSocialEnvironment"/>
+
+<c:set var="opensocial_engine_url" value="${openSocialEnv.engineProtocol}://${openSocialEnv.engineRoot}${openSocialEnv.engineGadgetPath}"/>
 
 <rave:rave_generic_page>
 <c:set var="defaultPage" value="${pages[0]}"/>
@@ -49,7 +47,7 @@
 <h1>Hello ${defaultPage.owner.username}, welcome to Rave!</h1>
 <script>
     //Define the global widgets variable
-	 //This array will be populated by RegionWidgetRender providers.
+     //This array will be populated by RegionWidgetRender providers.
     var widgets = [];
 </script>
 <c:forEach var="region" items="${defaultPage.regions}">
@@ -64,42 +62,42 @@
         <div class="widget-title-bar" >
             <span id="widget-${regionWidget.id}-title">${regionWidget.widget.title}</span>
             
-				<!-- These are toolbar buttons -->
-				<span id="widget-${regionWidget.id}-toolbar" style="float:right;">
-				  <button id="widget-${regionWidget.id}-max" 
-							 class="widget-toolbar-btn"
-							 onclick="rave.toolbarMaximize(this,{myRegionWidgetId:${regionWidget.id},myRegionId:${region.id},myPageId:${defaultPage.id}})">
-				  </button>
-				  <button id="widget-${regionWidget.id}-remove" 
-							 class="widget-toolbar-btn"
-							 onclick="rave.toolbarDelete(this,{myRegionWidgetId:${regionWidget.id},myRegionId:${region.id},myPageId:${defaultPage.id}})">
-				  </button>
-				  <script>
-					 //This decorates the toolbar buttons.  As currently written,
-					 //it needs to be in the forEach loop.
-					 $("#widget-${regionWidget.id}-max").button({
-					 text: false,
-					 icons: {
-					 primary: "ui-icon-arrow-4-diag"
-					 }
-					 });
-
-					 $("#widget-${regionWidget.id}-remove").button({
-					 text: false,
-					 icons: {
-					 primary: "ui-icon-close"
-					 }
-					 });
-					 rave.mapGadgetToRegion("${regionWidget.id}", "${region.id}");
-				  </script>
+                <!-- These are toolbar buttons -->
+                <span id="widget-${regionWidget.id}-toolbar" style="float:right;">
+                  <button id="widget-${regionWidget.id}-max" 
+                             class="widget-toolbar-btn"
+                             onclick="rave.toolbarMaximize(this,{myRegionWidgetId:${regionWidget.id},myRegionId:${region.id},myPageId:${defaultPage.id}})">
+                  </button>
+                  <button id="widget-${regionWidget.id}-remove" 
+                             class="widget-toolbar-btn"
+                             onclick="rave.toolbarDelete(this,{myRegionWidgetId:${regionWidget.id},myRegionId:${region.id},myPageId:${defaultPage.id}})">
+                  </button>
+                  <script>
+                     //This decorates the toolbar buttons.  As currently written,
+                     //it needs to be in the forEach loop.
+                     $("#widget-${regionWidget.id}-max").button({
+                     text: false,
+                     icons: {
+                     primary: "ui-icon-arrow-4-diag"
+                     }
+                     });
+
+                     $("#widget-${regionWidget.id}-remove").button({
+                     text: false,
+                     icons: {
+                     primary: "ui-icon-close"
+                     }
+                     });
+                     rave.mapGadgetToRegion("${regionWidget.id}", "${region.id}");
+                  </script>
 
-				</span>
-		  </div>
+                </span>
+          </div>
         <div class="widget" id="widget-${regionWidget.id}-body">
-			 <!-- 
-					Among other things, the render-widget tag will populate the widgets[] array.  
-					See the markup text in OpenSocialWidgetRenderer.java, for example.
-			 -->
+             <!-- 
+                    Among other things, the render-widget tag will populate the widgets[] array.  
+                    See the markup text in OpenSocialWidgetRenderer.java, for example.
+             -->
             <portal:render-widget regionWidget="${regionWidget}" />
         </div>
     </div>

Modified: incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/web.xml?rev=1141550&r1=1141549&r2=1141550&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/web.xml (original)
+++ incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/web.xml Thu Jun 30 14:26:19 2011
@@ -32,6 +32,7 @@
         <param-name>contextConfigLocation</param-name>
         <param-value>
             /WEB-INF/dataContext.xml
+            classpath:applicationContext-properties.xml
             /WEB-INF/applicationContext.xml
             /WEB-INF/applicationContext-security.xml
         </param-value>

Added: incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/util/OverridablePropertyPlaceholderConfigurerTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/util/OverridablePropertyPlaceholderConfigurerTest.java?rev=1141550&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/util/OverridablePropertyPlaceholderConfigurerTest.java (added)
+++ incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/util/OverridablePropertyPlaceholderConfigurerTest.java Thu Jun 30 14:26:19 2011
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.rave.util;
+
+import org.junit.Test;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Test for {@link OverridablePropertyPlaceholderConfigurer}
+ */
+public class OverridablePropertyPlaceholderConfigurerTest {
+    
+    @Test
+    public void testSetLocation() throws Exception {
+        System.setProperty("portal.override.properties", "classpath:portal-test.properties");
+        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext-test.xml","applicationContext-properties.xml");
+        final StringBuffer testBean = (StringBuffer) context.getBean("testBean");
+        assertEquals("Dummy value", testBean.toString());
+
+    }
+}

Added: incubator/rave/trunk/rave-portal/src/test/resources/applicationContext-test.xml
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/resources/applicationContext-test.xml?rev=1141550&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/resources/applicationContext-test.xml (added)
+++ incubator/rave/trunk/rave-portal/src/test/resources/applicationContext-test.xml Thu Jun 30 14:26:19 2011
@@ -0,0 +1,27 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+  -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+    <!-- make the the portal.properties props available to autowire injectors -->
+    <bean id="testBean" class="java.lang.StringBuffer">
+        <constructor-arg value="${dummy.key}"/>
+    </bean>
+</beans>

Added: incubator/rave/trunk/rave-portal/src/test/resources/portal-test.properties
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/resources/portal-test.properties?rev=1141550&view=auto
==============================================================================
--- incubator/rave/trunk/rave-portal/src/test/resources/portal-test.properties (added)
+++ incubator/rave/trunk/rave-portal/src/test/resources/portal-test.properties Thu Jun 30 14:26:19 2011
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+#
+
+dummy.key=Dummy value
+portal.opensocial_engine.root=127.0.0.1:8080



Re: svn commit: r1141550 - in /incubator/rave/trunk/rave-portal/src: main/java/org/apache/rave/portal/util/ main/java/org/apache/rave/portal/web/controller/ main/java/org/apache/rave/portal/web/util/ main/java/org/apache/rave/util/ main/resources/ main...

Posted by "Franklin, Matthew B." <mf...@mitre.org>.
On 6/30/11 10:26 AM, "jasha@apache.org" <ja...@apache.org> wrote:

>Author: jasha
>Date: Thu Jun 30 14:26:19 2011
>New Revision: 1141550
>
>URL: http://svn.apache.org/viewvc?rev=1141550&view=rev
>Log:
>RAVE-45 Portal host/ip configuration (Non-localhost support)
>
>Added:
>
>incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util
>/OpenSocialEnvironment.java

I just noticed that this got placed in the org.apache.rave.portal.util.
If we want to continue down the path of having a modular widget provider
model, I would recommend not adding provider specific implementations to
the org.apache.rave.x packages.  I would recommend moving it to
org.apache.rave.opensocial.x and creating either a tag that renders all
the widget provider specific script includes, or start looking at a
lifecycle that we can hook in the widget providers to do the same.  This
would leave our view implementations generic and not tied to a particular
set of widget providers.


>
>incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/util/Overri
>dablePropertyPlaceholderConfigurer.java
>
>incubator/rave/trunk/rave-portal/src/main/resources/applicationContext-pro
>perties.xml
>
>incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/util/Overri
>dablePropertyPlaceholderConfigurerTest.java
>
>incubator/rave/trunk/rave-portal/src/test/resources/applicationContext-tes
>t.xml
>
>incubator/rave/trunk/rave-portal/src/test/resources/portal-test.properties
>Modified:
>
>incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/
>controller/HomeController.java
>
>incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/
>util/ModelKeys.java
>
>incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/applicationContex
>t.xml
>
>incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp
>    incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/web.xml
>
>Added:
>incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util
>/OpenSocialEnvironment.java
>URL:
>http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/jav
>a/org/apache/rave/portal/util/OpenSocialEnvironment.java?rev=1141550&view=
>auto
>==========================================================================
>====
>---
>incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util
>/OpenSocialEnvironment.java (added)
>+++
>incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/util
>/OpenSocialEnvironment.java Thu Jun 30 14:26:19 2011
>@@ -0,0 +1,63 @@
>+/*
>+ * Licensed to the Apache Software Foundation (ASF) under one
>+ * or more contributor license agreements.  See the NOTICE file
>+ * distributed with this work for additional information
>+ * regarding copyright ownership.  The ASF licenses this file
>+ * to you 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.rave.portal.util;
>+
>+/**
>+ * Environment variables for OpenSocial calls from the portal (to
>Shindig)
>+ */
>+public class OpenSocialEnvironment {
>+    /**
>+     * Protocol for the opensocial engine (http, https)
>+     */
>+    private String engineProtocol;
>+    /**
>+     * Root location of the opensocial engine (localhost:8080,
>www.example.com)
>+     */
>+    private String engineRoot;
>+    /**
>+     * Path after the root for gadgets (gadgets)
>+     */
>+    private String engineGadgetPath;
>+
>+
>+    public void setEngineProtocol(String engineProtocol) {
>+        this.engineProtocol = engineProtocol;
>+    }
>+
>+    public String getEngineProtocol() {
>+        return engineProtocol;
>+    }
>+
>+    public void setEngineRoot(String engineRoot) {
>+        this.engineRoot = engineRoot;
>+    }
>+
>+    public String getEngineRoot() {
>+        return engineRoot;
>+    }
>+
>+    public void setEngineGadgetPath(String engineGadgetPath) {
>+        this.engineGadgetPath = engineGadgetPath;
>+    }
>+
>+    public String getEngineGadgetPath() {
>+        return engineGadgetPath;
>+    }
>+}
>
>Modified:
>incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/
>controller/HomeController.java
>URL:
>http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/jav
>a/org/apache/rave/portal/web/controller/HomeController.java?rev=1141550&r1
>=1141549&r2=1141550&view=diff
>==========================================================================
>====
>---
>incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/
>controller/HomeController.java (original)
>+++
>incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/
>controller/HomeController.java Thu Jun 30 14:26:19 2011
>@@ -22,6 +22,7 @@ import org.apache.rave.portal.model.Page
> import org.apache.rave.portal.model.User;
> import org.apache.rave.portal.service.PageService;
> import org.apache.rave.portal.service.UserService;
>+import org.apache.rave.portal.util.OpenSocialEnvironment;
> import org.apache.rave.portal.web.util.ModelKeys;
> import org.apache.rave.portal.web.util.ViewNames;
> import org.springframework.beans.factory.annotation.Autowired;
>@@ -42,6 +43,9 @@ public class HomeController {
>     private UserService userService;
>
>     @Autowired
>+    private OpenSocialEnvironment openSocialEnvironment;
>+
>+    @Autowired
>     public HomeController(PageService pageService, UserService
>userService) {
>         this.pageService = pageService;
>         this.userService = userService;
>@@ -52,6 +56,7 @@ public class HomeController {
>         User user = userService.getAuthenticatedUser();
>         List<Page> pages = pageService.getAllPages(user.getUserId());
>         model.addAttribute(ModelKeys.PAGES, pages);
>+        model.addAttribute(ModelKeys.OPENSOCIAL_ENVIRONMENT,
>openSocialEnvironment);
>         return ViewNames.HOME;
>     }
> }
>\ No newline at end of file
>
>Modified:
>incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/
>util/ModelKeys.java
>URL:
>http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/jav
>a/org/apache/rave/portal/web/util/ModelKeys.java?rev=1141550&r1=1141549&r2
>=1141550&view=diff
>==========================================================================
>====
>---
>incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/
>util/ModelKeys.java (original)
>+++
>incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/web/
>util/ModelKeys.java Thu Jun 30 14:26:19 2011
>@@ -24,9 +24,10 @@ package org.apache.rave.portal.web.util;
>  */
> public class ModelKeys {
>     private ModelKeys() {}
>-    public final static String PAGES = "pages"; // a list of pages
>available for the current user
>-    public final static String ERROR_MESSAGE = "errorMessage"; // an
>error message to be reported to the user
>+    public static final String PAGES = "pages"; // a list of pages
>available for the current user
>+    public static final String ERROR_MESSAGE = "errorMessage"; // an
>error message to be reported to the user
>     public static final String WIDGETS = "widgets"; // a list of widget
>objects
>     public static final String WIDGET = "widget";
>     public static final String REFERRING_PAGE_ID = "referringPageId";
>+    public static final String OPENSOCIAL_ENVIRONMENT = "openSocialEnv";
> }
>\ No newline at end of file
>
>Added:
>incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/util/Overri
>dablePropertyPlaceholderConfigurer.java
>URL:
>http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/jav
>a/org/apache/rave/util/OverridablePropertyPlaceholderConfigurer.java?rev=1
>141550&view=auto
>==========================================================================
>====
>---
>incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/util/Overri
>dablePropertyPlaceholderConfigurer.java (added)
>+++
>incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/util/Overri
>dablePropertyPlaceholderConfigurer.java Thu Jun 30 14:26:19 2011
>@@ -0,0 +1,51 @@
>+/*
>+ * Licensed to the Apache Software Foundation (ASF) under one
>+ * or more contributor license agreements.  See the NOTICE file
>+ * distributed with this work for additional information
>+ * regarding copyright ownership.  The ASF licenses this file
>+ * to you 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.rave.util;
>+
>+import org.apache.commons.lang.StringUtils;
>+import
>org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
>+import org.springframework.core.io.ClassPathResource;
>+import org.springframework.core.io.FileSystemResource;
>+import org.springframework.core.io.Resource;
>+
>+/**
>+ * Reads property from the default location unless a system property
>{@literal portal.override.properties} is set
>+ */
>+public class OverridablePropertyPlaceholderConfigurer extends
>PropertyPlaceholderConfigurer {
>+
>+    private static final String PORTAL_OVERRIDE_PROPERTIES =
>"portal.override.properties";
>+    private static final String CLASSPATH = "classpath:";
>+
>+    @Override
>+    public void setLocation(Resource location) {
>+        Resource locationResource;
>+        final String overrideProperty =
>System.getProperty(PORTAL_OVERRIDE_PROPERTIES);
>+
>+        if (StringUtils.isBlank(overrideProperty)) {
>+            locationResource = location;
>+        } else if (overrideProperty.startsWith(CLASSPATH)) {
>+            locationResource = new
>ClassPathResource(overrideProperty.substring(CLASSPATH.length()));
>+        } else {
>+            locationResource = new FileSystemResource(overrideProperty);
>+        }
>+        super.setLocation(locationResource);
>+    }
>+
>+}
>
>Added:
>incubator/rave/trunk/rave-portal/src/main/resources/applicationContext-pro
>perties.xml
>URL:
>http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/res
>ources/applicationContext-properties.xml?rev=1141550&view=auto
>==========================================================================
>====
>---
>incubator/rave/trunk/rave-portal/src/main/resources/applicationContext-pro
>perties.xml (added)
>+++
>incubator/rave/trunk/rave-portal/src/main/resources/applicationContext-pro
>perties.xml Thu Jun 30 14:26:19 2011
>@@ -0,0 +1,29 @@
>+<!--
>+  Licensed to the Apache Software Foundation (ASF) under one
>+  or more contributor license agreements.  See the NOTICE file
>+  distributed with this work for additional information
>+  regarding copyright ownership.  The ASF licenses this file
>+  to you 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.
>+  -->
>+<beans xmlns="http://www.springframework.org/schema/beans"
>+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>+       xsi:schemaLocation="http://www.springframework.org/schema/beans
>http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
>+
>+    <!-- make the the portal.properties props available to autowire
>injectors, location of the properties can
>+     be overridden by setting a system property
>"portal.override.properties" -->
>+    <bean id="portalPropertyPlaceholder"
>class="org.apache.rave.util.OverridablePropertyPlaceholderConfigurer">
>+        <property name="systemPropertiesModeName"
>value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
>+        <property name="location" value="classpath:portal.properties"/>
>+    </bean>
>+</beans>
>
>Modified:
>incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/applicationContex
>t.xml
>URL:
>http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/web
>app/WEB-INF/applicationContext.xml?rev=1141550&r1=1141549&r2=1141550&view=
>diff
>==========================================================================
>====
>---
>incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/applicationContex
>t.xml (original)
>+++
>incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/applicationContex
>t.xml Thu Jun 30 14:26:19 2011
>@@ -34,9 +34,6 @@
>         http://www.springframework.org/schema/oxm
>http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd
>         http://www.springframework.org/schema/util
>http://www.springframework.org/schema/util/spring-util-3.0.xsd">
>
>-    <!-- make the the portal.properties props available to autowire
>injectors -->
>-    <context:property-placeholder
>location="classpath:portal.properties"/>
>-
>     <context:component-scan base-package="org.apache.rave"
>annotation-config="true" />
>
>     <bean id="transactionManager"
>class="org.springframework.orm.jpa.JpaTransactionManager">
>@@ -92,4 +89,11 @@
>             </list>
>         </property>
>     </bean>
>+
>+    <!-- Environment variables for opensocial calls from the portal -->
>+    <bean id="openSocialEnvironment"
>class="org.apache.rave.portal.util.OpenSocialEnvironment">
>+        <property name="engineProtocol"
>value="${portal.opensocial_engine.protocol}"/>
>+        <property name="engineRoot"
>value="${portal.opensocial_engine.root}"/>
>+        <property name="engineGadgetPath"
>value="${portal.opensocial_engine.gadget_path}"/>
>+    </bean>
> </beans>
>\ No newline at end of file
>
>Modified:
>incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp
>URL:
>http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/web
>app/WEB-INF/views/home.jsp?rev=1141550&r1=1141549&r2=1141550&view=diff
>==========================================================================
>====
>---
>incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp
>(original)
>+++
>incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/views/home.jsp
>Thu Jun 30 14:26:19 2011
>@@ -25,11 +25,9 @@
> <%@ taglib prefix="portal" uri="http://www.apache.org/rave/tags" %>
> <%@ taglib tagdir="/WEB-INF/tags" prefix="rave"%>
> <jsp:useBean id="pages"
>type="java.util.List<org.apache.rave.portal.model.Page>" scope="request"/>
>-<fmt:setBundle basename="portal" var="portal"/>
>-<fmt:message bundle="${portal}" key="portal.opensocial_engine.protocol"
>var="osProtocol"/>
>-<fmt:message bundle="${portal}" key="portal.opensocial_engine.root"
>var="osRoot"/>
>-<fmt:message bundle="${portal}"
>key="portal.opensocial_engine.gadget_path" var="osGadget"/>
>-<c:set var="opensocial_engine_url"
>value="${osProtocol}://${osRoot}${osGadget}"/>
>+<jsp:useBean id="openSocialEnv" scope="request"
>type="org.apache.rave.portal.util.OpenSocialEnvironment"/>
>+
>+<c:set var="opensocial_engine_url"
>value="${openSocialEnv.engineProtocol}://${openSocialEnv.engineRoot}${open
>SocialEnv.engineGadgetPath}"/>
>
> <rave:rave_generic_page>
> <c:set var="defaultPage" value="${pages[0]}"/>
>@@ -49,7 +47,7 @@
> <h1>Hello ${defaultPage.owner.username}, welcome to Rave!</h1>
> <script>
>     //Define the global widgets variable
>-        //This array will be populated by RegionWidgetRender providers.
>+     //This array will be populated by RegionWidgetRender providers.
>     var widgets = [];
> </script>
> <c:forEach var="region" items="${defaultPage.regions}">
>@@ -64,42 +62,42 @@
>         <div class="widget-title-bar" >
>             <span
>id="widget-${regionWidget.id}-title">${regionWidget.widget.title}</span>
>
>-                               <!-- These are toolbar buttons -->
>-                               <span
>id="widget-${regionWidget.id}-toolbar" style="float:right;">
>-                                 <button
>id="widget-${regionWidget.id}-max"
>-
>class="widget-toolbar-btn"
>-
>onclick="rave.toolbarMaximize(this,{myRegionWidgetId:${regionWidget.id},my
>RegionId:${region.id},myPageId:${defaultPage.id}})">
>-                                 </button>
>-                                 <button
>id="widget-${regionWidget.id}-remove"
>-
>class="widget-toolbar-btn"
>-
>onclick="rave.toolbarDelete(this,{myRegionWidgetId:${regionWidget.id},myRe
>gionId:${region.id},myPageId:${defaultPage.id}})">
>-                                 </button>
>-                                 <script>
>-                                        //This decorates the toolbar
>buttons.  As currently written,
>-                                        //it needs to be in the forEach
>loop.
>-
>$("#widget-${regionWidget.id}-max").button({
>-                                        text: false,
>-                                        icons: {
>-                                        primary: "ui-icon-arrow-4-diag"
>-                                        }
>-                                        });
>-
>-
>$("#widget-${regionWidget.id}-remove").button({
>-                                        text: false,
>-                                        icons: {
>-                                        primary: "ui-icon-close"
>-                                        }
>-                                        });
>-
>rave.mapGadgetToRegion("${regionWidget.id}", "${region.id}");
>-                                 </script>
>+                <!-- These are toolbar buttons -->
>+                <span id="widget-${regionWidget.id}-toolbar"
>style="float:right;">
>+                  <button id="widget-${regionWidget.id}-max"
>+                             class="widget-toolbar-btn"
>+
>onclick="rave.toolbarMaximize(this,{myRegionWidgetId:${regionWidget.id},my
>RegionId:${region.id},myPageId:${defaultPage.id}})">
>+                  </button>
>+                  <button id="widget-${regionWidget.id}-remove"
>+                             class="widget-toolbar-btn"
>+
>onclick="rave.toolbarDelete(this,{myRegionWidgetId:${regionWidget.id},myRe
>gionId:${region.id},myPageId:${defaultPage.id}})">
>+                  </button>
>+                  <script>
>+                     //This decorates the toolbar buttons.  As currently
>written,
>+                     //it needs to be in the forEach loop.
>+                     $("#widget-${regionWidget.id}-max").button({
>+                     text: false,
>+                     icons: {
>+                     primary: "ui-icon-arrow-4-diag"
>+                     }
>+                     });
>+
>+                     $("#widget-${regionWidget.id}-remove").button({
>+                     text: false,
>+                     icons: {
>+                     primary: "ui-icon-close"
>+                     }
>+                     });
>+                     rave.mapGadgetToRegion("${regionWidget.id}",
>"${region.id}");
>+                  </script>
>
>-                               </span>
>-                 </div>
>+                </span>
>+          </div>
>         <div class="widget" id="widget-${regionWidget.id}-body">
>-                        <!--
>-                                       Among other things, the
>render-widget tag will populate the widgets[] array.
>-                                       See the markup text in
>OpenSocialWidgetRenderer.java, for example.
>-                        -->
>+             <!--
>+                    Among other things, the render-widget tag will
>populate the widgets[] array.
>+                    See the markup text in
>OpenSocialWidgetRenderer.java, for example.
>+             -->
>             <portal:render-widget regionWidget="${regionWidget}" />
>         </div>
>     </div>
>
>Modified: incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/web.xml
>URL:
>http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/web
>app/WEB-INF/web.xml?rev=1141550&r1=1141549&r2=1141550&view=diff
>==========================================================================
>====
>--- incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/web.xml
>(original)
>+++ incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/web.xml Thu
>Jun 30 14:26:19 2011
>@@ -32,6 +32,7 @@
>         <param-name>contextConfigLocation</param-name>
>         <param-value>
>             /WEB-INF/dataContext.xml
>+            classpath:applicationContext-properties.xml
>             /WEB-INF/applicationContext.xml
>             /WEB-INF/applicationContext-security.xml
>         </param-value>
>
>Added:
>incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/util/Overri
>dablePropertyPlaceholderConfigurerTest.java
>URL:
>http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/jav
>a/org/apache/rave/util/OverridablePropertyPlaceholderConfigurerTest.java?r
>ev=1141550&view=auto
>==========================================================================
>====
>---
>incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/util/Overri
>dablePropertyPlaceholderConfigurerTest.java (added)
>+++
>incubator/rave/trunk/rave-portal/src/test/java/org/apache/rave/util/Overri
>dablePropertyPlaceholderConfigurerTest.java Thu Jun 30 14:26:19 2011
>@@ -0,0 +1,40 @@
>+/*
>+ * Licensed to the Apache Software Foundation (ASF) under one
>+ * or more contributor license agreements.  See the NOTICE file
>+ * distributed with this work for additional information
>+ * regarding copyright ownership.  The ASF licenses this file
>+ * to you 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.rave.util;
>+
>+import org.junit.Test;
>+import
>org.springframework.context.support.ClassPathXmlApplicationContext;
>+
>+import static org.junit.Assert.assertEquals;
>+
>+/**
>+ * Test for {@link OverridablePropertyPlaceholderConfigurer}
>+ */
>+public class OverridablePropertyPlaceholderConfigurerTest {
>+
>+    @Test
>+    public void testSetLocation() throws Exception {
>+        System.setProperty("portal.override.properties",
>"classpath:portal-test.properties");
>+        ClassPathXmlApplicationContext context = new
>ClassPathXmlApplicationContext("applicationContext-test.xml","applicationC
>ontext-properties.xml");
>+        final StringBuffer testBean = (StringBuffer)
>context.getBean("testBean");
>+        assertEquals("Dummy value", testBean.toString());
>+
>+    }
>+}
>
>Added:
>incubator/rave/trunk/rave-portal/src/test/resources/applicationContext-tes
>t.xml
>URL:
>http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/res
>ources/applicationContext-test.xml?rev=1141550&view=auto
>==========================================================================
>====
>---
>incubator/rave/trunk/rave-portal/src/test/resources/applicationContext-tes
>t.xml (added)
>+++
>incubator/rave/trunk/rave-portal/src/test/resources/applicationContext-tes
>t.xml Thu Jun 30 14:26:19 2011
>@@ -0,0 +1,27 @@
>+<!--
>+  Licensed to the Apache Software Foundation (ASF) under one
>+  or more contributor license agreements.  See the NOTICE file
>+  distributed with this work for additional information
>+  regarding copyright ownership.  The ASF licenses this file
>+  to you 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.
>+  -->
>+<beans xmlns="http://www.springframework.org/schema/beans"
>+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>+       xsi:schemaLocation="http://www.springframework.org/schema/beans
>http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
>+
>+    <!-- make the the portal.properties props available to autowire
>injectors -->
>+    <bean id="testBean" class="java.lang.StringBuffer">
>+        <constructor-arg value="${dummy.key}"/>
>+    </bean>
>+</beans>
>
>Added:
>incubator/rave/trunk/rave-portal/src/test/resources/portal-test.properties
>URL:
>http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/test/res
>ources/portal-test.properties?rev=1141550&view=auto
>==========================================================================
>====
>---
>incubator/rave/trunk/rave-portal/src/test/resources/portal-test.properties
> (added)
>+++
>incubator/rave/trunk/rave-portal/src/test/resources/portal-test.properties
> Thu Jun 30 14:26:19 2011
>@@ -0,0 +1,21 @@
>+#
>+# Licensed to the Apache Software Foundation (ASF) under one
>+# or more contributor license agreements.  See the NOTICE file
>+# distributed with this work for additional information
>+# regarding copyright ownership.  The ASF licenses this file
>+# to you 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.
>+#
>+
>+dummy.key=Dummy value
>+portal.opensocial_engine.root=127.0.0.1:8080
>
>