You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2007/03/09 02:21:50 UTC

svn commit: r516252 - in /ofbiz/trunk/applications/content: servicedef/services_content.xml src/org/ofbiz/content/content/ContentMapFacade.java

Author: jaz
Date: Thu Mar  8 17:21:49 2007
New Revision: 516252

URL: http://svn.apache.org/viewvc?view=rev&rev=516252
Log:
fixed bug in update content (could not update due to non-optional fields) added data resource info to ContentMapFacade

Modified:
    ofbiz/trunk/applications/content/servicedef/services_content.xml
    ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentMapFacade.java

Modified: ofbiz/trunk/applications/content/servicedef/services_content.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/servicedef/services_content.xml?view=diff&rev=516252&r1=516251&r2=516252
==============================================================================
--- ofbiz/trunk/applications/content/servicedef/services_content.xml (original)
+++ ofbiz/trunk/applications/content/servicedef/services_content.xml Thu Mar  8 17:21:49 2007
@@ -107,7 +107,7 @@
         <description>Update a Content</description>
         <permission-service service-name="genericContentPermission" main-action="UPDATE"/>
         <implements service="genericContentPermission" optional="true"/>
-        <implements service="updateContentAssoc"/>
+        <implements service="updateContentAssoc" optional="true"/>
         <auto-attributes entity-name="Content" include="pk" mode="INOUT" optional="false"/>
         <auto-attributes entity-name="Content" include="nonpk" mode="IN" optional="true"/>
         <!-- TODO: the following fields are depricated; but will not be removed until all services and callers are updated -->

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentMapFacade.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentMapFacade.java?view=diff&rev=516252&r1=516251&r2=516252
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentMapFacade.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentMapFacade.java Thu Mar  8 17:21:49 2007
@@ -27,6 +27,7 @@
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
+import org.ofbiz.content.data.DataResourceWorker;
 
 import java.util.*;
 import java.io.IOException;
@@ -52,6 +53,7 @@
     protected boolean isTop = false;
 
     // internal objects
+    private DataResource dataResource;
     private SubContent subContent;
     private MetaData metaData;
     private Content content;
@@ -87,6 +89,7 @@
     }
 
     private void init() {
+        this.dataResource = new DataResource();
         this.subContent = new SubContent();
         this.metaData = new MetaData();
         this.content = new Content();
@@ -162,6 +165,11 @@
 
         }
 
+        // data (resource) object
+        if ("data".equals(name)) {
+            return dataResource;   
+        }
+
         // subcontent list of ordered subcontent
         if ("subcontent_all".equals(name)) {
             List subContent = FastList.newInstance();
@@ -308,9 +316,12 @@
                 Debug.logWarning("Key parameters must be a string", module);
                 return null;
             }
-            String name = (String) key;
+            String name = (String) key;            
+            if (name.toLowerCase().startsWith("id_")) {
+                name = name.substring(3);
+            }
 
-            // key is the mapKey            
+            // key is the mapKey
             List subs = null;
             try {
                 subs = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentId, "mapKey", name), UtilMisc.toList("-fromDate"));
@@ -343,6 +354,42 @@
                 Debug.logError(e, module);
             }
             return metaData;
+        }
+    }
+
+    class DataResource extends AbstractInfo {
+        public Object get(Object key) {
+            if (!(key instanceof String)) {
+                Debug.logWarning("Key parameters must be a string", module);
+                return null;
+            }
+            String name = (String) key;
+
+            // get the data resource value object
+            if ("fields".equals(name)) {
+                GenericValue dr = null;
+                try {
+                    dr = value.getRelatedOne("DataResource");
+                } catch (GenericEntityException e) {
+                    Debug.logError(e, module);
+                }
+                return dr;
+            }
+
+            // render just the dataresource
+            if ("render".equals(name)) {
+                try {
+                    return DataResourceWorker.renderDataResourceAsText(delegator, value.getString("dataResourceId"), context, locale, mimeType, cache);
+                } catch (GeneralException e) {
+                    Debug.logError(e, module);
+                    return e.toString();
+                } catch (IOException e) {
+                    Debug.logError(e, module);
+                    return e.toString();
+                }
+            }
+
+            return null;
         }
     }
 }