You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by sc...@apache.org on 2014/02/05 20:46:18 UTC
svn commit: r1564899 - in /wookie/trunk:
wookie-parser/java/src/main/java/org/apache/wookie/w3c/util/ wookie-server/
wookie-server/src/main/java/org/apache/wookie/beans/
wookie-server/src/main/java/org/apache/wookie/beans/jcr/
wookie-server/src/main/ja...
Author: scottbw
Date: Wed Feb 5 19:46:17 2014
New Revision: 1564899
URL: http://svn.apache.org/r1564899
Log:
refactored JPA code into wookie-jpa
Added:
wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/SharedContext.java
wookie/trunk/wookie-services/wookie-jpa/src/main/java/
wookie/trunk/wookie-services/wookie-jpa/src/main/java/org/
wookie/trunk/wookie-services/wookie-jpa/src/main/java/org/apache/
wookie/trunk/wookie-services/wookie-jpa/src/main/java/org/apache/wookie/
wookie/trunk/wookie-services/wookie-jpa/src/main/java/org/apache/wookie/beans/
wookie/trunk/wookie-services/wookie-jpa/src/main/java/org/apache/wookie/beans/jcr/
- copied from r1564870, wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/jcr/
wookie/trunk/wookie-services/wookie-jpa/src/main/java/org/apache/wookie/beans/jpa/
- copied from r1564870, wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/jpa/
wookie/trunk/wookie-services/wookie-jpa/src/main/java/org/apache/wookie/beans/util/
- copied from r1564870, wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/util/
wookie/trunk/wookie-services/wookie-spi/src/main/java/org/apache/wookie/beans/
- copied from r1564870, wookie/trunk/wookie-services/wookie-spi/src/main/java/org/apache/wookie/model/
wookie/trunk/wookie-services/wookie-spi/src/main/java/org/apache/wookie/beans/IBean.java
- copied unchanged from r1564870, wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/IBean.java
wookie/trunk/wookie-services/wookie-spi/src/main/java/org/apache/wookie/beans/IOAuthToken.java
- copied unchanged from r1564870, wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/IOAuthToken.java
wookie/trunk/wookie-services/wookie-spi/src/main/java/org/apache/wookie/beans/IParticipant.java
- copied unchanged from r1564870, wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/IParticipant.java
wookie/trunk/wookie-services/wookie-spi/src/main/java/org/apache/wookie/beans/IPreference.java
- copied unchanged from r1564870, wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/IPreference.java
wookie/trunk/wookie-services/wookie-spi/src/main/java/org/apache/wookie/beans/ISharedData.java
- copied unchanged from r1564870, wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/ISharedData.java
wookie/trunk/wookie-services/wookie-spi/src/main/java/org/apache/wookie/beans/IWidget.java
- copied unchanged from r1564879, wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/IWidget.java
wookie/trunk/wookie-services/wookie-spi/src/main/java/org/apache/wookie/beans/IWidgetInstance.java
- copied unchanged from r1564870, wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/IWidgetInstance.java
Removed:
wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/IBean.java
wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/IOAuthToken.java
wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/IParticipant.java
wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/IPreference.java
wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/ISharedData.java
wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/IWidget.java
wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/IWidgetInstance.java
wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/jcr/
wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/jpa/
wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/util/
wookie/trunk/wookie-services/wookie-spi/src/main/java/org/apache/wookie/model/
Modified:
wookie/trunk/wookie-parser/java/src/main/java/org/apache/wookie/w3c/util/FormattingUtils.java
wookie/trunk/wookie-server/pom.xml
wookie/trunk/wookie-services/wookie-jpa/pom.xml
wookie/trunk/wookie-services/wookie-jpa/src/main/java/org/apache/wookie/beans/util/PersistenceManagerFactory.java
Modified: wookie/trunk/wookie-parser/java/src/main/java/org/apache/wookie/w3c/util/FormattingUtils.java
URL: http://svn.apache.org/viewvc/wookie/trunk/wookie-parser/java/src/main/java/org/apache/wookie/w3c/util/FormattingUtils.java?rev=1564899&r1=1564898&r2=1564899&view=diff
==============================================================================
--- wookie/trunk/wookie-parser/java/src/main/java/org/apache/wookie/w3c/util/FormattingUtils.java (original)
+++ wookie/trunk/wookie-parser/java/src/main/java/org/apache/wookie/w3c/util/FormattingUtils.java Wed Feb 5 19:46:17 2014
@@ -109,7 +109,7 @@ public class FormattingUtils {
* @param value the value to modify
* @return a CSS i18n string
*/
- protected static String getFormatted(String dir, String value){
+ public static String getFormatted(String dir, String value){
// If the string has no embedded spans with dir attributes, and no set dir, just return the string
if ((dir == null || dir.equals("ltr") )&& !value.contains("dir=")) return value;
Modified: wookie/trunk/wookie-server/pom.xml
URL: http://svn.apache.org/viewvc/wookie/trunk/wookie-server/pom.xml?rev=1564899&r1=1564898&r2=1564899&view=diff
==============================================================================
--- wookie/trunk/wookie-server/pom.xml (original)
+++ wookie/trunk/wookie-server/pom.xml Wed Feb 5 19:46:17 2014
@@ -66,6 +66,12 @@
<groupId>org.apache.wookie</groupId>
<artifactId>wookie-jpa</artifactId>
<version>2.0.0-SNAPSHOT</version>
+ <classifier>classes</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.wookie</groupId>
+ <artifactId>wookie-jpa</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
<type>war</type>
</dependency>
@@ -110,12 +116,12 @@
<artifactId>commons-compress</artifactId>
<version>1.0</version>
<scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>commons-configuration</groupId>
- <artifactId>commons-configuration</artifactId>
- <version>1.7</version>
- <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ <version>1.7</version>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
@@ -196,12 +202,6 @@
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>org.apache.openjpa</groupId>
- <artifactId>openjpa-all</artifactId>
- <version>2.0.0</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>1.3</version>
@@ -231,12 +231,7 @@
<version>6.1.3</version>
<optional>true</optional>
</dependency>
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty-plus</artifactId>
- <version>6.1.3</version>
- <optional>true</optional>
- </dependency>
+
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-naming</artifactId>
@@ -256,12 +251,6 @@
<optional>true</optional>
</dependency>
<dependency>
- <groupId>commons-dbcp</groupId>
- <artifactId>commons-dbcp</artifactId>
- <version>1.2.2</version>
- <optional>true</optional>
- </dependency>
- <dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.4.2.0</version>
@@ -370,35 +359,7 @@
</container>
</configuration>
</plugin>
-
-
- <plugin>
- <groupId>org.apache.openjpa</groupId>
- <artifactId>openjpa-maven-plugin</artifactId>
- <version>2.2.1</version>
- <configuration>
- <includes>**/jpa/impl/*.class</includes>
- <addDefaultConstructor>true</addDefaultConstructor>
- <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
- </configuration>
- <executions>
- <execution>
- <id>enhancer</id>
- <phase>process-classes</phase>
- <goals>
- <goal>enhance</goal>
- </goals>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.apache.openjpa</groupId>
- <artifactId>openjpa</artifactId>
- <!-- set the version to be the same as the level in your runtime -->
- <version>2.2.1</version>
- </dependency>
- </dependencies>
- </plugin>
+
<!-- Include the context.xml from wookie-jpa -->
<plugin>
@@ -416,6 +377,7 @@
</overlays>
</configuration>
</plugin>
+
</plugins>
</build>
Added: wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/SharedContext.java
URL: http://svn.apache.org/viewvc/wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/SharedContext.java?rev=1564899&view=auto
==============================================================================
--- wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/SharedContext.java (added)
+++ wookie/trunk/wookie-server/src/main/java/org/apache/wookie/beans/SharedContext.java Wed Feb 5 19:46:17 2014
@@ -0,0 +1,332 @@
+/*
+ *
+ * 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.beans;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.wookie.beans.util.IPersistenceManager;
+import org.apache.wookie.beans.util.PersistenceManagerFactory;
+import org.apache.wookie.helpers.SharedDataHelper;
+
+/**
+ * Represents the shared context for a set of widget instances
+ * and the data objects that share that context (participants and data).
+ *
+ * Instances of this class are (currently) a "virtual" object rather than persisted,
+ * and are used to tie together the common objects of the shared context at
+ * a higher level of abstraction than specific data queries.
+ *
+ * In future this class could be used to reference other types of data associated
+ * with a shared context, for example to handle host/owner (see WOOKIE-66) or
+ * could allow us to have a storage model for shared data that is completely
+ * separate from the persistence model for the rest of Wookie, for example a
+ * tuple store or distributed keystore
+ */
+public class SharedContext {
+
+ private String sharedDataKey;
+ private IWidgetInstance widgetInstance;
+
+ public SharedContext(String sharedDataKey){
+ this.sharedDataKey = sharedDataKey;
+ }
+
+ public SharedContext(IWidgetInstance widgetInstance){
+ //
+ // Use the internal shared data key of the instance
+ //
+ this.sharedDataKey = SharedDataHelper.getInternalSharedDataKey(widgetInstance);
+ this.widgetInstance = widgetInstance;
+ }
+
+ /**
+ * get the shared data belonging to this shared context
+ * @return an array of SharedData instances, or null if no shared data exists
+ */
+ public ISharedData[] getSharedData(){
+ //
+ // Obtain a persistence manager and return the results of executing a query of SharedData objects matching the sharedDataKey
+ //
+ IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
+ return (ISharedData[]) persistenceManager.findByValue(ISharedData.class, "sharedDataKey", this.sharedDataKey);
+ }
+
+ /**
+ * Find a specific shared data object for a given Widget Instance and object key
+ * @param instance the widget instance
+ * @param key the key of the shared data object, i.e. the tuple key not the shared data key
+ * @return a SharedData object, or null if no matches are found
+ */
+ public ISharedData getSharedData(String key){
+
+ //
+ // Obtain a persistence manager and construct a query of SharedData objects matching the sharedDataKey and dkey
+ //
+ IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
+ HashMap<String, Object> params = new HashMap<String, Object>();
+ params.put("sharedDataKey", this.sharedDataKey);
+ params.put("dkey", key);
+
+ //
+ // Execute the query and obtain array of results
+ // We assert that there are never duplicates.
+ //
+ ISharedData[] results = (ISharedData[]) persistenceManager.findByValues(ISharedData.class, params);
+ assert(results.length <= 1);
+
+ //
+ // If the result contains a single item, return it, otherwise return null.
+ //
+ if (results.length != 0) return results[0];
+ return null;
+ }
+
+ /**
+ * Remove a single Shared Data Object
+ * @param name the name (key) of the data object
+ * @return true if a shared data object was located and deleted, false if no match was found
+ */
+ public boolean removeSharedData(String name){
+ //
+ // Find a matching item
+ //
+ ISharedData sharedData = this.getSharedData(name);
+
+ //
+ // If a match is found, delete it and return true;
+ // otherwise return false
+ //
+ if (sharedData == null) return false;
+ this.removeSharedData(sharedData);
+ return true;
+ }
+
+ /**
+ * Removes (deletes) the shared data object
+ * @param sharedData
+ */
+ private void removeSharedData(ISharedData sharedData){
+ IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
+ persistenceManager.delete(sharedData);
+ }
+
+ /**
+ * Creates a new shared data object in this shared context
+ * @param name
+ * @param value
+ */
+ private void addSharedData(String name, String value){
+ IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
+ ISharedData sharedData = persistenceManager.newInstance(ISharedData.class);
+ sharedData.setSharedDataKey(this.sharedDataKey);
+ sharedData.setDkey(name);
+ sharedData.setDvalue(value);
+ persistenceManager.save(sharedData);
+ }
+
+ /**
+ * Update a single Shared Data object
+ * @param name the name (key) of the data object
+ * @param value the value to set, or null to clear the entry
+ * @param append set to true to append the value to the current value
+ * @return true if the value was updated, false if a new object was created
+ */
+ public boolean updateSharedData(String name, String value, boolean append){
+ boolean found=false;
+ ISharedData sharedData = this.getSharedData(name);
+
+ //
+ // An existing object is found, so either update or delete
+ //
+ if (sharedData != null) {
+
+ //
+ // If the value is set to Null, remove the object
+ //
+ if(value==null || value.equalsIgnoreCase("null")) {
+ this.removeSharedData(sharedData);
+ } else {
+
+ //
+ // Either append the new value to the old, or overwrite it
+ //
+ if(append) {
+ sharedData.setDvalue(sharedData.getDvalue() + value);
+ } else {
+ sharedData.setDvalue(value);
+ }
+ }
+ found=true;
+ }
+
+ //
+ // No matching object exists, so create a new object
+ //
+ if(!found && value != null && !value.equalsIgnoreCase("null")){
+ addSharedData(name, value);
+ }
+ return found;
+ }
+
+ /**
+ * get the participants belonging to this shared context
+ * @return an arry of Participant instances, or null if there are no participants
+ */
+ public IParticipant[] getParticipants(){
+ IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
+ return persistenceManager.findByValue(IParticipant.class, "sharedDataKey", this.sharedDataKey);
+ }
+
+ /**
+ * Add a participant to a shared context
+ * @param participantId the id property of the participant to add
+ * @param participantDisplayName the display name property of the participant to add
+ * @param participantThumbnailUrl the thumbnail url property of the participant to add
+ * @return true if the participant was successfully added, otherwise false
+ */
+ public boolean addParticipant(String participantId, String participantDisplayName, String participantThumbnailUrl) {
+ return addParticipant(participantId, participantDisplayName, participantThumbnailUrl, null);
+ }
+
+ /**
+ * Add a participant to a shared context
+ * @param participantId the id property of the participant to add
+ * @param participantDisplayName the display name property of the participant to add
+ * @param participantThumbnailUrl the thumbnail url property of the participant to add
+ * @return true if the participant was successfully added, otherwise false
+ */
+ public boolean addParticipant(String participantId, String participantDisplayName, String participantThumbnailUrl, String role) {
+
+ //
+ // Does participant already exist?
+ //
+ IParticipant participant = this.getParticipant(participantId);
+ if (participant != null) return false;
+
+ //
+ // Add participant
+ //
+ IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
+ participant = persistenceManager.newInstance(IParticipant.class);
+ participant.setParticipantId(participantId);
+ participant.setParticipantDisplayName(participantDisplayName);
+ participant.setParticipantThumbnailUrl(participantThumbnailUrl);
+ participant.setRole(role);
+ participant.setSharedDataKey(this.sharedDataKey);
+ persistenceManager.save(participant);
+ return true;
+ }
+
+ /**
+ * Remove a participant from the shared context
+ * @param participant
+ */
+ public void removeParticipant(IParticipant participant){
+ IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
+ persistenceManager.delete(participant);
+ }
+
+ /**
+ * Removes a participant from a widget instance
+ * @param participantId the id property of the participant
+ * @return true if the participant is successfully removed, otherwise false
+ */
+ public boolean removeParticipant(String participantId) {
+
+ //
+ // Does participant exist?
+ //
+ IParticipant participant = this.getParticipant(participantId);
+ if (participant != null){
+
+ //
+ // Remove participant
+ //
+ removeParticipant(participant);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Get a participant by ID from this shared context
+ * @param participantId
+ * @return the participant, or null if there is no participant with the given id in the context
+ */
+ public IParticipant getParticipant(String participantId){
+ IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("sharedDataKey", this.sharedDataKey);//$NON-NLS-1$
+ map.put("participantId", participantId);//$NON-NLS-1$
+ IParticipant[] participants = persistenceManager.findByValues(IParticipant.class, map);
+ if (participants.length == 1) return participants[0];
+ return null;
+ }
+
+ /**
+ * Get the participant associated with the widget instance as the viewer
+ * @param widgetInstance
+ * @return the IParticipant representing the viewer, or null if no match is found
+ */
+ public IParticipant getViewer(IWidgetInstance widgetInstance){
+ IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("sharedDataKey", this.sharedDataKey);//$NON-NLS-1$
+ map.put("participantId", widgetInstance.getUserId());//$NON-NLS-1$
+ IParticipant [] participants = persistenceManager.findByValues(IParticipant.class, map);
+ if(participants != null && participants.length == 1) return participants[0];
+ return null;
+ }
+
+ /**
+ * Get the participant associated with the widget instance as the viewer
+ * @param widgetInstance
+ * @return the IParticipant representing the viewer, or null if no match is found
+ */
+ public IParticipant getViewer(){
+ IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("sharedDataKey", this.sharedDataKey);//$NON-NLS-1$
+ map.put("participantId", this.widgetInstance.getUserId());//$NON-NLS-1$
+ IParticipant [] participants = persistenceManager.findByValues(IParticipant.class, map);
+ if(participants != null && participants.length == 1) return participants[0];
+ return null;
+ }
+
+ /**
+ * Get the participant designated as the host of the shared context. Note that
+ * if there are multiple hosts, only the first is returned.
+ * @return a participant designated the host, or null if no participant is host
+ */
+ public IParticipant getHost(){
+ for (IParticipant participant : this.getParticipants()){
+ if (participant.getRole().equals(IParticipant.HOST_ROLE)) return participant;
+ }
+ return null;
+ }
+
+ public IParticipant[] getHosts(){
+ IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("sharedDataKey", this.sharedDataKey);//$NON-NLS-1$
+ map.put("role", IParticipant.HOST_ROLE); //$NON-NLS-1$
+ return persistenceManager.findByValues(IParticipant.class, map);
+ }
+}
Modified: wookie/trunk/wookie-services/wookie-jpa/pom.xml
URL: http://svn.apache.org/viewvc/wookie/trunk/wookie-services/wookie-jpa/pom.xml?rev=1564899&r1=1564898&r2=1564899&view=diff
==============================================================================
--- wookie/trunk/wookie-services/wookie-jpa/pom.xml (original)
+++ wookie/trunk/wookie-services/wookie-jpa/pom.xml Wed Feb 5 19:46:17 2014
@@ -40,6 +40,69 @@
<type>jar</type>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-all</artifactId>
+ <version>2.0.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.2.2</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ <version>1.7</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-plus</artifactId>
+ <version>6.1.3</version>
+ <optional>true</optional>
+ </dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-maven-plugin</artifactId>
+ <version>2.2.1</version>
+ <configuration>
+ <includes>**/jpa/impl/*.class</includes>
+ <addDefaultConstructor>true</addDefaultConstructor>
+ <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
+ </configuration>
+ <executions>
+ <execution>
+ <id>enhancer</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>enhance</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <!-- set the version to be the same as the level in your runtime -->
+ <version>2.2.1</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <attachClasses>true</attachClasses>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
Modified: wookie/trunk/wookie-services/wookie-jpa/src/main/java/org/apache/wookie/beans/util/PersistenceManagerFactory.java
URL: http://svn.apache.org/viewvc/wookie/trunk/wookie-services/wookie-jpa/src/main/java/org/apache/wookie/beans/util/PersistenceManagerFactory.java?rev=1564899&r1=1564870&r2=1564899&view=diff
==============================================================================
--- wookie/trunk/wookie-services/wookie-jpa/src/main/java/org/apache/wookie/beans/util/PersistenceManagerFactory.java (original)
+++ wookie/trunk/wookie-services/wookie-jpa/src/main/java/org/apache/wookie/beans/util/PersistenceManagerFactory.java Wed Feb 5 19:46:17 2014
@@ -23,7 +23,6 @@ import org.apache.wookie.w3c.IName;
import org.apache.wookie.w3c.IContent;
import org.apache.wookie.beans.IWidget;
import org.apache.wookie.w3c.IIcon;
-import org.apache.wookie.helpers.WidgetRuntimeHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -105,22 +104,41 @@ public class PersistenceManagerFactory
widgetDescription.setDescription("This widget is a placeholder for when no corresponding widget is found for a given type");
widget.getDescriptions().add(widgetDescription);
IContent widgetStartFile = persistenceManager.newInstance(IContent.class);
- widgetStartFile.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/deploy/notsupported/index.htm");
+
+ //
+ // I've had to remove this code as it created a reverse dependency on the runtime helper in wookie-server.
+ // However, we need to reinstate this functionality of not hard-coding the context path.
+ //
+ //widgetStartFile.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/deploy/notsupported/index.htm");
+ //widget.getContentList().add(widgetStartFile);
+ //IContent widgetBUStartFile = persistenceManager.newInstance(IContent.class);
+ //widgetBUStartFile.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/deploy/notsupported/locales/bu/index.htm");
+ //widgetBUStartFile.setLang("bu");
+ //widget.getContentList().add(widgetBUStartFile);
+ //IContent widgetFRStartFile = persistenceManager.newInstance(IContent.class);
+ //widgetFRStartFile.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/deploy/notsupported/locales/fr/index.htm");
+ //widgetFRStartFile.setLang("fr");
+ //widget.getContentList().add(widgetFRStartFile);
+ //IContent widgetENStartFile = persistenceManager.newInstance(IContent.class);
+ //widgetENStartFile.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/deploy/notsupported/locales/en/index.htm");
+
+
+ widgetStartFile.setSrc("/wookie/deploy/notsupported/index.htm");
widget.getContentList().add(widgetStartFile);
IContent widgetBUStartFile = persistenceManager.newInstance(IContent.class);
- widgetBUStartFile.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/deploy/notsupported/locales/bu/index.htm");
+ widgetBUStartFile.setSrc("/wookie/deploy/notsupported/locales/bu/index.htm");
widgetBUStartFile.setLang("bu");
widget.getContentList().add(widgetBUStartFile);
IContent widgetFRStartFile = persistenceManager.newInstance(IContent.class);
- widgetFRStartFile.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/deploy/notsupported/locales/fr/index.htm");
+ widgetFRStartFile.setSrc("/wookie/deploy/notsupported/locales/fr/index.htm");
widgetFRStartFile.setLang("fr");
widget.getContentList().add(widgetFRStartFile);
IContent widgetENStartFile = persistenceManager.newInstance(IContent.class);
- widgetENStartFile.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/deploy/notsupported/locales/en/index.htm");
+ widgetENStartFile.setSrc("/wookie/deploy/notsupported/locales/en/index.htm");
widgetENStartFile.setLang("en");
widget.getContentList().add(widgetENStartFile);
IIcon widgetIcon = persistenceManager.newInstance(IIcon.class);
- widgetIcon.setSrc(WidgetRuntimeHelper.getWebContextPath() + "/shared/images/defaultwidget.png");
+ widgetIcon.setSrc("/wookie/shared/images/defaultwidget.png");
widgetIcon.setHeight(80);
widgetIcon.setWidth(80);
widgetIcon.setLang("en");