Author: byersa
Date: Tue Jan 23 20:49:50 2007
New Revision: 499256
URL: http://svn.apache.org/viewvc?view=rev&rev=499256
Log:
Changes to ContentManagementServices.persistContentAndAssoc to comply with
change of subcontent "direction".
Some changes to that service def. Since there were service defs in there for
BlogServices.java/xml, those were included too.
Added:
ofbiz/trunk/applications/content/script/org/ofbiz/content/blog/
ofbiz/trunk/applications/content/script/org/ofbiz/content/blog/BlogServices.xml
ofbiz/trunk/applications/content/src/org/ofbiz/content/blog/
ofbiz/trunk/applications/content/src/org/ofbiz/content/blog/BlogServices.java
Modified:
ofbiz/trunk/applications/content/servicedef/services.xml
ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java
Added:
ofbiz/trunk/applications/content/script/org/ofbiz/content/blog/BlogServices.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/script/org/ofbiz/content/blog/BlogServices.xml?view=auto&rev=499256
==============================================================================
---
ofbiz/trunk/applications/content/script/org/ofbiz/content/blog/BlogServices.xml
(added)
+++
ofbiz/trunk/applications/content/script/org/ofbiz/content/blog/BlogServices.xml
Tue Jan 23 20:49:50 2007
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright 2001-2006 The Apache Software Foundation
+
+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.
+-->
+<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/simple-methods.xsd">
+ <simple-method method-name="getOwnedOrPublishedBlogEntries"
short-description="Get blog entries that the user owns or are published">
+ <log level="info" message="parameters: ${parameters}"/>
+ <entity-condition entity-name="ContentAssocViewTo" use-cache="false"
list-name="unfilteredList" >
+ <condition-list combine="and">
+ <condition-expr field-name="contentIdStart" operator="equals"
env-name="parameters.contentId" />
+ <condition-expr field-name="caContentAssocTypeId"
operator="equals" value="PUBLISH_LINK" />
+ <condition-expr field-name="caThruDate" operator="equals"
value=""/>
+ </condition-list>
+ <order-by field-name="caFromDate DESC"/>
+ </entity-condition>
+ <log level="info" message="unfilteredList: ${unfilteredList}"/>
+ <set field="mapIn.targetOperationList[]" value="CONTENT_VIEW"/>
+ <set field="mapIn.targetOperationList[]" value="CONTENT_UPDATE"/>
+ <set field="blogList[]"/>
+ <iterate entry-name="view" list-name="unfilteredList">
+ <make-value entity-name="Content" value-name="content"/>
+ <set-nonpk-fields value-name="content" map-name="view"/>
+ <set-pk-fields value-name="content" map-name="view"/>
+ <set field="mapIn.currentContent" from-field="content"/>
+ <log level="info" message="mapIn: ${mapIn}"/>
+ <call-service service-name="checkContentPermission"
in-map-name="mapIn">
+ <result-to-field result-name="permissionStatus"
field-name="permissionStatus"/>
+ </call-service>
+ <log level="info" message="permissionStatus: ${permissionStatus}"/>
+ <if-compare operator="equals" field-name="permissionStatus"
value="granted">
+ <set field="blogList[]" from-field="view" />
+ </if-compare>
+ </iterate>
+ <log level="info" message="blogList: ${blogList}"/>
+ <field-to-result field-name="blogList" result-name="blogList"/>
+ </simple-method>
+</simple-methods>
Modified: ofbiz/trunk/applications/content/servicedef/services.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/servicedef/services.xml?view=diff&rev=499256&r1=499255&r2=499256
==============================================================================
--- ofbiz/trunk/applications/content/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/content/servicedef/services.xml Tue Jan 23
20:49:50 2007
@@ -863,18 +863,14 @@
<exclude field-name="contentAssocTypeId"/>
<exclude field-name="sequenceNum"/>
</auto-attributes>
- <auto-attributes entity-name="ContentAssocDataResourceViewFrom"
include="all" mode="IN" optional="true">
+ <auto-attributes entity-name="ContentAssocDataResourceViewTo"
include="all" mode="IN" optional="true">
</auto-attributes>
<attribute mode="INOUT" entity-name="Content" name="contentId"
optional="true" type="String"/>
<attribute mode="INOUT" entity-name="DataResource"
name="dataResourceId" optional="true" type="String"/>
- <attribute mode="INOUT" entity-name="ContentAssoc" name="contentIdTo"
optional="true" type="String"/>
- <attribute mode="INOUT" entity-name="ContentAssoc"
name="contentIdFrom" optional="true" type="String"/>
- <attribute mode="INOUT" entity-name="ContentAssoc"
name="contentAssocTypeId" optional="true" type="String"/>
- <attribute mode="INOUT" entity-name="ContentAssoc" name="fromDate"
optional="true" type="Timestamp"/>
- <attribute mode="INOUT" entity-name="ContentAssoc" name="sequenceNum"
optional="true" type="Long"/>
<attribute mode="INOUT" entity-name="DataResource"
name="drDataResourceId" optional="true" type="String"/>
<attribute mode="INOUT" name="caContentIdTo" optional="true"
type="String"/>
+ <attribute mode="INOUT" name="caContentId" optional="true"
type="String"/>
<attribute mode="INOUT" name="caContentAssocTypeId" optional="true"
type="String"/>
<attribute mode="INOUT" name="caFromDate" optional="true"
type="Timestamp"/>
<attribute mode="INOUT" name="caSequenceNum" optional="true"
type="Long"/>
@@ -1487,5 +1483,25 @@
<attribute name="rootDir" type="String" mode="IN" optional="true"/>
<attribute name="locale" type="java.util.Locale" mode="IN"
optional="true"/>
<attribute name="outByteWrapper"
type="org.ofbiz.entity.util.ByteWrapper" mode="OUT" optional="false"/>
+ </service>
+ <!-- blog services -->
+ <service name="persistBlogAll" engine="java"
location="org.ofbiz.content.blog.BlogServices" invoke="persistBlogAll"
+ auth="true" transaction-timeout="72000">
+ <implements service="persistContentAndAssoc"/>
+ <attribute type="String" mode="IN" name="summaryData" optional="true"/>
+ <attribute type="String" mode="IN" name="mainData" optional="true"/>
+ <attribute type="String" mode="IN" name="drMimeTypeId_TEXT"
optional="true"/>
+ <attribute type="String" mode="IN" name="drMimeTypeId_IMAGE"
optional="true"/>
+ <attribute type="String" mode="IN" name="templateId" optional="true"/>
+ <attribute type="String" mode="INOUT" name="textContentId"
optional="true"/>
+ <attribute type="String" mode="INOUT" name="imageContentId"
optional="true"/>
+ <attribute type="String" mode="INOUT" name="textDataResourceId"
optional="true"/>
+ <attribute type="String" mode="INOUT" name="imageDataResourceId"
optional="true"/>
+ </service>
+ <service name="getOwnedOrPublishedBlogEntries" engine="simple"
location="org/ofbiz/content/blog/BlogServices.xml"
invoke="getOwnedOrPublishedBlogEntries"
+ auth="true" transaction-timeout="72000">
+ <attribute type="String" mode="IN" name="contentId" optional="false"/>
+ <attribute mode="IN" name="userLogin" optional="false"
type="GenericValue"/>
+ <attribute mode="OUT" name="blogList" optional="true" type="List"/>
</service>
</services>
Modified:
ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java?view=diff&rev=499256&r1=499255&r2=499256
==============================================================================
---
ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java
(original)
+++
ofbiz/trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java
Tue Jan 23 20:49:50 2007
@@ -156,6 +156,8 @@
* This service tries to handle DataResource and ContentAssoc fields with
and
* without "dr" and "ca" prefixes.
* Assumes binary data is always in field, "imageData".
+ *
+ * This service does not accept straight ContentAssoc parameters. They
must be prefaced with "ca" + cap first letter
*/
public static Map persistContentAndAssoc(DispatchContext dctx, Map
context) throws GenericServiceException {
GenericDelegator delegator = dctx.getDelegator();
@@ -170,7 +172,8 @@
// If "deactivateExisting" is set, other Contents that are tied to the
same
// contentIdTo will be deactivated (thruDate set to now)
- boolean deactivateExisting = UtilValidate.isNotEmpty((String)
context.get("deactivateExisting"));
+ String deactivateString = (String) context.get("deactivateExisting");
+ boolean deactivateExisting =
"true".equalsIgnoreCase(deactivateString);
if (Debug.infoOn()) Debug.logInfo("in persist... mapKey(0):" + mapKey,
null);
@@ -210,8 +213,6 @@
if (Debug.infoOn()) Debug.logInfo("in persist... dataResourceId(0):" +
dataResourceId, null);
GenericValue contentAssoc = delegator.makeValue("ContentAssoc", null);
- contentAssoc.setPKFields(context);
- contentAssoc.setNonPKFields(context);
contentAssoc.setAllFields(context, false, "ca", null);
context.putAll(contentAssoc);
@@ -223,11 +224,11 @@
Map results = ServiceUtil.returnSuccess();
results.put("contentId", content.get("contentId"));
results.put("dataResourceId", dataResource.get("dataResourceId"));
- results.put("contentIdTo", contentAssoc.get("contentIdTo"));
- results.put("fromDate", contentAssoc.get("fromDate"));
- results.put("contentAssocTypeId",
contentAssoc.get("contentAssocTypeId"));
+ results.put("drDataResourceId", dataResource.get("dataResourceId"));
+ results.put("caContentAssocTypeId",
contentAssoc.get("contentAssocTypeId"));
results.put("drDataResourceId", dataResource.get("dataResourceId"));
results.put("caContentIdTo", contentAssoc.get("contentIdTo"));
+ results.put("caContentId", contentAssoc.get("contentId"));
results.put("caFromDate", contentAssoc.get("fromDate"));
results.put("caContentAssocTypeId",
contentAssoc.get("contentAssocTypeId"));
@@ -324,15 +325,17 @@
}
results.put("contentId", contentId);
context.put("contentId", contentId);
- context.put("caContentId", contentId);
- contentAssoc.put("contentId", contentId);
+ context.put("caContentIdTo", contentId);
+ contentAssoc.put("contentIdTo", contentId);
// Add ContentPurposes if this is a create operation
if (contentId != null && !contentExists) {
try {
if (contentPurposeList != null) {
- for (int i=0; i < contentPurposeList.size(); i++) {
- String contentPurposeTypeId =
(String)contentPurposeList.get(i);
+ HashSet contentPurposeSet = new
HashSet(contentPurposeList);
+ Iterator iter = contentPurposeSet.iterator();
+ while (iter.hasNext()) {
+ String contentPurposeTypeId = (String)iter.next();
GenericValue contentPurpose =
delegator.makeValue("ContentPurpose",
UtilMisc.toMap("contentId", contentId,
"contentPurposeTypeId",
contentPurposeTypeId) );
@@ -384,20 +387,21 @@
if (ServiceUtil.isError(thisResult) ||
ServiceUtil.isFailure(thisResult) || UtilValidate.isNotEmpty(errMsg)) {
return ServiceUtil.returnError(errMsg);
}
- results.put("contentIdTo", thisResult.get("contentIdTo"));
- results.put("contentIdFrom",
thisResult.get("contentIdFrom"));
- //results.put("contentId",
thisResult.get("contentIdFrom"));
- results.put("contentAssocTypeId",
thisResult.get("contentAssocTypeId"));
- results.put("fromDate", thisResult.get("fromDate"));
- results.put("sequenceNum", thisResult.get("sequenceNum"));
+// results.put("contentIdTo",
thisResult.get("contentIdTo"));
+// results.put("contentIdFrom",
thisResult.get("contentIdFrom"));
+// //results.put("contentId",
thisResult.get("contentIdFrom"));
+// results.put("contentAssocTypeId",
thisResult.get("contentAssocTypeId"));
+// results.put("fromDate", thisResult.get("fromDate"));
+// results.put("sequenceNum",
thisResult.get("sequenceNum"));
results.put("caContentIdTo",
thisResult.get("contentIdTo"));
+ results.put("caContentId",
thisResult.get("contentIdFrom"));
results.put("caContentAssocTypeId",
thisResult.get("contentAssocTypeId"));
results.put("caFromDate", thisResult.get("fromDate"));
results.put("caSequenceNum",
thisResult.get("sequenceNum"));
} else {
if (deactivateExisting) {
-
contentAssoc.put("thruDate",UtilDateTime.nowTimestamp());
+
contentAssoc.put("thruDate",UtilDateTime.nowTimestamp());
}
ModelService contentAssocModel =
dispatcher.getDispatchContext().getModelService("updateContentAssoc");
Map ctx = contentAssocModel.makeValid(contentAssoc, "IN");
@@ -546,7 +550,7 @@
result = persistDataResourceAndDataMethod(dctx, context);
}
else {
- return ServiceUtil.returnError("no access to upload image");
+ return ServiceUtil.returnError("no access to upload image");
}
} catch (GenericServiceException e) {
return ServiceUtil.returnError(e.getMessage());
@@ -1695,7 +1699,7 @@
}
if (UtilValidate.isNotEmpty(oldDataResourceId)) {
try {
- dataResource = delegator.findByPrimaryKey("DataResource",
UtilMisc.toMap("dataResourceId", oldDataResourceId));
+ dataResource = delegator.findByPrimaryKey("DataResource",
UtilMisc.toMap("dataResourceId", oldDataResourceId));
} catch(GenericEntityException e) {
Debug.logError(e.getMessage(), module);
return ServiceUtil.returnError(e.getMessage());
@@ -1703,26 +1707,26 @@
}
try {
- ModelService persistContentAndAssocModel =
dispatcher.getDispatchContext().getModelService("persistContentAndAssoc");
- Map ctx = persistContentAndAssocModel.makeValid(context, "IN");
- if (dataResource != null) {
- ctx.remove("dataResourceId");
- ctx.remove("drDataResourceId");
- }
+ ModelService persistContentAndAssocModel =
dispatcher.getDispatchContext().getModelService("persistContentAndAssoc");
+ Map ctx = persistContentAndAssocModel.makeValid(context, "IN");
+ if (dataResource != null) {
+ ctx.remove("dataResourceId");
+ ctx.remove("drDataResourceId");
+ }
result = dispatcher.runSync("persistContentAndAssoc", ctx);
String errorMsg = ServiceUtil.getErrorMessage(result);
if (UtilValidate.isNotEmpty(errorMsg)) {
- return ServiceUtil.returnError(errorMsg);
+ return ServiceUtil.returnError(errorMsg);
}
String contentId = (String)result.get("contentId");
List parentList = new ArrayList();
if (UtilValidate.isEmpty(masterRevisionContentId)) {
- Map traversMap = new HashMap();
- traversMap.put("contentId", contentId);
- traversMap.put("direction", "To");
- traversMap.put("contentAssocTypeId", "COMPDOC_PART");
- Map traversResult = dispatcher.runSync("traverseContent",
traversMap);
- parentList = (List)traversResult.get("parentList");
+ Map traversMap = new HashMap();
+ traversMap.put("contentId", contentId);
+ traversMap.put("direction", "To");
+ traversMap.put("contentAssocTypeId", "COMPDOC_PART");
+ Map traversResult = dispatcher.runSync("traverseContent",
traversMap);
+ parentList = (List)traversResult.get("parentList");
} else {
parentList.add(masterRevisionContentId);
}
@@ -1739,7 +1743,7 @@
result = dispatcher.runSync("persistContentRevisionAndItem",
contentRevisionMap);
errorMsg = ServiceUtil.getErrorMessage(result);
if (UtilValidate.isNotEmpty(errorMsg)) {
- return ServiceUtil.returnError(errorMsg);
+ return ServiceUtil.returnError(errorMsg);
}
}
Added:
ofbiz/trunk/applications/content/src/org/ofbiz/content/blog/BlogServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/blog/BlogServices.java?view=auto&rev=499256
==============================================================================
---
ofbiz/trunk/applications/content/src/org/ofbiz/content/blog/BlogServices.java
(added)
+++
ofbiz/trunk/applications/content/src/org/ofbiz/content/blog/BlogServices.java
Tue Jan 23 20:49:50 2007
@@ -0,0 +1,232 @@
+/*******************************************************************************
+ * 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.ofbiz.content.blog;
+
+/*
+ * Created on Jan 28, 2005
+ *
+ * This service persists a blog article.
+ * It can persist text only, image only or a combination of content types.
+ * If text or image only, that content is attached directly to the main
+ * content as an ElectronicText or ImageDataResource entity.
+ * If a combination is desired, the two content pieces (image and text) are
associated
+ * through a predefined screen widget template (ie.
drDataTemplateTypeId="SCREEN_COMBINED").
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.service.DispatchContext;
+import org.ofbiz.service.GenericServiceException;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.service.ModelService;
+import org.ofbiz.service.ServiceUtil;
+
+public class BlogServices {
+
+ public static Map persistBlogAll(DispatchContext dctx, Map context) throws
GenericServiceException {
+
+ Map result = new HashMap();
+ GenericDelegator delegator = dctx.getDelegator();
+ LocalDispatcher dispatcher = dctx.getDispatcher();
+ GenericValue userLogin = (GenericValue)context.get("userLogin");
+ ModelService modelPersistContent =
dispatcher.getDispatchContext().getModelService("persistContentAndAssoc");
+ Map ctx = modelPersistContent.makeValid(context, "IN");
+ ctx.put("userLogin", userLogin);
+ ctx.put("textData", context.get("mainData"));
+ ctx.put("deactivateExisting", "false");
+ String drMimeTypeId_TEXT = (String)context.get("drMimeTypeId_TEXT");
+ boolean bTextMimeType = "Y".equals(drMimeTypeId_TEXT);
+ String drMimeTypeId_IMAGE = (String)context.get("drMimeTypeId_IMAGE");
+ boolean bImageMimeType = "Y".equals(drMimeTypeId_IMAGE);
+ String mainData = (String)context.get("mainData");
+ String imageMimeTypeId =
(String)context.get("_imageData_contentType");
+ if (UtilValidate.isEmpty(imageMimeTypeId)) imageMimeTypeId =
"image/jpeg";
+ String contentId = (String)context.get("contentId");
+ if (UtilValidate.isEmpty(contentId)) ctx.put("contentId",
context.get("contentIdTo"));
+
+ // if the content already exists, these will identify it.
+ // They are stored in the form
+ String textContentId = (String)context.get("textContentId");
+ String imageContentId = (String)context.get("imageContentId");
+ String textDataResourceId = (String)context.get("textDataResourceId");
+ String imageDataResourceId =
(String)context.get("imageDataResourceId");
+
+ String drDataResourceId = (String)context.get("drDataResourceId");
+ String drDataTemplateTypeId =
(String)context.get("drDataTemplateTypeId");
+
+ String templateId = (String)context.get("templateId");
+
+ if ("SCREEN_COMBINED".equals(drDataTemplateTypeId) && !bImageMimeType)
{
+ if (bTextMimeType) {
+ ctx.put("dataResourceId", textDataResourceId);
+ ctx.put("drDataResourceId", textDataResourceId);
+ ctx.put("drDataResourceTypeId", "ELECTRONIC_TEXT");
+ ctx.put("drDataTemplateTypeId", "NONE");
+ ctx.put("drMimeTypeId", "text/html");
+ }
+ } else if ("SCREEN_COMBINED".equals(drDataTemplateTypeId) &&
!bTextMimeType) {
+ if (bImageMimeType) {
+ ctx.put("dataResourceId", imageDataResourceId);
+ ctx.put("drDataResourceId", imageDataResourceId);
+ ctx.put("drDataResourceTypeId", "IMAGE_OBJECT");
+ ctx.put("drDataTemplateTypeId", "NONE");
+ ctx.put("drMimeTypeId", imageMimeTypeId);
+ ctx.put("drIsPublic", "Y");
+ }
+ } else if (!"SCREEN_COMBINED".equals(drDataTemplateTypeId) ) {
+
+ // Store the main record
+ // either text or image or both
+ if (bTextMimeType && !bImageMimeType) {
+ ctx.put("dataResourceId", drDataResourceId);
+ ctx.put("drDataResourceId", drDataResourceId);
+ ctx.put("drDataResourceTypeId", "ELECTRONIC_TEXT");
+ ctx.put("drDataTemplateTypeId", "NONE");
+ ctx.put("drMimeTypeId", "text/html");
+ } else if (!bTextMimeType && bImageMimeType) {
+ ctx.put("dataResourceId", drDataResourceId);
+ ctx.put("drDataResourceId", drDataResourceId);
+ ctx.put("drDataResourceTypeId", "IMAGE_OBJECT");
+ ctx.put("drDataTemplateTypeId", "NONE");
+ ctx.put("drMimeTypeId", imageMimeTypeId);
+ ctx.put("drIsPublic", "Y");
+ } else if (bTextMimeType && bImageMimeType) {
+ // if both then set up for and choose a template
+ ctx.put("drDataResourceTypeId", null);
+ ctx.put("dataResourceTypeId", null);
+ ctx.put("textData", null);
+ ctx.put("dataResourceId", templateId);
+ ctx.put("drDataResourceId", templateId);
+ ctx.put("drIsPublic", "Y");
+ }
+ } else if ("SCREEN_COMBINED".equals(drDataTemplateTypeId) ) {
+ if (bTextMimeType && bImageMimeType) {
+ // if both then set up for and choose a template
+ ctx.put("drDataResourceTypeId", "ELECTRONIC_TEXT");
+ ctx.put("drDataTemplateTypeId", "SCREEN_COMBINED");
+ ctx.put("drMimeTypeId", "text/html");
+ ctx.put("textData", null);
+ ctx.put("dataResourceId", templateId);
+ ctx.put("drDataResourceId", templateId);
+ ctx.put("drIsPublic", "Y");
+ }
+ }
+ // store the main content entity
+ result = dispatcher.runSync("persistContentAndAssoc", ctx);
+ if (ServiceUtil.isError(result)) {
+ return
ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
+ }
+ String mainContentId = (String)result.get("contentId");
+
+ // If both, then that content needs to be persisted
+ if (bTextMimeType && bImageMimeType) {
+
+ ctx = modelPersistContent.makeValid(context, "IN");
+ // first store the text
+ ctx.put("caContentId", mainContentId);
+ ctx.put("contentId", textContentId);
+ ctx.put("dataResourceId", textDataResourceId);
+ ctx.put("drDataResourceId", textDataResourceId);
+ ctx.put("caContentId", mainContentId);
+ ctx.put("drDataTemplateTypeId", "NONE");
+ ctx.put("caContentAssocTypeId", "SUB_CONTENT");
+ ctx.put("drDataResourceTypeId", "ELECTRONIC_TEXT");
+ ctx.put("drMimeTypeId", "text/html");
+ ctx.put("caMapKey", "MAIN");
+ ctx.put("textData", mainData);
+ Map textResult = dispatcher.runSync("persistContentAndAssoc", ctx);
+ if (ServiceUtil.isError(textResult)) {
+ return
ServiceUtil.returnError(ServiceUtil.getErrorMessage(textResult));
+ }
+ textContentId = (String)textResult.get("contentId");
+ textDataResourceId = (String)textResult.get("drDataResourceId");
+
+
+ // persist the image
+ String imageData_fileName =
(String)context.get("_imageData_fileName");
+ // In the update mode, if no upload file is given, do not upload
+ if (UtilValidate.isNotEmpty(imageData_fileName)) {
+ ctx = modelPersistContent.makeValid(context, "IN");
+ ctx.put("caContentId", mainContentId);
+ ctx.put("contentId", imageContentId);
+ ctx.put("dataResourceId", imageDataResourceId);
+ ctx.put("drDataResourceId", imageDataResourceId);
+ ctx.put("drDataTemplateTypeId", "NONE");
+ ctx.put("drDataResourceTypeId", "IMAGE_OBJECT");
+ ctx.put("caContentAssocTypeId", "SUB_CONTENT");
+ ctx.put("drMimeTypeId", imageMimeTypeId);
+ ctx.put("caMapKey", "IMAGE");
+ ctx.put("textData", null);
+ ctx.put("drIsPublic", "Y");
+ Map imageResult = dispatcher.runSync("persistContentAndAssoc",
ctx);
+ if (ServiceUtil.isError(imageResult)) {
+ return
ServiceUtil.returnError(ServiceUtil.getErrorMessage(imageResult));
+ }
+ imageContentId = (String)imageResult.get("contentId");
+ imageDataResourceId =
(String)imageResult.get("drDataResourceId");
+ }
+ }
+
+ // persist the summary info.
+ String summaryData = (String)context.get("summaryData");
+ String summaryParentContentId = mainContentId;
+ if (UtilValidate.isNotEmpty(summaryData) &&
UtilValidate.isNotEmpty(summaryParentContentId) ) {
+ Map subContentIn = new HashMap();
+ subContentIn.put("contentId", summaryParentContentId);
+ subContentIn.put("mapKey", "SUMMARY");
+ Map thisResult = dispatcher.runSync("getSubContent", subContentIn);
+ GenericValue view = (GenericValue)thisResult.get("view");
+ Map summaryContext = null;
+ if (view != null) {
+ summaryContext = modelPersistContent.makeValid(view, "IN");
+ summaryContext.put("textData", summaryData);
+ summaryContext.put("contentTypeId", null);
+ summaryContext.put("caContentAssocTypeId", null);
+ } else {
+ summaryContext = modelPersistContent.makeValid(result, "IN");
+ summaryContext.put("textData", summaryData);
+ summaryContext.put("caContentId", summaryParentContentId);
+ summaryContext.put("caMapKey", "SUMMARY");
+ summaryContext.put("caContentAssocTypeId", "SUB_CONTENT");
+ summaryContext.put("contentTypeId", "DOCUMENT");
+ summaryContext.put("dataResourceTypeId", "ELECTRONIC_TEXT");
+ summaryContext.put("contentId", null);
+ summaryContext.put("caFromDate", null);
+ summaryContext.put("drDataResourceId", null);
+ summaryContext.put("dataResourceId", null);
+ summaryContext.put("statusId", context.get("statusId"));
+ summaryContext.put("ownerContentId",
context.get("ownerContentId"));
+ summaryContext.put("contentPurposeString", "ARTICLE");
+ }
+ summaryContext.put("userLogin", userLogin);
+ Map summaryResult = dispatcher.runSync("persistContentAndAssoc",
summaryContext);
+ if (ServiceUtil.isError(summaryResult)) {
+ String errMsg = ServiceUtil.getErrorMessage(summaryResult);
+ return ServiceUtil.returnError(errMsg);
+ }
+ }
+
+ return result;
+ }
+}
Modified:
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java?view=diff&rev=499256&r1=499255&r2=499256
==============================================================================
---
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java
(original)
+++
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java
Tue Jan 23 20:49:50 2007
@@ -863,7 +863,7 @@
throw new GenericEntityException("contentId and
subContentId are null.");
}
Map results = null;
- results =
ContentServicesComplex.getAssocAndContentAndDataResourceMethod(delegator,
contentId, mapKey, "From", fromDate, null, null, null, assocTypes, null);
+ results =
ContentServicesComplex.getAssocAndContentAndDataResourceMethod(delegator,
contentId, mapKey, "To", fromDate, null, null, null, assocTypes, null);
List entityList = (List) results.get("entityList");
if (entityList == null || entityList.size() == 0) {
//throw new IOException("No subcontent found.");