Modified: ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderContentTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderContentTransform.java?rev=1752965&r1=1752964&r2=1752965&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderContentTransform.java (original) +++ ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderContentTransform.java Sat Jul 16 14:10:10 2016 @@ -130,7 +130,6 @@ public class RenderContentTransform impl } public void closeEditWrap(Writer out, String editRequestName) throws IOException { - // StringBuilder sb = new StringBuilder(); String fullRequest = editRequestName; String delim = "?"; if (UtilValidate.isNotEmpty(thisContentId)) {
Modified: ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentAsText.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentAsText.java?rev=1752965&r1=1752964&r2=1752965&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentAsText.java (original) +++ ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentAsText.java Sat Jul 16 14:10:10 2016 @@ -42,7 +42,6 @@ import org.apache.ofbiz.service.LocalDis import freemarker.core.Environment; import freemarker.template.TemplateTransformModel; -//import com.clarkware.profiler.Profiler; /** * RenderSubContentAsText - Freemarker Transform for Content rendering * This transform cannot be called recursively (at this time). @@ -56,12 +55,9 @@ public class RenderSubContentAsText impl @SuppressWarnings("unchecked") public Writer getWriter(final Writer out, Map args) { final Environment env = Environment.getCurrentEnvironment(); - // final Map templateCtx = FreeMarkerWorker.getWrappedObject("context", env); - // final Map templateCtx = new HashMap<String, Object>(); final LocalDispatcher dispatcher = FreeMarkerWorker.getWrappedObject("dispatcher", env); final Delegator delegator = FreeMarkerWorker.getWrappedObject("delegator", env); final HttpServletRequest request = FreeMarkerWorker.getWrappedObject("request", env); - // final HttpServletResponse response = FreeMarkerWorker.getWrappedObject("response", env); final Map<String, Object> templateRoot = FreeMarkerWorker.createEnvironmentMap(env); if (Debug.infoOn()) { Debug.logInfo("in RenderSubContent, contentId(0):" + templateRoot.get("contentId"), module); @@ -73,12 +69,6 @@ public class RenderSubContentAsText impl if (Debug.infoOn()) { Debug.logInfo("in RenderSubContent, contentId(2):" + templateRoot.get("contentId"), module); } - //final GenericValue userLogin = FreeMarkerWorker.getWrappedObject("userLogin", env); - //List trail = (List)templateRoot.get("globalNodeTrail"); - //if (Debug.infoOn()) Debug.logInfo("in Render(0), globalNodeTrail ." + trail , module); - //String contentAssocPredicateId = (String)templateRoot.get("contentAssocPredicateId"); - //String strNullThruDatesOnly = (String)templateRoot.get("nullThruDatesOnly"); - //Boolean nullThruDatesOnly = (strNullThruDatesOnly != null && strNullThruDatesOnly.equalsIgnoreCase("true")) ? Boolean.TRUE :Boolean.FALSE; final String thisContentId = (String)templateRoot.get("contentId"); final String thisMapKey = (String)templateRoot.get("mapKey"); final String xmlEscape = (String)templateRoot.get("xmlEscape"); @@ -89,44 +79,6 @@ public class RenderSubContentAsText impl if (Debug.infoOn()) { Debug.logInfo("in Render(0), directAssocMode ." + directAssocMode , module); } - /* - GenericValue val = null; - try { - val = FreeMarkerWorker.getCurrentContent(delegator, trail, userLogin, templateRoot, nullThruDatesOnly, contentAssocPredicateId); - } catch (GeneralException e) { - throw new RuntimeException("Error getting current content. " + e.toString()); - } - final GenericValue view = val; - - String dataResourceId = null; - String subContentIdSub = null; - if (view != null) { - try { - dataResourceId = (String) view.get("drDataResourceId"); - } catch (Exception e) { - dataResourceId = (String) view.get("dataResourceId"); - } - subContentIdSub = (String) view.get("contentId"); - } - // This order is taken so that the dataResourceType can be overridden in the transform arguments. - String subDataResourceTypeId = (String)templateRoot.get("subDataResourceTypeId"); - if (UtilValidate.isEmpty(subDataResourceTypeId)) { - try { - subDataResourceTypeId = (String) view.get("drDataResourceTypeId"); - } catch (Exception e) { - // view may be "Content" - } - // TODO: If this value is still empty then it is probably necessary to get a value from - // the parent context. But it will already have one and it is the same context that is - // being passed. - } - String mimeTypeId = FreeMarkerWorker.getMimeTypeId(delegator, view, templateRoot); - templateRoot.put("drDataResourceId", dataResourceId); - templateRoot.put("mimeTypeId", mimeTypeId); - templateRoot.put("dataResourceId", dataResourceId); - templateRoot.put("subContentId", subContentIdSub); - templateRoot.put("subDataResourceTypeId", subDataResourceTypeId); - */ final Map<String, Object> savedValues = new HashMap<String, Object>(); @@ -148,7 +100,6 @@ public class RenderSubContentAsText impl Debug.logInfo("Render close, globalNodeTrail(2a):" + ContentWorker.nodeTrailToCsv(globalNodeTrail), ""); } renderSubContent(); - //if (Debug.infoOn()) Debug.logInfo("in Render(2), globalNodeTrail ." + getWrapped(env, "globalNodeTrail") , module); } public void renderSubContent() throws IOException { @@ -161,9 +112,6 @@ public class RenderSubContentAsText impl locale = UtilMisc.ensureLocale(localeObject); } - // TemplateHashModel dataRoot = env.getDataModel(); - // Timestamp fromDate = UtilDateTime.nowTimestamp(); - // List passedGlobalNodeTrail = (List) templateRoot.get("globalNodeTrail"); String editRequestName = (String)templateRoot.get("editRequestName"); if (Debug.infoOn()) Debug.logInfo("in Render(3), editRequestName ." + editRequestName , module); @@ -175,7 +123,6 @@ public class RenderSubContentAsText impl FreeMarkerWorker.saveContextValues(templateRoot, saveKeyNames, savedValues); try { String txt = ContentWorker.renderSubContentAsText(dispatcher, delegator, thisContentId, thisMapKey, 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); } @@ -186,7 +133,6 @@ public class RenderSubContentAsText impl } catch (GeneralException e) { String errMsg = "Error rendering thisContentId:" + thisContentId + " msg:" + e.toString(); Debug.logError(e, errMsg, module); - //throw new IOException("Error rendering thisContentId:" + thisContentId + " msg:" + e.toString()); } FreeMarkerWorker.reloadValues(templateRoot, savedValues, env); FreeMarkerWorker.reloadValues(templateRoot, savedValuesUp, env); @@ -194,7 +140,6 @@ public class RenderSubContentAsText impl closeEditWrap(out, editRequestName); } - //if (Debug.infoOn()) Debug.logInfo("in Render(4), globalNodeTrail ." + getWrapped(env, "globalNodeTrail") , module); } public void openEditWrap(Writer out, String editStyle) throws IOException { @@ -204,76 +149,7 @@ public class RenderSubContentAsText impl } 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(); - String fullRequest = editRequestName; - String contentId = null; - String contentIdTo = null; - String contentAssocTypeId = null; - String mapKey = null; - String fromDate = null; - - contentIdTo = (String)templateRoot.get("contentId"); - contentAssocTypeId = (String)templateRoot.get("contentAssocTypeId"); - mapKey = (String)templateRoot.get("mapKey"); - fromDate = (String)templateRoot.get("fromDate"); - //if (Debug.infoOn()) Debug.logInfo("in Render(0), view ." + view , module); - if (view != null) { - ModelEntity modelEntity = view.getModelEntity(); - if (UtilValidate.isEmpty(contentId) && modelEntity.getField("caContentId") != null) - contentId = view.getString("caContentId"); - if (UtilValidate.isEmpty(contentId) && modelEntity.getField("contentId") != null) - contentId = view.getString("contentId"); - if (UtilValidate.isEmpty(contentIdTo) && modelEntity.getField("caContentIdTo") != null) - contentIdTo = view.getString("caContentIdTo"); - if (UtilValidate.isEmpty(contentIdTo) && modelEntity.getField("contentIdTo") != null) - contentIdTo = view.getString("contentIdTo"); - if (UtilValidate.isEmpty(contentAssocTypeId) && modelEntity.getField("caContentAssocTypeId") != null) - contentAssocTypeId = view.getString("caContentAssocTypeId"); - if (UtilValidate.isEmpty(contentAssocTypeId) && modelEntity.getField("contentAssocTypeId") != null) - contentAssocTypeId = view.getString("contentAssocTypeId"); - if (UtilValidate.isEmpty(mapKey) && modelEntity.getField("caMapKey") != null) - mapKey = view.getString("caMapKey"); - if (UtilValidate.isEmpty(mapKey) && modelEntity.getField("mapKey") != null) - mapKey = view.getString("mapKey"); - if (UtilValidate.isEmpty(fromDate) && modelEntity.getField("caFromDate") != null) - fromDate = view.getString("caFromDate"); - if (UtilValidate.isEmpty(fromDate) && modelEntity.getField("fromDate") != null) - fromDate = view.getString("fromDate"); - } - if (Debug.infoOn()) Debug.logInfo("in Render(0), contentIdTo ." + contentIdTo , module); - String delim = "?"; - if (UtilValidate.isNotEmpty(contentId)) { - fullRequest += delim + "contentId=" + contentId; - delim = "&"; - } - if (UtilValidate.isNotEmpty(contentIdTo)) { - fullRequest += delim + "contentIdTo=" + contentIdTo; - delim = "&"; - } - if (UtilValidate.isNotEmpty(contentAssocTypeId)) { - fullRequest += delim + "contentAssocTypeId=" + contentAssocTypeId; - delim = "&"; - } - if (UtilValidate.isNotEmpty(mapKey)) { - fullRequest += delim + "mapKey=" + mapKey; - delim = "&"; - } - if (UtilValidate.isNotEmpty(fromDate)) { - 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(); - String link = "<a href=\"" + url + "\">Edit</a>"; - out.write(link); - String divStr = "</div>"; - out.write(divStr); - */ } public String getEditStyle() { Modified: ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java?rev=1752965&r1=1752964&r2=1752965&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java (original) +++ ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java Sat Jul 16 14:10:10 2016 @@ -57,31 +57,23 @@ public class RenderSubContentCacheTransf @SuppressWarnings("unchecked") public Writer getWriter(final Writer out, Map args) { - // final StringBuilder buf = new StringBuilder(); final Environment env = Environment.getCurrentEnvironment(); - //final Map templateCtx = FreeMarkerWorker.getWrappedObject("context", env); - //final Map templateCtx = new HashMap<String, Object>(); final LocalDispatcher dispatcher = FreeMarkerWorker.getWrappedObject("dispatcher", env); final Delegator delegator = FreeMarkerWorker.getWrappedObject("delegator", env); final HttpServletRequest request = FreeMarkerWorker.getWrappedObject("request", env); final HttpServletResponse response = FreeMarkerWorker.getWrappedObject("response", env); final Map<String, Object> templateRoot = FreeMarkerWorker.createEnvironmentMap(env); - //if (Debug.infoOn()) Debug.logInfo("in RenderSubContent, contentId(0):" + templateRoot.get("contentId"), module); FreeMarkerWorker.getSiteParameters(request, templateRoot); final Map<String, Object> savedValuesUp = new HashMap<String, Object>(); FreeMarkerWorker.saveContextValues(templateRoot, upSaveKeyNames, savedValuesUp); FreeMarkerWorker.overrideWithArgs(templateRoot, args); - //if (Debug.infoOn()) Debug.logInfo("in RenderSubContent, contentId(2):" + templateRoot.get("contentId"), module); final GenericValue userLogin = FreeMarkerWorker.getWrappedObject("userLogin", env); List<Map<String, ? extends Object>> trail = UtilGenerics.checkList(templateRoot.get("globalNodeTrail")); - //if (Debug.infoOn()) Debug.logInfo("in Render(0), globalNodeTrail ." + trail , module); String contentAssocPredicateId = (String)templateRoot.get("contentAssocPredicateId"); String strNullThruDatesOnly = (String)templateRoot.get("nullThruDatesOnly"); Boolean nullThruDatesOnly = (strNullThruDatesOnly != null && strNullThruDatesOnly.equalsIgnoreCase("true")) ? Boolean.TRUE :Boolean.FALSE; String thisSubContentId = (String)templateRoot.get("subContentId"); - //if (Debug.infoOn()) Debug.logInfo("in Render(0), thisSubContentId ." + thisSubContentId , module); final boolean directAssocMode = UtilValidate.isNotEmpty(thisSubContentId) ? true : false; - //if (Debug.infoOn()) Debug.logInfo("in Render(0), directAssocMode ." + directAssocMode , module); GenericValue val = null; try { val = ContentWorker.getCurrentContent(delegator, trail, userLogin, templateRoot, nullThruDatesOnly, contentAssocPredicateId); @@ -119,9 +111,6 @@ public class RenderSubContentCacheTransf templateRoot.put("subContentId", subContentIdSub); templateRoot.put("subDataResourceTypeId", subDataResourceTypeId); - //final Map savedValues = new HashMap<String, Object>(); - //FreeMarkerWorker.saveContextValues(templateCtx, saveKeyNames, savedValues); - return new Writer(out) { @Override @@ -135,23 +124,17 @@ public class RenderSubContentCacheTransf @Override public void close() throws IOException { - // List<Map<String, ? extends Object>> globalNodeTrail = UtilGenerics.checkList(templateRoot.get("globalNodeTrail")); - // if (Debug.infoOn()) Debug.logInfo("Render close, globalNodeTrail(2a):" + FreeMarkerWorker.nodeTrailToCsv(globalNodeTrail), ""); try { renderSubContent(); FreeMarkerWorker.reloadValues(templateRoot, savedValuesUp, env); - //if (Debug.infoOn()) Debug.logInfo("in Render(2), globalNodeTrail ." + getWrapped(env, "globalNodeTrail") , module); } catch (IOException e) { throw new IOException(e.getMessage()); } } public void renderSubContent() throws IOException { - // TemplateHashModel dataRoot = env.getDataModel(); - // Timestamp fromDate = UtilDateTime.nowTimestamp(); List<Map<String, ? extends Object>> passedGlobalNodeTrail = UtilGenerics.checkList(templateRoot.get("globalNodeTrail")); String editRequestName = (String)templateRoot.get("editRequestName"); - //if (Debug.infoOn()) Debug.logInfo("in Render(3), editRequestName ." + editRequestName , module); GenericValue thisView = null; if (view != null) { thisView = view; @@ -164,8 +147,6 @@ public class RenderSubContentCacheTransf thisView = (GenericValue)map.get("value"); } } - //if (Debug.infoOn()) Debug.logInfo("in RenderSubContent, subContentId:" + templateRoot.get("subContentId"), module); - //if (Debug.infoOn()) Debug.logInfo("in RenderSubContent, contentId:" + templateRoot.get("contentId"), module); String mimeTypeId = (String) templateRoot.get("mimeTypeId"); Locale locale = (Locale) templateRoot.get("locale"); @@ -182,7 +163,6 @@ public class RenderSubContentCacheTransf if (contentId != null) { try { ContentWorker.renderContentAsText(dispatcher, delegator, contentId, out, templateRoot, locale, mimeTypeId, null, null, true); - //if (Debug.infoOn()) Debug.logInfo("in RenderSubContent, after renderContentAsTextCache:", module); } catch (GeneralException e) { Debug.logError(e, "Error rendering content", module); throw new IOException("Error rendering thisView:" + thisView + " msg:" + e.toString()); @@ -193,7 +173,6 @@ public class RenderSubContentCacheTransf closeEditWrap(out, editRequestName); } - //if (Debug.infoOn()) Debug.logInfo("in Render(4), globalNodeTrail ." + getWrapped(env, "globalNodeTrail") , module); } public void openEditWrap(Writer out, String editStyle) throws IOException { @@ -202,9 +181,6 @@ public class RenderSubContentCacheTransf } public void closeEditWrap(Writer out, String editRequestName) throws IOException { - // if (Debug.infoOn()) Debug.logInfo("in RenderSubContent, contentId(1):" + templateRoot.get("contentId"), module); - // if (Debug.infoOn()) Debug.logInfo("in Render(0), templateRoot ." + templateRoot , module); - // StringBuilder sb = new StringBuilder(); String fullRequest = editRequestName; String contentId = null; String contentIdTo = null; Modified: ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentTransform.java?rev=1752965&r1=1752964&r2=1752965&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentTransform.java (original) +++ ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentTransform.java Sat Jul 16 14:10:10 2016 @@ -74,7 +74,6 @@ public class RenderSubContentTransform i @SuppressWarnings("unchecked") public Writer getWriter(final Writer out, Map args) { - // final StringBuilder buf = new StringBuilder(); final Environment env = Environment.getCurrentEnvironment(); Map<String, Object> ctx = FreeMarkerWorker.getWrappedObject("context", env); if (ctx == null) { @@ -82,7 +81,6 @@ public class RenderSubContentTransform i } final String mapKey = FreeMarkerWorker.getArg(args, "mapKey", ctx); final String subContentId = FreeMarkerWorker.getArg(args, "subContentId", ctx); - // final String subDataResourceTypeId = FreeMarkerWorker.getArg(args, "subDataResourceTypeId", ctx); final String contentId = FreeMarkerWorker.getArg(args, "contentId", ctx); final String mimeTypeId = FreeMarkerWorker.getArg(args, "mimeTypeId", ctx); final String throwExceptionOnError = FreeMarkerWorker.getArg(args, "throwExceptionOnError", ctx); @@ -130,8 +128,6 @@ public class RenderSubContentTransform i } public void renderSubContent() throws IOException { - // TemplateHashModel dataRoot = env.getDataModel(); - // Timestamp fromDate = UtilDateTime.nowTimestamp(); ServletContext servletContext = request.getSession().getServletContext(); String rootDir = servletContext.getRealPath("/"); String webSiteId = WebSiteWorker.getWebSiteId(request); @@ -151,12 +147,10 @@ public class RenderSubContentTransform i } else { ContentWorker.renderSubContentAsText(dispatcher, delegator, contentId, out, mapKey, templateRoot, locale, mimeTypeId, false); } - //Map results = ContentWorker.renderSubContentAsText(delegator, contentId, out, mapKey, subContentId, subContentDataResourceView, templateRoot, locale, mimeTypeId, userLogin, fromDate); } catch (GeneralException e) { Debug.logError(e, "Error rendering content", module); throw new IOException("Error rendering content" + e.toString()); } - //Map resultCtx = FreeMarkerWorker.getWrappedObject("context", env); templateContext.put("mapKey", null); templateContext.put("subContentId", null); templateContext.put("subDataResourceTypeId", null); Modified: ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/TraverseSubContentCacheTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/TraverseSubContentCacheTransform.java?rev=1752965&r1=1752964&r2=1752965&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/TraverseSubContentCacheTransform.java (original) +++ ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/TraverseSubContentCacheTransform.java Sat Jul 16 14:10:10 2016 @@ -43,7 +43,6 @@ import freemarker.template.TemplateModel import freemarker.template.TemplateTransformModel; import freemarker.template.TransformControl; -//import com.clarkware.profiler.Profiler; /** * TraverseSubContentCacheTransform - Freemarker Transform for URLs (links) */ @@ -82,23 +81,17 @@ public class TraverseSubContentCacheTran public Writer getWriter(final Writer out, Map args) { final StringBuilder buf = new StringBuilder(); final Environment env = Environment.getCurrentEnvironment(); - //final Map templateRoot = FreeMarkerWorker.getWrappedObject("context", env); final Map<String, Object> templateRoot = FreeMarkerWorker.createEnvironmentMap(env); - //FreeMarkerWorker.convertContext(templateRoot); final Map<String, Object> savedValuesUp = new HashMap<String, Object>(); FreeMarkerWorker.saveContextValues(templateRoot, upSaveKeyNames, savedValuesUp); final Map<String, Object> savedValues = new HashMap<String, Object>(); FreeMarkerWorker.overrideWithArgs(templateRoot, args); String startContentAssocTypeId = (String)templateRoot.get("contentAssocTypeId"); - // if (Debug.infoOn()) Debug.logInfo("in TraverseSubContentCache, startContentAssocTypeId:" + startContentAssocTypeId, module); final Delegator delegator = FreeMarkerWorker.getWrappedObject("delegator", env); final HttpServletRequest request = FreeMarkerWorker.getWrappedObject("request", env); FreeMarkerWorker.getSiteParameters(request, templateRoot); final GenericValue userLogin = FreeMarkerWorker.getWrappedObject("userLogin", env); List<Map<String, ? extends Object>> globalNodeTrail = UtilGenerics.checkList(templateRoot.get("globalNodeTrail")); - // List globalNodeTrail = (List)templateRoot.get("globalNodeTrail"); - // String csvTrail = ContentWorker.nodeTrailToCsv(globalNodeTrail); - // if (Debug.infoOn()) Debug.logInfo("in Traverse(0), csvTrail:"+csvTrail,module); String strNullThruDatesOnly = (String)templateRoot.get("nullThruDatesOnly"); String contentAssocPredicateId = (String)templateRoot.get("contentAssocPredicateId"); Boolean nullThruDatesOnly = (strNullThruDatesOnly != null && strNullThruDatesOnly.equalsIgnoreCase("true")) ? Boolean.TRUE :Boolean.FALSE; @@ -110,8 +103,6 @@ public class TraverseSubContentCacheTran } catch (GeneralException e) { throw new RuntimeException("Error getting current content. " + e.toString()); } - // final GenericValue view = val; - final Map<String, Object> traverseContext = new HashMap<String, Object>(); traverseContext.put("delegator", delegator); @@ -134,9 +125,6 @@ public class TraverseSubContentCacheTran thruDate = UtilDateTime.toTimestamp(thruDateStr); } traverseContext.put("thruDate", thruDate); - //if (UtilValidate.isEmpty(startContentAssocTypeId)) { - //throw new RuntimeException("contentAssocTypeId is empty."); - //} traverseContext.put("contentAssocTypeId", startContentAssocTypeId); String direction = (String)templateRoot.get("direction"); if (UtilValidate.isEmpty(direction)) { @@ -148,8 +136,6 @@ public class TraverseSubContentCacheTran @Override public void write(char cbuf[], int off, int len) { - //StringBuilder ctxBuf = (StringBuilder) templateContext.get("buf"); - //ctxBuf.append(cbuf, off, len); buf.append(cbuf, off, len); } @@ -160,22 +146,15 @@ public class TraverseSubContentCacheTran @Override public int onStart() throws TemplateModelException, IOException { - //templateContext.put("buf", new StringBuilder()); List<Map<String, ? extends Object>> nodeTrail = null; Map<String, Object> node = null; - // GenericValue subContentDataResourceView = null; List<Map<String, ? extends Object>> globalNodeTrail = UtilGenerics.checkList(templateRoot.get("globalNodeTrail")); - // String trailCsv = ContentWorker.nodeTrailToCsv(globalNodeTrail); - // if (Debug.infoOn()) Debug.logInfo("in TraverseSubContentCache, onStart, trailCsv(1):" + trailCsv , module); if (globalNodeTrail.size() > 0) { int sz = globalNodeTrail.size() ; nodeTrail = new LinkedList<Map<String,? extends Object>>(); - //nodeTrail = passedGlobalNodeTrail.subList(sz - 1, sz); node = UtilGenerics.checkMap(globalNodeTrail.get(sz - 1)); - //if (Debug.infoOn()) Debug.logInfo("in TraverseSubContentCache, onStart, node(1):" + node , module); Boolean checkedObj = (Boolean)node.get("checked"); Map<String, Object> whenMap = UtilGenerics.checkMap(templateRoot.get("whenMap")); - //if (Debug.infoOn()) Debug.logInfo("in TraverseSubContentCache, whenMap(2):" + whenMap , module); if (checkedObj == null || !checkedObj.booleanValue()) { ContentWorker.checkConditions(delegator, node, null, whenMap); } @@ -188,19 +167,15 @@ public class TraverseSubContentCacheTran return TransformControl.SKIP_BODY; } - // GenericValue content = null; ContentWorker.selectKids(node, traverseContext); - //if (Debug.infoOn()) Debug.logInfo("in TraverseSubContentCache, onStart, node(2):" + node , module); nodeTrail.add(node); traverseContext.put("nodeTrail", nodeTrail); Boolean isPickBool = (Boolean)node.get("isPick"); Boolean isFollowBool = (Boolean)node.get("isFollow"); - //if (Debug.infoOn()) Debug.logInfo("in TraverseSubContentCache, onStart, isPickBool(1):" + isPickBool + " isFollowBool:" + isFollowBool, module); boolean isPick = true; if ((isPickBool == null || !isPickBool.booleanValue()) && (isFollowBool != null && isFollowBool.booleanValue())) { isPick = ContentWorker.traverseSubContent(traverseContext); - //if (Debug.infoOn()) Debug.logInfo("in TraverseSubContentCache, onStart, isPick(2):" + isPick, module); } if (isPick) { populateContext(traverseContext, templateRoot); @@ -214,18 +189,10 @@ public class TraverseSubContentCacheTran @Override public int afterBody() throws TemplateModelException, IOException { FreeMarkerWorker.reloadValues(templateRoot, savedValues, env); - // List globalNodeTrail = (List)templateRoot.get("globalNodeTrail"); - // if (Debug.infoOn()) Debug.logInfo("populateContext, globalNodeTrail(2a):" + FreeMarkerWorker.nodeTrailToCsv(globalNodeTrail), ""); - // List<Map<String, ? extends Object>> nodeTrail = UtilGenerics.checkList(traverseContext.get("nodeTrail")); - // List savedGlobalNodeTrail = (List)savedValues.get("globalNodeTrail"); - // templateRoot.put("globalNodeTrail", savedGlobalNodeTrail); - // int sz = nodeTrail.size(); boolean inProgress = ContentWorker.traverseSubContent(traverseContext); if (inProgress) { populateContext(traverseContext, templateRoot); FreeMarkerWorker.saveContextValues(templateRoot, saveKeyNames, savedValues); - //globalNodeTrail = (List)templateRoot.get("globalNodeTrail"); - //globalNodeTrail.addAll(nodeTrail); return TransformControl.REPEAT_EVALUATION; } else { return TransformControl.END_EVALUATION; @@ -237,17 +204,14 @@ public class TraverseSubContentCacheTran FreeMarkerWorker.reloadValues(templateRoot, savedValuesUp, env); String wrappedContent = buf.toString(); out.write(wrappedContent); - //if (Debug.infoOn()) Debug.logInfo("in TraverseSubContent, wrappedContent:" + wrappedContent, module); } public void populateContext(Map<String, Object> traverseContext, Map<String, Object> templateContext) { List<Map<String, ? extends Object>> nodeTrail = UtilGenerics.checkList(traverseContext.get("nodeTrail")); - // if (Debug.infoOn()) Debug.logInfo("populateContext, nodeTrail csv(a):" + FreeMarkerWorker.nodeTrailToCsv((List)nodeTrail), ""); int sz = nodeTrail.size(); Map<String, ? extends Object> node = nodeTrail.get(sz - 1); GenericValue content = (GenericValue)node.get("value"); String contentId = (String)node.get("contentId"); - // String subContentId = (String)node.get("subContentId"); String contentAssocTypeId = (String)node.get("contentAssocTypeId"); envWrap("contentAssocTypeId", contentAssocTypeId); envWrap("contentId", contentId); @@ -266,23 +230,18 @@ public class TraverseSubContentCacheTran } else { globalNodeTrail = new LinkedList<Map<String,? extends Object>>(); } - //if (Debug.infoOn()) Debug.logInfo("in TraverseSubContentCache, populateContext, contentIdEnd(1):" + contentIdEnd + " contentIdStart:" + contentIdStart + " equals:" + (contentIdStart.equals(contentIdEnd)), module); boolean bIdEnd = UtilValidate.isNotEmpty(contentIdEnd); boolean bIdStart = UtilValidate.isNotEmpty(contentIdStart); boolean bEquals = contentIdStart.equals(contentIdEnd); - // if (Debug.infoOn()) Debug.logInfo("in TraverseSubContentCache, populateContext, contentIdEnd(1):" + bIdEnd + " contentIdStart:" + bIdStart + " equals:" + bEquals, module); - // if (Debug.infoOn()) Debug.logInfo("populateContext, globalNodeTrail(1a):" + FreeMarkerWorker.nodeTrailToCsv(globalNodeTrail), ""); if (bIdEnd && bIdStart && bEquals) { List<Map<String, ? extends Object>> subList = nodeTrail.subList(1, sz); globalNodeTrail.addAll(subList); } else { globalNodeTrail.addAll(nodeTrail); } - // if (Debug.infoOn()) Debug.logInfo("populateContext, globalNodeTrail(1b):" + FreeMarkerWorker.nodeTrailToCsv(globalNodeTrail), ""); int indentSz = globalNodeTrail.size(); envWrap("indent", Integer.valueOf(indentSz)); String trailCsv = ContentWorker.nodeTrailToCsv(globalNodeTrail); - //if (Debug.infoOn()) Debug.logInfo("in TraverseSubContentCache, populateCtx, trailCsv(2):" + trailCsv , module); envWrap("nodeTrailCsv", trailCsv); envWrap("globalNodeTrail", globalNodeTrail); } Modified: ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java?rev=1752965&r1=1752964&r2=1752965&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java (original) +++ ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java Sat Jul 16 14:10:10 2016 @@ -85,32 +85,10 @@ public class TraverseSubContentTransform final StringBuilder buf = new StringBuilder(); final Environment env = Environment.getCurrentEnvironment(); final Map<String, Object> templateCtx = FreeMarkerWorker.getWrappedObject("context", env); - //FreeMarkerWorker.convertContext(templateCtx); final Map<String, Object> savedValues = FreeMarkerWorker.saveValues(templateCtx, saveKeyNames); FreeMarkerWorker.overrideWithArgs(templateCtx, args); final Delegator delegator = FreeMarkerWorker.getWrappedObject("delegator", env); -/* - final String editTemplate = FreeMarkerWorker.getArg(args, "editTemplate", ctx); - final String wrapTemplateId = FreeMarkerWorker.getArg(args, "wrapTemplateId", ctx); - //final String mapKey = FreeMarkerWorker.getArg(args, "mapKey", ctx); - final String templateContentId = FreeMarkerWorker.getArg(args, "templateContentId", ctx); - final String subDataResourceTypeId = FreeMarkerWorker.getArg(args, "subDataResourceTypeId", ctx); - final String contentId = FreeMarkerWorker.getArg(args, "contentId", ctx); - final String subContentId = FreeMarkerWorker.getArg(args, "subContentId", ctx); - final String rootDir = FreeMarkerWorker.getArg(args, "rootDir", ctx); - final String webSiteId = FreeMarkerWorker.getArg(args, "webSiteId", ctx); - final String https = FreeMarkerWorker.getArg(args, "https", ctx); - final String viewSize = FreeMarkerWorker.getArg(args, "viewSize", ctx); - final String viewIndex = FreeMarkerWorker.getArg(args, "viewIndex", ctx); - final String listSize = FreeMarkerWorker.getArg(args, "listSize", ctx); - final String highIndex = FreeMarkerWorker.getArg(args, "highIndex", ctx); - final String lowIndex = FreeMarkerWorker.getArg(args, "lowIndex", ctx); - final String queryString = FreeMarkerWorker.getArg(args, "queryString", ctx); - final Locale locale = FreeMarkerWorker.getWrappedObject("locale", env); - final String mimeTypeId = FreeMarkerWorker.getArg(args, "mimeTypeId", ctx); -*/ final LocalDispatcher dispatcher = FreeMarkerWorker.getWrappedObject("dispatcher", env); - //final GenericValue userLogin = FreeMarkerWorker.getWrappedObject("userLogin", env); GenericValue view = FreeMarkerWorker.getWrappedObject("subContentDataResourceView", env); final Integer indent = (templateCtx.get("indent") == null) ? Integer.valueOf(0) : (Integer)templateCtx.get("indent"); @@ -166,8 +144,6 @@ public class TraverseSubContentTransform @Override public void write(char cbuf[], int off, int len) { - //StringBuilder ctxBuf = (StringBuilder) templateContext.get("buf"); - //ctxBuf.append(cbuf, off, len); buf.append(cbuf, off, len); } @@ -178,20 +154,8 @@ public class TraverseSubContentTransform @Override public int onStart() throws TemplateModelException, IOException { - //templateContext.put("buf", new StringBuilder()); List<Map<String, Object>> nodeTrail = new LinkedList<Map<String,Object>>(); traverseContext.put("nodeTrail", nodeTrail); - // GenericValue content = null; -/* - if (UtilValidate.isNotEmpty(contentId)) { - try { - content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne(); - } catch (GenericEntityException e) { - // TODO: Not sure what to put here. - throw new RuntimeException(e.getMessage()); - } - } -*/ Map<String, Object> rootNode = ContentWorker.makeNode(subContentDataResourceView); ContentWorker.traceNodeTrail("1", nodeTrail); ContentWorker.selectKids(rootNode, traverseContext); @@ -215,9 +179,6 @@ public class TraverseSubContentTransform @Override public int afterBody() throws TemplateModelException, IOException { - //out.write(buf.toString()); - //buf.setLength(0); - //templateContext.put("buf", new StringBuilder()); List<Map<String, Object>> nodeTrail = UtilGenerics.checkList(traverseContext.get("nodeTrail")); ContentWorker.traceNodeTrail("6",nodeTrail); boolean inProgress = ContentWorker.traverseSubContent(traverseContext); @@ -242,19 +203,6 @@ public class TraverseSubContentTransform if (UtilValidate.isNotEmpty(wrapTemplateId)) { templateCtx.put("wrappedFTL", wrappedFTL); Map<String, Object> templateRoot = FreeMarkerWorker.createEnvironmentMap(env); -/* - templateRoot.put("viewSize", viewSize); - templateRoot.put("viewIndex", viewIndex); - templateRoot.put("listSize", listSize); - templateRoot.put("highIndex", highIndex); - templateRoot.put("lowIndex", lowIndex); - templateRoot.put("queryString", queryString); - templateRoot.put("wrapDataResourceTypeId", subDataResourceTypeId); - templateRoot.put("wrapContentIdTo", contentId); - templateRoot.put("wrapMimeTypeId", mimeTypeId); - //templateRoot.put("wrapMapKey", mapKey); - -*/ templateRoot.put("context", templateCtx); String mimeTypeId = (String) templateCtx.get("mimeTypeId"); Locale locale = (Locale) templateCtx.get("locale"); @@ -266,16 +214,6 @@ public class TraverseSubContentTransform Debug.logError(e, "Error rendering content", module); throw new IOException("Error rendering content" + e.toString()); } -/* - Map resultsCtx = FreeMarkerWorker.getWrappedObject("context", env); - templateContext.put("contentId", contentId); - templateContext.put("locale", locale); - templateContext.put("mapKey", null); - templateContext.put("subContentId", null); - templateContext.put("templateContentId", null); - templateContext.put("subDataResourceTypeId", null); - templateContext.put("mimeTypeId", null); -*/ } else { if (UtilValidate.isNotEmpty(wrappedFTL)) out.write(wrappedFTL); @@ -291,19 +229,12 @@ public class TraverseSubContentTransform contentAssocTypeId = ""; } assocContext.put("contentAssocTypeId", contentAssocTypeId); - // assocContext.put("contentTypeId", assocValue.get("contentTypeId")); - // String assocRelation = null; String thisDirection = (String)templateCtx.get("direction"); String thisContentId = (String)templateCtx.get("thisContentId"); - // String relatedDirection = null; if (thisDirection != null && thisDirection.equalsIgnoreCase("From")) { assocContext.put("contentIdFrom", thisContentId); - // assocRelation = "FromContent"; - // relatedDirection = "From"; } else { assocContext.put("contentIdTo", thisContentId); - // assocRelation = "ToContent"; - // relatedDirection = "To"; } assocContext.put("content", thisContent); List<Object> purposes = ContentWorker.getPurposes(thisContent); @@ -317,7 +248,6 @@ public class TraverseSubContentTransform } assocContext.put("typeAncestry", contentTypeAncestry); Map<String, Object> whenMap = UtilGenerics.checkMap(traverseContext.get("whenMap")); - // String pickWhen = (String)whenMap.get("pickWhen"); List<Map<String, ? extends Object>> nodeTrail = UtilGenerics.checkList(traverseContext.get("nodeTrail")); int indentSz = indent.intValue() + nodeTrail.size(); assocContext.put("indentObj", Integer.valueOf(indentSz)); @@ -329,9 +259,7 @@ public class TraverseSubContentTransform List<Map<String, Object>> nodeTrail = UtilGenerics.checkList(traverseContext.get("nodeTrail")); int sz = nodeTrail.size(); Map<String, Object> node = nodeTrail.get(sz - 1); - // GenericValue content = (GenericValue)node.get("value"); String contentId = (String)node.get("contentId"); - // String subContentId = (String)node.get("subContentId"); templateContext.put("subContentId", contentId); templateContext.put("subContentDataResourceView", null); int indentSz = indent.intValue() + nodeTrail.size(); Modified: ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/WrapSubContentCacheTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/WrapSubContentCacheTransform.java?rev=1752965&r1=1752964&r2=1752965&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/WrapSubContentCacheTransform.java (original) +++ ofbiz/trunk/applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/WrapSubContentCacheTransform.java Sat Jul 16 14:10:10 2016 @@ -41,7 +41,6 @@ import org.apache.ofbiz.service.LocalDis import freemarker.core.Environment; import freemarker.template.TemplateTransformModel; -//import com.clarkware.profiler.Profiler; /** * WrapSubContentCacheTransform - Freemarker Transform for URLs (links) * @@ -95,14 +94,10 @@ public class WrapSubContentCacheTransfor FreeMarkerWorker.getSiteParameters(request, templateCtx); final Map<String, Object> savedValuesUp = new HashMap<String, Object>(); FreeMarkerWorker.saveContextValues(templateCtx, upSaveKeyNames, savedValuesUp); - //if (Debug.infoOn()) Debug.logInfo("in Wrap(0a), savedValuesUp ." + savedValuesUp , module); FreeMarkerWorker.overrideWithArgs(templateCtx, args); - //if (Debug.infoOn()) Debug.logInfo("in Wrap(0b), savedValuesUp ." + savedValuesUp , module); final String wrapTemplateId = (String)templateCtx.get("wrapTemplateId"); - //if (Debug.infoOn()) Debug.logInfo("in WrapSubContent, wrapTemplateId(1):" + wrapTemplateId, module); final GenericValue userLogin = FreeMarkerWorker.getWrappedObject("userLogin", env); List<Map<String, ? extends Object>> trail = UtilGenerics.checkList(templateCtx.get("globalNodeTrail")); - //if (Debug.infoOn()) Debug.logInfo("in WrapSubContent, trail(0):" + trail, ""); String contentAssocPredicateId = (String)templateCtx.get("contentAssocPredicateId"); String strNullThruDatesOnly = (String)templateCtx.get("nullThruDatesOnly"); Boolean nullThruDatesOnly = (strNullThruDatesOnly != null && strNullThruDatesOnly.equalsIgnoreCase("true")) ? Boolean.TRUE :Boolean.FALSE; @@ -112,7 +107,6 @@ public class WrapSubContentCacheTransfor } catch (GeneralException e) { throw new RuntimeException("Error getting current content. " + e.toString()); } - //if (Debug.infoOn()) Debug.logInfo("in WrapSubContent, trail(1):" + trail, ""); final GenericValue view = val; String dataResourceId = null; @@ -136,7 +130,6 @@ public class WrapSubContentCacheTransfor } final Map<String, Object> savedValues = new HashMap<String, Object>(); FreeMarkerWorker.saveContextValues(templateCtx, saveKeyNames, savedValues); - //if (Debug.infoOn()) Debug.logInfo("in Wrap(1), savedValues ." + savedValues , module); // This order is taken so that the mimeType can be overridden in the transform arguments. String mimeTypeId = ContentWorker.getMimeTypeId(delegator, view, templateCtx); templateCtx.put("drDataResourceId", dataResourceId); @@ -161,16 +154,10 @@ public class WrapSubContentCacheTransfor @Override public void close() throws IOException { FreeMarkerWorker.reloadValues(templateCtx, savedValues, env); - //if (Debug.infoOn()) Debug.logInfo("in Wrap(2), savedValues ." + savedValues , module); String wrappedContent = buf.toString(); - //if (view != null && Debug.infoOn()) Debug.logInfo("in WrapSubContent, view(2):" + view.get("contentId"), module); - //if (Debug.infoOn()) Debug.logInfo("in WrapSubContent, wrappedContent:" + wrappedContent, module); - //if (Debug.infoOn()) Debug.logInfo("in WrapSubContent, wrapTemplateId(2):" + wrapTemplateId, module); if (UtilValidate.isNotEmpty(wrapTemplateId)) { templateCtx.put("wrappedContent", wrappedContent); - - //Map templateRoot = FreeMarkerWorker.createEnvironmentMap(env); Map<String, Object> templateRoot = null; Map<String, Object> templateRootTemplate = UtilGenerics.checkMap(templateCtx.get("templateRootTemplate")); if (templateRootTemplate == null) { @@ -186,9 +173,7 @@ public class WrapSubContentCacheTransfor String mimeTypeId = (String)templateCtx.get("mimeTypeId"); Locale locale = null; try { - //if (Debug.infoOn()) Debug.logInfo("in Edit(0), before calling renderContentAsText ." , module); ContentWorker.renderContentAsText(dispatcher, delegator, wrapTemplateId, out, templateRoot, locale, mimeTypeId, null, null, true); - //if (Debug.infoOn()) Debug.logInfo("in Edit(0), after calling renderContentAsText ." , module); } catch (IOException e) { Debug.logError(e, "Error rendering content" + e.getMessage(), module); throw new IOException("Error rendering content" + e.toString()); @@ -197,7 +182,6 @@ public class WrapSubContentCacheTransfor throw new IOException("Error rendering content" + e2.toString()); } FreeMarkerWorker.reloadValues(templateCtx, savedValuesUp, env); - //if (Debug.infoOn()) Debug.logInfo("in Wrap(2), savedValuesUp ." + savedValuesUp , module); } } };