Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java Fri Mar 27 17:00:22 2009 @@ -115,10 +115,10 @@ if (UtilValidate.isNotEmpty(contentPurposeTypeId)) { context.put("contentPurposeList", UtilMisc.toList(contentPurposeTypeId)); } - + Map result = dispatcher.runSync("persistContentAndAssoc", context); //Debug.logVerbose("in createLayoutImage, result:" + result, module); - + String dataResourceId = (String)result.get("dataResourceId"); String activeContentId = (String)result.get("contentId"); if (UtilValidate.isNotEmpty(activeContentId)) { @@ -127,14 +127,14 @@ //context2.put("dataResourceId", dataResourceId); context2.put("contentAssocTypeId", result.get("contentAssocTypeId")); context2.put("fromDate", result.get("fromDate")); - + request.setAttribute("contentId", result.get("contentId")); request.setAttribute("drDataResourceId", dataResourceId); request.setAttribute("currentEntityName", "SubContentDataResourceId"); - + context2.put("contentIdTo", formInput.get("contentIdTo")); context2.put("mapKey", formInput.get("mapKey")); - + //Debug.logVerbose("in createLayoutImage, context2:" + context2, module); Map result2 = dispatcher.runSync("deactivateAssocs", context2); } @@ -196,7 +196,7 @@ context.put("objectInfo", context.get("drobjectInfo")); context.put("drObjectInfo", null); context.put("drDataResourceTypeId", null); - + String dataResourceId = (String)context.get("drDataResourceId"); Debug.logVerbose("in createLayoutImage(java), dataResourceId:" + dataResourceId, ""); @@ -281,7 +281,7 @@ context.put("contentIdTo", contentIdTo); context.put("mapKey", mapKey); context.put("contentAssocTypeId", "SUB_CONTENT"); - + try { Map result = dispatcher.runSync("persistContentAndAssoc", context); //Debug.logVerbose("in replaceSubContent, result:" + result, module); @@ -291,13 +291,13 @@ //context2.put("dataResourceId", dataResourceId); context2.put("contentAssocTypeId", "SUB_CONTENT"); context2.put("fromDate", result.get("fromDate")); - + request.setAttribute("drDataResourceId", null); request.setAttribute("currentEntityName", "ContentDataResourceView"); - + context2.put("contentIdTo", contentIdTo); context2.put("mapKey", mapKey); - + //Debug.logVerbose("in replaceSubContent, context2:" + context2, module); Map result2 = dispatcher.runSync("deactivateAssocs", context2); } catch ( GenericServiceException e) { @@ -400,7 +400,7 @@ request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; } - + serviceIn = FastMap.newInstance(); serviceIn.put("userLogin", session.getAttribute("userLogin")); @@ -519,7 +519,7 @@ context2.put("fromDate", result.get("fromDate")); context2.put("contentIdTo", contentIdTo); context2.put("mapKey", mapKey); - + //Debug.logVerbose("in replaceSubContent, context2:" + context2, module); Map result2 = dispatcher.runSync("deactivateAssocs", context2); } catch ( GenericServiceException e) { @@ -590,7 +590,7 @@ context2.put("fromDate", result.get("fromDate")); context2.put("contentIdTo", contentIdTo); context2.put("mapKey", mapKey); - + //Debug.logVerbose("in replaceSubContent, context2:" + context2, module); Map result2 = dispatcher.runSync("deactivateAssocs", context2); */ @@ -606,7 +606,7 @@ Map paramMap = UtilHttp.getParameterMap(request); String entityName = (String)paramMap.get("entityName"); Locale locale = UtilHttp.getLocale(request); - + if (UtilValidate.isEmpty(entityName) ) { String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.entityname_empty", locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java Fri Mar 27 17:00:22 2009 @@ -53,7 +53,7 @@ //Debug.logVerbose("in uploadAndStoreImage", ""); Locale locale = UtilHttp.getLocale(request); - + Map results = FastMap.newInstance(); Map formInput = FastMap.newInstance(); results.put("formInput", formInput); @@ -104,7 +104,7 @@ ByteBuffer byteWrap = ByteBuffer.wrap(imageBytes); results.put("imageData", byteWrap); results.put("imageFileName", imageFi.getName()); - + //Debug.logVerbose("in uploadAndStoreImage, results:" + results, ""); return results; } Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayInputStream.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayInputStream.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayInputStream.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayInputStream.java Fri Mar 27 17:00:22 2009 @@ -31,22 +31,22 @@ */ public class OpenOfficeByteArrayInputStream extends ByteArrayInputStream implements XInputStream, XSeekable { - + public static final String module = OpenOfficeByteArrayInputStream.class.getName(); - + public OpenOfficeByteArrayInputStream(byte [] bytes) { super(bytes); } - - + + public long getPosition() throws com.sun.star.io.IOException { return this.pos; } - + public long getLength() throws com.sun.star.io.IOException { return this.count; } - + public void seek(long pos1) throws com.sun.star.io.IOException, IllegalArgumentException { this.pos = (int)pos1; } @@ -57,18 +57,18 @@ } public void closeInput() throws NotConnectedException, com.sun.star.io.IOException { - + try { close(); } catch ( IOException e) { String errMsg = e.getMessage(); throw new com.sun.star.io.IOException( errMsg, this ); } - + } - + public int readBytes(byte [][]buf, int pos2) throws BufferSizeExceededException, NotConnectedException, com.sun.star.io.IOException { - + int bytesRead = 0; byte [] buf2 = new byte[pos2]; try { @@ -77,7 +77,7 @@ String errMsg = e.getMessage(); throw new com.sun.star.io.IOException( errMsg, this ); } - + if (bytesRead > 0) { if (bytesRead < pos2) { byte [] buf3 = new byte[bytesRead]; Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayOutputStream.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayOutputStream.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayOutputStream.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayOutputStream.java Fri Mar 27 17:00:22 2009 @@ -33,7 +33,7 @@ public class OpenOfficeByteArrayOutputStream extends ByteArrayOutputStream implements XOutputStream { public static final String module = OpenOfficeByteArrayOutputStream.class.getName(); - + public OpenOfficeByteArrayOutputStream() { super(); // TODO Auto-generated constructor stub @@ -63,7 +63,7 @@ throw(new com.sun.star.io.IOException(e.getMessage())); } } - + public void flush() { try { Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java Fri Mar 27 17:00:22 2009 @@ -66,7 +66,7 @@ * and "/" for Linux/Unix. */ public static Map<String, Object> convertDocumentByteBuffer(DispatchContext dctx, Map<String, ? extends Object> context) { - + Map results = ServiceUtil.returnSuccess(); GenericDelegator delegator = dctx.getDelegator(); XMultiComponentFactory xmulticomponentfactory = null; @@ -78,7 +78,7 @@ String fileOutName = "OOOUT_" + uniqueSeqNum; File fileIn = null; File fileOut = null; - + ByteBuffer inByteBuffer = (ByteBuffer) context.get("inByteBuffer"); String inputMimeType = (String) context.get("inputMimeType"); String outputMimeType = (String) context.get("outputMimeType"); @@ -88,17 +88,17 @@ // if these are empty don't worry, the OpenOfficeWorker down below will take care of it String oooHost = (String) context.get("oooHost"); String oooPort = (String) context.get("oooPort"); - + try { xmulticomponentfactory = OpenOfficeWorker.getRemoteServer(oooHost, oooPort); byte[] inByteArray = inByteBuffer.getBytes(); - + // The following line work in linux, but not Windows or Mac environment. It is preferred because it does not use temporary files //OpenOfficeByteArrayInputStream oobais = new OpenOfficeByteArrayInputStream(inByteArray); //Debug.logInfo("Doing convertDocumentByteBuffer, inBytes size is [" + inByteArray.length + "]", module); //OpenOfficeByteArrayOutputStream baos = OpenOfficeWorker.convertOODocByteStreamToByteStream(xmulticomponentfactory, oobais, inputMimeType, outputMimeType); - - + + String tempDir = UtilProperties.getPropertyValue("content", "content.temp.dir"); fileIn = new File(tempDir + fileInName); FileOutputStream fos = new FileOutputStream(fileIn); @@ -114,7 +114,7 @@ baos.write(c); } fis.close(); - + results.put("outByteBuffer", new ByteBuffer(baos.toByteArray())); baos.close(); @@ -142,7 +142,7 @@ */ public static Map<String, Object> convertDocument(DispatchContext dctx, Map<String, ? extends Object> context) { XMultiComponentFactory xmulticomponentfactory = null; - + String stringUrl = "file:///" + context.get("filenameFrom"); String stringConvertedFile = "file:///" + context.get("filenameTo"); String filterName = "file:///" + context.get("filterName"); @@ -150,11 +150,11 @@ // if these are empty don't worry, the OpenOfficeWorker down below will take care of it String oooHost = (String) context.get("oooHost"); String oooPort = (String) context.get("oooPort"); - + try { xmulticomponentfactory = OpenOfficeWorker.getRemoteServer(oooHost, oooPort); OpenOfficeWorker.convertOODocToFile(xmulticomponentfactory, stringUrl, stringConvertedFile, filterName); - + Map results = ServiceUtil.returnSuccess(); return results; } catch (IOException e) { @@ -171,7 +171,7 @@ */ public static Map<String, Object> convertDocumentFileToFile(DispatchContext dctx, Map<String, ? extends Object> context) { XMultiComponentFactory xmulticomponentfactory = null; - + String stringUrl = (String) context.get("filenameFrom"); String stringConvertedFile = (String) context.get("filenameTo"); String inputMimeType = (String) context.get("inputMimeType"); @@ -180,7 +180,7 @@ // if these are empty don't worry, the OpenOfficeWorker down below will take care of it String oooHost = (String) context.get("oooHost"); String oooPort = (String) context.get("oooPort"); - + try { xmulticomponentfactory = OpenOfficeWorker.getRemoteServer(oooHost, oooPort); File inputFile = new File(stringUrl); @@ -199,7 +199,7 @@ fis.close(); oobais.close(); oobaos.close(); - + Map results = ServiceUtil.returnSuccess(); return results; } catch (IOException e) { @@ -216,7 +216,7 @@ */ public static Map<String, Object> convertDocumentStreamToStream(DispatchContext dctx, Map<String, ? extends Object> context) { XMultiComponentFactory xmulticomponentfactory = null; - + String stringUrl = "file:///" + context.get("filenameFrom"); String stringConvertedFile = "file:///" + context.get("filenameTo"); String inputMimeType = (String) context.get("inputMimeType"); @@ -225,7 +225,7 @@ // if these are empty don't worry, the OpenOfficeWorker down below will take care of it String oooHost = (String) context.get("oooHost"); String oooPort = (String) context.get("oooPort"); - + try { xmulticomponentfactory = OpenOfficeWorker.getRemoteServer(oooHost, oooPort); File inputFile = new File(stringUrl); @@ -244,7 +244,7 @@ fis.close(); oobais.close(); oobaos.close(); - + Map results = ServiceUtil.returnSuccess(); return results; } catch (IOException e) { @@ -261,7 +261,7 @@ */ public static Map<String, Object> compareDocuments(DispatchContext dctx, Map<String, ? extends Object> context) { XMultiComponentFactory xmulticomponentfactory = null; - + String stringUrl = "file:///" + context.get("filenameFrom"); String stringOriginalFile = "file:///" + context.get("filenameOriginal"); String stringOutFile = "file:///" + context.get("filenameOut"); @@ -269,7 +269,7 @@ // if these are empty don't worry, the OpenOfficeWorker down below will take care of it String oooHost = (String)context.get("oooHost"); String oooPort = (String)context.get("oooPort"); - + try { xmulticomponentfactory = OpenOfficeWorker.getRemoteServer(oooHost, oooPort); } catch (IOException e) { @@ -280,31 +280,31 @@ return ServiceUtil.returnError(e.toString()); } //System.out.println("xmulticomponentfactory: " + xmulticomponentfactory); - + // Converting the document to the favoured type try { // Composing the URL - - + + // Query for the XPropertySet interface. XPropertySet xpropertysetMultiComponentFactory = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xmulticomponentfactory); - + // Get the default context from the office server. Object objectDefaultContext = xpropertysetMultiComponentFactory.getPropertyValue("DefaultContext"); - + // Query for the interface XComponentContext. XComponentContext xcomponentcontext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, objectDefaultContext); - + /* A desktop environment contains tasks with one or more frames in which components can be loaded. Desktop is the environment for components which can instanciate within frames. */ - + Object desktopObj = xmulticomponentfactory.createInstanceWithContext("com.sun.star.frame.Desktop", xcomponentcontext); XDesktop desktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktopObj); XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktopObj); - - + + // Preparing properties for loading the document PropertyValue propertyvalue[] = new PropertyValue[ 1 ]; // Setting the flag for hidding the open document @@ -315,13 +315,13 @@ //propertyvalue[ 1 ] = new PropertyValue(); //propertyvalue[ 1 ].Name = "FilterName"; //propertyvalue[ 1 ].Value = "HTML (StarWriter)"; - + // Loading the wanted document Object objectDocumentToStore = xcomponentloader.loadComponentFromURL(stringUrl, "_blank", 0, propertyvalue); - + // Getting an object that will offer a simple way to store a document to a URL. XStorable xstorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, objectDocumentToStore); - + // Preparing properties for comparing the document propertyvalue = new PropertyValue[ 1 ]; // Setting the flag for overwriting @@ -338,7 +338,7 @@ XDispatchHelper dispatchHelper = (XDispatchHelper) UnoRuntime.queryInterface(XDispatchHelper.class, dispatchHelperObj); XDispatchProvider dispatchProvider = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class, frame); dispatchHelper.executeDispatch(dispatchProvider, ".uno:CompareDocuments", "", 0, propertyvalue); - + // Preparing properties for storing the document propertyvalue = new PropertyValue[ 1 ]; // Setting the flag for overwriting @@ -349,18 +349,18 @@ //propertyvalue[ 1 ] = new PropertyValue(); //propertyvalue[ 1 ].Name = "FilterName"; //propertyvalue[ 1 ].Value = context.get("convertFilterName"); - + Debug.logInfo("stringOutFile: "+stringOutFile, module); // Storing and converting the document xstorable.storeToURL(stringOutFile, propertyvalue); - + // Getting the method dispose() for closing the document XComponent xcomponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xstorable); - + // Closing the converted document xcomponent.dispose(); - + Map results = ServiceUtil.returnSuccess(); return results; } catch (Exception e) { Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeWorker.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeWorker.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeWorker.java Fri Mar 27 17:00:22 2009 @@ -54,15 +54,15 @@ public class OpenOfficeWorker{ public static final String module = OpenOfficeWorker.class.getName(); - + /** * Use OpenOffice to convert documents between types */ public static XMultiComponentFactory getRemoteServer(String host, String port) throws IOException, Exception { - + if (UtilValidate.isEmpty(host)) host = UtilProperties.getPropertyValue("openoffice-uno", "oo.host", "localhost"); if (UtilValidate.isEmpty(port)) port = UtilProperties.getPropertyValue("openoffice-uno", "oo.port", "8100"); - + XMultiComponentFactory xmulticomponentfactory = null; XComponentContext xcomponentcontext = null; Object objectUrlResolver = null; @@ -74,24 +74,24 @@ registered. Component context to be granted to a component for running. Arbitrary values can be retrieved from the context. */ xcomponentcontext = com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null); - + /* Gets the service manager instance to be used (or null). This method has been added for convenience, because the service manager is a often used object. */ xmulticomponentfactory = xcomponentcontext.getServiceManager(); - + /* Creates an instance of the component UnoUrlResolver which supports the services specified by the factory. */ objectUrlResolver = xmulticomponentfactory.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", xcomponentcontext); - + // Create a new url resolver xurlresolver = (XUnoUrlResolver) UnoRuntime.queryInterface(XUnoUrlResolver.class, objectUrlResolver); - + // Resolves an object that is specified as follow: // uno:<connection description>;<protocol description>;<initial object name> String url = "uno:socket,host=" + host + ",port=" + port + ";urp;StarOffice.ServiceManager"; objectInitial = xurlresolver.resolve(url); - + // Create a service manager from the initial object xmulticomponentfactory = (XMultiComponentFactory) UnoRuntime.queryInterface(XMultiComponentFactory.class, objectInitial); } catch (Exception e) { @@ -112,13 +112,13 @@ Debug.logError(e, errMsg, module); throw new IllegalArgumentException(errMsg); } - + return xmulticomponentfactory; } - + public static String listFilterNamesEvent(HttpServletRequest request, HttpServletResponse response) { XMultiComponentFactory factory = null; - + try { factory = getRemoteServer("localhost", "8100"); List filterList = getFilterNames(factory); @@ -132,7 +132,7 @@ } return "success"; } - + public static List getFilterNames(XMultiComponentFactory xmulticomponentfactory) throws Exception { XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xmulticomponentfactory); Object oDefaultContext = xPropertySet.getPropertyValue("DefaultContext"); @@ -142,7 +142,7 @@ Object filterFactory = xmulticomponentfactory.createInstanceWithContext("com.sun.star.document.FilterFactory", xComponentContext); XNameAccess xNameAccess = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, filterFactory); String [] filterNames = xNameAccess.getElementNames(); - + //String [] serviceNames = filterFactory.getAvailableServiceNames(); for (int i=0; i < filterNames.length; i++) { String s = filterNames[i]; @@ -160,28 +160,28 @@ List filterNameList = UtilMisc.toListArray(filterNames); return filterNameList; } - + public static void convertOODocToFile(XMultiComponentFactory xmulticomponentfactory, String fileInPath, String fileOutPath, String outputMimeType) throws FileNotFoundException, IOException, MalformedURLException, Exception { // Converting the document to the favoured type // Query for the XPropertySet interface. XPropertySet xpropertysetMultiComponentFactory = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xmulticomponentfactory); - + // Get the default context from the office server. Object objectDefaultContext = xpropertysetMultiComponentFactory.getPropertyValue("DefaultContext"); - + // Query for the interface XComponentContext. XComponentContext xcomponentcontext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, objectDefaultContext); - + /* A desktop environment contains tasks with one or more frames in which components can be loaded. Desktop is the environment for components which can instanciate within frames. */ - + Object desktopObj = xmulticomponentfactory.createInstanceWithContext("com.sun.star.frame.Desktop", xcomponentcontext); //XDesktop desktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktopObj); XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktopObj); - - + + // Preparing properties for loading the document PropertyValue propertyvalue[] = new PropertyValue[ 2 ]; // Setting the flag for hidding the open document @@ -197,10 +197,10 @@ String stringUrl = convertToUrl(fileInPath, xcomponentcontext); Debug.logInfo("stringUrl:" + stringUrl, module); Object objectDocumentToStore = xcomponentloader.loadComponentFromURL(stringUrl, "_blank", 0, propertyvalue); - + // Getting an object that will offer a simple way to store a document to a URL. XStorable xstorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, objectDocumentToStore); - + // Preparing properties for converting the document propertyvalue = new PropertyValue[ 3 ]; // Setting the flag for overwriting @@ -210,52 +210,52 @@ // Setting the filter name // Preparing properties for converting the document String filterName = getFilterNameFromMimeType(outputMimeType); - + propertyvalue[ 1 ] = new PropertyValue(); propertyvalue[ 1 ].Name = "FilterName"; propertyvalue[ 1 ].Value = filterName; - + propertyvalue[2] = new PropertyValue(); propertyvalue[2].Name = "CompressionMode"; propertyvalue[2].Value = "1"; - + // Storing and converting the document //File newFile = new File(stringConvertedFile); //newFile.createNewFile(); - + String stringConvertedFile = convertToUrl(fileOutPath, xcomponentcontext); Debug.logInfo("stringConvertedFile: "+stringConvertedFile, module); xstorable.storeToURL(stringConvertedFile, propertyvalue); - + // Getting the method dispose() for closing the document XComponent xcomponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xstorable); - + // Closing the converted document xcomponent.dispose(); return; } - + public static OpenOfficeByteArrayOutputStream convertOODocByteStreamToByteStream(XMultiComponentFactory xmulticomponentfactory, OpenOfficeByteArrayInputStream is, String inputMimeType, String outputMimeType) throws Exception { - + // Query for the XPropertySet interface. XPropertySet xpropertysetMultiComponentFactory = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xmulticomponentfactory); - + // Get the default context from the office server. Object objectDefaultContext = xpropertysetMultiComponentFactory.getPropertyValue("DefaultContext"); - + // Query for the interface XComponentContext. XComponentContext xcomponentcontext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, objectDefaultContext); - + /* A desktop environment contains tasks with one or more frames in which components can be loaded. Desktop is the environment for components which can instanciate within frames. */ - + Object desktopObj = xmulticomponentfactory.createInstanceWithContext("com.sun.star.frame.Desktop", xcomponentcontext); //XDesktop desktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktopObj); XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktopObj); - + // Preparing properties for loading the document PropertyValue propertyvalue[] = new PropertyValue[2]; // Setting the flag for hidding the open document @@ -266,23 +266,23 @@ propertyvalue[1] = new PropertyValue(); propertyvalue[1].Name = "InputStream"; propertyvalue[1].Value = is; - + // Loading the wanted document Object objectDocumentToStore = xcomponentloader.loadComponentFromURL("private:stream", "_blank", 0, propertyvalue); if (objectDocumentToStore == null) { Debug.logError("Could not get objectDocumentToStore object from xcomponentloader.loadComponentFromURL", module); } - + // Getting an object that will offer a simple way to store a document to a URL. XStorable xstorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, objectDocumentToStore); if (xstorable == null) { Debug.logError("Could not get XStorable object from UnoRuntime.queryInterface", module); } - + // Preparing properties for converting the document String filterName = getFilterNameFromMimeType(outputMimeType); propertyvalue = new PropertyValue[4]; - + propertyvalue[0] = new PropertyValue(); propertyvalue[0].Name = "OutputStream"; OpenOfficeByteArrayOutputStream os = new OpenOfficeByteArrayOutputStream(); @@ -299,19 +299,19 @@ propertyvalue[2] = new PropertyValue(); propertyvalue[2].Name = "CompressionMode"; propertyvalue[2].Value = "1"; - + xstorable.storeToURL("private:stream", propertyvalue); //xstorable.storeToURL("file:///home/byersa/testdoc1_file.pdf", propertyvalue); - + // Getting the method dispose() for closing the document XComponent xcomponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xstorable); - + // Closing the converted document xcomponent.dispose(); - + return os; } - + public static String getFilterNameFromMimeType(String mimeType) { String filterName = ""; if (UtilValidate.isEmpty(mimeType)) { @@ -328,7 +328,7 @@ return filterName; } - + public static String getExtensionFromMimeType(String mimeType) { String extension = ""; if (UtilValidate.isEmpty(mimeType)) { @@ -354,5 +354,5 @@ return returnUrl; } - + } Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/report/JREntityListIteratorDataSource.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/report/JREntityListIteratorDataSource.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/report/JREntityListIteratorDataSource.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/report/JREntityListIteratorDataSource.java Fri Mar 27 17:00:22 2009 @@ -32,7 +32,7 @@ * <code>JREntityListIteratorDataSource</code> */ public class JREntityListIteratorDataSource implements JRDataSource { - + public static final String module = JREntityListIteratorDataSource.class.getName(); private EntityListIterator entityListIterator = null; Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchEvents.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchEvents.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/search/SearchEvents.java Fri Mar 27 17:00:22 2009 @@ -43,7 +43,7 @@ public class SearchEvents { public static final String module = SearchEvents.class.getName(); - + public static String indexTree(HttpServletRequest request, HttpServletResponse response) { Map result; Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java Fri Mar 27 17:00:22 2009 @@ -69,7 +69,7 @@ */ public class PdfSurveyServices { - + public static final String module = PdfSurveyServices.class.getName(); /** @@ -89,7 +89,7 @@ PdfStamper pdfStamper = new PdfStamper(pdfReader, os); AcroFields acroFields = pdfStamper.getAcroFields(); Map acroFieldMap = acroFields.getFields(); - + String contentId = (String) context.get("contentId"); GenericValue survey = null; surveyId = (String) context.get("surveyId"); @@ -101,12 +101,12 @@ survey = delegator.createSetNextSeqId(survey); surveyId = survey.getString("surveyId"); } - + // create a SurveyQuestionCategory to put the questions in Map createCategoryResultMap = dispatcher.runSync("createSurveyQuestionCategory", UtilMisc.<String, Object>toMap("description", "From AcroForm in Content [" + contentId + "] for Survey [" + surveyId + "]", "userLogin", userLogin)); String surveyQuestionCategoryId = (String) createCategoryResultMap.get("surveyQuestionCategoryId"); - + pdfStamper.setFormFlattening(true); Iterator i = acroFieldMap.keySet().iterator(); while (i.hasNext()) { @@ -135,13 +135,13 @@ surveyQuestion.set("surveyQuestionTypeId", "TEXT_SHORT"); Debug.logWarning("Building Survey from PDF, fieldName=[" + fieldName + "]: don't know how to handle field type: " + type + "; defaulting to short text", module); } - + // ==== create a good sequenceNum based on tab order or if no tab order then the page location - + Integer tabPage = (Integer) item.page.get(0); Integer tabOrder = (Integer) item.tabOrder.get(0); Debug.logInfo("tabPage=" + tabPage + ", tabOrder=" + tabOrder, module); - + //array of float multiple of 5. For each of this groups the values are: [page, llx, lly, urx, ury] float[] fieldPositions = acroFields.getFieldPositions(fieldName); float fieldPage = fieldPositions[0]; @@ -159,15 +159,15 @@ sequenceNum = Long.valueOf((long) fieldPage * 10000 + (long) fieldLly * 1000 + (long) fieldLlx); Debug.logInfo("fieldPage=" + fieldPage + ", fieldLlx=" + fieldLlx + ", fieldLly=" + fieldLly + ", fieldUrx=" + fieldUrx + ", fieldUry=" + fieldUry + ", sequenceNum=" + sequenceNum, module); } - + // TODO: need to find something better to put into these fields... String annotation = null; Iterator widgetIter = item.widgets.iterator(); while (widgetIter.hasNext()) { PdfDictionary dict = (PdfDictionary) widgetIter.next(); - + // if the "/Type" value is "/Annot", then get the value of "/TU" for the annotation - + /* Interesting... this doesn't work, I guess we have to iterate to find the stuff... PdfObject typeValue = dict.get(new PdfName("/Type")); if (typeValue != null && "/Annot".equals(typeValue.toString())) { @@ -175,16 +175,16 @@ annotation = tuValue.toString(); } */ - + PdfObject typeValue = null; PdfObject tuValue = null; - + Set dictKeys = dict.getKeys(); Iterator dictKeyIter = dictKeys.iterator(); while (dictKeyIter.hasNext()) { PdfName dictKeyName = (PdfName) dictKeyIter.next(); PdfObject dictObject = dict.get(dictKeyName); - + if ("/Type".equals(dictKeyName.toString())) { typeValue = dictObject; } else if ("/TU".equals(dictKeyName.toString())) { @@ -196,7 +196,7 @@ annotation = tuValue.toString(); } } - + surveyQuestion.set("description", fieldName); if (UtilValidate.isNotEmpty(annotation)) { surveyQuestion.set("question", annotation); @@ -233,12 +233,12 @@ Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } - + Map results = ServiceUtil.returnSuccess(); results.put("surveyId", surveyId); return results; } - + /** * */ @@ -246,7 +246,7 @@ String surveyResponseId = null; try { - + GenericDelegator delegator = dctx.getDelegator(); String partyId = (String)context.get("partyId"); String surveyId = (String)context.get("surveyId"); @@ -264,15 +264,15 @@ surveyResponse.set("lastModifiedDate", UtilDateTime.nowTimestamp()); surveyResponse.create(); } - + ByteArrayOutputStream os = new ByteArrayOutputStream(); ByteBuffer byteBuffer = getInputByteBuffer(context, delegator); PdfReader r = new PdfReader(byteBuffer.array()); PdfStamper s = new PdfStamper(r,os); AcroFields fs = s.getAcroFields(); Map hm = fs.getFields(); - - + + s.setFormFlattening(true); Iterator i = hm.keySet().iterator(); while (i.hasNext()) { @@ -280,13 +280,13 @@ //AcroFields.Item item = fs.getFieldItem(fieldName); //int type = fs.getFieldType(fieldName); String value = fs.getField(fieldName); - + List questions = delegator.findByAnd("SurveyQuestionAndAppl", UtilMisc.toMap("surveyId", surveyId, "externalFieldRef", fieldName)); if (questions.size() == 0 ) { Debug.logInfo("No question found for surveyId:" + surveyId + " and externalFieldRef:" + fieldName, module); continue; } - + GenericValue surveyQuestionAndAppl = (GenericValue)questions.get(0); String surveyQuestionId = (String)surveyQuestionAndAppl.get("surveyQuestionId"); String surveyQuestionTypeId = (String)surveyQuestionAndAppl.get("surveyQuestionTypeId"); @@ -310,7 +310,7 @@ Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } - + Map results = ServiceUtil.returnSuccess(); results.put("surveyResponseId", surveyResponseId); return results; @@ -319,7 +319,7 @@ /** */ public static Map<String, Object> getAcroFieldsFromPdf(DispatchContext dctx, Map<String, ? extends Object> context) { - + Map acroFieldMap = FastMap.newInstance(); try { ByteArrayOutputStream os = new ByteArrayOutputStream(); @@ -329,21 +329,21 @@ PdfStamper s = new PdfStamper(r,os); AcroFields fs = s.getAcroFields(); Map map = fs.getFields(); - + s.setFormFlattening(true); - + // Debug code to get the values for setting TDP // String[] sa = fs.getAppearanceStates("TDP"); // for (int i=0;i<sa.length;i++) // Debug.log("Appearance="+sa[i]); - + Iterator iter = map.keySet().iterator(); while (iter.hasNext()) { String fieldName=(String)iter.next(); String parmValue = fs.getField(fieldName); acroFieldMap.put(fieldName, parmValue); } - + } catch (DocumentException e) { System.err.println(e.getMessage()); ServiceUtil.returnError(e.getMessage()); @@ -354,16 +354,16 @@ System.err.println(ioe.getMessage()); ServiceUtil.returnError(ioe.getMessage()); } - + Map results = ServiceUtil.returnSuccess(); results.put("acroFieldMap", acroFieldMap); return results; } - + /** */ public static Map<String, Object> setAcroFields(DispatchContext dctx, Map<String, ? extends Object> context) { - + Map results = ServiceUtil.returnSuccess(); GenericDelegator delegator = dctx.getDelegator(); try { @@ -374,14 +374,14 @@ PdfStamper s = new PdfStamper(r, baos); AcroFields fs = s.getAcroFields(); Map map = fs.getFields(); - + s.setFormFlattening(true); - + // Debug code to get the values for setting TDP // String[] sa = fs.getAppearanceStates("TDP"); // for (int i=0;i<sa.length;i++) // Debug.log("Appearance="+sa[i]); - + Iterator iter = map.keySet().iterator(); while (iter.hasNext()) { String fieldName=(String)iter.next(); @@ -399,11 +399,11 @@ } else { fieldValue=(String)obj; } - + if (UtilValidate.isNotEmpty(fieldValue)) fs.setField(fieldName, fieldValue); } - + s.close(); baos.close(); ByteBuffer outByteBuffer = ByteBuffer.wrap(baos.toByteArray()); @@ -424,11 +424,11 @@ System.err.println(ioe.getMessage()); ServiceUtil.returnError(ioe.getMessage()); } - + return results; } - - + + /** */ public static Map<String, Object> buildPdfFromSurveyResponse(DispatchContext dctx, Map<String, ? extends Object> rcontext) { @@ -457,10 +457,10 @@ } } } - + ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); - + List responses = delegator.findByAnd("SurveyResponseAnswer", UtilMisc.toMap("surveyResponseId", surveyResponseId)); Iterator iter = responses.iterator(); while (iter.hasNext()) { @@ -497,10 +497,10 @@ System.err.println(e.getMessage()); ServiceUtil.returnError(e.getMessage()); } - + return results; } - + /** * Returns list of maps with "question"->SurveyQuestion and "response"->SurveyResponseAnswer */ @@ -520,7 +520,7 @@ surveyId = surveyResponse.getString("surveyId"); } } - + List responses = delegator.findByAnd("SurveyResponseAnswer", UtilMisc.toMap("surveyResponseId", surveyResponseId)); Iterator iter = responses.iterator(); while (iter.hasNext()) { @@ -535,10 +535,10 @@ System.err.println(e.getMessage()); ServiceUtil.returnError(e.getMessage()); } - + return results; } - + /** */ public static Map<String, Object> setAcroFieldsFromSurveyResponse(DispatchContext dctx, Map<String, ? extends Object> context) { @@ -548,7 +548,7 @@ Map acroFieldMap = FastMap.newInstance(); String surveyResponseId = (String)context.get("surveyResponseId"); String acroFormContentId = null; - + try { String surveyId = null; if (UtilValidate.isNotEmpty(surveyResponseId)) { @@ -564,7 +564,7 @@ acroFormContentId = survey.getString("acroFormContentId"); } } - + List responses = delegator.findByAnd("SurveyResponseAnswer", UtilMisc.toMap("surveyResponseId", surveyResponseId)); Iterator iter = responses.iterator(); while (iter.hasNext()) { @@ -573,10 +573,10 @@ String surveyQuestionId = (String) surveyResponseAnswer.get("surveyQuestionId"); GenericValue surveyQuestion = delegator.findByPrimaryKeyCache("SurveyQuestion", UtilMisc.toMap("surveyQuestionId", surveyQuestionId)); - + List surveyQuestionApplList = EntityUtil.filterByDate(delegator.findByAndCache("SurveyQuestionAppl", UtilMisc.toMap("surveyId", surveyId, "surveyQuestionId", surveyQuestionId), UtilMisc.toList("-fromDate")), false); GenericValue surveyQuestionAppl = EntityUtil.getFirst(surveyQuestionApplList); - + String questionType = surveyQuestion.getString("surveyQuestionTypeId"); String fieldName = surveyQuestionAppl.getString("externalFieldRef"); if ("OPTION".equals(questionType)) { @@ -599,7 +599,7 @@ System.err.println(e.getMessage()); ServiceUtil.returnError(e.getMessage()); } - + try { ModelService modelService = dispatcher.getDispatchContext().getModelService("setAcroFields"); Map ctx = modelService.makeValid(context, "IN"); @@ -629,14 +629,14 @@ System.err.println(e.getMessage()); ServiceUtil.returnError(e.getMessage()); } - + return results; } - + public static ByteBuffer getInputByteBuffer(Map context, GenericDelegator delegator) throws GeneralException { - + ByteBuffer inputByteBuffer = (ByteBuffer)context.get("inputByteBuffer"); - + if (inputByteBuffer == null) { String pdfFileNameIn = (String)context.get("pdfFileNameIn"); String contentId = (String)context.get("contentId"); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java Fri Mar 27 17:00:22 2009 @@ -177,7 +177,7 @@ } else { currentAnswers = this.getResponseAnswers(null); } - + Map sqaaWithColIdListByMultiRespId = FastMap.newInstance(); Iterator surveyQuestionAndApplIter = surveyQuestionAndAppls.iterator(); while (surveyQuestionAndApplIter.hasNext()) { @@ -260,7 +260,7 @@ if (this.edit) { return true; } - + GenericValue survey = this.getSurvey(); if (!"Y".equals(survey.getString("allowMultiple")) || !"Y".equals(survey.getString("allowUpdate"))) { return false; @@ -404,7 +404,7 @@ boolean beganTransaction = false; try { beganTransaction = TransactionUtil.begin(); - + EntityListIterator eli = this.getEli(question); if (startIndex > 0 && number > 0) { resp = eli.getPartialList(startIndex, number); @@ -537,14 +537,14 @@ boolean beganTransaction = false; try { beganTransaction = TransactionUtil.begin(); - + long[] result = { 0, 0, 0 }; // index 0 = total responses // index 1 = total yes // index 2 = total no - + EntityListIterator eli = this.getEli(question); - + if (eli != null) { GenericValue value; while (((value = (GenericValue) eli.next()) != null)) { @@ -555,10 +555,10 @@ } result[0]++; // increment the count } - + eli.close(); } - + return result; } catch (GenericEntityException e) { try { @@ -589,9 +589,9 @@ boolean beganTransaction = false; try { beganTransaction = TransactionUtil.begin(); - + EntityListIterator eli = this.getEli(question); - + if (eli != null) { GenericValue value; while (((value = (GenericValue) eli.next()) != null)) { @@ -617,7 +617,7 @@ } result[0]++; // increment the count } - + eli.close(); } } catch (GenericEntityException e) { @@ -678,7 +678,7 @@ boolean beganTransaction = false; try { beganTransaction = TransactionUtil.begin(); - + EntityListIterator eli = this.getEli(question); if (eli != null) { GenericValue value; @@ -695,7 +695,7 @@ total++; // increment the count } } - + eli.close(); } } catch (GenericEntityException e) { Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java Fri Mar 27 17:00:22 2009 @@ -49,10 +49,10 @@ * This handler will use JPublish to generate the XSL-FO */ public class SimpleContentViewHandler extends AbstractViewHandler { - + public static final String module = SimpleContentViewHandler.class.getName(); protected ServletContext servletContext = null; - + public void init(ServletContext context) throws ViewHandlerException { this.servletContext = context; } @@ -60,7 +60,7 @@ * @see org.ofbiz.webapp.view.ViewHandler#render(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ public void render(String name, String page, String info, String contentType, String encoding, HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException { - + String contentId = request.getParameter("contentId"); String rootContentId = request.getParameter("rootContentId"); String mapKey = request.getParameter("mapKey"); @@ -73,7 +73,7 @@ String rootDir = null; String webSiteId = null; String https = null; - + if (UtilValidate.isEmpty(rootDir)) { rootDir = servletContext.getRealPath("/"); } Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/CheckPermissionTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/CheckPermissionTransform.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/CheckPermissionTransform.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/CheckPermissionTransform.java Fri Mar 27 17:00:22 2009 @@ -104,7 +104,7 @@ //Debug.logInfo("in CheckPermission, trailCsv(2):" + trailCsv,""); //Debug.logInfo("in CheckPermission, contentId(2):" + templateCtx.get("contentId"),""); //Debug.logInfo("in CheckPermission, subContentId(2):" + templateCtx.get("subContentId"),""); - + GenericValue currentContent = null; String contentAssocPredicateId = (String)templateCtx.get("contentAssocPredicateId"); String strNullThruDatesOnly = (String)templateCtx.get("nullThruDatesOnly"); @@ -126,12 +126,12 @@ currentContent.put("ownerContentId", templateCtx.get("ownerContentId")); } //Debug.logInfo("in CheckPermission, currentContent(1):" + currentContent.get("contentId"),""); - + Security security = null; if (request != null) { security = (Security) request.getAttribute("security"); } - + String statusId = (String)currentContent.get("statusId"); String passedStatusId = (String)templateCtx.get("statusId"); List statusList = StringUtil.split(passedStatusId, "|"); @@ -155,7 +155,7 @@ throw new IOException("targetOperationList has zero size."); } List roleList = FastList.newInstance(); - + String privilegeEnumId = (String)currentContent.get("privilegeEnumId"); Map results = EntityPermissionChecker.checkPermission(currentContent, statusList, userLogin, purposeList, targetOperationList, roleList, delegator, security, entityOperation, privilegeEnumId, quickCheckContentId); @@ -167,7 +167,7 @@ String permissionStatus = (String) results.get("permissionStatus"); if (UtilValidate.isEmpty(permissionStatus) || !permissionStatus.equals("granted")) { - + String errorMessage = "Permission to add response is denied (2)"; PermissionRecorder recorder = (PermissionRecorder)results.get("permissionRecorder"); //Debug.logInfo("recorder(0):" + recorder, ""); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentCacheTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentCacheTransform.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentCacheTransform.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentCacheTransform.java Fri Mar 27 17:00:22 2009 @@ -53,7 +53,7 @@ public static final String module = EditRenderSubContentCacheTransform.class.getName(); public static final String [] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale", "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly"}; - + /** * A wrapper for the FreeMarkerWorker version. */ @@ -138,7 +138,7 @@ String wrapTemplateId = (String)templateCtx.get("wrapTemplateId"); if (UtilValidate.isNotEmpty(wrapTemplateId)) { templateCtx.put("wrappedContent", wrappedContent); - + //Map templateRoot = FreeMarkerWorker.createEnvironmentMap(env); Map templateRoot = null; Map templateRootTemplate = (Map)templateCtx.get("templateRootTemplate"); @@ -149,7 +149,7 @@ } else { templateRoot = UtilMisc.makeMapWritable(templateRootTemplate); } - + templateRoot.put("context", templateCtx); if (Debug.verboseOn()) { Set kySet = templateCtx.keySet(); @@ -159,7 +159,7 @@ Object val = templateCtx.get(ky); } } - + String mimeTypeId = (String)templateCtx.get("mimeTypeId"); Locale locale = null; try { @@ -173,7 +173,7 @@ Debug.logError(e2, "Error rendering content" + e2.getMessage(), module); throw new IOException("Error rendering content" + e2.toString()); } - + } else { out.write(wrappedContent); } Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java Fri Mar 27 17:00:22 2009 @@ -48,7 +48,7 @@ public class EditRenderSubContentTransform implements TemplateTransformModel { public static final String module = EditRenderSubContentTransform.class.getName(); - + /** * A wrapper for the FreeMarkerWorker version. */ @@ -76,7 +76,7 @@ String subDataResourceTypeIdTemp = getArg(args, "subDataResourceTypeId", ctx); final String contentId = getArg(args, "contentId", ctx); - + final Locale locale = (Locale) FreeMarkerWorker.getWrappedObject("locale", env); String mimeTypeIdTemp = getArg(args, "mimeTypeId", ctx); final String rootDir = getArg(args, "rootDir", ctx); @@ -179,9 +179,9 @@ templateContext.put("webSiteId", webSiteId); templateContext.put("https", https); templateContext.put("rootDir", rootDir); - + Map templateRoot = FreeMarkerWorker.createEnvironmentMap(env); - + templateRoot.put("wrapDataResourceId", dataResourceId); templateRoot.put("wrapDataResourceTypeId", subDataResourceTypeId); templateRoot.put("wrapContentIdTo", contentId); @@ -189,7 +189,7 @@ templateRoot.put("wrapMimeTypeId", mimeTypeId); templateRoot.put("wrapMapKey", mapKey); templateRoot.put("context", templateContext); - + try { ContentWorker.renderContentAsText(dispatcher, delegator, wrapTemplateId, out, templateRoot, locale, mimeTypeId, false); } catch (IOException e) { @@ -199,7 +199,7 @@ Debug.logError(e2, "Error rendering content" + e2.getMessage(), module); throw new IOException("Error rendering content" + e2.toString()); } - + Map ctx = (Map) FreeMarkerWorker.getWrappedObject("context", env); templateContext.put("contentId", contentId); templateContext.put("locale", locale); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/InjectNodeTrailCsvTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/InjectNodeTrailCsvTransform.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/InjectNodeTrailCsvTransform.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/InjectNodeTrailCsvTransform.java Fri Mar 27 17:00:22 2009 @@ -136,7 +136,7 @@ } else { lastPassedContentId = passedCsv; } - + if (UtilValidate.isNotEmpty(lastPassedContentId)) { if (UtilValidate.isNotEmpty(trail)) { Map nd = (Map)trail.get(0); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LimitedSubContentCacheTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LimitedSubContentCacheTransform.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LimitedSubContentCacheTransform.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LimitedSubContentCacheTransform.java Fri Mar 27 17:00:22 2009 @@ -94,7 +94,7 @@ contentAssocTypeId = "SUB_CONTENT"; templateRoot.put("contentAssocTypeId ", contentAssocTypeId); } - + final Map pickedEntityIds = FastMap.newInstance(); List assocTypes = StringUtil.split(contentAssocTypeId, "|"); @@ -131,7 +131,7 @@ String strNullThruDatesOnly = (String) templateRoot.get("nullThruDatesOnly"); String orderBy = (String) templateRoot.get("orderBy"); Boolean nullThruDatesOnly = (strNullThruDatesOnly != null && strNullThruDatesOnly.equalsIgnoreCase("true")) ? Boolean.TRUE : Boolean.FALSE; - + // NOTE this was looking for subContentId, but that doesn't make ANY sense, so changed to contentId String contentId = (String) templateRoot.get("contentId"); @@ -190,7 +190,7 @@ List subList = list.subList(0, list.size() - 1); templateRoot.put("globalNodeTrail", subList); env.setVariable("globalNodeTrail", FreeMarkerWorker.autoWrap(subList, env)); - + //if (Debug.infoOn()) Debug.logInfo("highIndex(2):" + highIndexInteger , ""); //if (Debug.infoOn()) Debug.logInfo("in limited, returnLimit(2):" + returnLimit , ""); //if (Debug.verboseOn()) Debug.logVerbose("in limited, pickedEntityIds(2):" + pickedEntityIds , ""); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java Fri Mar 27 17:00:22 2009 @@ -143,13 +143,13 @@ final GenericDelegator delegator = (GenericDelegator) FreeMarkerWorker.getWrappedObject("delegator", env); final Map savedValues = FreeMarkerWorker.saveValues(templateCtx, saveKeyNames); FreeMarkerWorker.overrideWithArgs(templateCtx, args); - + String contentAssocTypeId = (String) templateCtx.get("contentAssocTypeId"); if (UtilValidate.isEmpty(contentAssocTypeId)) { contentAssocTypeId = "SUB_CONTENT"; templateCtx.put("contentAssocTypeId ", contentAssocTypeId); } - + List assocTypes = UtilMisc.toList(contentAssocTypeId); templateCtx.put("assocTypes", assocTypes); Locale locale = (Locale) templateCtx.get("locale"); @@ -164,12 +164,12 @@ fromDate = UtilDateTime.toTimestamp(fromDateStr); } if (fromDate == null) fromDate = UtilDateTime.nowTimestamp(); - + String thisContentId = (String) templateCtx.get("contentId"); - + //DEJ20080730 Should always use contentId, not subContentId since we're searching for that and it is confusing //if (UtilValidate.isEmpty(thisContentId)) thisContentId = (String)templateCtx.get("subContentId"); - + String thisMapKey = (String)templateCtx.get("mapKey"); //GenericValue subContentDataResourceView = null; Map results = ContentServicesComplex.getAssocAndContentAndDataResourceMethod(delegator, thisContentId, thisMapKey, null, fromDate, null, null, null, assocTypes, null); @@ -216,14 +216,14 @@ String wrapTemplateId = (String)templateCtx.get("wrapTemplateId"); if (UtilValidate.isNotEmpty(wrapTemplateId)) { templateCtx.put("wrappedFTL", wrappedFTL); - + Map templateRoot = FreeMarkerWorker.createEnvironmentMap(env); - + templateRoot.put("wrapDataResourceTypeId", templateCtx.get("subDataResourceTypeId")); templateRoot.put("wrapContentIdTo", templateCtx.get("contentId")); templateRoot.put("wrapMimeTypeId", templateCtx.get("mimeTypeId")); templateRoot.put("context", templateCtx); - + Locale locale = (Locale) templateCtx.get("locale"); if (locale == null) locale = Locale.getDefault(); String mimeTypeId = (String) templateCtx.get("mimeTypeId"); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java Fri Mar 27 17:00:22 2009 @@ -73,7 +73,7 @@ FreeMarkerWorker.overrideWithArgs(templateRoot, args); final Map savedValues = FastMap.newInstance(); - + return new Writer(out) { public void write(char cbuf[], int off, int len) { @@ -111,7 +111,7 @@ // if ("true".equals(xmlEscape)) { // txt = UtilFormatOut.encodeXmlValue(txt); // } - + out.write(txt); // if (Debug.infoOn()) Debug.logInfo("in RenderSubContent, after renderContentAsTextCache:", module); @@ -131,7 +131,7 @@ } //FreeMarkerWorker.reloadValues(templateRoot, savedValues, env); //FreeMarkerWorker.reloadValues(templateRoot, savedValuesUp, env); - + } catch (GeneralException e) { String errMsg = "Error rendering thisContentId:" + (String)templateRoot.get("contentId") + " msg:" + e.toString(); Debug.logError(e, errMsg, module); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAsText.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAsText.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAsText.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAsText.java Fri Mar 27 17:00:22 2009 @@ -184,9 +184,9 @@ if ("true".equals(xmlEscape)) { txt = UtilFormatOut.encodeXmlValue(txt); } - + out.write(txt); - + // if (Debug.infoOn()) Debug.logInfo("in RenderSubContent, after renderContentAsTextCache:", module); } catch (GeneralException e) { String errMsg = "Error rendering thisContentId:" + thisContentId + " msg:" + e.toString(); @@ -219,7 +219,7 @@ fullRequest += delim + "contentId=" + contentId; delim = "&"; } - + out.write("<a href=\""); ServletContext servletContext = (ServletContext) request.getSession().getServletContext(); RequestHandler rh = (RequestHandler) servletContext.getAttribute("_REQUEST_HANDLER_"); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentTransform.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentTransform.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentTransform.java Fri Mar 27 17:00:22 2009 @@ -58,7 +58,7 @@ final LocalDispatcher dispatcher = (LocalDispatcher) FreeMarkerWorker.getWrappedObject("dispatcher", env); final HttpServletRequest request = (HttpServletRequest) FreeMarkerWorker.getWrappedObject("request", env); final HttpServletResponse response = (HttpServletResponse) FreeMarkerWorker.getWrappedObject("response", env); - + final Map templateRoot = MapStack.create(FreeMarkerWorker.createEnvironmentMap(env)); ((MapStack)templateRoot).push(args); final String xmlEscape = (String)templateRoot.get("xmlEscape"); @@ -96,7 +96,7 @@ try { String txt = null; - + String mapKey = (String)templateRoot.get("mapKey"); if ( UtilValidate.isEmpty(mapKey)) { txt = ContentWorker.renderContentAsText(dispatcher, delegator, thisContentId, templateRoot, locale, mimeTypeId, true); @@ -106,9 +106,9 @@ if ("true".equals(xmlEscape)) { txt = UtilFormatOut.encodeXmlValue(txt); } - + out.write(txt); - + } catch (GeneralException e) { String errMsg = "Error rendering thisContentId:" + thisContentId + " msg:" + e.toString(); Debug.logError(e, errMsg, module); @@ -133,7 +133,7 @@ fullRequest += delim + "contentId=" + thisContentId; delim = "&"; } - + out.write("<a href=\""); ServletContext servletContext = (ServletContext) request.getSession().getServletContext(); RequestHandler rh = (RequestHandler) servletContext.getAttribute("_REQUEST_HANDLER_"); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentAsText.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentAsText.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentAsText.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentAsText.java Fri Mar 27 17:00:22 2009 @@ -168,7 +168,7 @@ if ("true".equals(xmlEscape)) { txt = UtilFormatOut.encodeXmlValue(txt); } - + out.write(txt); if (Debug.infoOn()) Debug.logInfo("in RenderSubContent, after renderContentAsTextCache:", module); @@ -187,7 +187,7 @@ } public void openEditWrap(Writer out, String editStyle) throws IOException { - + String divStr = "<div class=\"" + editStyle + "\">"; out.write(divStr); } @@ -203,7 +203,7 @@ String contentAssocTypeId = null; String mapKey = null; String fromDate = null; - + contentIdTo = (String)templateRoot.get("contentId"); contentAssocTypeId = (String)templateRoot.get("contentAssocTypeId"); mapKey = (String)templateRoot.get("mapKey"); @@ -254,7 +254,7 @@ fullRequest += delim + "fromDate=" + fromDate; delim = "&"; } - + if (Debug.infoOn()) Debug.logInfo("in Render(2), contentIdTo ." + contentIdTo , module); WidgetWorker.appendOfbizUrl(sb, fullRequest, request, response); String url = sb.toString(); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java Fri Mar 27 17:00:22 2009 @@ -208,7 +208,7 @@ String contentAssocTypeId = null; String mapKey = null; String fromDate = null; - + if (!directAssocMode) { contentIdTo = (String)templateRoot.get("contentId"); contentAssocTypeId = (String)templateRoot.get("contentAssocTypeId"); @@ -263,7 +263,7 @@ fullRequest += delim + "fromDate=" + fromDate; delim = "&"; } - + if (Debug.infoOn()) Debug.logInfo("in Render(2), contentIdTo ." + contentIdTo , module); out.write("<a href=\""); ServletContext servletContext = (ServletContext) request.getSession().getServletContext(); @@ -284,7 +284,7 @@ return editStyle; } }; - + } } Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java Fri Mar 27 17:00:22 2009 @@ -102,7 +102,7 @@ //final GenericValue userLogin = (GenericValue) FreeMarkerWorker.getWrappedObject("userLogin", env); GenericValue view = (GenericValue) FreeMarkerWorker.getWrappedObject("subContentDataResourceView", env); final Integer indent = (templateCtx.get("indent") == null) ? Integer.valueOf(0) : (Integer)templateCtx.get("indent"); - + String contentId = (String)templateCtx.get("contentId"); String subContentId = (String)templateCtx.get("subContentId"); if (view == null) { @@ -111,7 +111,7 @@ thisContentId = contentId; if (UtilValidate.isNotEmpty(thisContentId)) { - + try { view = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", thisContentId)); } catch (GenericEntityException e) { @@ -229,9 +229,9 @@ String wrapTemplateId = (String)templateCtx.get("wrapTemplateId"); if (UtilValidate.isNotEmpty(wrapTemplateId)) { templateCtx.put("wrappedFTL", wrappedFTL); - + Map templateRoot = FreeMarkerWorker.createEnvironmentMap(env); - + /* templateRoot.put("viewSize", viewSize); templateRoot.put("viewIndex", viewIndex); @@ -243,7 +243,7 @@ templateRoot.put("wrapContentIdTo", contentId); templateRoot.put("wrapMimeTypeId", mimeTypeId); //templateRoot.put("wrapMapKey", mapKey); - + */ templateRoot.put("context", templateCtx); String mimeTypeId = (String) templateCtx.get("mimeTypeId"); @@ -277,7 +277,7 @@ } private boolean checkWhen (GenericValue thisContent, String contentAssocTypeId) { - + boolean isPick = false; Map assocContext = FastMap.newInstance(); if (UtilValidate.isEmpty(contentAssocTypeId)) Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/WrapSubContentCacheTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/WrapSubContentCacheTransform.java?rev=759248&r1=759247&r2=759248&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/WrapSubContentCacheTransform.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/WrapSubContentCacheTransform.java Fri Mar 27 17:00:22 2009 @@ -52,7 +52,7 @@ public static final String module = WrapSubContentCacheTransform.class.getName(); public static final String [] upSaveKeyNames = {"globalNodeTrail"}; public static final String [] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale", "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly"}; - + /** * A wrapper for the FreeMarkerWorker version. */ @@ -149,13 +149,13 @@ FreeMarkerWorker.reloadValues(templateCtx, savedValues, env); //if (Debug.infoOn()) Debug.logInfo("in Wrap(2), savedValues ." + savedValues , module); String wrappedContent = buf.toString(); - + //if (view != null && Debug.infoOn()) Debug.logInfo("in WrapSubContent, view(2):" + view.get("contentId"), module); //if (Debug.infoOn()) Debug.logInfo("in WrapSubContent, wrappedContent:" + wrappedContent, module); //if (Debug.infoOn()) Debug.logInfo("in WrapSubContent, wrapTemplateId(2):" + wrapTemplateId, module); if (UtilValidate.isNotEmpty(wrapTemplateId)) { templateCtx.put("wrappedContent", wrappedContent); - + //Map templateRoot = FreeMarkerWorker.createEnvironmentMap(env); Map templateRoot = null; Map templateRootTemplate = (Map)templateCtx.get("templateRootTemplate"); @@ -166,9 +166,9 @@ } else { templateRoot = UtilMisc.makeMapWritable(templateRootTemplate); } - + templateRoot.put("context", templateCtx); - + String mimeTypeId = (String)templateCtx.get("mimeTypeId"); Locale locale = null; try { @@ -182,7 +182,7 @@ Debug.logError(e2, "Error rendering content" + e2.getMessage(), module); throw new IOException("Error rendering content" + e2.toString()); } - + FreeMarkerWorker.reloadValues(templateCtx, savedValuesUp, env); //if (Debug.infoOn()) Debug.logInfo("in Wrap(2), savedValuesUp ." + savedValuesUp , module); } |
Free forum by Nabble | Edit this page |