[OFBiz] SVN: r4396 - in trunk/components/content: servicedef
src/org/ofbiz/content src/org/ofbiz/content/content
byersa at svn.ofbiz.org
byersa at svn.ofbiz.org
Tue Feb 1 01:33:25 EST 2005
Author: byersa
Date: 2005-02-01 00:33:17 -0600 (Tue, 01 Feb 2005)
New Revision: 4396
Modified:
trunk/components/content/servicedef/services.xml
trunk/components/content/src/org/ofbiz/content/ContentManagementServices.java
trunk/components/content/src/org/ofbiz/content/content/ContentServices.java
Log:
Fixes to the foToPdf service and supporting services.
Had some incorrect service definitions.
Modified: trunk/components/content/servicedef/services.xml
===================================================================
--- trunk/components/content/servicedef/services.xml 2005-01-31 23:20:13 UTC (rev 4395)
+++ trunk/components/content/servicedef/services.xml 2005-02-01 06:33:17 UTC (rev 4396)
@@ -1617,9 +1617,10 @@
location="org.ofbiz.content.content.ContentServices" invoke="foToPdf">
<attribute name="foFileIn" mode="IN" type="String" optional="false"/>
<attribute name="pdfFileOut" mode="IN" type="String" optional="true"/>
- <attribute name="dataResourceTypeId" mode="IN" type="String" optional="true"/>
- <attribute name="contentId" mode="INOUT" type="String" optional="true"/>
- <attribute name="foContentId" mode="IN" type="String" optional="true"/>
+ <attribute name="inputDataResourceTypeId" mode="IN" type="String" optional="true"/>
+ <attribute name="outputDataResourceTypeId" mode="IN" type="String" optional="true"/>
+ <attribute name="outputContentId" mode="INOUT" type="String" optional="true"/>
+ <attribute name="foContentId" mode="INOUT" type="String" optional="true"/>
<attribute name="templateDataResourceId" mode="IN" type="String" optional="true"/>
<attribute name="fmContext" type="java.util.Map" mode="IN" optional="true"/>
<attribute name="fmPrefixMap" type="java.util.Map" mode="IN" optional="true" string-map-prefix="CTX_"/>
Modified: trunk/components/content/src/org/ofbiz/content/ContentManagementServices.java
===================================================================
--- trunk/components/content/src/org/ofbiz/content/ContentManagementServices.java 2005-01-31 23:20:13 UTC (rev 4395)
+++ trunk/components/content/src/org/ofbiz/content/ContentManagementServices.java 2005-02-01 06:33:17 UTC (rev 4396)
@@ -328,7 +328,7 @@
}
if (hasData) {
fileContext.put("rootDir", context.get("rootDir"));
- fileContext.put("dataResourcetype", dataResourceTypeId);
+ fileContext.put("dataResourceTypeId", dataResourceTypeId);
fileContext.put("objectInfo", dataResource.get("objectInfo"));
thisResult = dispatcher.runSync("createFile", fileContext);
errorMsg = ServiceUtil.getErrorMessage(thisResult);
Modified: trunk/components/content/src/org/ofbiz/content/content/ContentServices.java
===================================================================
--- trunk/components/content/src/org/ofbiz/content/content/ContentServices.java 2005-01-31 23:20:13 UTC (rev 4395)
+++ trunk/components/content/src/org/ofbiz/content/content/ContentServices.java 2005-02-01 06:33:17 UTC (rev 4396)
@@ -895,7 +895,7 @@
Writer outWriter = new StringWriter();
GenericValue view = (GenericValue)context.get("subContentDataResourceView");
try {
- results = ContentWorker.renderContentAsTextCache(delegator, contentId, outWriter, templateContext, view, locale, mimeTypeId);
+ Map thisResults = ContentWorker.renderContentAsTextCache(delegator, contentId, outWriter, templateContext, view, locale, mimeTypeId);
out.write(outWriter.toString());
results.put("textData", outWriter.toString());
} catch (GeneralException e) {
@@ -1081,14 +1081,40 @@
return result;
}
+ /**
+ * foFileIn - path to FO template, can be null if template is in the CMS
+ * inputDataResourceTypeId - can be LOCAL_FILE or OFBIZ_FILE. Used if foFileIn is not null.
+ * pdfFileOut - path to where output PDF will be stored.Can be null if either PDF will be
+ * stored as ELECTRONIC_TEXT or not stored at all, but returned as pdfByteWrapper
+ * outputDataResourceTypeId - can be LOCAL_FILE, OFBIZ_FILE or ELECTRONIC_TEXT.
+ * outputContentId - The CMS id of PDF output Content entity. Type is INOUT, but can be null,
+ * in which case it will be generated.
+ * foContentId - The CMS id of FO template Content entity. Type is INOUT, but can be null,
+ * in which case it will be generated.
+ * If not null, then foFileIn will be ignored.
+ * There is no current way to specify what you want the generated FO template ID to be.
+ * fmContext - the Map that will be used in processing the FO template.
+ * fmPrefixMap - If fmContext is null, this Map will be used. It is generated by using the
+ * prefix, "CTX_" on form parameters. Allows this service to be used as
+ * in request event handler.
+ * @param dctx
+ * @param context
+ * @return
+ * @throws GenericServiceException
+ */
public static Map foToPdf(DispatchContext dctx, Map context) throws GenericServiceException{
LocalDispatcher dispatcher = dctx.getDispatcher();
+ GenericValue userLogin = (GenericValue)context.get("userLogin");
Map result = new HashMap();
String foFileIn = (String)context.get("foFileIn");
String pdfFileOut = (String)context.get("pdfFileOut");
- String dataResourceTypeId = (String)context.get("dataResourceTypeId");
- String contentId = (String)context.get("contentId");
+ String outputDataResourceTypeId = (String)context.get("outputDataResourceTypeId");
+ String inputDataResourceTypeId = (String)context.get("inputDataResourceTypeId");
+ if (UtilValidate.isEmpty(inputDataResourceTypeId)) {
+ inputDataResourceTypeId = "LOCAL_FILE";
+ }
+ String outputContentId = (String)context.get("outputContentId");
String foContentId = (String)context.get("foContentId");
String templateDataResourceId = (String)context.get("templateDataResourceId");
Map fmContext = (Map)context.get("fmContext");
@@ -1107,11 +1133,12 @@
}
Map mapIn = new HashMap();
mapIn.put("drObjectInfo", foFileIn);
- mapIn.put("drDataResourceTypeId", "CONTEXT_FILE");
+ mapIn.put("drDataResourceTypeId", inputDataResourceTypeId);
mapIn.put("contentTypeId", "DOCUMENT");
mapIn.put("contentPurposeString", "SOURCE");
mapIn.put("templateDataResourceId", templateDataResourceId);
mapIn.put("drDataTemplateTypeId", "FTL");
+ mapIn.put("userLogin", userLogin);
try {
Map thisResult = dispatcher.runSync("persistContentAndAssoc", mapIn);
foContentId = (String)thisResult.get("contentId");
@@ -1119,6 +1146,7 @@
Debug.logError("Could not add FO content - foContentId is null.", "ContentServices");
return ServiceUtil.returnError("Could not add FO conten - foContentId is null.");
}
+ result.put("foContentId", foContentId);
} catch (GenericServiceException e) {
Debug.logError(e, "Problem adding FO content.", "ContentServices");
return ServiceUtil.returnError("Problem adding FO content.");
@@ -1205,28 +1233,30 @@
// Put output into CMS if dataResourceTypeId is present
// else, just write it to a file
- if (UtilValidate.isNotEmpty(dataResourceTypeId)) {
+ if (UtilValidate.isNotEmpty(outputDataResourceTypeId)) {
if (pdfByteWrapper != null) {
Map mapIn2 = new HashMap();
- mapIn2.put("contentId", contentId);
- mapIn2.put("drDataResourceTypeId", dataResourceTypeId);
+ mapIn2.put("contentId", outputContentId);
+ mapIn2.put("drDataResourceTypeId", outputDataResourceTypeId);
mapIn2.put("contentTypeId", "DOCUMENT");
mapIn2.put("imageData", pdfByteWrapper);
- mapIn2.put("_imageData_ContentType", "application/pdf");
+ mapIn2.put("_imageData_contentType", "application/pdf");
mapIn2.put("_imageData_fileName", pdfFileOut);
mapIn2.put("drObjectInfo", pdfFileOut);
+ mapIn2.put("userLogin", userLogin);
try {
Map thisResult = dispatcher.runSync("persistContentAndAssoc", mapIn2);
- contentId = (String)thisResult.get("contentId");
+ outputContentId = (String)thisResult.get("contentId");
if (UtilValidate.isEmpty(foContentId)) {
Debug.logError("Could not add PDF content - contentId is null.", "ContentServices");
return ServiceUtil.returnError("Could not add PDF conten - contentId is null.");
}
+ result.put("outputContentId", outputContentId);
} catch (GenericServiceException e) {
Debug.logError(e, "Problem adding FO content.", module);
return ServiceUtil.returnError("Problem adding FO content.");
}
- result.put("contentId", contentId);
+ result.put("outputContentId", outputContentId);
}
} else {
if (UtilValidate.isEmpty(pdfFileOut)) {
More information about the Svn
mailing list