[OFBiz] SVN: r6832 - in trunk/applications/content: data servicedef src/org/ofbiz/content/data src/org/ofbiz/content/openoffice webapp/content/WEB-INF widget/compdoc
byersa@svn.ofbiz.org
byersa at svn.ofbiz.org
Thu Feb 23 17:19:49 CST 2006
Author: byersa
Date: 2006-02-23 17:19:38 -0600 (Thu, 23 Feb 2006)
New Revision: 6832
Modified:
trunk/applications/content/data/CompDocData.xml
trunk/applications/content/servicedef/services.xml
trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java
trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeEvents.java
trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java
trunk/applications/content/webapp/content/WEB-INF/controller.xml
trunk/applications/content/widget/compdoc/CompDocScreens.xml
Log:
A fix to DataResourceWorker.getContentFile.
Fixed seed data for CompDoc.
Got CompDoc PDF generation almost working for MSWord and PDFs.
Just need to figure out why it is only getting first page.
Modified: trunk/applications/content/data/CompDocData.xml
===================================================================
--- trunk/applications/content/data/CompDocData.xml 2006-02-23 05:56:22 UTC (rev 6831)
+++ trunk/applications/content/data/CompDocData.xml 2006-02-23 23:19:38 UTC (rev 6832)
@@ -9,7 +9,7 @@
]]></textData>
</ElectronicText>
<DataResource dataResourceId="DR1103b" dataResourceTypeId="OFBIZ_FILE_BIN" objectInfo="/applications/content/data/pdftest2.pdf" mimeTypeId="application/pdf" dataResourceName="Personal Profile" />
- <DataResource dataResourceId="DR1105b" dataResourceTypeId="OFBIZ_FILE_BIN" objectInfo="/applications/content/data/mswordtest2.pdf" mimeTypeId="application/msword" dataResourceName="2nd Quarter Review" />
+ <DataResource dataResourceId="DR1105b" dataResourceTypeId="OFBIZ_FILE_BIN" objectInfo="/applications/content/data/mswordtest2.doc" mimeTypeId="application/msword" dataResourceName="2nd Quarter Review" />
<DataResource dataResourceId="DR1102a" dataResourceTypeId="ELECTRONIC_TEXT" mimeTypeId="text/html" dataResourceName="POA Contract" />
<ElectronicText dataResourceId="DR1102a">
@@ -19,19 +19,19 @@
]]></textData>
</ElectronicText>
<DataResource dataResourceId="DR1103a" dataResourceTypeId="OFBIZ_FILE_BIN" objectInfo="/applications/content/data/pdftest2.pdf" mimeTypeId="application/pdf" dataResourceName="Personal Profile" />
- <DataResource dataResourceId="DR1105a" dataResourceTypeId="OFBIZ_FILE_BIN" objectInfo="/applications/content/data/mswordtest2.pdf" mimeTypeId="application/msword" dataResourceName="2nd Quarter Review" />
+ <DataResource dataResourceId="DR1105a" dataResourceTypeId="OFBIZ_FILE_BIN" objectInfo="/applications/content/data/mswordtest2.doc" mimeTypeId="application/msword" dataResourceName="2nd Quarter Review" />
<!-- A CDT (Composite Document Template) that can be used independently, or as part of CD0001 defined below -->
- <Content contentId="CDT1201" contentTypeId="COMPDOC_TEMPLATE" contentName="Demo Template Root (CDT) 1201" description="" ownerContentId="" dataResourceId=""/>
+ <Content contentId="CDT1201" contentTypeId="COMPDOC_TEMPLATE" contentName="Demo Template Root (CDT) 1201" description="" ownerContentId="" />
- <Content contentId="CDT0211" contentTypeId="COMPDOC_TEMPLATE" ownerContentId="" dataResourceId="" contentName="2J Placeholder (CDT Root/Sub-Root)" description=""/>
+ <Content contentId="CDT0211" contentTypeId="COMPDOC_TEMPLATE" ownerContentId="" contentName="2J Placeholder (CDT Root/Sub-Root)" description=""/>
- <Content contentId="CDT1121" contentTypeId="TEMPLATE" contentName="Receive letter of inquiry" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1122" contentTypeId="TEMPLATE" contentName="POA Contract" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1123" contentTypeId="TEMPLATE" contentName="Personal Profile" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1124" contentTypeId="TEMPLATE" contentName="1st Quarter Review" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1125" contentTypeId="TEMPLATE" contentName="2st Quarter Review" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1126" contentTypeId="TEMPLATE" contentName="Other Upload" description="" ownerContentId="" dataResourceId=""/>
+ <Content contentId="CDT1121" contentTypeId="TEMPLATE" contentName="Receive letter of inquiry" description="" ownerContentId="" />
+ <Content contentId="CDT1122" contentTypeId="TEMPLATE" contentName="POA Contract" description="" ownerContentId="" />
+ <Content contentId="CDT1123" contentTypeId="TEMPLATE" contentName="Personal Profile" description="" ownerContentId="" />
+ <Content contentId="CDT1124" contentTypeId="TEMPLATE" contentName="1st Quarter Review" description="" ownerContentId="" />
+ <Content contentId="CDT1125" contentTypeId="TEMPLATE" contentName="2st Quarter Review" description="" ownerContentId="" />
+ <Content contentId="CDT1126" contentTypeId="TEMPLATE" contentName="Other Upload" description="" ownerContentId="" />
<ContentAssoc contentIdTo="CDT1201" contentId="CDT1121" contentAssocTypeId="COMPDOC_PART" fromDate="2006-01-12 01:01:01"/>
<ContentAssoc contentIdTo="CDT1201" contentId="CDT1122" contentAssocTypeId="COMPDOC_PART" fromDate="2006-01-12 01:01:01"/>
<ContentAssoc contentIdTo="CDT1201" contentId="CDT1123" contentAssocTypeId="COMPDOC_PART" fromDate="2006-01-12 01:01:01"/>
@@ -40,22 +40,22 @@
<ContentAssoc contentIdTo="CDT1201" contentId="CDT1126" contentAssocTypeId="COMPDOC_PART" fromDate="2006-01-12 01:01:01"/>
- <Content contentId="CDT1101" contentTypeId="TEMPLATE" contentName="Letter of inquiry" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1102" dataResourceId="DR1102b" contentTypeId="TEMPLATE" contentName="POA Contract" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1103" dataResourceId="DR1103b" contentTypeId="TEMPLATE" contentName="Personal Profile" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1104" contentTypeId="TEMPLATE" contentName="1st Quarter Review" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1105" dataResourceId="DR1105b" contentTypeId="TEMPLATE" contentName="2nd Quarter Review" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1106" contentTypeId="TEMPLATE" contentName="3rd Quarter Review" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1107" contentTypeId="TEMPLATE" contentName="4th Quarter Review" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1108" contentTypeId="TEMPLATE" contentName="Phase I Budget" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1109" contentTypeId="TEMPLATE" contentName="Phase II Budget" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1110" contentTypeId="TEMPLATE" contentName="IJK 4988" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1111" contentTypeId="TEMPLATE" contentName="ABC 123" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1112" contentTypeId="TEMPLATE" contentName="Yearly Review" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1113" contentTypeId="TEMPLATE" contentName="Miscellaneous Notes" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1114" contentTypeId="TEMPLATE" contentName="Disclosure Agreement" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1115" contentTypeId="TEMPLATE" contentName="Performance Review" description="" ownerContentId="" dataResourceId=""/>
- <Content contentId="CDT1116" contentTypeId="TEMPLATE" contentName="Other Upload" description="" ownerContentId="" dataResourceId=""/>
+ <Content contentId="CDT1101" contentTypeId="TEMPLATE" contentName="Letter of inquiry" description="" ownerContentId=""/>
+ <Content contentId="CDT1102" contentTypeId="TEMPLATE" contentName="POA Contract" description="" ownerContentId="" />
+ <Content contentId="CDT1103" contentTypeId="TEMPLATE" contentName="Personal Profile" description="" ownerContentId=""/>
+ <Content contentId="CDT1104" contentTypeId="TEMPLATE" contentName="1st Quarter Review" description="" ownerContentId="" />
+ <Content contentId="CDT1105" contentTypeId="TEMPLATE" contentName="2nd Quarter Review" description="" ownerContentId="" />
+ <Content contentId="CDT1106" contentTypeId="TEMPLATE" contentName="3rd Quarter Review" description="" ownerContentId="" />
+ <Content contentId="CDT1107" contentTypeId="TEMPLATE" contentName="4th Quarter Review" description="" ownerContentId="" />
+ <Content contentId="CDT1108" contentTypeId="TEMPLATE" contentName="Phase I Budget" description="" ownerContentId="" />
+ <Content contentId="CDT1109" contentTypeId="TEMPLATE" contentName="Phase II Budget" description="" ownerContentId="" />
+ <Content contentId="CDT1110" contentTypeId="TEMPLATE" contentName="IJK 4988" description="" ownerContentId="" />
+ <Content contentId="CDT1111" contentTypeId="TEMPLATE" contentName="ABC 123" description="" ownerContentId="" />
+ <Content contentId="CDT1112" contentTypeId="TEMPLATE" contentName="Yearly Review" description="" ownerContentId="" />
+ <Content contentId="CDT1113" contentTypeId="TEMPLATE" contentName="Miscellaneous Notes" description="" ownerContentId="" />
+ <Content contentId="CDT1114" contentTypeId="TEMPLATE" contentName="Disclosure Agreement" description="" ownerContentId="" />
+ <Content contentId="CDT1115" contentTypeId="TEMPLATE" contentName="Performance Review" description="" ownerContentId="" />
+ <Content contentId="CDT1116" contentTypeId="TEMPLATE" contentName="Other Upload" description="" ownerContentId="" />
<ContentAssoc contentIdTo="CDT1201" contentId="CDT1101" contentAssocTypeId="COMPDOC_PART" fromDate="2006-01-12 01:01:01" sequenceNum="0010"/>
<ContentAssoc contentIdTo="CDT1201" contentId="CDT1102" contentAssocTypeId="COMPDOC_PART" fromDate="2006-01-12 01:01:01" sequenceNum="0020"/>
@@ -74,7 +74,20 @@
<ContentAssoc contentIdTo="CDT1201" contentId="CDT1115" contentAssocTypeId="COMPDOC_PART" fromDate="2006-01-12 01:01:01" sequenceNum="0150"/>
<ContentAssoc contentIdTo="CDT1201" contentId="CDT1116" contentAssocTypeId="COMPDOC_PART" fromDate="2006-01-12 01:01:01" sequenceNum="0160"/>
- <!-- sample revision entries for CDT CD0001 -->
+ <!-- sample instances CDT CDT1201 -->
+ <Content contentId="CDI1201" instanceOfContentId="CDT1201" contentTypeId="COMPDOC_INSTANCE" contentName="Demo Instance Root (CDI) 1201" description="" ownerContentId="" />
+ <Content contentId="CDI1102" instanceOfContentId="CDT1102" dataResourceId="DR1102b" contentTypeId="DOCUMENT" contentName="POA Contract" description="" ownerContentId="" />
+ <Content contentId="CDI1103" instanceOfContentId="CDT1103" dataResourceId="DR1103b" contentTypeId="DOCUMENT" contentName="Personal Profile" description="" ownerContentId=""/>
+ <Content contentId="CDI1104" instanceOfContentId="CDT1104" contentTypeId="DOCUMENT" contentName="1st Quarter Review" description="" ownerContentId="" />
+ <Content contentId="CDI1105" instanceOfContentId="CDT1105" dataResourceId="DR1105b" contentTypeId="DOCUMENT" contentName="2nd Quarter Review" description="" ownerContentId="" />
+
+ <ContentAssoc contentIdTo="CDT1201" contentId="CDI1201" contentAssocTypeId="INSTANCE" fromDate="2006-01-12 01:01:01" sequenceNum="0020"/>
+ <ContentAssoc contentIdTo="CDI1201" contentId="CDI1102" contentAssocTypeId="COMPDOC_PART" fromDate="2006-01-12 01:01:01" sequenceNum="00220"/>
+ <ContentAssoc contentIdTo="CDI1201" contentId="CDI1103" contentAssocTypeId="COMPDOC_PART" fromDate="2006-01-12 01:01:01" sequenceNum="00130"/>
+ <ContentAssoc contentIdTo="CDI1201" contentId="CDI1104" contentAssocTypeId="COMPDOC_PART" fromDate="2006-01-12 01:01:01" sequenceNum="00440"/>
+ <ContentAssoc contentIdTo="CDI1201" contentId="CDI1105" contentAssocTypeId="COMPDOC_PART" fromDate="2006-01-12 01:01:01" sequenceNum="0050"/>
+
+ <!-- sample revision entries for CDT CDT1201 -->
<ContentRevision contentId="CDT1201" contentRevisionSeqId="000002"/>
<ContentRevisionItem contentId="CDT1201" contentRevisionSeqId="000002" itemContentId="CDT0211"/>
<ContentRevisionItem contentId="CDT1201" contentRevisionSeqId="000002" itemContentId="CDT1101"/>
@@ -105,6 +118,11 @@
<ContentRevisionItem contentId="CDT1201" contentRevisionSeqId="000004" itemContentId="CDT1103" oldDataResourceId="DR1103a" newDataResourceId="DR1103b"/>
<ContentRevisionItem contentId="CDT1201" contentRevisionSeqId="000004" itemContentId="CDT1105" oldDataResourceId="DR1105a" newDataResourceId="DR1105b"/>
+ <ContentRevision contentId="CDI1201" contentRevisionSeqId="000004"/>
+ <ContentRevisionItem contentId="CDI1201" contentRevisionSeqId="000004" itemContentId="CDI1102" oldDataResourceId="DR1102a" newDataResourceId="DR1102b" />
+ <ContentRevisionItem contentId="CDI1201" contentRevisionSeqId="000004" itemContentId="CDI1103" oldDataResourceId="DR1103a" newDataResourceId="DR1103b"/>
+ <ContentRevisionItem contentId="CDI1201" contentRevisionSeqId="000004" itemContentId="CDI1105" oldDataResourceId="DR1105a" newDataResourceId="DR1105b"/>
+
<!-- sample approval entries for CDT CD0001 -->
<ContentApproval contentApprovalId="CA0101" contentId="CDT1201" contentRevisionSeqId="000002" partyId="admin"/>
<ContentApproval contentApprovalId="CA0102" contentId="CDT1201" contentRevisionSeqId="000002" partyId="BLOG_EDITOR"/>
Modified: trunk/applications/content/servicedef/services.xml
===================================================================
--- trunk/applications/content/servicedef/services.xml 2006-02-23 05:56:22 UTC (rev 6831)
+++ trunk/applications/content/servicedef/services.xml 2006-02-23 23:19:38 UTC (rev 6832)
@@ -1376,11 +1376,11 @@
</service>
<service name="renderCompDocPdf" engine="java"
- location="org.ofbiz.content.openoffice.OpenOfficeEvents"
- invoke="genCompDocPdf" auth="true">
+ location="org.ofbiz.content.openoffice.OpenOfficeServices"
+ invoke="renderCompDocPdf" auth="true">
<description>Convert all the CompDoc parts into PDF and concatenate and put in CMS</description>
<attribute name="contentId" type="String" mode="IN" optional="false"/>
- <attribute name="contentRevisionSeqId" type="String" mode="IN" optional="false"/>
+ <attribute name="contentRevisionSeqId" type="String" mode="IN" optional="true"/>
<attribute name="webSiteId" type="String" mode="IN" optional="true"/>
<attribute name="https" type="String" mode="IN" optional="true"/>
<attribute name="rootDir" type="String" mode="IN" optional="true"/>
@@ -1389,11 +1389,11 @@
</service>
<service name="renderContentPdf" engine="java"
- location="org.ofbiz.content.openoffice.OpenOfficeEvents"
- invoke="genContentPdf" auth="true">
+ location="org.ofbiz.content.openoffice.OpenOfficeServices"
+ invoke="renderContentPdf" auth="true">
<description>Convert all the CompDoc parts into PDF and concatenate and put in CMS</description>
<attribute name="contentId" type="String" mode="IN" optional="false"/>
- <attribute name="contentRevisionSeqId" type="String" mode="IN" optional="false"/>
+ <attribute name="contentRevisionSeqId" type="String" mode="IN" optional="true"/>
<attribute name="webSiteId" type="String" mode="IN" optional="true"/>
<attribute name="https" type="String" mode="IN" optional="true"/>
<attribute name="rootDir" type="String" mode="IN" optional="true"/>
Modified: trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java
===================================================================
--- trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java 2006-02-23 05:56:22 UTC (rev 6831)
+++ trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java 2006-02-23 23:19:38 UTC (rev 6832)
@@ -1119,7 +1119,7 @@
byteWrapper = new ByteWrapper(text.getBytes());
} else if (dataResourceTypeId.indexOf("_FILE") >= 0) {
String objectInfo = dataResource.getString("objectInfo");
- File inputFile = getContentFile(dataResourceId, objectInfo, rootDir);
+ File inputFile = getContentFile(dataResourceTypeId, objectInfo, rootDir);
long fileSize = inputFile.length();
FileInputStream fis = new FileInputStream(inputFile);
ByteArrayOutputStream baos = new ByteArrayOutputStream((int)fileSize);
Modified: trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeEvents.java
===================================================================
--- trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeEvents.java 2006-02-23 05:56:22 UTC (rev 6831)
+++ trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeEvents.java 2006-02-23 23:19:38 UTC (rev 6832)
@@ -4,7 +4,9 @@
import java.util.Map;
import java.util.HashMap;
import java.io.ByteArrayInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.FileNotFoundException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -14,8 +16,10 @@
import org.ofbiz.base.util.UtilHttp;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.util.ByteWrapper;
+import org.ofbiz.entity.GenericValue;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.service.GenericServiceException;
+import org.ofbiz.service.ServiceAuthException;
import org.ofbiz.service.ServiceUtil;
public class OpenOfficeEvents {
@@ -26,6 +30,7 @@
String responseStr = "success";
ByteWrapper byteWrapper = null;
HttpSession session = request.getSession();
+ GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");
ServletContext servletContext = session.getServletContext();
LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher");
Map paramMap = UtilHttp.getParameterMap(request);
@@ -51,14 +56,27 @@
mapIn.put("rootDir", rootDir);
mapIn.put("webSiteId", webSiteId);
mapIn.put("https", https);
+ mapIn.put("userLogin", userLogin);
Map results = null;
try {
results = dispatcher.runSync("renderCompDocPdf", mapIn);
+ } catch(ServiceAuthException e) {
+ request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
+ return "error";
} catch(GenericServiceException e) {
- ServiceUtil.returnError(e.getMessage());
+ request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
+ return "error";
+ } catch(Exception e) {
+ request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
+ return "error";
}
+ if (ServiceUtil.isError(results)) {
+ request.setAttribute("_ERROR_MESSAGE_", ServiceUtil.getErrorMessage(results));
+ return "error";
+ }
+
ByteWrapper pdfByteWrapper = (ByteWrapper)results.get("pdfByteWrapper");
// setup content type
@@ -66,6 +84,13 @@
ByteArrayInputStream bais = new ByteArrayInputStream(pdfByteWrapper.getBytes());
try {
+ FileOutputStream fos = new FileOutputStream("/home/byersa/pdftest.pdf");
+ fos.write(pdfByteWrapper.getBytes());
+ } catch(FileNotFoundException e) {
+ } catch(IOException e) {
+
+ }
+ try {
UtilHttp.streamContentToBrowser(response, bais, pdfByteWrapper.getLength(), contentType);
} catch(IOException e) {
Modified: trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java
===================================================================
--- trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java 2006-02-23 05:56:22 UTC (rev 6831)
+++ trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java 2006-02-23 23:19:38 UTC (rev 6832)
@@ -94,6 +94,7 @@
import com.lowagie.text.pdf.PdfImportedPage;
import com.lowagie.text.Document;
import com.lowagie.text.Rectangle;
+import com.lowagie.text.PageSize;
/**
* OpenOfficeServices Class
@@ -407,48 +408,68 @@
EntityConditionList conditionList = new EntityConditionList(exprList, EntityOperator.AND);
String [] fields = {"rootRevisionContentId", "itemContentId", "maxRevisionSeqId", "contentId", "dataResourceId", "contentIdTo", "contentAssocTypeId", "fromDate", "sequenceNum"};
List selectFields = UtilMisc.toListArray(fields);
- List compDocParts = delegator.findByCondition("ContentAssocRevisionItemView", conditionList, selectFields, null);
+ List orderByFields = UtilMisc.toList("sequenceNum");
+ List compDocParts = delegator.findByCondition("ContentAssocRevisionItemView", conditionList, selectFields, orderByFields);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- Document document = new Document(new Rectangle(60, 120));
+ Document document = new Document();
+ document.setPageSize(PageSize.LETTER);
+ Rectangle rect = document.getPageSize();
+ float left = rect.left();
+ float height = rect.height();
PdfWriter writer = PdfWriter.getInstance(document, baos);
document.open();
PdfContentByte cb = writer.getDirectContent();
Iterator iter = compDocParts.iterator();
+ int pgCnt =0;
while (iter.hasNext()) {
GenericValue contentAssocRevisionItemView = (GenericValue)iter.next();
String thisContentId = contentAssocRevisionItemView.getString("contentId");
String thisContentRevisionSeqId = contentAssocRevisionItemView.getString("maxRevisionSeqId");
String thisDataResourceId = contentAssocRevisionItemView.getString("dataResourceId");
- GenericValue dataResource = delegator.findByPrimaryKey("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId));
+ GenericValue dataResource = delegator.findByPrimaryKey("DataResource", UtilMisc.toMap("dataResourceId", thisDataResourceId));
String inputMimeType = null;
if(dataResource != null) {
inputMimeType = (String)dataResource.getString("mimeTypeId");
}
- byteWrapper = DataResourceWorker.getContentAsByteWrapper(delegator, dataResourceId, https, webSiteId, locale, rootDir);
- OpenOfficeByteArrayInputStream oobais = new OpenOfficeByteArrayInputStream(byteWrapper.getBytes());
- OpenOfficeByteArrayOutputStream oobaos = OpenOfficeWorker.convertOODocByteStreamToByteStream(xmulticomponentfactory, oobais, inputMimeType, "application/pdf");
- PdfReader reader = new PdfReader(oobaos.toByteArray());
+ byteWrapper = DataResourceWorker.getContentAsByteWrapper(delegator, thisDataResourceId, https, webSiteId, locale, rootDir);
+ byte [] inputByteArray = null;
+ PdfReader reader = null;
+ if (inputMimeType != null && inputMimeType.equals("application/pdf")) {
+ inputByteArray = byteWrapper.getBytes();
+ reader = new PdfReader(inputByteArray);
+ } else if (inputMimeType != null && inputMimeType.equals("text/html")) {
+ inputByteArray = byteWrapper.getBytes();
+ String s = new String(inputByteArray);
+ Debug.logInfo("text/html string:" + s, module);
+ continue;
+ } else {
+ OpenOfficeByteArrayInputStream oobais = new OpenOfficeByteArrayInputStream(byteWrapper.getBytes());
+ OpenOfficeByteArrayOutputStream oobaos = OpenOfficeWorker.convertOODocByteStreamToByteStream(xmulticomponentfactory, oobais, inputMimeType, "application/pdf");
+ inputByteArray = oobaos.toByteArray();
+ oobais.close();
+ oobaos.close();
+ reader = new PdfReader(inputByteArray);
+ }
int n = reader.getNumberOfPages();
for (int i=0; i < n; i++) {
- PdfImportedPage pg = writer.getImportedPage(reader, i);
- cb.addTemplate(pg, .5f, 0, 0, .5f, 60, 120);
+ PdfImportedPage pg = writer.getImportedPage(reader, i + 1);
+ cb.addTemplate(pg, left, height * pgCnt);
+ pgCnt++;
}
- oobais.close();
- oobaos.close();
}
+ document.close();
ByteWrapper outByteWrapper = new ByteWrapper(baos.toByteArray());
results.put("pdfByteWrapper", outByteWrapper);
} catch (GenericEntityException e) {
- ServiceUtil.returnError(e.getMessage());
+ return ServiceUtil.returnError(e.getMessage());
} catch (IOException ioe) {
ioe.printStackTrace();
- ServiceUtil.returnError(ioe.getMessage());
+ return ServiceUtil.returnError(ioe.getMessage());
} catch( Exception e2 ) {
e2.printStackTrace();
- ServiceUtil.returnError(e2.getMessage());
+ return ServiceUtil.returnError(e2.getMessage());
}
- System.out.println("xmulticomponentfactory: " + xmulticomponentfactory);
return results;
}
@@ -523,13 +544,13 @@
ByteWrapper outByteWrapper = new ByteWrapper(baos.toByteArray());
results.put("pdfByteWrapper", outByteWrapper);
} catch (GenericEntityException e) {
- ServiceUtil.returnError(e.getMessage());
+ return ServiceUtil.returnError(e.getMessage());
} catch (IOException ioe) {
ioe.printStackTrace();
- ServiceUtil.returnError(ioe.getMessage());
+ return ServiceUtil.returnError(ioe.getMessage());
} catch( Exception e2 ) {
e2.printStackTrace();
- ServiceUtil.returnError(e2.getMessage());
+ return ServiceUtil.returnError(e2.getMessage());
}
System.out.println("xmulticomponentfactory: " + xmulticomponentfactory);
return results;
Modified: trunk/applications/content/webapp/content/WEB-INF/controller.xml
===================================================================
--- trunk/applications/content/webapp/content/WEB-INF/controller.xml 2006-02-23 05:56:22 UTC (rev 6831)
+++ trunk/applications/content/webapp/content/WEB-INF/controller.xml 2006-02-23 23:19:38 UTC (rev 6832)
@@ -885,6 +885,12 @@
<response name="success" type="view" value="ViewCompDocTemplateTree"/>
<response name="error" type="view" value="ViewCompDocTemplateTree"/>
</request-map>
+
+ <request-map uri="GenCompDocPdf">
+ <security auth="true" https="true"/>
+ <event invoke="genCompDocPdf" path="org.ofbiz.content.openoffice.OpenOfficeEvents" type="java"/>
+ <response name="error" type="view" value="error"/>
+ </request-map>
<!-- ================ CompDoc ContentRole Requests ================= -->
<request-map uri="EditCompDocContentRole"><security auth="true" https="true"/><response name="success" type="view" value="EditCompDocContentRole"/></request-map>
<request-map uri="addCompDocContentRole">
Modified: trunk/applications/content/widget/compdoc/CompDocScreens.xml
===================================================================
--- trunk/applications/content/widget/compdoc/CompDocScreens.xml 2006-02-23 05:56:22 UTC (rev 6831)
+++ trunk/applications/content/widget/compdoc/CompDocScreens.xml 2006-02-23 23:19:38 UTC (rev 6832)
@@ -836,7 +836,7 @@
<widgets>
<decorator-screen name="commonCompDocDecorator" location="component://content/widget/CommonScreens.xml">
<decorator-section name="body">
- <link target="GenCompDocPDF?contentId=${contentId}&contentRevisionSeqId=${contentRevisionSeqId}" text="Generate Composite PDF" style="buttontext"/>
+ <container><link target="GenCompDocPdf?contentId=${contentId}&contentRevisionSeqId=${contentRevisionSeqId}" text="Generate Composite PDF" style="buttontext"/></container>
<include-tree name="CompDocInstanceTree" location="component://content/widget/compdoc/CompDocTemplateTree.xml"/>
</decorator-section>
</decorator-screen>
More information about the Svn
mailing list