From cee09e0576e46c309d3dac1687f974ae17a82537 Mon Sep 17 00:00:00 2001 From: Adam Heath Date: Sat, 21 Mar 2009 23:43:51 +0000 Subject: [PATCH] Fix purely empty whitespace lines, and remove trailing whitespace. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@757086 13f79535-47bb-0310-9956-ffa450edef68 --- applications/content/src/ControlApplet.java | 122 ++--- .../content/ContentManagementEvents.java | 6 +- .../content/ContentManagementServices.java | 280 ++++++------ .../content/ContentManagementWorker.java | 52 +-- .../src/org/ofbiz/content/ConvertTree.java | 36 +- .../ofbiz/content/blog/BlogRssServices.java | 2 +- .../src/org/ofbiz/content/cms/CmsEvents.java | 16 +- .../ofbiz/content/compdoc/CompDocEvents.java | 44 +- .../content/compdoc/CompDocServices.java | 56 +-- .../ofbiz/content/content/ContentEvents.java | 4 +- .../content/content/ContentMapFacade.java | 16 +- .../content/ContentPermissionServices.java | 90 ++-- .../content/content/ContentServices.java | 38 +- .../content/ContentServicesComplex.java | 24 +- .../ofbiz/content/content/ContentWorker.java | 80 ++-- .../ofbiz/content/content/ContentWrapper.java | 6 +- .../content/content/PermissionRecorder.java | 14 +- .../content/UploadContentAndImage.java | 30 +- .../org/ofbiz/content/data/DataEvents.java | 26 +- .../content/data/DataResourceWorker.java | 28 +- .../org/ofbiz/content/data/DataServices.java | 20 +- .../ofbiz/content/layout/LayoutEvents.java | 60 +-- .../ofbiz/content/layout/LayoutServices.java | 4 +- .../ofbiz/content/layout/LayoutWorker.java | 18 +- .../OpenOfficeByteArrayInputStream.java | 28 +- .../OpenOfficeByteArrayOutputStream.java | 8 +- .../openoffice/OpenOfficeServices.java | 86 ++-- .../content/openoffice/OpenOfficeWorker.java | 108 ++--- .../ofbiz/content/output/OutputServices.java | 420 +++++++++--------- .../JREntityListIteratorDataSource.java | 6 +- .../report/JRMapCollectionDataSource.java | 4 +- .../ofbiz/content/search/ContentDocument.java | 4 +- .../content/search/DataResourceDocument.java | 4 +- .../ofbiz/content/search/SearchEvents.java | 6 +- .../ofbiz/content/search/SearchServices.java | 4 +- .../content/survey/PdfSurveyServices.java | 130 +++--- .../ofbiz/content/survey/SurveyWrapper.java | 30 +- .../view/SimpleContentViewHandler.java | 12 +- .../webapp/ftl/CheckPermissionTransform.java | 18 +- .../EditRenderSubContentCacheTransform.java | 16 +- .../ftl/EditRenderSubContentTransform.java | 18 +- .../ftl/InjectNodeTrailCsvTransform.java | 12 +- .../ftl/LimitedSubContentCacheTransform.java | 12 +- .../webapp/ftl/LoopSubContentTransform.java | 20 +- .../ftl/RenderContentAndSubContent.java | 18 +- .../webapp/ftl/RenderContentAsText.java | 12 +- .../webapp/ftl/RenderContentTransform.java | 16 +- .../webapp/ftl/RenderSubContentAsText.java | 18 +- .../ftl/RenderSubContentCacheTransform.java | 12 +- .../webapp/ftl/RenderSubContentTransform.java | 4 +- .../ftl/TraverseSubContentCacheTransform.java | 6 +- .../ftl/TraverseSubContentTransform.java | 20 +- .../ftl/WrapSubContentCacheTransform.java | 18 +- 53 files changed, 1071 insertions(+), 1071 deletions(-) diff --git a/applications/content/src/ControlApplet.java b/applications/content/src/ControlApplet.java index 307c416756..8f501e55d0 100644 --- a/applications/content/src/ControlApplet.java +++ b/applications/content/src/ControlApplet.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -36,82 +36,82 @@ import java.util.Map; * Control Applet - Client applet for page pushing and (future) chat */ public class ControlApplet extends Applet implements Runnable { - + private static String pushUrl = "/commonapp/control/pushapplet"; private static String pullUrl = "/commonapp/control/pullapplet"; - + protected AppletContext ctx = null; - + protected String sessionId = null; protected String visitId = null; - protected String serverUrl = null; + protected String serverUrl = null; protected String timeoutUrl = null; - protected String currentPage = null; + protected String currentPage = null; protected String debug = null; - + protected int waitTime = 1500; protected int timeout = 300000; - + protected boolean isRunning = false; protected boolean stopped = true; - + protected Thread thread = null; - + public void init() { ctx = this.getAppletContext(); this.sessionId = this.getParameter("sessionId"); this.visitId = this.getParameter("visitId"); - this.serverUrl = this.getParameter("serverUrl"); - this.timeoutUrl = this.getParameter("timeoutUrl"); - this.currentPage = this.getParameter("currentPage"); + this.serverUrl = this.getParameter("serverUrl"); + this.timeoutUrl = this.getParameter("timeoutUrl"); + this.currentPage = this.getParameter("currentPage"); this.debug = this.getParameter("debug"); - + // see if we override the integer values try { int waitInt = Integer.parseInt(this.getParameter("waitTime")); if (waitInt > 0) - waitTime = waitInt; + waitTime = waitInt; } catch (NumberFormatException e) { } try { int outInt = Integer.parseInt(this.getParameter("timeout")); - if (outInt > 0) + if (outInt > 0) timeout = outInt; } catch (NumberFormatException e) { } - + if (serverUrl != null) { boolean sessionOkay = false; boolean visitOkay = false; - boolean pageOkay = false; - + boolean pageOkay = false; + if (sessionId != null && sessionId.length() > 0) sessionOkay = true; if (visitId != null && visitId.length() > 0) - visitOkay = true; - if (currentPage != null && currentPage.length() > 0) - pageOkay = true; - - if (sessionOkay && visitOkay && pageOkay) { + visitOkay = true; + if (currentPage != null && currentPage.length() > 0) + pageOkay = true; + + if (sessionOkay && visitOkay && pageOkay) { // tell the host about our current page (mainly for followers) this.push(); } - + // start the polling thread this.isRunning = true; this.stopped = false; thread = new Thread(this); - thread.setDaemon(false); + thread.setDaemon(false); thread.start(); - } + } } - + public void destroy() { - this.stopped = true; + this.stopped = true; } - + // poll the servlet for page request - public void run() { + public void run() { while (isRunning && !stopped) { this.pull(); try { @@ -119,55 +119,55 @@ public class ControlApplet extends Applet implements Runnable { } catch (InterruptedException e) { this.stopped = true; this.isRunning = false; - } + } } if (debug != null && debug.equalsIgnoreCase("true")) System.out.println("Polling finished."); } - - protected void pull() { + + protected void pull() { Map params = new HashMap(); params.put("sessionId", this.sessionId.trim()); params.put("visitId", this.visitId.trim()); - + String pullResp = null; URL callPullUrl = null; try { callPullUrl = new URL(serverUrl + pullUrl); } catch (MalformedURLException e) { } - + if (callPullUrl != null) { try { pullResp = callServer(callPullUrl, params); } catch (IOException e) { - } + } } - + if (pullResp != null && pullResp.length() > 0) { URL docUrl = null; try { docUrl = new URL(pullResp); } catch (MalformedURLException e) { } - if (docUrl != null) + if (docUrl != null) ctx.showDocument(docUrl, "appletWindow"); } } - + protected void push() { - Map params = new HashMap(); + Map params = new HashMap(); params.put("sessionId", this.sessionId.trim()); - params.put("visitId", this.visitId.trim()); - params.put("currentPage", this.currentPage.trim()); - + params.put("visitId", this.visitId.trim()); + params.put("currentPage", this.currentPage.trim()); + String pushResp = null; URL callPushUrl = null; try { - callPushUrl = new URL(serverUrl + pushUrl); + callPushUrl = new URL(serverUrl + pushUrl); } catch (MalformedURLException e) { } - + if (callPushUrl != null) { try { pushResp = callServer(callPushUrl, params); @@ -175,19 +175,19 @@ public class ControlApplet extends Applet implements Runnable { } } } - - private String callServer(URL serverUrl, Map parms) throws IOException { - // send the request - String parameters = this.encodeArgs(parms); - if (debug != null && debug.equalsIgnoreCase("true")) - System.out.println("Sending parameters: " + parameters); + + private String callServer(URL serverUrl, Map parms) throws IOException { + // send the request + String parameters = this.encodeArgs(parms); + if (debug != null && debug.equalsIgnoreCase("true")) + System.out.println("Sending parameters: " + parameters); URLConnection uc = serverUrl.openConnection(); uc.setDoOutput(true); uc.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); PrintWriter pw = new PrintWriter(uc.getOutputStream()); pw.println(parameters); pw.close(); - + // read the response BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream())); String responseStr = in.readLine(); @@ -195,10 +195,10 @@ public class ControlApplet extends Applet implements Runnable { if (responseStr != null) responseStr = responseStr.trim(); if (debug != null && debug.equalsIgnoreCase("true")) - System.out.println("Receive response: " + responseStr); - return responseStr; + System.out.println("Receive response: " + responseStr); + return responseStr; } - + public String encodeArgs(Map args) { StringBuffer buf = new StringBuffer(); if (args != null) { @@ -214,24 +214,24 @@ public class ControlApplet extends Applet implements Runnable { } else { valueStr = value.toString(); } - + if (valueStr != null && valueStr.length() > 0) { if (buf.length() > 0) buf.append('&'); try { buf.append(URLEncoder.encode(name, "UTF-8")); } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + e.printStackTrace(); } buf.append('='); try { buf.append(URLEncoder.encode(valueStr, "UTF-8")); } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + e.printStackTrace(); } } } } } return buf.toString(); - } + } } diff --git a/applications/content/src/org/ofbiz/content/ContentManagementEvents.java b/applications/content/src/org/ofbiz/content/ContentManagementEvents.java index 42ae1cd362..895c92ad9d 100644 --- a/applications/content/src/org/ofbiz/content/ContentManagementEvents.java +++ b/applications/content/src/org/ofbiz/content/ContentManagementEvents.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -287,7 +287,7 @@ public class ContentManagementEvents { serviceIn.put("targetOperationList", targetOperationList); serviceIn.put("contentPurposeList", contentPurposeList); results = dispatcher.runSync("createContentAssoc", serviceIn); - responseMessage = (String)results.get(ModelService.RESPONSE_MESSAGE); + responseMessage = (String)results.get(ModelService.RESPONSE_MESSAGE); if (UtilValidate.isNotEmpty(responseMessage)) { errorMessage = (String)results.get(ModelService.ERROR_MESSAGE); Debug.logError("in updatePublishLinks, serviceIn:" + serviceIn , module); diff --git a/applications/content/src/org/ofbiz/content/ContentManagementServices.java b/applications/content/src/org/ofbiz/content/ContentManagementServices.java index cfd41cb1bd..06ee1e3500 100644 --- a/applications/content/src/org/ofbiz/content/ContentManagementServices.java +++ b/applications/content/src/org/ofbiz/content/ContentManagementServices.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -75,17 +75,17 @@ public class ContentManagementServices { //Security security = dctx.getSecurity(); GenericDelegator delegator = dctx.getDelegator(); //LocalDispatcher dispatcher = dctx.getDispatcher(); - String contentId = (String) context.get("contentId"); - String subContentId = (String) context.get("subContentId"); - String mapKey = (String) context.get("mapKey"); + String contentId = (String) context.get("contentId"); + String subContentId = (String) context.get("subContentId"); + String mapKey = (String) context.get("mapKey"); GenericValue userLogin = (GenericValue)context.get("userLogin"); Timestamp fromDate = (Timestamp)context.get("fromDate"); - List assocTypes = (List) context.get("assocTypes"); + List assocTypes = (List) context.get("assocTypes"); String assocTypesString = (String)context.get("assocTypesString"); if (UtilValidate.isNotEmpty(assocTypesString)) { List lst = StringUtil.split(assocTypesString, "|"); if (assocTypes == null) { - assocTypes = FastList.newInstance(); + assocTypes = FastList.newInstance(); } assocTypes.addAll(lst); } @@ -112,7 +112,7 @@ public class ContentManagementServices { public static Map getContent(DispatchContext dctx, Map context) { //Security security = dctx.getSecurity(); GenericDelegator delegator = dctx.getDelegator(); - String contentId = (String) context.get("contentId"); + String contentId = (String) context.get("contentId"); //GenericValue userLogin = (GenericValue)context.get("userLogin"); GenericValue view = null; @@ -137,8 +137,8 @@ public class ContentManagementServices { //Security security = dctx.getSecurity(); //GenericDelegator delegator = dctx.getDelegator(); //LocalDispatcher dispatcher = dctx.getDispatcher(); - //HttpServletRequest request = (HttpServletRequest)context.get("request"); - //String suffix = (String) context.get("suffix"); + //HttpServletRequest request = (HttpServletRequest)context.get("request"); + //String suffix = (String) context.get("suffix"); GenericValue val = (GenericValue)context.get("pk"); GenericPK pk = val.getPrimaryKey(); HttpSession session = (HttpSession)context.get("session"); @@ -151,32 +151,32 @@ public class ContentManagementServices { /** * persistContentAndAssoc * A combination method that will create or update all or one of the following: - * a Content entity, a ContentAssoc related to the Content, and + * a Content entity, a ContentAssoc related to the Content, and * the ElectronicText that may be associated with the Content. * The keys for determining if each entity is created is the presence * of the contentTypeId, contentAssocTypeId and dataResourceTypeId. * This service tries to handle DataResource fields with and * without "dr" prefixes. * Assumes binary data is always in field, "imageData". - * + * * This service does not accept straight ContentAssoc parameters. They must be prefaced with "ca" + cap first letter */ public static Map persistContentAndAssoc(DispatchContext dctx, Map rcontext) throws GenericServiceException { GenericDelegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); Map context = UtilMisc.makeMapWritable(rcontext); - + Debug.logInfo("=========== type:" + (String)context.get("dataresourceTypeId") , module); // Knowing why a request fails permission check is one of the more difficult // aspects of content management. Setting "displayFailCond" to true will // put an html table in result.errorMessage that will show what tests were performed Boolean bDisplayFailCond = (Boolean)context.get("displayFailCond"); - String mapKey = (String) context.get("mapKey"); - + String mapKey = (String) context.get("mapKey"); + // If "deactivateExisting" is set, other Contents that are tied to the same // contentIdTo will be deactivated (thruDate set to now) String deactivateString = (String) context.get("deactivateExisting"); - boolean deactivateExisting = "true".equalsIgnoreCase(deactivateString); + boolean deactivateExisting = "true".equalsIgnoreCase(deactivateString); if (Debug.infoOn()) Debug.logInfo("in persist... mapKey(0):" + mapKey, null); @@ -190,12 +190,12 @@ public class ContentManagementServices { contentPurposeList.addAll(tmpPurposes); } if (contentPurposeList != null ) { - context.put("contentPurposeList", contentPurposeList); - context.put("contentPurposeString", null); + context.put("contentPurposeList", contentPurposeList); + context.put("contentPurposeString", null); } if (Debug.infoOn()) Debug.logInfo("in persist... contentPurposeList(0):" + contentPurposeList, null); if (Debug.infoOn()) Debug.logInfo("in persist... textData(0):" + context.get("textData"), null); - + GenericValue content = delegator.makeValue("Content"); content.setPKFields(context); @@ -228,7 +228,7 @@ public class ContentManagementServices { GenericValue electronicText = delegator.makeValue("ElectronicText"); electronicText.setPKFields(context); electronicText.setNonPKFields(context); - + // save expected primary keys on result now in case there is no operation that uses them Map results = ServiceUtil.returnSuccess(); results.put("contentId", content.get("contentId")); @@ -239,15 +239,15 @@ public class ContentManagementServices { results.put("caContentId", contentAssoc.get("contentId")); results.put("caFromDate", contentAssoc.get("fromDate")); results.put("caContentAssocTypeId", contentAssoc.get("contentAssocTypeId")); - + // get user info for multiple use - GenericValue userLogin = (GenericValue) context.get("userLogin"); + GenericValue userLogin = (GenericValue) context.get("userLogin"); // TODO: DEJ20060221 Should these be used somewhere? //String textData = (String)electronicText.get("textData"); //String userLoginId = (String)userLogin.get("userLoginId"); - + //String createdByUserLogin = userLoginId; //String lastModifiedByUserLogin = userLoginId; //Timestamp createdDate = UtilDateTime.nowTimestamp(); @@ -349,7 +349,7 @@ public class ContentManagementServices { while (iter.hasNext()) { String contentPurposeTypeId = (String)iter.next(); GenericValue contentPurpose = delegator.makeValue("ContentPurpose", - UtilMisc.toMap("contentId", contentId, + UtilMisc.toMap("contentId", contentId, "contentPurposeTypeId", contentPurposeTypeId) ); contentPurpose.create(); } @@ -369,7 +369,7 @@ public class ContentManagementServices { if (Debug.infoOn()) Debug.logInfo("in persist... context:" + context, module); Map r = ContentServices.updateContentMethod(dctx, map); boolean isError = ModelService.RESPOND_ERROR.equals(r.get(ModelService.RESPONSE_MESSAGE)); - if (isError) + if (isError) return ServiceUtil.returnError( (String)r.get(ModelService.ERROR_MESSAGE)); } } @@ -448,8 +448,8 @@ public class ContentManagementServices { } /** - Service for update publish sites with a ContentRole that will tie them to the passed - in party. + Service for update publish sites with a ContentRole that will tie them to the passed + in party. */ public static Map updateSiteRoles(DispatchContext dctx, Map context) { LocalDispatcher dispatcher = dctx.getDispatcher(); @@ -476,7 +476,7 @@ public class ContentManagementServices { } catch (GenericEntityException e) { return ServiceUtil.returnError( e.toString()); } - + Iterator siteRoleIter = siteRoles.iterator(); while (siteRoleIter.hasNext()) { Map serviceContext = FastMap.newInstance(); @@ -510,7 +510,7 @@ public class ContentManagementServices { if (Debug.infoOn()) Debug.logInfo("updateSiteRoles, serviceContext(1):" + serviceContext, module); permResults = dispatcher.runSync("createContentRole", serviceContext); String errMsg = ServiceUtil.getErrorMessage(permResults); - if (UtilValidate.isNotEmpty(errMsg)) + if (UtilValidate.isNotEmpty(errMsg)) return ServiceUtil.returnError(errMsg); //addRoleToUser(delegator, dispatcher, serviceContext); } catch (GenericServiceException e) { @@ -537,7 +537,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); newContext.put("userLogin", userLogin); Map permResults = dispatcher.runSync("deactivateAllContentRoles", newContext); String errMsg = ServiceUtil.getErrorMessage(permResults); - if (UtilValidate.isNotEmpty(errMsg)) + if (UtilValidate.isNotEmpty(errMsg)) return ServiceUtil.returnError(errMsg); } catch (GenericServiceException e) { Debug.logError(e, e.toString(), module); @@ -551,7 +551,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); } return results; } - + public static Map persistDataResourceAndData(DispatchContext dctx, Map context) { //GenericDelegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); @@ -567,7 +567,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); result = persistDataResourceAndDataMethod(dctx, context); } else { - return ServiceUtil.returnError("no access to upload image"); + return ServiceUtil.returnError("no access to upload image"); } } catch (GenericServiceException e) { Debug.logError(e, e.toString(), module); @@ -585,7 +585,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); } return result; } - + public static Map persistDataResourceAndDataMethod(DispatchContext dctx, Map rcontext) throws GenericServiceException, GenericEntityException, Exception { GenericDelegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); @@ -597,13 +597,13 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); dataResource.setNonPKFields(context); dataResource.setAllFields(context, false, "dr", null); context.putAll(dataResource); - + GenericValue electronicText = delegator.makeValue("ElectronicText"); electronicText.setPKFields(context); electronicText.setNonPKFields(context); String textData = (String)electronicText.get("textData"); - + String dataResourceId = (String)dataResource.get("dataResourceId"); String dataResourceTypeId = (String)dataResource.get("dataResourceTypeId"); if (Debug.infoOn()) Debug.logInfo("in persist... dataResourceId(0):" + dataResourceId, null); @@ -620,7 +620,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); return ServiceUtil.returnError(e.toString()); } } - GenericValue userLogin = (GenericValue) context.get("userLogin"); + GenericValue userLogin = (GenericValue) context.get("userLogin"); //String userLoginId = (String)userLogin.get("userLoginId"); ModelService dataResourceModel = dispatcher.getDispatchContext().getModelService("updateDataResource"); Map ctx = dataResourceModel.makeValid(dataResource, "IN"); @@ -637,7 +637,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); } newDrContext.put("mimeTypeId", mimeTypeId); } - + if (!dataResourceExists) { Map thisResult = dispatcher.runSync("createDataResource", newDrContext); String errorMsg = ServiceUtil.getErrorMessage(thisResult); @@ -755,13 +755,13 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); } } } - + result.put("dataResourceId", dataResourceId); result.put("drDataResourceId", dataResourceId); context.put("dataResourceId", dataResourceId); return result; } - + public static void addRoleToUser(GenericDelegator delegator, LocalDispatcher dispatcher, Map serviceContext) throws GenericServiceException, GenericEntityException { String partyId = (String)serviceContext.get("partyId"); Map findMap = UtilMisc.toMap("partyId", partyId); @@ -887,14 +887,14 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); if (Debug.infoOn()) Debug.logInfo("in updateOrRemove, entityValueExisting: REMOVED", module); } } - + } catch (GenericEntityException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.toString()); } - return results; + return results; } - + public static Map resequence(DispatchContext dctx, Map context) throws GenericServiceException{ Map result = FastMap.newInstance(); @@ -926,7 +926,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); if (contentId.equals(thisContentId)) { if (dir.startsWith("up")) { if (i > 0) { - // Swap with previous entry + // Swap with previous entry try { GenericValue prevValue = (GenericValue)listFiltered.get(i-1); Long prevSeqNum = (Long)prevValue.get("sequenceNum"); @@ -935,12 +935,12 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); contentAssoc.put("sequenceNum", prevSeqNum); contentAssoc.store(); } catch (Exception e) { - return ServiceUtil.returnError(e.toString()); + return ServiceUtil.returnError(e.toString()); } } } else { if (i < listFiltered.size()) { - // Swap with next entry + // Swap with next entry GenericValue nextValue = (GenericValue)listFiltered.get(i+1); nextValue.put("sequenceNum", Long.valueOf(seqNum)); nextValue.store(); @@ -962,13 +962,13 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); } } catch (GenericEntityException e) { Debug.logError(e, module); - return ServiceUtil.returnError(e.toString()); + return ServiceUtil.returnError(e.toString()); } - - + + return result; } - + public static Map changeLeafToNode(DispatchContext dctx, Map context) throws GenericServiceException{ Map result = FastMap.newInstance(); GenericDelegator delegator = dctx.getDelegator(); @@ -1000,7 +1000,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); content.set("lastModifiedDate", UtilDateTime.nowTimestamp()); content.set("lastModifiedByUserLogin", userLoginId); content.store(); - + if (UtilValidate.isNotEmpty(dataResourceId)) { // add previous DataResource as part of new subcontent GenericValue contentClone = (GenericValue)content.clone(); @@ -1009,7 +1009,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); content.set("lastModifiedByUserLogin", userLoginId); content.set("createdDate", UtilDateTime.nowTimestamp()); content.set("createdByUserLogin", userLoginId); - + contentClone.set("contentId", null); ModelService modelService = dctx.getModelService("persistContentAndAssoc"); Map serviceIn = modelService.makeValid(contentClone, "IN"); @@ -1020,22 +1020,22 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); try { Map thisResult = dispatcher.runSync("persistContentAndAssoc", serviceIn); } catch (ServiceAuthException e) { - return ServiceUtil.returnError(e.toString()); + return ServiceUtil.returnError(e.toString()); } - + List typeList = UtilMisc.toList("SUB_CONTENT"); int leafCount = ContentManagementWorker.updateStatsTopDown(delegator, contentId, typeList); } - + } catch (GenericEntityException e) { Debug.logError(e, module); - return ServiceUtil.returnError(e.toString()); + return ServiceUtil.returnError(e.toString()); } - - + + return result; } - + public static Map updateLeafCount(DispatchContext dctx, Map context) throws GenericServiceException{ Map result = FastMap.newInstance(); @@ -1049,11 +1049,11 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); result.put("leafCount", Integer.valueOf(leafCount)); } catch (GenericEntityException e) { Debug.logError(e, module); - return ServiceUtil.returnError(e.toString()); + return ServiceUtil.returnError(e.toString()); } return result; } - + /* public static Map updateLeafChange(DispatchContext dctx, Map context) throws GenericServiceException{ @@ -1063,12 +1063,12 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); if (typeList == null) typeList = UtilMisc.toList("PUBLISH_LINK", "SUB_CONTENT"); String contentId = (String)context.get("contentId"); - + try { GenericValue thisContent = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentId)); if (thisContent == null) throw new RuntimeException("No entity found for id=" + contentId); - + String thisContentId = thisContent.getString("contentId"); Long leafCount = (Long)thisContent.get("nodeLeafCount"); int subLeafCount = (leafCount == null) ? 1 : leafCount.intValue(); @@ -1079,7 +1079,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); // TODO: ??? what is this supposed to do: //subLeafCount = subLeafCount; } - + EntityCondition conditionType = EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList); EntityCondition conditionMain = EntityCondition.makeCondition(UtilMisc.toList( EntityCondition.makeCondition("contentId", EntityOperator.EQUALS, thisContentId), conditionType), EntityOperator.AND); List listAll = delegator.findByConditionCache("ContentAssoc", conditionMain, null, null); @@ -1097,29 +1097,29 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); branchCount += 1; // For the level just above only, update the branch count contentTo.put("childBranchCount", Integer.valueOf(branchCount)); - + // Start the updating of leaf counts above ContentManagementWorker.updateStatsBottomUp(delegator, subContentId, typeList, subLeafCount); } - - + + } catch (GenericEntityException e) { Debug.logError(e, module); - return ServiceUtil.returnError(e.toString()); + return ServiceUtil.returnError(e.toString()); } return result; } */ - + /** * This service changes the contentTypeId of the current content and its children depending on the pageMode. - * if pageMode == "outline" then if the contentTypeId of children is not "OUTLINE_NODE" or "PAGE_NODE" + * if pageMode == "outline" then if the contentTypeId of children is not "OUTLINE_NODE" or "PAGE_NODE" * (it could be DOCUMENT or SUBPAGE_NODE) then it will get changed to PAGE_NODE.` - * if pageMode == "page" then if the contentTypeId of children is not "PAGE_NODE" or "SUBPAGE_NODE" - * (it could be DOCUMENT or OUTLINE_NODE) then it will get changed to SUBPAGE_NODE.` + * if pageMode == "page" then if the contentTypeId of children is not "PAGE_NODE" or "SUBPAGE_NODE" + * (it could be DOCUMENT or OUTLINE_NODE) then it will get changed to SUBPAGE_NODE.` */ public static Map updatePageType(DispatchContext dctx, Map rcontext) throws GenericServiceException{ - + GenericDelegator delegator = dctx.getDelegator(); Map context = UtilMisc.makeMapWritable(rcontext); Map results = FastMap.newInstance(); @@ -1127,7 +1127,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); if (visitedSet == null) { visitedSet = FastSet.newInstance(); context.put("visitedSet", visitedSet); - } + } String pageMode = (String)context.get("pageMode"); String contentId = (String)context.get("contentId"); visitedSet.add(contentId); @@ -1155,12 +1155,12 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); Debug.logError(e, module); return ServiceUtil.returnError(e.toString()); } - + return results; } - + public static Map resetToOutlineMode(DispatchContext dctx, Map rcontext) throws GenericServiceException{ - + GenericDelegator delegator = dctx.getDelegator(); Map context = UtilMisc.makeMapWritable(rcontext); Map results = FastMap.newInstance(); @@ -1168,7 +1168,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); if (visitedSet == null) { visitedSet = FastSet.newInstance(); context.put("visitedSet", visitedSet); - } + } String contentId = (String)context.get("contentId"); String pageMode = (String)context.get("pageMode"); String contentTypeId = "OUTLINE_NODE"; @@ -1202,10 +1202,10 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); Debug.logError(e, module); return ServiceUtil.returnError(e.toString()); } - + return results; } - + public static Map clearContentAssocViewCache(DispatchContext dctx, Map context) throws GenericServiceException{ Map results = FastMap.newInstance(); @@ -1214,7 +1214,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); if (utilCache != null) { utilCache.clear(); } - + utilCache = UtilCache.findCache("entitycache.entity-list.default.ContentAssocViewTo"); if (utilCache != null) { utilCache.clear(); @@ -1222,16 +1222,16 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); return results; } - + public static Map clearContentAssocDataResourceViewCache(DispatchContext dctx, Map context) throws GenericServiceException{ - + Map results = FastMap.newInstance(); UtilCache utilCache = UtilCache.findCache("entitycache.entity-list.default.ContentAssocViewDataResourceFrom"); if (utilCache != null) { utilCache.clear(); } - + utilCache = UtilCache.findCache("entitycache.entity-list.default.ContentAssocViewDataResourceTo"); if (utilCache != null) { utilCache.clear(); @@ -1239,9 +1239,9 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); return results; } - + public static void updatePageNodeChildren(GenericValue content, Map context) throws GenericEntityException { - + String contentId = content.getString("contentId"); Set visitedSet = (Set)context.get("visitedSet"); if (visitedSet == null) { @@ -1252,7 +1252,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); Debug.logWarning("visitedSet already contains:" + contentId, module); return; } else { - visitedSet.add(contentId); + visitedSet.add(contentId); } } String contentTypeId = content.getString("contentTypeId"); @@ -1262,10 +1262,10 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); // } else if (contentTypeId.equals("OUTLINE_NODE")) { // newContentTypeId = "PAGE_NODE"; // } - + content.put("contentTypeId", newContentTypeId); content.store(); - + //if (contentTypeId == null || contentTypeId.equals("OUTLINE_DOCUMENT") || contentTypeId.equals("DOCUMENT")) { List kids = ContentWorker.getAssociatedContent(content, "from", UtilMisc.toList("SUB_CONTENT"), null, null, null); Iterator iter = kids.iterator(); @@ -1277,7 +1277,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); } public static void updateOutlineNodeChildren(GenericValue content, boolean forceOutline, Map context) throws GenericEntityException { - + String contentId = content.getString("contentId"); Set visitedSet = (Set)context.get("visitedSet"); if (visitedSet == null) { @@ -1288,7 +1288,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); Debug.logWarning("visitedSet already contains:" + contentId, module); return; } else { - visitedSet.add(contentId); + visitedSet.add(contentId); } } String contentTypeId = content.getString("contentTypeId"); @@ -1305,10 +1305,10 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); } else if (contentTypeId.equals("SUBPAGE_NODE")) { newContentTypeId = "PAGE_NODE"; } - + content.put("contentTypeId", newContentTypeId); content.store(); - + if (contentTypeId == null || contentTypeId.equals("DOCUMENT") || contentTypeId.equals("OUTLINE_NODE")) { //if (contentTypeId == null || contentTypeId.equals("DOCUMENT")) { List kids = ContentWorker.getAssociatedContent(content, "from", UtilMisc.toList("SUB_CONTENT"), null, null, null); @@ -1337,11 +1337,11 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); results.put("_LIST_", lst); } catch (GenericEntityException e) { Debug.logError(e, module); - return ServiceUtil.returnError(e.toString()); + return ServiceUtil.returnError(e.toString()); } return results; } - + public static String updateTypeAndFile(GenericValue dataResource, Map context) { String retVal = null; String mimeTypeId = (String) context.get("_imageData_contentType"); @@ -1360,20 +1360,20 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); public static Map initContentChildCounts(DispatchContext dctx, Map context) throws GenericServiceException{ Map result = FastMap.newInstance(); - + GenericValue content = (GenericValue)context.get("content"); if (content == null) { return ServiceUtil.returnError("No Content found."); } Long leafCount = (Long)content.get("childLeafCount"); if (leafCount == null) { - content.set("childLeafCount", Long.valueOf(0)); + content.set("childLeafCount", Long.valueOf(0)); } Long branchCount = (Long)content.get("childBranchCount"); if (branchCount == null) { - content.set("childBranchCount", Long.valueOf(0)); + content.set("childBranchCount", Long.valueOf(0)); } - + //content.store(); return result; @@ -1382,10 +1382,10 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); public static Map incrementContentChildStats(DispatchContext dctx, Map context) throws GenericServiceException{ Map result = FastMap.newInstance(); GenericDelegator delegator = dctx.getDelegator(); - + String contentId = (String)context.get("contentId"); String contentAssocTypeId = (String)context.get("contentAssocTypeId"); - + try { GenericValue content = delegator.findByPrimaryKeyCache("Content", UtilMisc.toMap("contentId", contentId)); if (content == null) { @@ -1397,21 +1397,21 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); } int changeLeafCount = leafCount.intValue() + 1; int changeBranchCount = 1; - + ContentManagementWorker.updateStatsBottomUp(delegator, contentId, UtilMisc.toList(contentAssocTypeId), changeBranchCount, changeLeafCount); } catch (GenericEntityException e) { return ServiceUtil.returnError(e.toString()); } return result; } - + public static Map decrementContentChildStats(DispatchContext dctx, Map context) throws GenericServiceException{ Map result = FastMap.newInstance(); GenericDelegator delegator = dctx.getDelegator(); - + String contentId = (String)context.get("contentId"); String contentAssocTypeId = (String)context.get("contentAssocTypeId"); - + try { GenericValue content = delegator.findByPrimaryKeyCache("Content", UtilMisc.toMap("contentId", contentId)); if (content == null) { @@ -1423,7 +1423,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); } int changeLeafCount = -1 * leafCount.intValue() - 1; int changeBranchCount = -1; - + ContentManagementWorker.updateStatsBottomUp(delegator, contentId, UtilMisc.toList(contentAssocTypeId), changeBranchCount, changeLeafCount); } catch (GenericEntityException e) { return ServiceUtil.returnError(e.toString()); @@ -1434,7 +1434,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); public static Map updateContentChildStats(DispatchContext dctx, Map context) throws GenericServiceException{ Map result = FastMap.newInstance(); GenericDelegator delegator = dctx.getDelegator(); - + String contentId = (String)context.get("contentId"); String contentAssocTypeId = (String)context.get("contentAssocTypeId"); List typeList = FastList.newInstance(); @@ -1443,7 +1443,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); } else { typeList = UtilMisc.toList("PUBLISH_LINK", "SUB_CONTENT"); } - + try { ContentManagementWorker.updateStatsTopDown(delegator, contentId, typeList); } catch (GenericEntityException e) { @@ -1451,13 +1451,13 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); } return result; } - + public static Map updateContentSubscription(DispatchContext dctx, Map context) throws GenericServiceException{ Map result = FastMap.newInstance(); GenericDelegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); - + String partyId = (String) context.get("partyId"); String webPubPt = (String) context.get("contentId"); String roleTypeId = (String) context.get("useRoleTypeId"); @@ -1477,7 +1477,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); } catch (GenericEntityException e) { return ServiceUtil.returnError(e.toString()); } - + if (contentRole == null) { contentRole = delegator.makeValue("ContentRole"); contentRole.set("contentId", webPubPt); @@ -1485,7 +1485,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); contentRole.set("roleTypeId", roleTypeId); contentRole.set("fromDate", nowTimestamp); } - + Timestamp thruDate = (Timestamp) contentRole.get("thruDate"); if (thruDate == null) { // no thruDate? start with NOW @@ -1501,13 +1501,13 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); calendar.setTime(thruDate); int field = Calendar.MONTH; if ("TF_day".equals(useTimeUomId)) { - field = Calendar.DAY_OF_YEAR; + field = Calendar.DAY_OF_YEAR; } else if ("TF_wk".equals(useTimeUomId)) { - field = Calendar.WEEK_OF_YEAR; + field = Calendar.WEEK_OF_YEAR; } else if ("TF_mon".equals(useTimeUomId)) { - field = Calendar.MONTH; + field = Calendar.MONTH; } else if ("TF_yr".equals(useTimeUomId)) { - field = Calendar.YEAR; + field = Calendar.YEAR; } else { Debug.logWarning("Don't know anything about useTimeUomId [" + useTimeUomId + "], defaulting to month", module); } @@ -1530,7 +1530,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); } return result; } - + public static Map updateContentSubscriptionByProduct(DispatchContext dctx, Map rcontext) throws GenericServiceException{ Map context = UtilMisc.makeMapWritable(rcontext); Map result = FastMap.newInstance(); @@ -1541,10 +1541,10 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); if (qty == null) { qty = Integer.valueOf(1); } - + Timestamp orderCreatedDate = (Timestamp) context.get("orderCreatedDate"); if (orderCreatedDate == null) { - orderCreatedDate = UtilDateTime.nowTimestamp(); + orderCreatedDate = UtilDateTime.nowTimestamp(); } GenericValue productContent = null; try { @@ -1553,9 +1553,9 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); List listOrdered = EntityUtil.orderBy(listFiltered, UtilMisc.toList("purchaseFromDate", "purchaseThruDate")); List listThrusOnly = EntityUtil.filterOutByCondition(listOrdered, EntityCondition.makeCondition("purchaseThruDate", EntityOperator.EQUALS, null)); if (listThrusOnly.size() > 0) { - productContent = (GenericValue) listThrusOnly.get(0); + productContent = (GenericValue) listThrusOnly.get(0); } else if (listOrdered.size() > 0) { - productContent = (GenericValue) listOrdered.get(0); + productContent = (GenericValue) listOrdered.get(0); } } catch (GenericEntityException e) { Debug.logError(e.toString(), module); @@ -1564,7 +1564,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); if (productContent == null) { String msg = "No ProductContent found for productId:" + productId; Debug.logError(msg, module); - return ServiceUtil.returnError(msg); + return ServiceUtil.returnError(msg); } Long useTime = (Long)productContent.get("useTime"); Integer newUseTime = Integer.valueOf(useTime.intValue() * qty.intValue()); @@ -1577,16 +1577,16 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); result = dispatcher.runSync("updateContentSubscription", ctx); return result; } - + public static Map updateContentSubscriptionByOrder(DispatchContext dctx, Map rcontext) throws GenericServiceException{ Map context = UtilMisc.makeMapWritable(rcontext); Map result = FastMap.newInstance(); GenericDelegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); String orderId = (String) context.get("orderId"); - + Debug.logInfo("In updateContentSubscriptionByOrder service with orderId: " + orderId, module); - + GenericValue orderHeader = null; try { List orderRoleList = delegator.findByAnd("OrderRole", UtilMisc.toMap("orderId", orderId, "roleTypeId", "END_USER_CUSTOMER")); @@ -1596,13 +1596,13 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); context.put("partyId", partyId); } else { String msg = "No OrderRole found for orderId:" + orderId; - return ServiceUtil.returnFailure(msg); - + return ServiceUtil.returnFailure(msg); + } orderHeader = delegator.findByPrimaryKeyCache("OrderHeader", UtilMisc.toMap("orderId", orderId)); if (orderHeader == null) { String msg = "No OrderHeader found for orderId:" + orderId; - return ServiceUtil.returnError(msg); + return ServiceUtil.returnError(msg); } Timestamp orderCreatedDate = (Timestamp) orderHeader.get("orderDate"); context.put("orderCreatedDate", orderCreatedDate); @@ -1610,7 +1610,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); Iterator orderItemIter = orderItemList.iterator(); ModelService subscriptionModel = dispatcher.getDispatchContext().getModelService("updateContentSubscriptionByProduct"); while (orderItemIter.hasNext()) { - GenericValue orderItem = (GenericValue)orderItemIter.next(); + GenericValue orderItem = (GenericValue)orderItemIter.next(); BigDecimal qty = orderItem.getBigDecimal("quantity"); String productId = (String) orderItem.get("productId"); List productContentList = delegator.findByAnd("ProductContent", UtilMisc.toMap("productId", productId, "productContentTypeId", "ONLINE_ACCESS")); @@ -1619,7 +1619,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); context.put("productId", productId); context.put("quantity", Integer.valueOf(qty.intValue())); Map ctx = subscriptionModel.makeValid(context, "IN"); - Map thisResult = dispatcher.runSync("updateContentSubscriptionByProduct", ctx); + Map thisResult = dispatcher.runSync("updateContentSubscriptionByProduct", ctx); } } } catch (GenericEntityException e) { @@ -1630,7 +1630,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); } public static Map followNodeChildren(DispatchContext dctx, Map context) throws GenericServiceException{ - + Map result = null; GenericDelegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); @@ -1644,16 +1644,16 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); String contentAssocTypeId = (String)context.get("contentAssocTypeId"); List contentAssocTypeIdList = FastList.newInstance(); if (UtilValidate.isNotEmpty(contentAssocTypeId)) { - contentAssocTypeIdList = StringUtil.split(contentAssocTypeId, "|"); + contentAssocTypeIdList = StringUtil.split(contentAssocTypeId, "|"); } if (contentAssocTypeIdList.size() == 0) { - contentAssocTypeIdList.add("SUB_CONTENT"); + contentAssocTypeIdList.add("SUB_CONTENT"); } Map ctx = FastMap.newInstance(); ctx.put("userLogin", userLogin); ctx.put("contentAssocTypeIdList", contentAssocTypeIdList); try { - + GenericValue content = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentId)); result = followNodeChildrenMethod(content, dispatcher, serviceName, ctx); } catch (GenericEntityException e) { @@ -1662,9 +1662,9 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); } return result; } - public static Map followNodeChildrenMethod(GenericValue content, LocalDispatcher dispatcher, String serviceName, Map context) + public static Map followNodeChildrenMethod(GenericValue content, LocalDispatcher dispatcher, String serviceName, Map context) throws GenericEntityException, GenericServiceException { - + Map result = null; String contentId = content.getString("contentId"); List contentAssocTypeIdList = (List)context.get("contentAssocTypeIdList" ); @@ -1677,13 +1677,13 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); Debug.logWarning("visitedSet already contains:" + contentId, module); return ServiceUtil.returnError("visitedSet already contains:" + contentId); } else { - visitedSet.add(contentId); + visitedSet.add(contentId); } } GenericValue userLogin = (GenericValue)context.get("userLogin"); result = dispatcher.runSync(serviceName, UtilMisc.toMap("content", content, "userLogin", userLogin)); - + List kids = ContentWorker.getAssociatedContent(content, "from", contentAssocTypeIdList, null, null, null); Iterator iter = kids.iterator(); while (iter.hasNext()) { @@ -1713,7 +1713,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); return ServiceUtil.returnError(e.toString()); } } - + try { ModelService persistContentAndAssocModel = dispatcher.getDispatchContext().getModelService("persistContentAndAssoc"); Map ctx = persistContentAndAssocModel.makeValid(context, "IN"); @@ -1738,7 +1738,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); } else { parentList.add(masterRevisionContentId); } - + // Update ContentRevision and ContentRevisonItem Map contentRevisionMap = FastMap.newInstance(); contentRevisionMap.put("itemContentId", contentId); @@ -1754,7 +1754,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); return ServiceUtil.returnError(errorMsg); } } - + } catch (GenericServiceException e) { Debug.logError(e.toString(), module); return ServiceUtil.returnError(e.toString()); diff --git a/applications/content/src/org/ofbiz/content/ContentManagementWorker.java b/applications/content/src/org/ofbiz/content/ContentManagementWorker.java index 1bb95abd00..9d38a54889 100644 --- a/applications/content/src/org/ofbiz/content/ContentManagementWorker.java +++ b/applications/content/src/org/ofbiz/content/ContentManagementWorker.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -82,7 +82,7 @@ public class ContentManagementWorker { if (lookupCaches == null) { lookupCaches = FastMap.newInstance(); session.setAttribute("lookupCaches", lookupCaches); - } + } String entityName = pk.getEntityName(); mruAddByEntityName( entityName, pk, lookupCaches); @@ -92,7 +92,7 @@ public class ContentManagementWorker { * Makes an entry in the "most recently used" cache. It picks the cache * by the entity name and builds a signature from the primary key values. * - * @param entityName + * @param entityName * @param lookupCaches * @param pk either a GenericValue or GenericPK - populated */ @@ -103,8 +103,8 @@ public class ContentManagementWorker { if (lkupCache == null) { lkupCache = new LifoSet(); lookupCaches.put(cacheEntityName, lkupCache); - } - + } + lkupCache.add(pk.getPrimaryKey()); if (Debug.infoOn()) Debug.logInfo("in mruAddByEntityName, entityName:" + entityName + " lifoSet.size()" + lkupCache.size(), module); } @@ -116,8 +116,8 @@ public class ContentManagementWorker { if (lkupCache == null) { lkupCache = new LifoSet(); lookupCaches.put(cacheEntityName, lkupCache); - } - + } + Iterator mrvIterator = lkupCache.iterator(); return mrvIterator; } @@ -153,7 +153,7 @@ public class ContentManagementWorker { public static void setCurrentEntityMap(HttpServletRequest request, GenericEntity ent) { - + String entityName = ent.getEntityName(); setCurrentEntityMap(request, entityName, ent); } @@ -306,7 +306,7 @@ public class ContentManagementWorker { request.setAttribute("currentPK", currentPK); GenericValue currentValue = null; try { - currentValue = delegator.findOne(currentPK.getEntityName(), currentPK, false); + currentValue = delegator.findOne(currentPK.getEntityName(), currentPK, false); } catch (GenericEntityException e) { } request.setAttribute("currentValue", currentValue); @@ -317,7 +317,7 @@ public class ContentManagementWorker { public static List getPermittedPublishPoints(GenericDelegator delegator, List allPublishPoints, GenericValue userLogin, Security security, String permittedAction, String permittedOperations, String passedRoles) throws GeneralException { List permittedPublishPointList = FastList.newInstance(); - + // Check that user has permission to admin sites Iterator it = allPublishPoints.iterator(); while (it.hasNext()) { @@ -515,12 +515,12 @@ public class ContentManagementWorker { public static String getParentWebSitePublishPointId(GenericDelegator delegator, String contentId) throws GenericEntityException { - + String contentIdTo = null; List contentAssocList = delegator.findByAndCache("ContentAssoc", UtilMisc.toMap("contentId", contentId, "contentAssocTypeId", "SUBSITE")); List filteredContentAssocList = EntityUtil.filterByDate(contentAssocList); if (filteredContentAssocList.size() > 0) { - GenericValue contentAssoc = (GenericValue)filteredContentAssocList.get(0); + GenericValue contentAssoc = (GenericValue)filteredContentAssocList.get(0); if (contentAssoc != null) contentIdTo = contentAssoc.getString("contentIdTo"); } @@ -663,7 +663,7 @@ public class ContentManagementWorker { public static List getPermittedDepartmentPoints(GenericDelegator delegator, List allDepartmentPoints, GenericValue userLogin, Security security, String permittedAction, String permittedOperations, String passedRoles) throws GeneralException { List permittedDepartmentPointList = FastList.newInstance(); - + // Check that user has permission to admin sites Iterator it = allDepartmentPoints.iterator(); while (it.hasNext()) { @@ -695,7 +695,7 @@ public class ContentManagementWorker { } /** - Returns a list of "department" (having ContentAssoc of type "DEPARTMENT") + Returns a list of "department" (having ContentAssoc of type "DEPARTMENT") Content entities that are children of parentPubPt @param parentPubPt The parent publish point. @@ -740,7 +740,7 @@ public class ContentManagementWorker { GenericValue thisContent = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentId)); if (thisContent == null) throw new RuntimeException("No entity found for id=" + contentId); - + EntityCondition conditionMain = null; if (typeList.size() > 0 ) { EntityCondition conditionType = EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList); @@ -756,22 +756,22 @@ public class ContentManagementWorker { String subContentId = contentAssoc.getString("contentId"); subLeafCount += updateStatsTopDown(delegator, subContentId, typeList); } - + // If no children, count this as a leaf if (subLeafCount == 0) subLeafCount = 1; thisContent.put("childBranchCount", Long.valueOf(listFiltered.size())); thisContent.put("childLeafCount", Long.valueOf(subLeafCount)); thisContent.store(); - + return subLeafCount; } - + public static void updateStatsBottomUp(GenericDelegator delegator, String contentId, List typeList, int branchChangeAmount, int leafChangeAmount) throws GenericEntityException { GenericValue thisContent = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentId)); if (thisContent == null) throw new RuntimeException("No entity found for id=" + contentId); - + EntityCondition conditionType = EntityCondition.makeCondition("contentAssocTypeId", EntityOperator.IN, typeList); EntityCondition conditionMain = EntityCondition.makeCondition(UtilMisc.toList( EntityCondition.makeCondition("contentId", EntityOperator.EQUALS, contentId), conditionType), EntityOperator.AND); List listAll = delegator.findList("ContentAssoc", conditionMain, null, null, null, true); @@ -786,21 +786,21 @@ public class ContentManagementWorker { if (leafCount != null) { intLeafCount = leafCount.intValue(); } - contentTo.set("childLeafCount", Long.valueOf(intLeafCount + leafChangeAmount)); - + contentTo.set("childLeafCount", Long.valueOf(intLeafCount + leafChangeAmount)); + if (branchChangeAmount != 0) { int intBranchCount = 0; Long branchCount = (Long)contentTo.get("childBranchCount"); if (branchCount != null) { intBranchCount = branchCount.intValue(); } - contentTo.set("childBranchCount", Long.valueOf(intBranchCount + branchChangeAmount)); + contentTo.set("childBranchCount", Long.valueOf(intBranchCount + branchChangeAmount)); } contentTo.store(); updateStatsBottomUp(delegator, contentIdTo, typeList, 0, leafChangeAmount); } - - + + } - + } diff --git a/applications/content/src/org/ofbiz/content/ConvertTree.java b/applications/content/src/org/ofbiz/content/ConvertTree.java index c56a8b5dea..69f3bce6f1 100644 --- a/applications/content/src/org/ofbiz/content/ConvertTree.java +++ b/applications/content/src/org/ofbiz/content/ConvertTree.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -47,8 +47,8 @@ public class ConvertTree{ This program will convert the output of the DOS 'tree' command into a contantAssoc tree. the leaves in the tree will point to filenames on the local disk. -With this program and the content navigation a office file server can be replaced with a -document tree in OFBiz. From that point on the documents can be connected to the cutomers, +With this program and the content navigation a office file server can be replaced with a +document tree in OFBiz. From that point on the documents can be connected to the cutomers, orders, invoices etc.. In order ta make this service active add the following to the service definition file: @@ -93,7 +93,7 @@ In order ta make this service active add the following to the service definition Entity.set("createdStamp",UtilDateTime.nowTimestamp()); Entity.set("createdTxStamp",UtilDateTime.nowTimestamp()); delegator.create(Entity); - + Entity = null; Entity = delegator.makeValue("Content"); Entity.set("contentId", "HOME_DUCUMENT"); @@ -117,13 +117,13 @@ In order ta make this service active add the following to the service definition int recordCount = 0; while (( line = input.readLine()) != null) {//start line boolean hasFolder=true; - String + String rootContent=null, contentId = null; counterLine++; if (counterLine>1) { size = line.length(); - String + String check = "\\", checkSubContent = ",", contentName = "", @@ -132,7 +132,7 @@ In order ta make this service active add the following to the service definition //Debug.log("======Data======"+data); size = data.length(); List contents = null; - + for(int index = 0; index< size; index++) {//start character in line boolean contentNameMatch = false; int contentAssocSize=0; @@ -160,7 +160,7 @@ In order ta make this service active add the following to the service definition GenericValue contentcheck = delegator.findByPrimaryKey("Content",UtilMisc.toMap("contentId",contentAss.get("contentId"))); if (contentcheck!=null) { if (contentcheck.get("contentName").equals(contentName) && contentNameMatch==false) { - contentNameMatch = true; + contentNameMatch = true; contentId = contentcheck.get("contentId").toString(); } } @@ -168,11 +168,11 @@ In order ta make this service active add the following to the service definition } else { rootContent = "HOME_DUCUMENT"; contentAssocs= delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId",contentId, "contentIdTo", rootContent)); - + } contentAssocSize=contentAssocs.size(); } - + if ( contentAssocSize == 0 && contentNameMatch==false) {//New Root Content Entity = null; contentId = delegator.getNextSeqId("Content"); @@ -197,7 +197,7 @@ In order ta make this service active add the following to the service definition if (rootContent==null) { rootContent = "HOME_DUCUMENT"; } - contentAssocs = delegator.findByAnd("ContentAssoc", + contentAssocs = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId",contentId,"contentIdTo",rootContent,"contentAssocTypeId","TREE_CHILD")); if (contentAssocs.size()==0) { contentAssoc = FastMap.newInstance(); @@ -253,12 +253,12 @@ In order ta make this service active add the following to the service definition return ServiceUtil.returnError(errMsg); } } - + public static Map createSubContent(int index,String line,String rootContent, Map context, DispatchContext dctx) { GenericDelegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); GenericValue userLogin = (GenericValue) context.get("userLogin"); - String + String subContents=null, check = ",", oldChar = "\"", @@ -317,7 +317,7 @@ In order ta make this service active add the following to the service definition Entity.set("createdStamp",UtilDateTime.nowTimestamp()); Entity.set("createdTxStamp",UtilDateTime.nowTimestamp()); delegator.create(Entity); - + //Relation Content Map contentAssoc = FastMap.newInstance(); contentAssoc.put("contentId", contentId); @@ -329,7 +329,7 @@ In order ta make this service active add the following to the service definition contentName =""; contentNameInprogress=""; } - + if ((subContents.charAt(index))!= check.charAt(0)) { contentNameInprogress = contentNameInprogress.concat(Character.toString(subContents.charAt(index))); if (contentNameInprogress.length() > 99) { @@ -377,7 +377,7 @@ In order ta make this service active add the following to the service definition Entity.set("createdStamp",UtilDateTime.nowTimestamp()); Entity.set("createdTxStamp",UtilDateTime.nowTimestamp()); delegator.create(Entity); - + //create ContentAssoc Map contentAssoc = FastMap.newInstance(); contentAssoc.put("contentId", contentId); @@ -387,7 +387,7 @@ In order ta make this service active add the following to the service definition dispatcher.runSync("createContentAssoc", contentAssoc); } } - + } return ServiceUtil.returnSuccess(sucMsg); } catch (GenericEntityException e) { diff --git a/applications/content/src/org/ofbiz/content/blog/BlogRssServices.java b/applications/content/src/org/ofbiz/content/blog/BlogRssServices.java index f00d99ae86..4a5fd0d096 100644 --- a/applications/content/src/org/ofbiz/content/blog/BlogRssServices.java +++ b/applications/content/src/org/ofbiz/content/blog/BlogRssServices.java @@ -133,7 +133,7 @@ public class BlogRssServices { entry.setPublishedDate(v.getTimestamp("createdDate")); entry.setDescription(desc); entry.setLink(thisLink); - entry.setAuthor((v.getString("createdByUserLogin"))); + entry.setAuthor((v.getString("createdByUserLogin"))); entries.add(entry); } } diff --git a/applications/content/src/org/ofbiz/content/cms/CmsEvents.java b/applications/content/src/org/ofbiz/content/cms/CmsEvents.java index 22129695af..26433c82e7 100644 --- a/applications/content/src/org/ofbiz/content/cms/CmsEvents.java +++ b/applications/content/src/org/ofbiz/content/cms/CmsEvents.java @@ -65,7 +65,7 @@ public class CmsEvents { LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); ServletContext servletContext = request.getSession().getServletContext(); HttpSession session = request.getSession(); - + String webSiteId = (String) session.getAttribute("webSiteId"); if (webSiteId == null) { webSiteId = WebSiteWorker.getWebSiteId(request); @@ -130,9 +130,9 @@ public class CmsEvents { } if (pathInfo.endsWith("/")) { pathInfo = pathInfo.substring(0, pathInfo.length() - 1); - } + } Debug.log("Path INFO for Alias: " + pathInfo, module); - + GenericValue pathAlias = null; try { pathAlias = delegator.findByPrimaryKeyCache("WebSitePathAlias", UtilMisc.toMap("webSiteId", webSiteId, "pathAlias", pathInfo)); @@ -198,12 +198,12 @@ public class CmsEvents { MapStack templateMap = MapStack.create(); ScreenRenderer.populateContextForRequest(templateMap, null, request, response, servletContext); templateMap.put("formStringRenderer", new HtmlFormRenderer(request, response)); - + // make the link prefix ServletContext ctx = (ServletContext) request.getAttribute("servletContext"); RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_"); templateMap.put("_REQUEST_HANDLER_", rh); - + // NOTE DEJ20080817: this is done in the ContentMapFacade class now to avoid problems with the jsessionid being in the middle of the URL and such //String contextLinkPrefix = rh.makeLink(request, response, "", true, false, true); //templateMap.put("_CONTEXT_LINK_PREFIX_", contextLinkPrefix); @@ -226,7 +226,7 @@ public class CmsEvents { if (UtilValidate.isEmpty(mapKey)) { ContentWorker.renderContentAsText(dispatcher, delegator, contentId, writer, templateMap, locale, "text/html", true); } else { - ContentWorker.renderSubContentAsText(dispatcher, delegator, contentId, writer, mapKey, templateMap, locale, "text/html", true); + ContentWorker.renderSubContentAsText(dispatcher, delegator, contentId, writer, mapKey, templateMap, locale, "text/html", true); } } catch (IOException e) { @@ -253,7 +253,7 @@ public class CmsEvents { } } String siteName = null; - try { + try { siteName = delegator.findByPrimaryKeyCache("WebSite", UtilMisc.toMap("webSiteId", webSiteId)).getString("siteName"); } catch (GenericEntityException e) { Debug.logError(e, module); @@ -281,7 +281,7 @@ public class CmsEvents { return true; } else { // the passed in contentId is not a publish point for the web site; - // however we will publish its content if it is a node of one of the trees that have a publish point as the root + // however we will publish its content if it is a node of one of the trees that have a publish point as the root List topLevelContentValues = delegator.findByAndCache("WebSiteContent", UtilMisc.toMap("webSiteId", webSiteId, "webSiteContentTypeId", "PUBLISH_POINT"), UtilMisc.toList("-fromDate")); topLevelContentValues = EntityUtil.filterByDate(topLevelContentValues); diff --git a/applications/content/src/org/ofbiz/content/compdoc/CompDocEvents.java b/applications/content/src/org/ofbiz/content/compdoc/CompDocEvents.java index 13f7bb6370..205eab5831 100644 --- a/applications/content/src/org/ofbiz/content/compdoc/CompDocEvents.java +++ b/applications/content/src/org/ofbiz/content/compdoc/CompDocEvents.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -56,13 +56,13 @@ import org.ofbiz.webapp.event.CoreEvents; */ public class CompDocEvents { public static final String module = CompDocEvents.class.getName(); - - /** - * + + /** + * * @param request * @param response * @return - * + * * Creates the topmost Content entity of a Composite Document tree. * Also creates an "empty" Composite Document Instance Content entity. * Creates ContentRevision/Item records for each, as well. @@ -78,7 +78,7 @@ public class CompDocEvents { GenericValue userLogin = (GenericValue)session.getAttribute("userLogin"); String contentId = (String)paramMap.get("contentId"); //String instanceContentId = null; - + boolean contentExists = true; if (UtilValidate.isEmpty(contentId)) { contentExists = false; @@ -93,7 +93,7 @@ public class CompDocEvents { return "error"; } } - + ModelService modelService = null; try { modelService = dispatcher.getDispatchContext().getModelService("persistContentAndAssoc"); @@ -136,7 +136,7 @@ public class CompDocEvents { request.setAttribute("_ERROR_MESSAGE_", "
  • " + errMsg + "
  • "); return "error"; } - + } catch (GenericServiceException e) { String errMsg = "Error running serviceName, 'persistContentAndAssoc'. " + e.toString(); Debug.logError(errMsg, module); @@ -145,7 +145,7 @@ public class CompDocEvents { } return "success"; } - + public static String padNumberWithLeadingZeros(Long num, Integer padLen) { String s = UtilFormatOut.formatPaddedNumber(num.longValue(), padLen.intValue()); return s; @@ -164,7 +164,7 @@ public class CompDocEvents { String rootDir = null; String webSiteId = null; String https = null; - + if (UtilValidate.isEmpty(rootDir)) { rootDir = servletContext.getRealPath("/"); } @@ -174,7 +174,7 @@ public class CompDocEvents { if (UtilValidate.isEmpty(https)) { https = (String) servletContext.getAttribute("https"); } - + Map mapIn = FastMap.newInstance(); mapIn.put("contentId", contentId); mapIn.put("locale", locale); @@ -182,7 +182,7 @@ public class CompDocEvents { mapIn.put("webSiteId", webSiteId); mapIn.put("https", https); mapIn.put("userLogin", userLogin); - + Map results = null; try { results = dispatcher.runSync("renderCompDocPdf", mapIn); @@ -196,19 +196,19 @@ public class CompDocEvents { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; } - + if (ServiceUtil.isError(results)) { request.setAttribute("_ERROR_MESSAGE_", ServiceUtil.getErrorMessage(results)); return "error"; } - + ByteBuffer outByteBuffer = (ByteBuffer) results.get("outByteBuffer"); // setup content type String contentType = "application/pdf; charset=ISO-8859-1"; ByteArrayInputStream bais = new ByteArrayInputStream(outByteBuffer.array()); - + /* try { FileOutputStream fos = new FileOutputStream(FileUtil.getFile("/home/byersa/pdftest.pdf")); @@ -238,7 +238,7 @@ public class CompDocEvents { String rootDir = null; String webSiteId = null; String https = null; - + if (UtilValidate.isEmpty(rootDir)) { rootDir = servletContext.getRealPath("/"); } @@ -248,7 +248,7 @@ public class CompDocEvents { if (UtilValidate.isEmpty(https)) { https = (String) servletContext.getAttribute("https"); } - + Map mapIn = FastMap.newInstance(); mapIn.put("contentId", contentId); mapIn.put("locale", locale); @@ -256,7 +256,7 @@ public class CompDocEvents { mapIn.put("webSiteId", webSiteId); mapIn.put("https", https); mapIn.put("userLogin", userLogin); - + Map results = null; try { results = dispatcher.runSync("renderContentPdf", mapIn); @@ -270,19 +270,19 @@ public class CompDocEvents { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; } - + if (ServiceUtil.isError(results)) { request.setAttribute("_ERROR_MESSAGE_", ServiceUtil.getErrorMessage(results)); return "error"; } - + ByteBuffer outByteBuffer = (ByteBuffer) results.get("outByteBuffer"); // setup content type String contentType = "application/pdf; charset=ISO-8859-1"; ByteArrayInputStream bais = new ByteArrayInputStream(outByteBuffer.array()); - + /* try { FileOutputStream fos = new FileOutputStream(FileUtil.getFile("/home/byersa/pdftest.pdf")); diff --git a/applications/content/src/org/ofbiz/content/compdoc/CompDocServices.java b/applications/content/src/org/ofbiz/content/compdoc/CompDocServices.java index d9924e88de..f459badbca 100644 --- a/applications/content/src/org/ofbiz/content/compdoc/CompDocServices.java +++ b/applications/content/src/org/ofbiz/content/compdoc/CompDocServices.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -63,13 +63,13 @@ import com.lowagie.text.pdf.PdfReader; public class CompDocServices { public static final String module = CompDocServices.class.getName(); - - /** - * + + /** + * * @param request * @param response * @return - * + * * Creates the topmost Content entity of a Composite Document tree. * Also creates an "empty" Composite Document Instance Content entity. * Creates ContentRevision/Item records for each, as well. @@ -83,7 +83,7 @@ public class CompDocServices { GenericValue userLogin = (GenericValue)context.get("userLogin"); String contentId = (String)context.get("contentId"); //String instanceContentId = null; - + boolean contentExists = true; if (UtilValidate.isEmpty(contentId)) { contentExists = false; @@ -97,7 +97,7 @@ public class CompDocServices { return ServiceUtil.returnError(errMsg); } } - + ModelService modelService = null; try { modelService = dispatcher.getDispatchContext().getModelService("persistContentAndAssoc"); @@ -142,21 +142,21 @@ public class CompDocServices { public static Map renderCompDocPdf(DispatchContext dctx, Map context) { LocalDispatcher dispatcher = dctx.getDispatcher(); - + Locale locale = (Locale) context.get("locale"); String rootDir = (String) context.get("rootDir"); String webSiteId = (String) context.get("webSiteId"); String https = (String) context.get("https"); - + GenericDelegator delegator = dctx.getDelegator(); - + String contentId = (String) context.get("contentId"); String contentRevisionSeqId = (String) context.get("contentRevisionSeqId"); String oooHost = (String) context.get("oooHost"); String oooPort = (String) context.get("oooPort"); GenericValue userLogin = (GenericValue) context.get("userLogin"); - - try { + + try { Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); List exprList = FastList.newInstance(); exprList.add(EntityCondition.makeCondition("contentIdTo", EntityOperator.EQUALS, contentId)); @@ -173,15 +173,15 @@ public class CompDocServices { exprList.add(EntityCondition.makeCondition(thruList, EntityOperator.OR)); EntityConditionList conditionList = EntityCondition.makeCondition(exprList, EntityOperator.AND); - + String [] fields = {"rootRevisionContentId", "itemContentId", "maxRevisionSeqId", "contentId", "dataResourceId", "contentIdTo", "contentAssocTypeId", "fromDate", "sequenceNum"}; Set selectFields = UtilMisc.toSetArray(fields); List orderByFields = UtilMisc.toList("sequenceNum"); List compDocParts = delegator.findList("ContentAssocRevisionItemView", conditionList, selectFields, orderByFields, null, false); - + ByteArrayOutputStream baos = new ByteArrayOutputStream(); Document document = new Document(); - document.setPageSize(PageSize.LETTER); + document.setPageSize(PageSize.LETTER); //Rectangle rect = document.getPageSize(); //PdfWriter writer = PdfWriter.getInstance(document, baos); PdfCopy writer = new PdfCopy(document, baos); @@ -261,7 +261,7 @@ public class CompDocServices { if (UtilValidate.isNotEmpty(oooPort)) convertInMap.put("oooPort", oooPort); Map convertResult = dispatcher.runSync("convertDocumentByteBuffer", convertInMap); - + if (ServiceUtil.isError(convertResult)) { return ServiceUtil.returnError("Error in Open", null, null, convertResult); } @@ -301,25 +301,25 @@ public class CompDocServices { LocalDispatcher dispatcher = dctx.getDispatcher(); Map results = ServiceUtil.returnSuccess(); String dataResourceId = null; - + Locale locale = (Locale) context.get("locale"); String rootDir = (String) context.get("rootDir"); String webSiteId = (String) context.get("webSiteId"); String https = (String) context.get("https"); - + GenericDelegator delegator = dctx.getDelegator(); - + String contentId = (String) context.get("contentId"); String contentRevisionSeqId = (String) context.get("contentRevisionSeqId"); String oooHost = (String) context.get("oooHost"); String oooPort = (String) context.get("oooPort"); GenericValue userLogin = (GenericValue) context.get("userLogin"); - - try { + + try { //Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); //ByteArrayOutputStream baos = new ByteArrayOutputStream(); Document document = new Document(); - document.setPageSize(PageSize.LETTER); + document.setPageSize(PageSize.LETTER); //Rectangle rect = document.getPageSize(); //PdfCopy writer = new PdfCopy(document, baos); document.open(); @@ -376,7 +376,7 @@ public class CompDocServices { } } } - + if (surveyResponse != null) { if (UtilValidate.isEmpty(acroFormContentId)) { // Create AcroForm PDF @@ -400,14 +400,14 @@ public class CompDocServices { } } else { ByteBuffer inByteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, dataResourceId, https, webSiteId, locale, rootDir); - - Map convertInMap = UtilMisc.toMap("userLogin", userLogin, "inByteBuffer", inByteBuffer, + + Map convertInMap = UtilMisc.toMap("userLogin", userLogin, "inByteBuffer", inByteBuffer, "inputMimeType", inputMimeType, "outputMimeType", "application/pdf"); if (UtilValidate.isNotEmpty(oooHost)) convertInMap.put("oooHost", oooHost); if (UtilValidate.isNotEmpty(oooPort)) convertInMap.put("oooPort", oooPort); Map convertResult = dispatcher.runSync("convertDocumentByteBuffer", convertInMap); - + if (ServiceUtil.isError(convertResult)) { return ServiceUtil.returnError("Error in Open", null, null, convertResult); } @@ -415,7 +415,7 @@ public class CompDocServices { ByteBuffer outByteBuffer = (ByteBuffer) convertResult.get("outByteBuffer"); inputByteArray = outByteBuffer.array(); } - + ByteBuffer outByteBuffer = ByteBuffer.wrap(inputByteArray); results.put("outByteBuffer", outByteBuffer); } catch (GenericEntityException e) { diff --git a/applications/content/src/org/ofbiz/content/content/ContentEvents.java b/applications/content/src/org/ofbiz/content/content/ContentEvents.java index 615c24cf63..c2ff1819b4 100644 --- a/applications/content/src/org/ofbiz/content/content/ContentEvents.java +++ b/applications/content/src/org/ofbiz/content/content/ContentEvents.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY diff --git a/applications/content/src/org/ofbiz/content/content/ContentMapFacade.java b/applications/content/src/org/ofbiz/content/content/ContentMapFacade.java index a1730aa075..da4854663f 100644 --- a/applications/content/src/org/ofbiz/content/content/ContentMapFacade.java +++ b/applications/content/src/org/ofbiz/content/content/ContentMapFacade.java @@ -47,7 +47,7 @@ import javolution.util.FastSet; public class ContentMapFacade implements Map { public static final String module = ContentMapFacade.class.getName(); - + protected static final Set mapKeySet = FastSet.newInstance(); static { mapKeySet.add("fields"); @@ -123,7 +123,7 @@ public class ContentMapFacade implements Map { public void setRenderFlag(boolean render) { this.allowRender = render; } - + public void setIsDecorated(boolean isDecorated) { this.isDecorated = isDecorated; } @@ -219,7 +219,7 @@ public class ContentMapFacade implements Map { } } else if ("data".equalsIgnoreCase(name) || "dataresource".equalsIgnoreCase(name)) { // data (resource) object - return dataResource; + return dataResource; } else if ("subcontent_all".equalsIgnoreCase(name)) { // subcontent list of ordered subcontent List subContent = FastList.newInstance(); @@ -257,7 +257,7 @@ public class ContentMapFacade implements Map { return null; } - + protected String renderThis() { if (!this.allowRender && !this.isDecorated) { String errorMsg = "WARNING: Cannot render content being rendered! (Infinite Recursion NOT allowed!)"; @@ -267,11 +267,11 @@ public class ContentMapFacade implements Map { // TODO: change to use the MapStack instead of a cloned Map Map renderCtx = FastMap.newInstance(); renderCtx.putAll(context); - + if (this.isDecorated) { renderCtx.put("_IS_DECORATED_", Boolean.TRUE); } - + try { return ContentWorker.renderContentAsText(dispatcher, delegator, contentId, renderCtx, locale, mimeType, cache); } catch (GeneralException e) { @@ -351,7 +351,7 @@ public class ContentMapFacade implements Map { if (name.toLowerCase().startsWith("id_")) { name = name.substring(3); } - + // look up the content ID (of name) GenericValue content = null; try { @@ -377,7 +377,7 @@ public class ContentMapFacade implements Map { Debug.logWarning("Key parameters must be a string", module); return null; } - String name = (String) key; + String name = (String) key; if (name.toLowerCase().startsWith("id_")) { name = name.substring(3); } diff --git a/applications/content/src/org/ofbiz/content/content/ContentPermissionServices.java b/applications/content/src/org/ofbiz/content/content/ContentPermissionServices.java index 0ec48d75ca..394ff8d513 100644 --- a/applications/content/src/org/ofbiz/content/content/ContentPermissionServices.java +++ b/applications/content/src/org/ofbiz/content/content/ContentPermissionServices.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -42,7 +42,7 @@ import org.ofbiz.service.LocalDispatcher; /** * ContentPermissionServices Class - * + * * Services for granting operation permissions on Content entities in a data-driven manner. */ public class ContentPermissionServices { @@ -62,26 +62,26 @@ public class ContentPermissionServices { * This service goes thru a series of test to determine if the user has * authority to performed anyone of the passed in target operations. * - * It expects a Content entity in "currentContent" + * It expects a Content entity in "currentContent" * It expects a list of contentOperationIds in "targetOperationList" rather * than a scalar because it is thought that sometimes more than one operation * would fit the situation. * Similarly, it expects a list of contentPurposeTypeIds in "contentPurposeList". - * Again, normally there will just be one, but it is possible that a Content + * Again, normally there will just be one, but it is possible that a Content * entity could have multiple purposes associated with it. * The userLogin GenericValue is also required. * A list of roleTypeIds is also possible. * * The basic sequence of testing events is: - * First the ContentPurposeOperation table is checked to see if there are any + * First the ContentPurposeOperation table is checked to see if there are any * entries with matching purposes (and operations) with no roleTypeId (ie. _NA_). * This is done because it would be the most common scenario and is quick to check. * * Secondly, the CONTENTMGR permission is checked. * - * Thirdly, the ContentPurposeOperation table is rechecked to see if there are + * Thirdly, the ContentPurposeOperation table is rechecked to see if there are * any conditions with roleTypeIds that match associated ContentRoles tied to the - * user. + * user. * If a Party of "PARTY_GROUP" type is found, the PartyRelationship table is checked * to see if the current user is linked to that group. * @@ -91,29 +91,29 @@ public class ContentPermissionServices { */ public static Map checkContentPermission(DispatchContext dctx, Map context) { Debug.logWarning(new Exception(), "This service has been depricated in favor of [genericContentPermission]", module); - + Security security = dctx.getSecurity(); GenericDelegator delegator = dctx.getDelegator(); String statusId = (String) context.get("statusId"); String privilegeEnumId = (String) context.get("privilegeEnumId"); - GenericValue content = (GenericValue) context.get("currentContent"); + GenericValue content = (GenericValue) context.get("currentContent"); Boolean bDisplayFailCond = (Boolean)context.get("displayFailCond"); boolean displayFailCond = false; if (bDisplayFailCond != null && bDisplayFailCond.booleanValue()) { - displayFailCond = true; + displayFailCond = true; } Debug.logInfo("displayFailCond(0):" + displayFailCond, ""); Boolean bDisplayPassCond = (Boolean)context.get("displayPassCond"); boolean displayPassCond = false; if (bDisplayPassCond != null && bDisplayPassCond.booleanValue()) { - displayPassCond = true; + displayPassCond = true; } Debug.logInfo("displayPassCond(0):" + displayPassCond, ""); Map results = FastMap.newInstance(); String contentId = null; if (content != null) contentId = content.getString("contentId"); - GenericValue userLogin = (GenericValue) context.get("userLogin"); + GenericValue userLogin = (GenericValue) context.get("userLogin"); String partyId = (String) context.get("partyId"); if (UtilValidate.isEmpty(partyId)) { String passedUserLoginId = (String)context.get("userLoginId"); @@ -121,7 +121,7 @@ public class ContentPermissionServices { try { userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", passedUserLoginId)); if (userLogin != null) { - partyId = userLogin.getString("partyId"); + partyId = userLogin.getString("partyId"); } } catch (GenericEntityException e) { ServiceUtil.returnError(e.getMessage()); @@ -138,8 +138,8 @@ public class ContentPermissionServices { // I realized, belatedly, that I wanted to be able to pass parameters in as // strings so this service could be used in an action event directly, // so I had to write this code to handle both list and strings - List passedPurposes = (List) context.get("contentPurposeList"); - String contentPurposeString = (String) context.get("contentPurposeString"); + List passedPurposes = (List) context.get("contentPurposeList"); + String contentPurposeString = (String) context.get("contentPurposeString"); //Debug.logInfo("contentPurposeString(b):" + contentPurposeString, ""); if (UtilValidate.isNotEmpty(contentPurposeString)) { List purposesFromString = StringUtil.split(contentPurposeString, "|"); @@ -148,15 +148,15 @@ public class ContentPermissionServices { } passedPurposes.addAll(purposesFromString); } - + EntityPermissionChecker.StdAuxiliaryValueGetter auxGetter = new EntityPermissionChecker.StdAuxiliaryValueGetter("ContentPurpose", "contentPurposeTypeId", "contentId"); - // Sometimes permissions need to be checked before an entity is created, so + // Sometimes permissions need to be checked before an entity is created, so // there needs to be a method for setting a purpose list auxGetter.setList(passedPurposes); //Debug.logInfo("passedPurposes(b):" + passedPurposes, ""); - List targetOperations = (List) context.get("targetOperationList"); + List targetOperations = (List) context.get("targetOperationList"); //Debug.logInfo("targetOperations(b):" + targetOperations, ""); - String targetOperationString = (String) context.get("targetOperationString"); + String targetOperationString = (String) context.get("targetOperationString"); //Debug.logInfo("targetOperationString(b):" + targetOperationString, ""); if (UtilValidate.isNotEmpty(targetOperationString)) { List operationsFromString = StringUtil.split(targetOperationString, "|"); @@ -168,44 +168,44 @@ public class ContentPermissionServices { //Debug.logInfo("targetOperations(c):" + targetOperations, ""); EntityPermissionChecker.StdPermissionConditionGetter permCondGetter = new EntityPermissionChecker.StdPermissionConditionGetter("ContentPurposeOperation", "contentOperationId", "roleTypeId", "statusId", "contentPurposeTypeId", "privilegeEnumId"); permCondGetter.setOperationList(targetOperations); - + EntityPermissionChecker.StdRelatedRoleGetter roleGetter = new EntityPermissionChecker.StdRelatedRoleGetter("Content", "roleTypeId", "contentId", "partyId", "ownerContentId", "ContentRole"); //Debug.logInfo("targetOperations(b):" + targetOperations, ""); - List passedRoles = (List) context.get("roleTypeList"); + List passedRoles = (List) context.get("roleTypeList"); if (passedRoles == null) passedRoles = FastList.newInstance(); - String roleTypeString = (String) context.get("roleTypeString"); + String roleTypeString = (String) context.get("roleTypeString"); if (UtilValidate.isNotEmpty(roleTypeString)) { List rolesFromString = StringUtil.split(roleTypeString, "|"); passedRoles.addAll(rolesFromString); } roleGetter.setList(passedRoles); - + String entityAction = (String) context.get("entityOperation"); if (entityAction == null) entityAction = "_ADMIN"; if (userLogin != null && entityAction != null) { passed = security.hasEntityPermission("CONTENTMGR", entityAction, userLogin); } - + StringBuilder errBuf = new StringBuilder(); String permissionStatus = null; List entityIds = FastList.newInstance(); if (passed) { - results.put("permissionStatus", "granted"); + results.put("permissionStatus", "granted"); permissionStatus = "granted"; if (displayPassCond) { errBuf.append("\n hasEntityPermission(" + entityAction + "): PASSED" ); - } - + } + } else { if (displayFailCond) { errBuf.append("\n hasEntityPermission(" + entityAction + "): FAILED" ); - } + } if (content != null) entityIds.add(content); String quickCheckContentId = (String) context.get("quickCheckContentId"); if (UtilValidate.isNotEmpty(quickCheckContentId)) { - List quickList = StringUtil.split(quickCheckContentId, "|"); + List quickList = StringUtil.split(quickCheckContentId, "|"); if (UtilValidate.isNotEmpty(quickList)) entityIds.addAll(quickList); } try { @@ -216,13 +216,13 @@ public class ContentPermissionServices { results.put("permissionStatus", "rejected"); } } catch (GenericEntityException e) { - ServiceUtil.returnError(e.getMessage()); + ServiceUtil.returnError(e.getMessage()); } permissionStatus = (String)results.get("permissionStatus"); errBuf.append("\n permissionStatus:" ); errBuf.append(permissionStatus); } - + if ((permissionStatus.equals("granted") && displayPassCond) || (permissionStatus.equals("rejected") && displayFailCond)) { // Don't show this if passed on 'hasEntityPermission' @@ -238,27 +238,27 @@ public class ContentPermissionServices { errBuf.append(partyId); errBuf.append("\n entityIds:" ); errBuf.append(entityIds); - + if (auxGetter != null) { errBuf.append("\n auxList:" ); errBuf.append(auxGetter.getList()); } - + if (roleGetter != null) { errBuf.append("\n roleList:" ); errBuf.append(roleGetter.getList()); } } - + } } Debug.logInfo("displayPass/FailCond(0), errBuf:" + errBuf.toString(), ""); results.put(ModelService.ERROR_MESSAGE, errBuf.toString()); return results; } - + public static Map checkAssocPermission(DispatchContext dctx, Map context) { - + Map results = FastMap.newInstance(); Security security = dctx.getSecurity(); GenericDelegator delegator = dctx.getDelegator(); @@ -266,12 +266,12 @@ public class ContentPermissionServices { Boolean bDisplayFailCond = (Boolean)context.get("displayFailCond"); String contentIdFrom = (String) context.get("contentIdFrom"); String contentIdTo = (String) context.get("contentIdTo"); - GenericValue userLogin = (GenericValue) context.get("userLogin"); + GenericValue userLogin = (GenericValue) context.get("userLogin"); String entityAction = (String) context.get("entityOperation"); if (entityAction == null) entityAction = "_ADMIN"; List roleIds = null; String permissionStatus = null; - + GenericValue contentTo = null; GenericValue contentFrom = null; try { @@ -285,12 +285,12 @@ public class ContentPermissionServices { } Map resultsMap = null; boolean isMatch = false; - + boolean isMatchTo = false; boolean isMatchFrom = false; Map permResults = FastMap.newInstance(); String skipPermissionCheck = null; - + if (skipPermissionCheck == null || skipPermissionCheck.length() == 0 || (!skipPermissionCheck.equalsIgnoreCase("true") && !skipPermissionCheck.equalsIgnoreCase("granted"))) { @@ -303,7 +303,7 @@ public class ContentPermissionServices { serviceInMap.put("contentPurposeList", relatedPurposesTo); serviceInMap.put("currentContent", contentTo); serviceInMap.put("displayFailCond", bDisplayFailCond); - + try { permResults = dispatcher.runSync("checkContentPermission", serviceInMap); } catch (GenericServiceException e) { @@ -327,7 +327,7 @@ public class ContentPermissionServices { } permissionStatus = (String)permResults.get("permissionStatus"); if (permissionStatus != null && permissionStatus.equals("granted") ) { - results.put("permissionStatus", "granted"); + results.put("permissionStatus", "granted"); } else { if (bDisplayFailCond != null && bDisplayFailCond.booleanValue()) { String errMsg = (String)permResults.get(ModelService.ERROR_MESSAGE); @@ -335,9 +335,9 @@ public class ContentPermissionServices { } } } else { - results.put("permissionStatus", "granted"); + results.put("permissionStatus", "granted"); } return results; } - + } diff --git a/applications/content/src/org/ofbiz/content/content/ContentServices.java b/applications/content/src/org/ofbiz/content/content/ContentServices.java index 734fea3fb4..ba786d96f7 100644 --- a/applications/content/src/org/ofbiz/content/content/ContentServices.java +++ b/applications/content/src/org/ofbiz/content/content/ContentServices.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -150,7 +150,7 @@ public class ContentServices { } return results; } - + private static void walkParentTree(Map nodeMap, List parentList) { List kids = (List)nodeMap.get("kids"); if (UtilValidate.isEmpty(kids)) { @@ -272,12 +272,12 @@ public class ContentServices { GenericValue userLogin = (GenericValue) context.get("userLogin"); String userLoginId = (String) userLogin.get("userLoginId"); - // get first statusId for content out of the statusItem table if not provided + // get first statusId for content out of the statusItem table if not provided if (UtilValidate.isEmpty(context.get("statusId"))) { try { List statusItems = delegator.findByAnd("StatusItem",UtilMisc.toMap("statusTypeId", "CONTENT_STATUS"), UtilMisc.toList("sequenceId")); if (!UtilValidate.isEmpty(statusItems)) { - content.put("statusId", ((GenericValue) statusItems.get(0)).getString("statusId")); + content.put("statusId", ((GenericValue) statusItems.get(0)).getString("statusId")); } } catch (GenericEntityException e) { return ServiceUtil.returnError(e.getMessage()); @@ -558,7 +558,7 @@ public class ContentServices { return ServiceUtil.returnError("Problem updating content Status: " + e); } } - + content.setNonPKFields(context); content.put("lastModifiedByUserLogin", lastModifiedByUserLogin); content.put("lastModifiedDate", lastModifiedDate); @@ -1037,25 +1037,25 @@ public class ContentServices { return results; } - + public static Map publishContent(DispatchContext dctx, Map context) throws GenericServiceException{ - + Map result = FastMap.newInstance(); GenericValue content = (GenericValue)context.get("content"); - GenericValue userLogin = (GenericValue)context.get("userLogin"); - + GenericValue userLogin = (GenericValue)context.get("userLogin"); + try { content.put("statusId", "CTNT_PUBLISHED"); - content.store(); + content.store(); } catch (GenericEntityException e) { Debug.logError(e.getMessage(), module); return ServiceUtil.returnError(e.getMessage()); } return result; } - + public static Map getPrefixedMembers(DispatchContext dctx, Map context) throws GenericServiceException{ - + Map result = FastMap.newInstance(); Map mapIn = (Map)context.get("mapIn"); String prefix = (String)context.get("prefix"); @@ -1076,19 +1076,19 @@ public class ContentServices { } return result; } - + public static Map splitString(DispatchContext dctx, Map context) throws GenericServiceException{ Map result = FastMap.newInstance(); List outputList = FastList.newInstance(); String delimiter = UtilFormatOut.checkEmpty((String)context.get("delimiter"), "|"); String inputString = (String)context.get("inputString"); if (UtilValidate.isNotEmpty(inputString)) { - outputList = StringUtil.split(inputString, delimiter); + outputList = StringUtil.split(inputString, delimiter); } result.put("outputList", outputList); return result; } - + public static Map joinString(DispatchContext dctx, Map context) throws GenericServiceException{ Map result = FastMap.newInstance(); String outputString = null; @@ -1100,9 +1100,9 @@ public class ContentServices { result.put("outputString", outputString); return result; } - + public static Map urlEncodeArgs(DispatchContext dctx, Map context) throws GenericServiceException{ - + Map result = FastMap.newInstance(); Map mapFiltered = FastMap.newInstance(); Map mapIn = (Map)context.get("mapIn"); @@ -1126,5 +1126,5 @@ public class ContentServices { } return result; } - + } diff --git a/applications/content/src/org/ofbiz/content/content/ContentServicesComplex.java b/applications/content/src/org/ofbiz/content/content/ContentServicesComplex.java index f0bb529c64..dcb9684c7a 100644 --- a/applications/content/src/org/ofbiz/content/content/ContentServicesComplex.java +++ b/applications/content/src/org/ofbiz/content/content/ContentServicesComplex.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -65,7 +65,7 @@ public class ContentServicesComplex { public static Map getAssocAndContentAndDataResource(DispatchContext dctx, Map context) { GenericDelegator delegator = dctx.getDelegator(); - List assocTypes = (List) context.get("assocTypes"); + List assocTypes = (List) context.get("assocTypes"); List contentTypes = (List)context.get("contentTypes"); Timestamp fromDate = (Timestamp)context.get("fromDate"); Timestamp thruDate = (Timestamp)context.get("thruDate"); @@ -140,7 +140,7 @@ public class ContentServicesComplex { EntityConditionList assocExprList = EntityCondition.makeCondition(exprList, EntityOperator.AND); List relatedAssocs = null; try { - //relatedAssocs = delegator.findByCondition(viewName, joinExpr, + //relatedAssocs = delegator.findByCondition(viewName, joinExpr, relatedAssocs = delegator.findList(viewName, assocExprList, null,UtilMisc.toList("caFromDate"), null, false); } catch (GenericEntityException e) { return ServiceUtil.returnError(e.getMessage()); @@ -171,12 +171,12 @@ public class ContentServicesComplex { public static Map getAssocAndContentAndDataResourceCache(DispatchContext dctx, Map context) { GenericDelegator delegator = dctx.getDelegator(); - List assocTypes = (List) context.get("assocTypes"); + List assocTypes = (List) context.get("assocTypes"); String assocTypesString = (String)context.get("assocTypesString"); if (UtilValidate.isNotEmpty(assocTypesString)) { List lst = StringUtil.split(assocTypesString, "|"); if (assocTypes == null) { - assocTypes = FastList.newInstance(); + assocTypes = FastList.newInstance(); } assocTypes.addAll(lst); } @@ -185,7 +185,7 @@ public class ContentServicesComplex { if (UtilValidate.isNotEmpty(contentTypesString)) { List lst = StringUtil.split(contentTypesString, "|"); if (contentTypes == null) { - contentTypes = FastList.newInstance(); + contentTypes = FastList.newInstance(); } contentTypes.addAll(lst); } @@ -199,7 +199,7 @@ public class ContentServicesComplex { Map results = null; try { results = getAssocAndContentAndDataResourceCacheMethod(delegator, - contentId, mapKey, direction, fromDate, + contentId, mapKey, direction, fromDate, fromDateStr, assocTypes, contentTypes, nullThruDatesOnly, contentAssocPredicateId); } catch (GenericEntityException e) { return ServiceUtil.returnError(e.getMessage()); @@ -210,15 +210,15 @@ public class ContentServicesComplex { } - public static Map getAssocAndContentAndDataResourceCacheMethod(GenericDelegator delegator, String contentId, String mapKey, String direction, + public static Map getAssocAndContentAndDataResourceCacheMethod(GenericDelegator delegator, String contentId, String mapKey, String direction, Timestamp fromDate, String fromDateStr, List assocTypes, List contentTypes, Boolean nullThruDatesOnly, String contentAssocPredicateId) throws GenericEntityException, MiniLangException { Map results = getAssocAndContentAndDataResourceCacheMethod(delegator, - contentId, mapKey, direction, fromDate, fromDateStr, assocTypes, + contentId, mapKey, direction, fromDate, fromDateStr, assocTypes, contentTypes, nullThruDatesOnly, contentAssocPredicateId, null); return results; } - public static Map getAssocAndContentAndDataResourceCacheMethod(GenericDelegator delegator, String contentId, String mapKey, String direction, + public static Map getAssocAndContentAndDataResourceCacheMethod(GenericDelegator delegator, String contentId, String mapKey, String direction, Timestamp fromDate, String fromDateStr, List assocTypes, List contentTypes, Boolean nullThruDatesOnly, String contentAssocPredicateId, String orderBy) throws GenericEntityException, MiniLangException { //List exprList = FastList.newInstance(); @@ -258,7 +258,7 @@ public class ContentServicesComplex { fieldMap.putAll(UtilMisc.toMap("thruDate", null)); } List contentAssocsUnfiltered = null; - + //if (Debug.infoOn()) Debug.logInfo("in getAssocAndContent...Cache, fieldMap:" + fieldMap, module); contentAssocsUnfiltered = delegator.findByAndCache("ContentAssoc", fieldMap, UtilMisc.toList("-fromDate")); diff --git a/applications/content/src/org/ofbiz/content/content/ContentWorker.java b/applications/content/src/org/ofbiz/content/content/ContentWorker.java index e906ecf04f..2b4bf1cfd9 100644 --- a/applications/content/src/org/ofbiz/content/content/ContentWorker.java +++ b/applications/content/src/org/ofbiz/content/content/ContentWorker.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -318,7 +318,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { if (locale == null) { return contentAssocDataResourceViewFrom; } - + String localeStr = locale.toString(); boolean isTwoLetterLocale = localeStr.length() == 2; @@ -329,7 +329,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { Debug.logError(e, "Error finding alternate locale content: " + e.toString(), module); return contentAssocDataResourceViewFrom; } - + alternateViews = EntityUtil.filterByDate(alternateViews, UtilDateTime.nowTimestamp(), "caFromDate", "caThruDate", true); Iterator alternateViewIter = alternateViews.iterator(); while (alternateViewIter.hasNext()) { @@ -338,9 +338,9 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { if (UtilValidate.isEmpty(currentLocaleString)) { continue; } - + int currentLocaleLength = currentLocaleString.length(); - + // could be a 2 letter or 5 letter code if (isTwoLetterLocale) { if (currentLocaleLength == 2) { @@ -370,12 +370,12 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { } } } - + return contentAssocDataResourceViewFrom; } public static void traverse(GenericDelegator delegator, GenericValue content, Timestamp fromDate, Timestamp thruDate, Map whenMap, int depthIdx, Map masterNode, String contentAssocTypeId, List pickList, String direction) { - + //String startContentAssocTypeId = null; String contentTypeId = null; String contentId = null; @@ -477,7 +477,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { List nodeTrail = (List)ctx.get("nodeTrail"); ContentWorker.traceNodeTrail("11",nodeTrail); int sz = nodeTrail.size(); - if (sz == 0) { + if (sz == 0) { return false; } @@ -494,7 +494,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { currentNode = (Map)kids.get(idx); ContentWorker.traceNodeTrail("12",nodeTrail); Boolean isPick = (Boolean)currentNode.get("isPick"); - + if (isPick != null && isPick.booleanValue()) { nodeTrail.add(currentNode); inProgress = true; @@ -514,7 +514,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { } idx++; } - } + } if (!inProgress) { // look for next sibling @@ -608,7 +608,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { } public static void selectKids(Map currentNode, Map ctx) { - + GenericDelegator delegator = (GenericDelegator) ctx.get("delegator"); GenericValue parentContent = (GenericValue) currentNode.get("value"); String contentAssocTypeId = (String) ctx.get("contentAssocTypeId"); @@ -624,7 +624,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { direction = "From"; Timestamp fromDate = (Timestamp) ctx.get("fromDate"); Timestamp thruDate = (Timestamp) ctx.get("thruDate"); - + List assocTypeList = StringUtil.split(contentAssocTypeId, " "); List contentTypeList = StringUtil.split(contentTypeId, " "); String contentAssocPredicateId = null; @@ -662,7 +662,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { } public static boolean checkWhen(Map context, String whenStr) { - + boolean isWhen = true; //opposite default from checkReturnWhen if (whenStr != null && whenStr.length() > 0) { FlexibleStringExpander fse = FlexibleStringExpander.getInstance(whenStr); @@ -703,7 +703,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { GenericDelegator delegator = currentContent.getDelegator(); List assocList = getAssociations(currentContent, linkDir, assocTypes, fromDate, thruDate); - if (UtilValidate.isEmpty(assocList)) { + if (UtilValidate.isEmpty(assocList)) { return assocList; } if (Debug.infoOn()) Debug.logInfo("assocList:" + assocList.size() + " contentId:" + currentContent.getString("contentId"), ""); @@ -870,7 +870,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { contentIdField = "contentIdTo"; contentIdOtherField = "contentId"; } - + if (Debug.infoOn()) Debug.logInfo("getContentAncestry, contentId:" + contentId, ""); if (Debug.infoOn()) Debug.logInfo("getContentAncestry, contentAssocTypeId:" + contentAssocTypeId, ""); Map andMap = null; @@ -890,11 +890,11 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { contentAncestorList.add(contentAssoc.getString(contentIdOtherField)); } } catch (GenericEntityException e) { - Debug.logError(e,module); + Debug.logError(e,module); return; } } - + public static void getContentAncestryAll(GenericDelegator delegator, String contentId, String passedContentTypeId, String direction, List contentAncestorList) { String contentIdField = null; String contentIdOtherField = null; @@ -905,7 +905,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { contentIdField = "contentIdTo"; contentIdOtherField = "contentId"; } - + if (Debug.infoOn()) Debug.logInfo("getContentAncestry, contentId:" + contentId, ""); Map andMap = UtilMisc.toMap(contentIdField, contentId); try { @@ -928,7 +928,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { } } } catch (GenericEntityException e) { - Debug.logError(e,module); + Debug.logError(e,module); return; } } @@ -938,7 +938,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { List contentAncestorList = FastList.newInstance(); List nodeTrail = FastList.newInstance(); getContentAncestry(delegator, contentId, contentAssocTypeId, direction, contentAncestorList); - Iterator contentAncestorListIter = contentAncestorList.iterator(); + Iterator contentAncestorListIter = contentAncestorList.iterator(); while (contentAncestorListIter.hasNext()) { GenericValue value = (GenericValue) contentAncestorListIter.next(); Map thisNode = ContentWorker.makeNode(value); @@ -965,7 +965,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { contentIdField = "contentIdTo"; contentIdOtherField = "contentId"; } - + //if (Debug.infoOn()) Debug.logInfo("getContentAncestry, contentId:" + contentId, ""); try { List lst = delegator.findByAndCache("ContentAssoc", UtilMisc.toMap(contentIdField, contentId, "contentAssocTypeId", contentAssocTypeId)); @@ -976,11 +976,11 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { GenericValue contentAssoc = (GenericValue)lst2.get(0); getContentAncestryValues(delegator, contentAssoc.getString(contentIdOtherField), contentAssocTypeId, direction, contentAncestorList); GenericValue content = delegator.findByPrimaryKeyCache("Content", UtilMisc.toMap("contentId", contentAssoc.getString(contentIdOtherField))); - + contentAncestorList.add(content); } } catch (GenericEntityException e) { - Debug.logError(e,module); + Debug.logError(e,module); return; } } @@ -1002,7 +1002,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { } public static Map callContentPermissionCheckResult(GenericDelegator delegator, LocalDispatcher dispatcher, Map context) { - + Map permResults = FastMap.newInstance(); String skipPermissionCheck = (String) context.get("skipPermissionCheck"); @@ -1026,7 +1026,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { Debug.logError(e, "Problem checking permissions", "ContentServices"); } } else { - permResults.put("permissionStatus", "granted"); + permResults.put("permissionStatus", "granted"); } return permResults; } @@ -1117,7 +1117,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { List passedGlobalNodeTrail = null; GenericValue currentContent = null; String viewContentId = null; - if (UtilValidate.isNotEmpty(trail)) { + if (UtilValidate.isNotEmpty(trail)) { passedGlobalNodeTrail = UtilMisc.makeListWritable(trail); } else { passedGlobalNodeTrail = FastList.newInstance(); @@ -1128,7 +1128,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { Map nd = (Map)passedGlobalNodeTrail.get(sz - 1); if (nd != null) currentContent = (GenericValue)nd.get("value"); - if (currentContent != null) + if (currentContent != null) viewContentId = (String)currentContent.get("contentId"); } @@ -1271,7 +1271,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { } return bool; } - + public static List prepTargetOperationList(Map context, String md) { @@ -1296,7 +1296,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { } /** - * Checks to see if there is a purpose string (delimited by pipes) and + * Checks to see if there is a purpose string (delimited by pipes) and * turns it into a list and concants to any existing purpose list. * @param context * @return @@ -1323,7 +1323,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { public static String prepPermissionErrorMsg(Map permResults) { String permissionStatus = (String)permResults.get("permissionStatus"); - String errorMessage = "Permission is denied." + permissionStatus; + String errorMessage = "Permission is denied." + permissionStatus; errorMessage += ServiceUtil.getErrorMessage(permResults); PermissionRecorder recorder = (PermissionRecorder)permResults.get("permissionRecorder"); Debug.logInfo("recorder(0):" + recorder, ""); @@ -1383,7 +1383,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { public static Map makeNode(GenericValue thisContent) { Map thisNode = null; - if (thisContent == null) + if (thisContent == null) return thisNode; thisNode = FastMap.newInstance(); @@ -1408,7 +1408,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { public static String nodeTrailToCsv(List nodeTrail) { - + if (nodeTrail == null) return ""; StringBuilder csv = new StringBuilder(); @@ -1427,7 +1427,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { } public static List csvToList(String csv, GenericDelegator delegator) { - + List outList = FastList.newInstance(); List contentIdList = StringUtil.split(csv, ","); GenericValue content = null; @@ -1447,7 +1447,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { values = FastList.newInstance(); values.add(contentId); values.add(contentName); - outList.add(values); + outList.add(values); } return outList; } @@ -1519,7 +1519,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { /* * Tries to find the mime type of the associated content and parent content. * - * @param delegator + * @param delegator * @param view SubContentDataResourceView * @param parentContent Content entity * @param contentId part of primary key of view. To be used if view is null. @@ -1577,7 +1577,7 @@ public class ContentWorker implements org.ofbiz.widget.ContentWorkerInterface { public static String logMap(String lbl, Map map, int indentLevel) { StringBuilder indent = new StringBuilder(); - for (int i=0; i createFileNoPerm(DispatchContext dctx, Map rcontext) { Map context = UtilMisc.makeMapWritable(rcontext); - context.put("skipPermissionCheck", "true"); + context.put("skipPermissionCheck", "true"); return createFileMethod(dctx, context); } @@ -311,7 +311,7 @@ public class DataServices { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); } - + result.put("dataResource", dataResource); return result; } @@ -344,7 +344,7 @@ public class DataServices { String errMsg = "dataResourceId is null."; Debug.logError(errMsg, module); return ServiceUtil.returnError(errMsg); - + } String textData = (String) context.get("textData"); if (Debug.verboseOn()) Debug.logVerbose("in updateElectronicText, textData:" + textData, module); @@ -419,7 +419,7 @@ public class DataServices { if (file == null) { throw new IOException("File: " + file + " is null"); } - + // write the data to the file if (UtilValidate.isNotEmpty(textData)) { try { diff --git a/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java b/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java index 0797ecadb6..c3c45dc926 100644 --- a/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java +++ b/applications/content/src/org/ofbiz/content/layout/LayoutEvents.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -70,7 +70,7 @@ public class LayoutEvents { Map context = FastMap.newInstance(); ByteBuffer byteWrap = (ByteBuffer) uploadResults.get("imageData"); if (byteWrap == null) { - String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.image_data_null", locale); + String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.image_data_null", locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } @@ -80,7 +80,7 @@ public class LayoutEvents { String imageFileNameExt = null; if (UtilValidate.isNotEmpty(imageFileName)) { int pos = imageFileName.lastIndexOf("."); - if (pos >= 0) + if (pos >= 0) imageFileNameExt = imageFileName.substring(pos + 1); } String mimeTypeId = "image/" + imageFileNameExt; @@ -115,10 +115,10 @@ public class LayoutEvents { 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 @@ public class LayoutEvents { //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 @@ public class LayoutEvents { 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, ""); @@ -263,8 +263,8 @@ public class LayoutEvents { // Look for an existing associated Content try { List lst = delegator.findByAnd( - "DataResourceContentView ", - UtilMisc.toMap("dataResourceId", dataResourceId)); + "DataResourceContentView ", + UtilMisc.toMap("dataResourceId", dataResourceId)); if (lst.size() > 0) { GenericValue dataResourceContentView = (GenericValue)lst.get(0); contentId = (String)dataResourceContentView.get("coContentId"); @@ -274,14 +274,14 @@ public class LayoutEvents { return "error"; } // Else, create and associate a Content - } + } */ if (UtilValidate.isNotEmpty(contentId)) { context.put("contentId", contentId); 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 @@ public class LayoutEvents { //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) { @@ -320,7 +320,7 @@ public class LayoutEvents { Debug.logVerbose("in cloneLayout, contentId:" + contentId, ""); if (UtilValidate.isEmpty(contentId)) { String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.content_id_empty", locale); - request.setAttribute("_ERROR_MESSAGE_", errMsg); + request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } String contentIdTo = (String)paramMap.get("contentIdTo"); @@ -333,7 +333,7 @@ public class LayoutEvents { String newId = null; String newDataResourceId = null; try { - content = delegator.findByPrimaryKey("Content", + content = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentId)); Debug.logVerbose("in cloneLayout, content:" + content, ""); if (content == null) { @@ -347,7 +347,7 @@ public class LayoutEvents { newId = delegator.getNextSeqId("Content"); newContent.set("contentId", newId); String dataResourceId = (String)content.get("dataResourceId"); - GenericValue dataResource = delegator.findByPrimaryKey("DataResource", + GenericValue dataResource = delegator.findByPrimaryKey("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); if (dataResource != null) { GenericValue newDataResource = delegator.makeValue("DataResource", dataResource); @@ -400,7 +400,7 @@ public class LayoutEvents { request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; } - + serviceIn = FastMap.newInstance(); serviceIn.put("userLogin", session.getAttribute("userLogin")); @@ -447,7 +447,7 @@ public class LayoutEvents { view.set("contentId", newId); view.set("drDataResourceId", newDataResourceId); Debug.logVerbose("in cloneLayout, view:" + view, ""); - ContentManagementWorker.setCurrentEntityMap(request, view); + ContentManagementWorker.setCurrentEntityMap(request, view); request.setAttribute("contentId", view.get("contentId")); request.setAttribute("drDataResourceId", view.get("drDataResourceId")); return "success"; @@ -460,7 +460,7 @@ public class LayoutEvents { Map paramMap = UtilHttp.getParameterMap(request); String contentIdTo = (String)paramMap.get("contentIdTo"); String mapKey = (String)paramMap.get("mapKey"); - if (Debug.verboseOn()) { + if (Debug.verboseOn()) { Debug.logVerbose("in createSubContent, contentIdTo:" + contentIdTo, module); Debug.logVerbose("in createSubContent, mapKey:" + mapKey, module); } @@ -473,7 +473,7 @@ public class LayoutEvents { GenericValue userLogin = (GenericValue)session.getAttribute("userLogin"); context.put("userLogin", userLogin); - String rootDir = request.getSession().getServletContext().getRealPath("/"); + String rootDir = request.getSession().getServletContext().getRealPath("/"); context.put("rootDir", rootDir); try { SimpleMapProcessor.runSimpleMapProcessor( @@ -519,7 +519,7 @@ public class LayoutEvents { 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) { @@ -540,13 +540,13 @@ public class LayoutEvents { Map context = FastMap.newInstance(); List errorMessages = null; Locale loc = (Locale)request.getSession().getServletContext().getAttribute("locale"); - if (loc == null) + if (loc == null) loc = Locale.getDefault(); context.put("locale", loc); GenericValue userLogin = (GenericValue)session.getAttribute("userLogin"); context.put("userLogin", userLogin); - String rootDir = request.getSession().getServletContext().getRealPath("/"); + String rootDir = request.getSession().getServletContext().getRealPath("/"); context.put("rootDir", rootDir); try { SimpleMapProcessor.runSimpleMapProcessor( @@ -590,7 +590,7 @@ public class LayoutEvents { 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,12 +606,12 @@ public class LayoutEvents { 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); return "error"; - } + } GenericValue v = delegator.makeValue(entityName); GenericPK passedPK = v.getPrimaryKey(); Collection keyColl = passedPK.getAllKeys(); diff --git a/applications/content/src/org/ofbiz/content/layout/LayoutServices.java b/applications/content/src/org/ofbiz/content/layout/LayoutServices.java index 269071c573..164357dc05 100644 --- a/applications/content/src/org/ofbiz/content/layout/LayoutServices.java +++ b/applications/content/src/org/ofbiz/content/layout/LayoutServices.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY diff --git a/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java b/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java index 4eb6626acb..ec0ca05842 100644 --- a/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java +++ b/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -45,7 +45,7 @@ public class LayoutWorker { public static final String err_resource = "ContentErrorUiLabels"; /** - * Uploads image data from a form and stores it in ImageDataResource. + * Uploads image data from a form and stores it in ImageDataResource. * Expects key data in a field identitified by the "idField" value * and the binary data to be in a field id'd by uploadField. */ @@ -53,7 +53,7 @@ public class LayoutWorker { //Debug.logVerbose("in uploadAndStoreImage", ""); Locale locale = UtilHttp.getLocale(request); - + Map results = FastMap.newInstance(); Map formInput = FastMap.newInstance(); results.put("formInput", formInput); @@ -66,7 +66,7 @@ public class LayoutWorker { } if (lst.size() == 0) { - String errMsg = UtilProperties.getMessage(LayoutWorker.err_resource, "layoutEvents.no_files_uploaded", locale); + String errMsg = UtilProperties.getMessage(LayoutWorker.err_resource, "layoutEvents.no_files_uploaded", locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); //Debug.logWarning("[DataEvents.uploadImage] No files uploaded", module); return ServiceUtil.returnError("No files uploaded."); @@ -93,7 +93,7 @@ public class LayoutWorker { } if (imageFi == null ) { - Map messageMap = UtilMisc.toMap("imageFi", imageFi); + Map messageMap = UtilMisc.toMap("imageFi", imageFi); String errMsg = UtilProperties.getMessage(LayoutWorker.err_resource, "layoutEvents.image_null", messageMap, locale); request.setAttribute("_ERROR_MESSAGE_", errMsg); //Debug.logWarning("[DataEvents.uploadImage] imageFi(" + imageFi + ") is null", module); @@ -104,13 +104,13 @@ public class LayoutWorker { ByteBuffer byteWrap = ByteBuffer.wrap(imageBytes); results.put("imageData", byteWrap); results.put("imageFileName", imageFi.getName()); - + //Debug.logVerbose("in uploadAndStoreImage, results:" + results, ""); return results; } - public static ByteBuffer returnByteBuffer(Map map) { + public static ByteBuffer returnByteBuffer(Map map) { ByteBuffer byteBuff = (ByteBuffer)map.get("imageData"); return byteBuff; - } + } } diff --git a/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayInputStream.java b/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayInputStream.java index 41c7d46bbf..f4201359ef 100644 --- a/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayInputStream.java +++ b/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayInputStream.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -31,44 +31,44 @@ import com.sun.star.io.NotConnectedException; */ 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; } - public void skipBytes(int pos1) throws BufferSizeExceededException, + public void skipBytes(int pos1) throws BufferSizeExceededException, NotConnectedException, com.sun.star.io.IOException { skip(pos1); } 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 @@ public class OpenOfficeByteArrayInputStream extends ByteArrayInputStream impleme String errMsg = e.getMessage(); throw new com.sun.star.io.IOException( errMsg, this ); } - + if (bytesRead > 0) { if (bytesRead < pos2) { byte [] buf3 = new byte[bytesRead]; diff --git a/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayOutputStream.java b/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayOutputStream.java index 9ccc67675a..d223a44a55 100644 --- a/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayOutputStream.java +++ b/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeByteArrayOutputStream.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -33,7 +33,7 @@ import com.sun.star.io.NotConnectedException; 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 @@ public class OpenOfficeByteArrayOutputStream extends ByteArrayOutputStream imple throw(new com.sun.star.io.IOException(e.getMessage())); } } - + public void flush() { try { diff --git a/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java b/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java index f0cc5ae716..186b64211c 100644 --- a/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java +++ b/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeServices.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -66,7 +66,7 @@ public class OpenOfficeServices { * and "/" for Linux/Unix. */ public static Map convertDocumentByteBuffer(DispatchContext dctx, Map context) { - + Map results = ServiceUtil.returnSuccess(); GenericDelegator delegator = dctx.getDelegator(); XMultiComponentFactory xmulticomponentfactory = null; @@ -78,7 +78,7 @@ public class OpenOfficeServices { 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 @@ public class OpenOfficeServices { // 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 { + + 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 @@ public class OpenOfficeServices { baos.write(c); } fis.close(); - + results.put("outByteBuffer", new ByteBuffer(baos.toByteArray())); baos.close(); @@ -142,7 +142,7 @@ public class OpenOfficeServices { */ public static Map convertDocument(DispatchContext dctx, Map 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 @@ public class OpenOfficeServices { // 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 { + + 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 class OpenOfficeServices { */ public static Map convertDocumentFileToFile(DispatchContext dctx, Map context) { XMultiComponentFactory xmulticomponentfactory = null; - + String stringUrl = (String) context.get("filenameFrom"); String stringConvertedFile = (String) context.get("filenameTo"); String inputMimeType = (String) context.get("inputMimeType"); @@ -180,8 +180,8 @@ public class OpenOfficeServices { // 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 { + + try { xmulticomponentfactory = OpenOfficeWorker.getRemoteServer(oooHost, oooPort); File inputFile = new File(stringUrl); long fileSize = inputFile.length(); @@ -199,7 +199,7 @@ public class OpenOfficeServices { fis.close(); oobais.close(); oobaos.close(); - + Map results = ServiceUtil.returnSuccess(); return results; } catch (IOException e) { @@ -216,7 +216,7 @@ public class OpenOfficeServices { */ public static Map convertDocumentStreamToStream(DispatchContext dctx, Map context) { XMultiComponentFactory xmulticomponentfactory = null; - + String stringUrl = "file:///" + context.get("filenameFrom"); String stringConvertedFile = "file:///" + context.get("filenameTo"); String inputMimeType = (String) context.get("inputMimeType"); @@ -225,8 +225,8 @@ public class OpenOfficeServices { // 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 { + + try { xmulticomponentfactory = OpenOfficeWorker.getRemoteServer(oooHost, oooPort); File inputFile = new File(stringUrl); long fileSize = inputFile.length(); @@ -244,7 +244,7 @@ public class OpenOfficeServices { fis.close(); oobais.close(); oobaos.close(); - + Map results = ServiceUtil.returnSuccess(); return results; } catch (IOException e) { @@ -261,7 +261,7 @@ public class OpenOfficeServices { */ public static Map compareDocuments(DispatchContext dctx, Map context) { XMultiComponentFactory xmulticomponentfactory = null; - + String stringUrl = "file:///" + context.get("filenameFrom"); String stringOriginalFile = "file:///" + context.get("filenameOriginal"); String stringOutFile = "file:///" + context.get("filenameOut"); @@ -269,8 +269,8 @@ public class OpenOfficeServices { // 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 { + + try { xmulticomponentfactory = OpenOfficeWorker.getRemoteServer(oooHost, oooPort); } catch (IOException e) { Debug.logError(e, "Error in OpenOffice operation: ", module); @@ -280,31 +280,31 @@ public class OpenOfficeServices { 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 @@ public class OpenOfficeServices { //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 @@ -337,8 +337,8 @@ public class OpenOfficeServices { Object dispatchHelperObj = xmulticomponentfactory.createInstanceWithContext("com.sun.star.frame.DispatchHelper", xcomponentcontext); XDispatchHelper dispatchHelper = (XDispatchHelper) UnoRuntime.queryInterface(XDispatchHelper.class, dispatchHelperObj); XDispatchProvider dispatchProvider = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class, frame); - dispatchHelper.executeDispatch(dispatchProvider, ".uno:CompareDocuments", "", 0, propertyvalue); - + 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 @@ public class OpenOfficeServices { //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) { diff --git a/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeWorker.java b/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeWorker.java index dc85f42d04..0d5dc1dbaf 100644 --- a/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeWorker.java +++ b/applications/content/src/org/ofbiz/content/openoffice/OpenOfficeWorker.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -47,22 +47,22 @@ import com.sun.star.uri.ExternalUriReferenceTranslator; /** * OpenOfficeWorker Class - * - * Note that for this to work you must start OpenOffice with a command such as the following: + * + * Note that for this to work you must start OpenOffice with a command such as the following: * soffice -accept=socket,host=localhost,port=8100;urp; */ 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 @@ public class OpenOfficeWorker{ 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:;; 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 @@ public class OpenOfficeWorker{ 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); @@ -131,10 +131,10 @@ public class OpenOfficeWorker{ return "error"; } return "success"; - } - + } + public static List getFilterNames(XMultiComponentFactory xmulticomponentfactory) throws Exception { - XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xmulticomponentfactory); + XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xmulticomponentfactory); Object oDefaultContext = xPropertySet.getPropertyValue("DefaultContext"); XComponentContext xComponentContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, oDefaultContext); @@ -142,7 +142,7 @@ public class OpenOfficeWorker{ 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 @@ public class OpenOfficeWorker{ 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 @@ public class OpenOfficeWorker{ 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. + + // 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 @@ public class OpenOfficeWorker{ // 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[ 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, + + 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 @@ public class OpenOfficeWorker{ 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 @@ public class OpenOfficeWorker{ 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 @@ public class OpenOfficeWorker{ return filterName; } - + public static String getExtensionFromMimeType(String mimeType) { String extension = ""; if (UtilValidate.isEmpty(mimeType)) { @@ -354,5 +354,5 @@ public class OpenOfficeWorker{ return returnUrl; } - + } diff --git a/applications/content/src/org/ofbiz/content/output/OutputServices.java b/applications/content/src/org/ofbiz/content/output/OutputServices.java index 8052eb4ced..0f9f7e89d8 100644 --- a/applications/content/src/org/ofbiz/content/output/OutputServices.java +++ b/applications/content/src/org/ofbiz/content/output/OutputServices.java @@ -1,259 +1,259 @@ -/******************************************************************************* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. - *******************************************************************************/ -package org.ofbiz.content.output; + * under the License. + *******************************************************************************/ +package org.ofbiz.content.output; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.Writer; -import java.util.List; -import java.util.Locale; -import java.util.Map; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.Writer; +import java.util.List; +import java.util.Locale; +import java.util.Map; -import javax.print.Doc; -import javax.print.DocFlavor; -import javax.print.DocPrintJob; -import javax.print.PrintService; -import javax.print.PrintServiceLookup; -import javax.print.SimpleDoc; -import javax.print.attribute.DocAttribute; -import javax.print.attribute.DocAttributeSet; -import javax.print.attribute.HashDocAttributeSet; -import javax.print.attribute.HashPrintRequestAttributeSet; -import javax.print.attribute.HashPrintServiceAttributeSet; -import javax.print.attribute.PrintRequestAttribute; -import javax.print.attribute.PrintRequestAttributeSet; -import javax.print.attribute.PrintServiceAttributeSet; -import javax.print.attribute.standard.PrinterName; -import javax.xml.transform.stream.StreamSource; +import javax.print.Doc; +import javax.print.DocFlavor; +import javax.print.DocPrintJob; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.SimpleDoc; +import javax.print.attribute.DocAttribute; +import javax.print.attribute.DocAttributeSet; +import javax.print.attribute.HashDocAttributeSet; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.HashPrintServiceAttributeSet; +import javax.print.attribute.PrintRequestAttribute; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.print.attribute.PrintServiceAttributeSet; +import javax.print.attribute.standard.PrinterName; +import javax.xml.transform.stream.StreamSource; -import org.ofbiz.base.util.Debug; -import org.ofbiz.base.util.UtilDateTime; -import org.ofbiz.base.util.UtilProperties; -import org.ofbiz.base.util.UtilValidate; -import org.ofbiz.base.util.collections.MapStack; -import org.ofbiz.service.DispatchContext; -import org.ofbiz.service.ServiceUtil; -import org.ofbiz.webapp.view.ApacheFopWorker; -import org.ofbiz.widget.fo.FoFormRenderer; -import org.ofbiz.widget.fo.FoScreenRenderer; -import org.ofbiz.widget.screen.ScreenRenderer; +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilDateTime; +import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.base.util.collections.MapStack; +import org.ofbiz.service.DispatchContext; +import org.ofbiz.service.ServiceUtil; +import org.ofbiz.webapp.view.ApacheFopWorker; +import org.ofbiz.widget.fo.FoFormRenderer; +import org.ofbiz.widget.fo.FoScreenRenderer; +import org.ofbiz.widget.screen.ScreenRenderer; -import javolution.util.FastMap; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.MimeConstants; +import javolution.util.FastMap; +import org.apache.fop.apps.Fop; +import org.apache.fop.apps.MimeConstants; -/** +/** * Output Services - */ -public class OutputServices { + */ +public class OutputServices { - public final static String module = OutputServices.class.getName(); + public final static String module = OutputServices.class.getName(); - protected static final FoScreenRenderer foScreenRenderer = new FoScreenRenderer(); - protected static final FoFormRenderer foFormRenderer = new FoFormRenderer(); + protected static final FoScreenRenderer foScreenRenderer = new FoScreenRenderer(); + protected static final FoFormRenderer foFormRenderer = new FoFormRenderer(); - public static Map sendPrintFromScreen(DispatchContext dctx, Map serviceContext) { + public static Map sendPrintFromScreen(DispatchContext dctx, Map serviceContext) { - Locale locale = (Locale) serviceContext.get("locale"); - String screenLocation = (String) serviceContext.remove("screenLocation"); - Map screenContext = (Map) serviceContext.remove("screenContext"); - String contentType = (String) serviceContext.remove("contentType"); - String printerContentType = (String) serviceContext.remove("printerContentType"); + Locale locale = (Locale) serviceContext.get("locale"); + String screenLocation = (String) serviceContext.remove("screenLocation"); + Map screenContext = (Map) serviceContext.remove("screenContext"); + String contentType = (String) serviceContext.remove("contentType"); + String printerContentType = (String) serviceContext.remove("printerContentType"); - if (UtilValidate.isEmpty(screenContext)) { - screenContext = FastMap.newInstance(); - } - screenContext.put("locale", locale); - if (UtilValidate.isEmpty(contentType)) { - contentType = "application/postscript"; - } - if (UtilValidate.isEmpty(printerContentType)) { - printerContentType = contentType; - } + if (UtilValidate.isEmpty(screenContext)) { + screenContext = FastMap.newInstance(); + } + screenContext.put("locale", locale); + if (UtilValidate.isEmpty(contentType)) { + contentType = "application/postscript"; + } + if (UtilValidate.isEmpty(printerContentType)) { + printerContentType = contentType; + } - try { + try { - MapStack screenContextTmp = MapStack.create(); - screenContextTmp.put("locale", locale); + MapStack screenContextTmp = MapStack.create(); + screenContextTmp.put("locale", locale); - Writer writer = new StringWriter(); - // substitute the freemarker variables... - ScreenRenderer screensAtt = new ScreenRenderer(writer, screenContextTmp, foScreenRenderer); - screensAtt.populateContextForService(dctx, screenContext); - screenContextTmp.putAll(screenContext); - screensAtt.getContext().put("formStringRenderer", foFormRenderer); - screensAtt.render(screenLocation); + Writer writer = new StringWriter(); + // substitute the freemarker variables... + ScreenRenderer screensAtt = new ScreenRenderer(writer, screenContextTmp, foScreenRenderer); + screensAtt.populateContextForService(dctx, screenContext); + screenContextTmp.putAll(screenContext); + screensAtt.getContext().put("formStringRenderer", foFormRenderer); + screensAtt.render(screenLocation); - // create the input stream for the generation - StreamSource src = new StreamSource(new StringReader(writer.toString())); + // create the input stream for the generation + StreamSource src = new StreamSource(new StringReader(writer.toString())); - // create the output stream for the generation - ByteArrayOutputStream baos = new ByteArrayOutputStream(); + // create the output stream for the generation + ByteArrayOutputStream baos = new ByteArrayOutputStream(); - Fop fop = ApacheFopWorker.createFopInstance(baos, MimeConstants.MIME_PDF); - ApacheFopWorker.transform(src, null, fop); + Fop fop = ApacheFopWorker.createFopInstance(baos, MimeConstants.MIME_PDF); + ApacheFopWorker.transform(src, null, fop); - baos.flush(); - baos.close(); + baos.flush(); + baos.close(); - // Print is sent - DocFlavor psInFormat = new DocFlavor.INPUT_STREAM(printerContentType); - InputStream bais = new ByteArrayInputStream(baos.toByteArray()); + // Print is sent + DocFlavor psInFormat = new DocFlavor.INPUT_STREAM(printerContentType); + InputStream bais = new ByteArrayInputStream(baos.toByteArray()); - DocAttributeSet docAttributeSet = new HashDocAttributeSet(); - List docAttributes = (List) serviceContext.remove("docAttributes"); - if (UtilValidate.isNotEmpty(docAttributes)) { - for (Object da : docAttributes) { - Debug.logInfo("Adding DocAttribute: " + da, module); - docAttributeSet.add((DocAttribute) da); - } - } + DocAttributeSet docAttributeSet = new HashDocAttributeSet(); + List docAttributes = (List) serviceContext.remove("docAttributes"); + if (UtilValidate.isNotEmpty(docAttributes)) { + for (Object da : docAttributes) { + Debug.logInfo("Adding DocAttribute: " + da, module); + docAttributeSet.add((DocAttribute) da); + } + } - Doc myDoc = new SimpleDoc(bais, psInFormat, docAttributeSet); + Doc myDoc = new SimpleDoc(bais, psInFormat, docAttributeSet); - PrintService printer = null; + PrintService printer = null; - // lookup the print service for the supplied printer name - String printerName = (String) serviceContext.remove("printerName"); - if (UtilValidate.isNotEmpty(printerName)) { + // lookup the print service for the supplied printer name + String printerName = (String) serviceContext.remove("printerName"); + if (UtilValidate.isNotEmpty(printerName)) { - PrintServiceAttributeSet printServiceAttributes = new HashPrintServiceAttributeSet(); - printServiceAttributes.add(new PrinterName(printerName, locale)); + PrintServiceAttributeSet printServiceAttributes = new HashPrintServiceAttributeSet(); + printServiceAttributes.add(new PrinterName(printerName, locale)); - PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, printServiceAttributes); - if (printServices.length > 0) { - printer = printServices[0]; - Debug.logInfo("Using printer: " + printer.getName(), module); - if (!printer.isDocFlavorSupported(psInFormat)) { - return ServiceUtil.returnError("DocFlavor [" + psInFormat + "] not supported by printer: " + printer.getName()); - } - } - if (printer == null) { - return ServiceUtil.returnError("No printer found with name: " + printerName); - } + PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, printServiceAttributes); + if (printServices.length > 0) { + printer = printServices[0]; + Debug.logInfo("Using printer: " + printer.getName(), module); + if (!printer.isDocFlavorSupported(psInFormat)) { + return ServiceUtil.returnError("DocFlavor [" + psInFormat + "] not supported by printer: " + printer.getName()); + } + } + if (printer == null) { + return ServiceUtil.returnError("No printer found with name: " + printerName); + } - } else { + } else { - // if no printer name was supplied, try to get the default printer - printer = PrintServiceLookup.lookupDefaultPrintService(); - if (printer != null) { - Debug.logInfo("No printer name supplied, using default printer: " + printer.getName(), module); - } - } + // if no printer name was supplied, try to get the default printer + printer = PrintServiceLookup.lookupDefaultPrintService(); + if (printer != null) { + Debug.logInfo("No printer name supplied, using default printer: " + printer.getName(), module); + } + } - if (printer == null) { - return ServiceUtil.returnError("No printer available"); - } + if (printer == null) { + return ServiceUtil.returnError("No printer available"); + } - PrintRequestAttributeSet praset = new HashPrintRequestAttributeSet(); - List printRequestAttributes = (List) serviceContext.remove("printRequestAttributes"); - if (UtilValidate.isNotEmpty(printRequestAttributes)) { - for (Object pra : printRequestAttributes) { - Debug.logInfo("Adding PrintRequestAttribute: " + pra, module); - praset.add((PrintRequestAttribute) pra); - } - } - DocPrintJob job = printer.createPrintJob(); - job.print(myDoc, praset); + PrintRequestAttributeSet praset = new HashPrintRequestAttributeSet(); + List printRequestAttributes = (List) serviceContext.remove("printRequestAttributes"); + if (UtilValidate.isNotEmpty(printRequestAttributes)) { + for (Object pra : printRequestAttributes) { + Debug.logInfo("Adding PrintRequestAttribute: " + pra, module); + praset.add((PrintRequestAttribute) pra); + } + } + DocPrintJob job = printer.createPrintJob(); + job.print(myDoc, praset); - } catch (Exception e) { - String errMsg = "Error rendering [" + contentType + "]: " + e.toString(); - Debug.logError(e, errMsg, module); - return ServiceUtil.returnError(errMsg); - } + } catch (Exception e) { + String errMsg = "Error rendering [" + contentType + "]: " + e.toString(); + Debug.logError(e, errMsg, module); + return ServiceUtil.returnError(errMsg); + } - return ServiceUtil.returnSuccess(); - } + return ServiceUtil.returnSuccess(); + } - public static Map createFileFromScreen(DispatchContext dctx, Map serviceContext) { + public static Map createFileFromScreen(DispatchContext dctx, Map serviceContext) { - Locale locale = (Locale) serviceContext.get("locale"); - String screenLocation = (String) serviceContext.remove("screenLocation"); - Map screenContext = (Map) serviceContext.remove("screenContext"); - String contentType = (String) serviceContext.remove("contentType"); - String filePath = (String) serviceContext.remove("filePath"); - String fileName = (String) serviceContext.remove("fileName"); + Locale locale = (Locale) serviceContext.get("locale"); + String screenLocation = (String) serviceContext.remove("screenLocation"); + Map screenContext = (Map) serviceContext.remove("screenContext"); + String contentType = (String) serviceContext.remove("contentType"); + String filePath = (String) serviceContext.remove("filePath"); + String fileName = (String) serviceContext.remove("fileName"); - if (UtilValidate.isEmpty(screenContext)) { - screenContext = FastMap.newInstance(); - } - screenContext.put("locale", locale); - if (UtilValidate.isEmpty(contentType)) { - contentType = "application/pdf"; - } + if (UtilValidate.isEmpty(screenContext)) { + screenContext = FastMap.newInstance(); + } + screenContext.put("locale", locale); + if (UtilValidate.isEmpty(contentType)) { + contentType = "application/pdf"; + } - try { - MapStack screenContextTmp = MapStack.create(); - screenContextTmp.put("locale", locale); + try { + MapStack screenContextTmp = MapStack.create(); + screenContextTmp.put("locale", locale); - Writer writer = new StringWriter(); - // substitute the freemarker variables... - ScreenRenderer screensAtt = new ScreenRenderer(writer, screenContextTmp, foScreenRenderer); - screensAtt.populateContextForService(dctx, screenContext); - screenContextTmp.putAll(screenContext); - screensAtt.getContext().put("formStringRenderer", foFormRenderer); - screensAtt.render(screenLocation); + Writer writer = new StringWriter(); + // substitute the freemarker variables... + ScreenRenderer screensAtt = new ScreenRenderer(writer, screenContextTmp, foScreenRenderer); + screensAtt.populateContextForService(dctx, screenContext); + screenContextTmp.putAll(screenContext); + screensAtt.getContext().put("formStringRenderer", foFormRenderer); + screensAtt.render(screenLocation); - // create the input stream for the generation - StreamSource src = new StreamSource(new StringReader(writer.toString())); + // create the input stream for the generation + StreamSource src = new StreamSource(new StringReader(writer.toString())); - // create the output stream for the generation - ByteArrayOutputStream baos = new ByteArrayOutputStream(); + // create the output stream for the generation + ByteArrayOutputStream baos = new ByteArrayOutputStream(); - Fop fop = ApacheFopWorker.createFopInstance(baos, MimeConstants.MIME_PDF); - ApacheFopWorker.transform(src, null, fop); + Fop fop = ApacheFopWorker.createFopInstance(baos, MimeConstants.MIME_PDF); + ApacheFopWorker.transform(src, null, fop); - baos.flush(); - baos.close(); + baos.flush(); + baos.close(); - fileName += UtilDateTime.nowAsString(); - if ("application/pdf".equals(contentType)) { - fileName += ".pdf"; - } else if ("application/postscript".equals(contentType)) { - fileName += ".ps"; - } else if ("text/plain".equals(contentType)) { - fileName += ".txt"; - } - if (UtilValidate.isEmpty(filePath)) { - filePath = UtilProperties.getPropertyValue("content.properties", "content.output.path", "/output"); - } - File file = new File(filePath, fileName); + fileName += UtilDateTime.nowAsString(); + if ("application/pdf".equals(contentType)) { + fileName += ".pdf"; + } else if ("application/postscript".equals(contentType)) { + fileName += ".ps"; + } else if ("text/plain".equals(contentType)) { + fileName += ".txt"; + } + if (UtilValidate.isEmpty(filePath)) { + filePath = UtilProperties.getPropertyValue("content.properties", "content.output.path", "/output"); + } + File file = new File(filePath, fileName); - FileOutputStream fos = new FileOutputStream(file); - fos.write(baos.toByteArray()); - fos.close(); + FileOutputStream fos = new FileOutputStream(file); + fos.write(baos.toByteArray()); + fos.close(); - } catch (Exception e) { - String errMsg = "Error rendering [" + contentType + "]: " + e.toString(); - Debug.logError(e, errMsg, module); - return ServiceUtil.returnError(errMsg); - } + } catch (Exception e) { + String errMsg = "Error rendering [" + contentType + "]: " + e.toString(); + Debug.logError(e, errMsg, module); + return ServiceUtil.returnError(errMsg); + } - return ServiceUtil.returnSuccess(); - } + return ServiceUtil.returnSuccess(); + } -} +} diff --git a/applications/content/src/org/ofbiz/content/report/JREntityListIteratorDataSource.java b/applications/content/src/org/ofbiz/content/report/JREntityListIteratorDataSource.java index 74fa5b05ce..cf401bc8f0 100644 --- a/applications/content/src/org/ofbiz/content/report/JREntityListIteratorDataSource.java +++ b/applications/content/src/org/ofbiz/content/report/JREntityListIteratorDataSource.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -32,7 +32,7 @@ import org.ofbiz.entity.util.EntityListIterator; * JREntityListIteratorDataSource */ public class JREntityListIteratorDataSource implements JRDataSource { - + public static final String module = JREntityListIteratorDataSource.class.getName(); private EntityListIterator entityListIterator = null; diff --git a/applications/content/src/org/ofbiz/content/report/JRMapCollectionDataSource.java b/applications/content/src/org/ofbiz/content/report/JRMapCollectionDataSource.java index cb32c39be6..6d3ea3efcc 100644 --- a/applications/content/src/org/ofbiz/content/report/JRMapCollectionDataSource.java +++ b/applications/content/src/org/ofbiz/content/report/JRMapCollectionDataSource.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY diff --git a/applications/content/src/org/ofbiz/content/search/ContentDocument.java b/applications/content/src/org/ofbiz/content/search/ContentDocument.java index 7ffb8c6df0..1bb027652a 100644 --- a/applications/content/src/org/ofbiz/content/search/ContentDocument.java +++ b/applications/content/src/org/ofbiz/content/search/ContentDocument.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY diff --git a/applications/content/src/org/ofbiz/content/search/DataResourceDocument.java b/applications/content/src/org/ofbiz/content/search/DataResourceDocument.java index 6b4719da62..60e0fd6348 100644 --- a/applications/content/src/org/ofbiz/content/search/DataResourceDocument.java +++ b/applications/content/src/org/ofbiz/content/search/DataResourceDocument.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY diff --git a/applications/content/src/org/ofbiz/content/search/SearchEvents.java b/applications/content/src/org/ofbiz/content/search/SearchEvents.java index 33f647870d..631318b71d 100644 --- a/applications/content/src/org/ofbiz/content/search/SearchEvents.java +++ b/applications/content/src/org/ofbiz/content/search/SearchEvents.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -43,7 +43,7 @@ import org.ofbiz.service.ServiceUtil; public class SearchEvents { public static final String module = SearchEvents.class.getName(); - + public static String indexTree(HttpServletRequest request, HttpServletResponse response) { Map result; diff --git a/applications/content/src/org/ofbiz/content/search/SearchServices.java b/applications/content/src/org/ofbiz/content/search/SearchServices.java index 234b9bd295..3a8c70f7e8 100644 --- a/applications/content/src/org/ofbiz/content/search/SearchServices.java +++ b/applications/content/src/org/ofbiz/content/search/SearchServices.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY diff --git a/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java b/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java index db44246349..76bbee8c9b 100644 --- a/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java +++ b/applications/content/src/org/ofbiz/content/survey/PdfSurveyServices.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -69,11 +69,11 @@ import com.lowagie.text.pdf.PdfWriter; */ public class PdfSurveyServices { - + public static final String module = PdfSurveyServices.class.getName(); /** - * + * */ public static Map buildSurveyFromPdf(DispatchContext dctx, Map context) { GenericDelegator delegator = dctx.getDelegator(); @@ -89,7 +89,7 @@ public class PdfSurveyServices { 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 @@ public class PdfSurveyServices { survey = delegator.createSetNextSeqId(survey); surveyId = survey.getString("surveyId"); } - + // create a SurveyQuestionCategory to put the questions in - Map createCategoryResultMap = dispatcher.runSync("createSurveyQuestionCategory", + Map createCategoryResultMap = dispatcher.runSync("createSurveyQuestionCategory", UtilMisc.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 @@ public class PdfSurveyServices { 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 @@ public class PdfSurveyServices { 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 @@ public class PdfSurveyServices { 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 @@ public class PdfSurveyServices { annotation = tuValue.toString(); } } - + surveyQuestion.set("description", fieldName); if (UtilValidate.isNotEmpty(annotation)) { surveyQuestion.set("question", annotation); @@ -214,7 +214,7 @@ public class PdfSurveyServices { surveyQuestion.create(); surveyQuestionAppl.create(); - } + } pdfStamper.close(); if (UtilValidate.isNotEmpty(contentId)) { survey = delegator.findByPrimaryKey("Survey", UtilMisc.toMap("surveyId", surveyId)); @@ -233,20 +233,20 @@ public class PdfSurveyServices { Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } - + Map results = ServiceUtil.returnSuccess(); results.put("surveyId", surveyId); return results; } - + /** - * + * */ public static Map buildSurveyResponseFromPdf(DispatchContext dctx, Map context) { String surveyResponseId = null; try { - + GenericDelegator delegator = dctx.getDelegator(); String partyId = (String)context.get("partyId"); String surveyId = (String)context.get("surveyId"); @@ -264,15 +264,15 @@ public class PdfSurveyServices { 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 @@ public class PdfSurveyServices { //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"); @@ -296,7 +296,7 @@ public class PdfSurveyServices { } delegator.create(surveyResponseAnswer); - } + } s.close(); } catch (GenericEntityException e) { String errMsg = "Error generating PDF: " + e.toString(); @@ -310,7 +310,7 @@ public class PdfSurveyServices { Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } - + Map results = ServiceUtil.returnSuccess(); results.put("surveyResponseId", surveyResponseId); return results; @@ -319,7 +319,7 @@ public class PdfSurveyServices { /** */ public static Map getAcroFieldsFromPdf(DispatchContext dctx, Map context) { - + Map acroFieldMap = FastMap.newInstance(); try { ByteArrayOutputStream os = new ByteArrayOutputStream(); @@ -329,21 +329,21 @@ public class PdfSurveyServices { 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 setAcroFields(DispatchContext dctx, Map context) { - + Map results = ServiceUtil.returnSuccess(); GenericDelegator delegator = dctx.getDelegator(); try { @@ -374,14 +374,14 @@ public class PdfSurveyServices { 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;iSurveyQuestion and "response"->SurveyResponseAnswer */ @@ -520,7 +520,7 @@ public class PdfSurveyServices { surveyId = surveyResponse.getString("surveyId"); } } - + List responses = delegator.findByAnd("SurveyResponseAnswer", UtilMisc.toMap("surveyResponseId", surveyResponseId)); Iterator iter = responses.iterator(); while (iter.hasNext()) { @@ -535,10 +535,10 @@ public class PdfSurveyServices { System.err.println(e.getMessage()); ServiceUtil.returnError(e.getMessage()); } - + return results; } - + /** */ public static Map setAcroFieldsFromSurveyResponse(DispatchContext dctx, Map context) { @@ -548,7 +548,7 @@ public class PdfSurveyServices { 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 @@ public class PdfSurveyServices { acroFormContentId = survey.getString("acroFormContentId"); } } - + List responses = delegator.findByAnd("SurveyResponseAnswer", UtilMisc.toMap("surveyResponseId", surveyResponseId)); Iterator iter = responses.iterator(); while (iter.hasNext()) { @@ -573,10 +573,10 @@ public class PdfSurveyServices { 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 @@ public class PdfSurveyServices { 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 @@ public class PdfSurveyServices { 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"); @@ -655,7 +655,7 @@ public class PdfSurveyServices { } else if (UtilValidate.isNotEmpty(contentId)) { try { Locale locale = (Locale)context.get("locale"); - String https = (String)context.get("https"); + String https = (String)context.get("https"); String webSiteId = (String)context.get("webSiteId"); String rootDir = (String)context.get("rootDir"); GenericValue content = delegator.findByPrimaryKeyCache("Content", UtilMisc.toMap("contentId", contentId)); diff --git a/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java b/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java index d78175d731..e018c0f767 100644 --- a/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java +++ b/applications/content/src/org/ofbiz/content/survey/SurveyWrapper.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -177,7 +177,7 @@ public class SurveyWrapper { } else { currentAnswers = this.getResponseAnswers(null); } - + Map sqaaWithColIdListByMultiRespId = FastMap.newInstance(); Iterator surveyQuestionAndApplIter = surveyQuestionAndAppls.iterator(); while (surveyQuestionAndApplIter.hasNext()) { @@ -260,7 +260,7 @@ public class SurveyWrapper { 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 @@ public class SurveyWrapper { 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 @@ public class SurveyWrapper { 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 @@ public class SurveyWrapper { } result[0]++; // increment the count } - + eli.close(); } - + return result; } catch (GenericEntityException e) { try { @@ -589,9 +589,9 @@ public class SurveyWrapper { 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 @@ public class SurveyWrapper { } result[0]++; // increment the count } - + eli.close(); } } catch (GenericEntityException e) { @@ -678,7 +678,7 @@ public class SurveyWrapper { boolean beganTransaction = false; try { beganTransaction = TransactionUtil.begin(); - + EntityListIterator eli = this.getEli(question); if (eli != null) { GenericValue value; @@ -695,7 +695,7 @@ public class SurveyWrapper { total++; // increment the count } } - + eli.close(); } } catch (GenericEntityException e) { diff --git a/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java b/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java index 54d0ea247d..49285da26b 100644 --- a/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java +++ b/applications/content/src/org/ofbiz/content/view/SimpleContentViewHandler.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -49,10 +49,10 @@ import org.ofbiz.webapp.view.ViewHandlerException; * 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 @@ public class SimpleContentViewHandler extends AbstractViewHandler { * @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 @@ public class SimpleContentViewHandler extends AbstractViewHandler { String rootDir = null; String webSiteId = null; String https = null; - + if (UtilValidate.isEmpty(rootDir)) { rootDir = servletContext.getRealPath("/"); } diff --git a/applications/content/src/org/ofbiz/content/webapp/ftl/CheckPermissionTransform.java b/applications/content/src/org/ofbiz/content/webapp/ftl/CheckPermissionTransform.java index 7f0065ff05..c2b0bf310b 100644 --- a/applications/content/src/org/ofbiz/content/webapp/ftl/CheckPermissionTransform.java +++ b/applications/content/src/org/ofbiz/content/webapp/ftl/CheckPermissionTransform.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -104,7 +104,7 @@ public class CheckPermissionTransform implements TemplateTransformModel { //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 @@ public class CheckPermissionTransform implements TemplateTransformModel { 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, "|"); @@ -139,7 +139,7 @@ public class CheckPermissionTransform implements TemplateTransformModel { statusList = FastList.newInstance(); if (UtilValidate.isNotEmpty(statusId) && !statusList.contains(statusId)) { statusList.add(statusId); - } + } String targetPurpose = (String)templateCtx.get("contentPurposeList"); List purposeList = StringUtil.split(targetPurpose, "|"); String entityOperation = (String)templateCtx.get("entityOperation"); @@ -155,9 +155,9 @@ public class CheckPermissionTransform implements TemplateTransformModel { 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); + Map results = EntityPermissionChecker.checkPermission(currentContent, statusList, userLogin, purposeList, targetOperationList, roleList, delegator, security, entityOperation, privilegeEnumId, quickCheckContentId); boolean isError = ModelService.RESPOND_ERROR.equals(results.get(ModelService.RESPONSE_MESSAGE)); if (isError) { @@ -167,7 +167,7 @@ public class CheckPermissionTransform implements TemplateTransformModel { 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, ""); diff --git a/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentCacheTransform.java b/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentCacheTransform.java index 8a64502e60..398e5cf780 100644 --- a/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentCacheTransform.java +++ b/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentCacheTransform.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -46,14 +46,14 @@ import freemarker.template.TemplateTransformModel; //import com.clarkware.profiler.Profiler; /** * EditRenderSubContentCacheTransform - Freemarker Transform for URLs (links) - * + * * This is an interactive FreeMarker tranform that allows the user to modify the contents that are placed within it. */ public class EditRenderSubContentCacheTransform implements TemplateTransformModel { 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 @@ public class EditRenderSubContentCacheTransform implements TemplateTransformMode 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 @@ public class EditRenderSubContentCacheTransform implements TemplateTransformMode } else { templateRoot = UtilMisc.makeMapWritable(templateRootTemplate); } - + templateRoot.put("context", templateCtx); if (Debug.verboseOn()) { Set kySet = templateCtx.keySet(); @@ -159,7 +159,7 @@ public class EditRenderSubContentCacheTransform implements TemplateTransformMode Object val = templateCtx.get(ky); } } - + String mimeTypeId = (String)templateCtx.get("mimeTypeId"); Locale locale = null; try { @@ -173,7 +173,7 @@ public class EditRenderSubContentCacheTransform implements TemplateTransformMode Debug.logError(e2, "Error rendering content" + e2.getMessage(), module); throw new IOException("Error rendering content" + e2.toString()); } - + } else { out.write(wrappedContent); } diff --git a/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java b/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java index f5886b3ad2..4cd0e73b1e 100644 --- a/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java +++ b/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -42,13 +42,13 @@ import freemarker.template.TemplateTransformModel; /** * EditRenderSubContentTransform - Freemarker Transform for URLs (links) - * + * * This is an interactive FreeMarker tranform that allows the user to modify the contents that are placed within it. */ public class EditRenderSubContentTransform implements TemplateTransformModel { public static final String module = EditRenderSubContentTransform.class.getName(); - + /** * A wrapper for the FreeMarkerWorker version. */ @@ -76,7 +76,7 @@ public class EditRenderSubContentTransform implements TemplateTransformModel { 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 @@ public class EditRenderSubContentTransform implements TemplateTransformModel { 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 @@ public class EditRenderSubContentTransform implements TemplateTransformModel { 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 @@ public class EditRenderSubContentTransform implements TemplateTransformModel { 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); diff --git a/applications/content/src/org/ofbiz/content/webapp/ftl/InjectNodeTrailCsvTransform.java b/applications/content/src/org/ofbiz/content/webapp/ftl/InjectNodeTrailCsvTransform.java index e7ff9d8398..fd896a2ecb 100644 --- a/applications/content/src/org/ofbiz/content/webapp/ftl/InjectNodeTrailCsvTransform.java +++ b/applications/content/src/org/ofbiz/content/webapp/ftl/InjectNodeTrailCsvTransform.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -109,12 +109,12 @@ public class InjectNodeTrailCsvTransform implements TemplateTransformModel { if (Debug.infoOn()) Debug.logInfo("in InjectNodeTrailCsv(0), contentAssocTypeId:"+contentAssocTypeId,module); try { if (UtilValidate.isNotEmpty(subContentId)) { - csvTrail = ContentWorker.getContentAncestryNodeTrailCsv(delegator, subContentId, contentAssocTypeId, "to"); + csvTrail = ContentWorker.getContentAncestryNodeTrailCsv(delegator, subContentId, contentAssocTypeId, "to"); if (UtilValidate.isNotEmpty(csvTrail)) csvTrail += ","; csvTrail += subContentId; } else if (UtilValidate.isNotEmpty(contentId)) { - csvTrail = ContentWorker.getContentAncestryNodeTrailCsv(delegator, contentId, contentAssocTypeId, "to"); + csvTrail = ContentWorker.getContentAncestryNodeTrailCsv(delegator, contentId, contentAssocTypeId, "to"); if (UtilValidate.isNotEmpty(csvTrail)) csvTrail += ","; csvTrail += contentId; @@ -131,12 +131,12 @@ public class InjectNodeTrailCsvTransform implements TemplateTransformModel { csvTrail = passedCsv; int lastComma = passedCsv.lastIndexOf(","); String lastPassedContentId = null; - if (lastComma >= 0) { + if (lastComma >= 0) { lastPassedContentId = passedCsv.substring(lastComma + 1); } else { lastPassedContentId = passedCsv; } - + if (UtilValidate.isNotEmpty(lastPassedContentId)) { if (UtilValidate.isNotEmpty(trail)) { Map nd = (Map)trail.get(0); diff --git a/applications/content/src/org/ofbiz/content/webapp/ftl/LimitedSubContentCacheTransform.java b/applications/content/src/org/ofbiz/content/webapp/ftl/LimitedSubContentCacheTransform.java index ec48d149f9..7f24d75592 100644 --- a/applications/content/src/org/ofbiz/content/webapp/ftl/LimitedSubContentCacheTransform.java +++ b/applications/content/src/org/ofbiz/content/webapp/ftl/LimitedSubContentCacheTransform.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -94,7 +94,7 @@ public class LimitedSubContentCacheTransform implements TemplateTransformModel { contentAssocTypeId = "SUB_CONTENT"; templateRoot.put("contentAssocTypeId ", contentAssocTypeId); } - + final Map pickedEntityIds = FastMap.newInstance(); List assocTypes = StringUtil.split(contentAssocTypeId, "|"); @@ -123,7 +123,7 @@ public class LimitedSubContentCacheTransform implements TemplateTransformModel { fromDate = UtilDateTime.nowTimestamp(); String limitSize = (String) templateRoot.get("limitSize"); - final int returnLimit = Integer.parseInt(limitSize); + final int returnLimit = Integer.parseInt(limitSize); // limitMode will be "random" to begin with String limitMode = (String) templateRoot.get("limitMode"); final GenericValue userLogin = (GenericValue) FreeMarkerWorker.getWrappedObject("userLogin", env); @@ -131,7 +131,7 @@ public class LimitedSubContentCacheTransform implements TemplateTransformModel { 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 @@ public class LimitedSubContentCacheTransform implements TemplateTransformModel { 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 , ""); diff --git a/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java b/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java index f522ef97ce..8c3c862d4e 100644 --- a/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java +++ b/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -143,13 +143,13 @@ public class LoopSubContentTransform implements TemplateTransformModel { 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 @@ public class LoopSubContentTransform implements TemplateTransformModel { 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 @@ public class LoopSubContentTransform implements TemplateTransformModel { 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"); diff --git a/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java b/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java index ceb405b2e7..b76a2c978f 100644 --- a/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java +++ b/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -51,7 +51,7 @@ import freemarker.template.TemplateTransformModel; * RenderContentAndSubContent - Freemarker Transform for Content rendering * This transform cannot be called recursively (at this time). */ -public class RenderContentAndSubContent implements TemplateTransformModel { +public class RenderContentAndSubContent implements TemplateTransformModel { public static final String module = RenderContentAndSubContent.class.getName(); // public static final String [] upSaveKeyNames = {"globalNodeTrail"}; @@ -73,7 +73,7 @@ public class RenderContentAndSubContent implements TemplateTransformModel { FreeMarkerWorker.overrideWithArgs(templateRoot, args); final Map savedValues = FastMap.newInstance(); - + return new Writer(out) { public void write(char cbuf[], int off, int len) { @@ -106,12 +106,12 @@ public class RenderContentAndSubContent implements TemplateTransformModel { String mapKey = (String)templateRoot.get("mapKey"); String contentAssocTypeId = (String)templateRoot.get("contentAssocTypeId"); if (UtilValidate.isNotEmpty(mapKey) || UtilValidate.isNotEmpty(contentAssocTypeId)) { - String txt = ContentWorker.renderSubContentAsText(dispatcher, delegator, contentId, mapKey, templateRoot, locale, mimeTypeId, true); + String txt = ContentWorker.renderSubContentAsText(dispatcher, delegator, contentId, mapKey, templateRoot, locale, mimeTypeId, true); //String txt = ContentWorker.renderSubContentAsTextCache(delegator, thisContentId, thisMapKey, null, templateRoot, locale, mimeTypeId, null, fromDate); // if ("true".equals(xmlEscape)) { // txt = UtilFormatOut.encodeXmlValue(txt); // } - + out.write(txt); // if (Debug.infoOn()) Debug.logInfo("in RenderSubContent, after renderContentAsTextCache:", module); @@ -120,18 +120,18 @@ public class RenderContentAndSubContent implements TemplateTransformModel { // assocList = UtilMisc.toList(contentAssocTypeId); // } // GenericValue content = ContentWorker.getSubContent(delegator, contentId, mapKey, null, null, assocList, null); -// if (content != null) { +// if (content != null) { // contentId = content.getString("contentId"); // } else { // contentId = null; // } - } else if (contentId != null) { + } else if (contentId != null) { ContentWorker.renderContentAsText(dispatcher, delegator, contentId, out, templateRoot, locale, mimeTypeId, true); // ((MapStack)templateRoot).pop(); } //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); diff --git a/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAsText.java b/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAsText.java index 7e56dc5254..96bb9c356e 100644 --- a/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAsText.java +++ b/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAsText.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -184,9 +184,9 @@ public class RenderContentAsText implements TemplateTransformModel { 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 @@ public class RenderContentAsText implements TemplateTransformModel { fullRequest += delim + "contentId=" + contentId; delim = "&"; } - + out.write(""; out.write(divStr); } public void closeEditWrap(Writer out, String editRequestName) throws IOException { - /* + /* if (Debug.infoOn()) Debug.logInfo("in RenderSubContent, contentId(5):" + templateRoot.get("contentId"), module); if (Debug.infoOn()) Debug.logInfo("in RenderSubContent, subContentId(5):" + templateRoot.get("subContentId"), module); StringBuilder sb = new StringBuilder(); @@ -203,7 +203,7 @@ public class RenderSubContentAsText implements TemplateTransformModel { 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 @@ public class RenderSubContentAsText implements TemplateTransformModel { 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(); @@ -273,7 +273,7 @@ public class RenderSubContentAsText implements TemplateTransformModel { if (UtilValidate.isEmpty(editStyle)) { editStyle = "buttontext"; } - return editStyle; + return editStyle; } }; } diff --git a/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java b/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java index 09df725e4e..ab460281eb 100644 --- a/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java +++ b/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -208,7 +208,7 @@ public class RenderSubContentCacheTransform implements TemplateTransformModel { 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 @@ public class RenderSubContentCacheTransform implements TemplateTransformModel { fullRequest += delim + "fromDate=" + fromDate; delim = "&"; } - + if (Debug.infoOn()) Debug.logInfo("in Render(2), contentIdTo ." + contentIdTo , module); out.write("