Applied patch from jira issue - OFBIZ-7838 - Clean up commented out code in Java source for Content.

Thanks so much Harsh for the contribution.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1752965 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ashish Vijaywargiya
2016-07-16 14:10:10 +00:00
parent f77d94bca9
commit 40bd2bb3e3
41 changed files with 1 additions and 1067 deletions
@@ -64,7 +64,6 @@ public class ContentManagementEvents {
Delegator delegator = (Delegator)request.getAttribute("delegator");
LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher");
Map<String, Object> paramMap = UtilHttp.getParameterMap(request);
//if (Debug.infoOn()) Debug.logInfo("in updateStaticValues, paramMap:" + paramMap , module);
String parentPlaceholderId = (String)paramMap.get("ph");
if (UtilValidate.isEmpty(parentPlaceholderId)) {
request.setAttribute("_ERROR_MESSAGE_", "ParentPlaceholder is empty.");
@@ -82,33 +81,15 @@ public class ContentManagementEvents {
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
return "error";
}
/*
Set keySet = paramMap.keySet();
Iterator itKeySet = keySet.iterator();
Map contentIdLookup = new HashMap<String, Object>();
while (itKeySet.hasNext()) {
String idxAndContentId = (String)itKeySet.next();
int pos = idxAndContentId.indexOf("_");
if (pos > 0) {
String idxStr = idxAndContentId.substring(0, pos);
int idx = Integer.parseInt(idxStr);
String contentId = idxAndContentId.substring(pos + 1);
contentIdLookup.put(contentId, Integer.valueOf(idx));
}
}
*/
int counter = 0;
for (Map<String, Object> map : valueList) {
String contentId = (String)map.get("contentId");
//Integer idxObj = (Integer)contentIdLookup.get(contentId);
//int idx = idxObj.intValue();
for (String [] pubArr : permittedPublishPointList) {
String pubContentId = pubArr[0];
String pubValue = (String)map.get(pubContentId);
String paramName = Integer.toString(counter) + "_" + pubContentId;
String paramValue = (String)paramMap.get(paramName);
//if (Debug.infoOn()) Debug.logInfo("in updateStaticValues, contentId:" + contentId + " pubContentId:" + pubContentId + " pubValue:" + pubValue + " paramName:" + paramName + " paramValue:" + paramValue, module);
Map<String, Object> serviceIn = new HashMap<String, Object>();
serviceIn.put("userLogin", userLogin);
serviceIn.put("contentIdTo", contentId);
@@ -160,7 +141,6 @@ public class ContentManagementEvents {
Delegator delegator = (Delegator)request.getAttribute("delegator");
LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher");
Map<String, Object> paramMap = UtilHttp.getParameterMap(request);
//if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, paramMap:" + paramMap , module);
String targContentId = (String)paramMap.get("contentId"); // The content to be linked to one or more sites
String roles = null;
String authorId = null;
@@ -174,7 +154,6 @@ public class ContentManagementEvents {
// Determine if user is owner of target content
String userLoginId = userLogin.getString("userLoginId");
//if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, userLoginId:" + userLoginId + " authorId:" + authorId , module);
List<String> roleTypeList = null;
if (authorId != null && userLoginId != null && authorId.equals(userLoginId)) {
roles = "OWNER";
@@ -182,7 +161,6 @@ public class ContentManagementEvents {
}
List<String> targetOperationList = UtilMisc.<String>toList("CONTENT_PUBLISH");
List<String> contentPurposeList = null; //UtilMisc.toList("ARTICLE");
//if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, roles:" + roles +" roleTypeList:" + roleTypeList , module);
String permittedAction = (String)paramMap.get("permittedAction"); // The content to be linked to one or more sites
String permittedOperations = (String)paramMap.get("permittedOperations"); // The content to be linked to one or more sites
if (UtilValidate.isEmpty(targContentId)) {
@@ -203,40 +181,31 @@ public class ContentManagementEvents {
request.setAttribute("_ERROR_MESSAGE_", e2.getMessage());
return "error";
}
//if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, origPublishedLinkList:" + origPublishedLinkList , module);
// make a map of the values that are passed in using the top subSite as the key.
// Content can only be linked to one subsite under a top site (ends with "_MASTER")
Map<String, String> siteIdLookup = new HashMap<String, String>();
for (String param : paramMap.keySet()) {
int pos = param.indexOf("select_");
//if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, param:" + param + " pos:" + pos , module);
if (pos >= 0) {
String siteId = param.substring(7);
String subSiteVal = (String)paramMap.get(param);
siteIdLookup.put(siteId, subSiteVal);
}
}
//if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, siteIdLookup:" + siteIdLookup , module);
// Loop thru all the possible subsites
Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
// int counter = 0;
String responseMessage = null;
String errorMessage = null;
// String permissionMessage = null;
boolean statusIdUpdated = false;
Map<String, Object> results = null;
for (Object [] arr : origPublishedLinkList) {
//if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, arr:" + Arrays.asList(arr) , module);
String contentId = (String)arr[0]; // main (2nd level) site id
String origSubContentId = null;
List<Object []> origSubList = UtilGenerics.checkList(arr[1]);
// Timestamp topFromDate = (Timestamp)arr[3];
Timestamp origFromDate = null;
for (Object [] pubArr : origSubList) {
// see if a link already exists by looking for non-null fromDate
//if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, pubArr:" + Arrays.asList(pubArr) , module);
Timestamp fromDate = (Timestamp)pubArr[2];
origSubContentId = null;
if (fromDate != null) {
@@ -247,8 +216,6 @@ public class ContentManagementEvents {
}
String currentSubContentId = siteIdLookup.get(contentId);
//if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, currentSubContentId:" + currentSubContentId , module);
//if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, origSubContentId:" + origSubContentId , module);
try {
if (UtilValidate.isNotEmpty(currentSubContentId)) {
if (!currentSubContentId.equals(origSubContentId)) {
@@ -263,7 +230,6 @@ public class ContentManagementEvents {
for (GenericValue cAssoc : oldActiveValues) {
cAssoc.set("thruDate", nowTimestamp);
cAssoc.store();
//if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, deactivating:" + cAssoc , module);
}
}
// create new link
@@ -295,9 +261,7 @@ public class ContentManagementEvents {
serviceIn.put("roleTypeList", roleTypeList);
serviceIn.put("targetOperationList", targetOperationList);
serviceIn.put("contentPurposeList", contentPurposeList);
//if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, serviceIn(3b):" + serviceIn , module);
results = dispatcher.runSync("createContentAssoc", serviceIn);
//if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, results(3b):" + results , module);
if (!statusIdUpdated) {
try {
GenericValue targContent = EntityQuery.use(delegator).from("Content").where("contentId", targContentId).queryOne();
@@ -71,9 +71,7 @@ public class ContentManagementServices {
* This service calls a same-named method in ContentWorker to do the work.
*/
public static Map<String, Object> getSubContent(DispatchContext dctx, Map<String, ? extends Object> context) {
//Security security = dctx.getSecurity();
Delegator 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");
@@ -109,10 +107,8 @@ public class ContentManagementServices {
* This service calls a same-named method in ContentWorker to do the work.
*/
public static Map<String, Object> getContent(DispatchContext dctx, Map<String, ? extends Object> context) {
//Security security = dctx.getSecurity();
Delegator delegator = dctx.getDelegator();
String contentId = (String) context.get("contentId");
//GenericValue userLogin = (GenericValue)context.get("userLogin");
GenericValue view = null;
try {
@@ -233,22 +229,6 @@ public class ContentManagementServices {
// get user info for multiple use
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();
//Timestamp lastModifiedDate = UtilDateTime.nowTimestamp();
// Do update and create permission checks on DataResource if warranted.
//boolean updatePermOK = false;
//boolean createPermOK = false;
boolean dataResourceExists = true;
if (Debug.infoOn()) {
Debug.logInfo("in persist... dataResourceTypeId(0):" + dataResourceTypeId, module);
@@ -296,11 +276,8 @@ public class ContentManagementServices {
return ServiceUtil.returnError(e.toString());
}
}
//List targetOperations = new LinkedList<String>();
//context.put("targetOperations", targetOperations);
context.putAll(content);
if (contentExists) {
//targetOperations.add("CONTENT_UPDATE");
Map<String, Object> contentContext = new HashMap<String, Object>();
ModelService contentModel = dispatcher.getDispatchContext().getModelService("updateContent");
contentContext.putAll(contentModel.makeValid(content, "IN"));
@@ -312,9 +289,7 @@ public class ContentManagementServices {
if (ServiceUtil.isError(thisResult) || ServiceUtil.isFailure(thisResult)) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentContentUpdatingError", UtilMisc.toMap("serviceName", "persistContentAndAssoc"), locale), null, null, thisResult);
}
//Map thisResult = ContentServices.updateContentMethod(dctx, context);
} else {
//targetOperations.add("CONTENT_CREATE");
Map<String, Object> contentContext = new HashMap<String, Object>();
ModelService contentModel = dispatcher.getDispatchContext().getModelService("createContent");
contentContext.putAll(contentModel.makeValid(content, "IN"));
@@ -326,8 +301,6 @@ public class ContentManagementServices {
if (ServiceUtil.isError(thisResult) || ServiceUtil.isFailure(thisResult)) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentContentCreatingError", UtilMisc.toMap("serviceName", "persistContentAndAssoc"), locale), null, null, thisResult);
}
//Map thisResult = ContentServices.createContentMethod(dctx, context);
contentId = (String) thisResult.get("contentId");
}
results.put("contentId", contentId);
@@ -392,17 +365,6 @@ public class ContentManagementServices {
if (ServiceUtil.isError(thisResult) || ServiceUtil.isFailure(thisResult) || UtilValidate.isNotEmpty(errMsg)) {
return ServiceUtil.returnError(errMsg);
}
// results.put("contentIdTo",
// thisResult.get("contentIdTo"));
// results.put("contentIdFrom",
// thisResult.get("contentIdFrom"));
// results.put("contentId",
// thisResult.get("contentIdFrom"));
// results.put("contentAssocTypeId",
// thisResult.get("contentAssocTypeId"));
// results.put("fromDate", thisResult.get("fromDate"));
// results.put("sequenceNum",
// thisResult.get("sequenceNum"));
results.put("caContentIdTo", thisResult.get("contentIdTo"));
results.put("caContentId", thisResult.get("contentIdFrom"));
@@ -450,21 +412,13 @@ public class ContentManagementServices {
LocalDispatcher dispatcher = dctx.getDispatcher();
Delegator delegator = dctx.getDelegator();
GenericValue userLogin = (GenericValue)context.get("userLogin");
//String userLoginPartyId = userLogin.getString("partyId");
Map<String, Object> results = new HashMap<String, Object>();
// siteContentId will equal "ADMIN_MASTER", "AGINC_MASTER", etc.
// Remember that this service is called in the "multi" mode,
// with a new siteContentId each time.
// siteContentId could also have been name deptContentId, since this same
// service is used for updating department roles, too.
String siteContentId = (String)context.get("contentId");
String partyId = (String)context.get("partyId");
if (UtilValidate.isEmpty(siteContentId) || UtilValidate.isEmpty(partyId))
return results;
//Debug.logInfo("updateSiteRoles, context(0):" + context, module);
List<GenericValue> siteRoles = null;
try {
siteRoles = EntityQuery.use(delegator).from("RoleType").where("parentTypeId", "BLOG").cache().queryList();
@@ -495,7 +449,6 @@ public class ContentManagementServices {
serviceContext.put("roleTypeId", siteRole);
if (siteRoleVal != null && siteRoleVal.equalsIgnoreCase("Y")) {
// for now, will assume that any error is due to duplicates - ignore
//return ServiceUtil.returnError(e.toString());
if (fromDate == null) {
try {
Map<String, Object> newContext = new HashMap<String, Object>();
@@ -511,7 +464,6 @@ public class ContentManagementServices {
if (UtilValidate.isNotEmpty(errMsg)) {
return ServiceUtil.returnError(errMsg);
}
//addRoleToUser(delegator, dispatcher, serviceContext);
} catch (GenericServiceException e) {
Debug.logError(e, e.toString(), module);
return ServiceUtil.returnError(e.toString());
@@ -523,12 +475,8 @@ public class ContentManagementServices {
} else {
if (fromDate != null) {
// for now, will assume that any error is due to non-existence - ignore
//return ServiceUtil.returnError(e.toString());
try {
Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module);
//Timestamp thruDate = UtilDateTime.nowTimestamp();
//serviceContext.put("thruDate", thruDate);
//serviceContext.put("fromDate", fromDate);
Map<String, Object> newContext = new HashMap<String, Object>();
newContext.put("contentId", serviceContext.get("contentId"));
newContext.put("partyId", serviceContext.get("partyId"));
@@ -552,13 +500,10 @@ public class ContentManagementServices {
}
public static Map<String, Object> persistDataResourceAndData(DispatchContext dctx, Map<String, ? extends Object> context) {
//Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
//String contentId = (String)context.get("contentId");
Locale locale = (Locale) context.get("locale");
Map<String, Object> result = new HashMap<String, Object>();
try {
//GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
ModelService checkPermModel = dispatcher.getDispatchContext().getModelService("checkContentPermission");
Map<String, Object> ctx = checkPermModel.makeValid(context, "IN");
Map<String, Object> thisResult = dispatcher.runSync("checkContentPermission", ctx);
@@ -624,7 +569,6 @@ public class ContentManagementServices {
}
}
GenericValue userLogin = (GenericValue) context.get("userLogin");
//String userLoginId = (String)userLogin.get("userLoginId");
ModelService dataResourceModel = dispatcher.getDispatchContext().getModelService("updateDataResource");
Map<String, Object> ctx = dataResourceModel.makeValid(dataResource, "IN");
newDrContext.putAll(ctx);
@@ -751,8 +695,6 @@ public class ContentManagementServices {
String partyId = (String)context.get("partyId");
serviceContext.put("partyId", partyId);
serviceContext.put("contentId", siteContentId);
//Debug.logInfo("updateSiteRoles, serviceContext(0):" + serviceContext, module);
//Debug.logInfo("updateSiteRoles, context(0):" + context, module);
List<GenericValue> siteRoles = null;
try {
@@ -763,14 +705,12 @@ public class ContentManagementServices {
for (GenericValue roleType : siteRoles) {
String siteRole = (String)roleType.get("roleTypeId"); // BLOG_EDITOR, BLOG_ADMIN, etc.
String cappedSiteRole = ModelUtil.dbNameToVarName(siteRole);
//if (Debug.infoOn()) Debug.logInfo("updateSiteRoles, cappediteRole(1):" + cappedSiteRole, module);
String siteRoleVal = (String)context.get(cappedSiteRole);
Object fromDate = context.get(cappedSiteRole + "FromDate");
serviceContext.put("roleTypeId", siteRole);
if (siteRoleVal != null && siteRoleVal.equalsIgnoreCase("Y")) {
// for now, will assume that any error is due to duplicates - ignore
//return ServiceUtil.returnError(e.toString());
if (fromDate == null) {
try {
serviceContext.put("fromDate", UtilDateTime.nowTimestamp());
@@ -791,9 +731,6 @@ public class ContentManagementServices {
//return ServiceUtil.returnError(e.toString());
try {
Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module);
//Timestamp thruDate = UtilDateTime.nowTimestamp();
//serviceContext.put("thruDate", thruDate);
//serviceContext.put("fromDate", fromDate);
Map<String, Object> newContext = new HashMap<String, Object>();
newContext.put("contentId", serviceContext.get("contentId"));
newContext.put("partyId", serviceContext.get("partyId"));
@@ -952,7 +889,6 @@ public class ContentManagementServices {
GenericValue userLogin = (GenericValue)context.get("userLogin");
String userLoginId = userLogin.getString("userLoginId");
Locale locale = (Locale) context.get("locale");
//int seqNum = 9999;
try {
GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
if (content == null) {
@@ -960,17 +896,6 @@ public class ContentManagementServices {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentNoContentFound", UtilMisc.toMap("contentId", ""), locale));
}
String dataResourceId = content.getString("dataResourceId");
//String contentTypeIdTo = content.getString("contentTypeId");
/* this does not seem to be correct or needed
if (UtilValidate.isNotEmpty(contentTypeIdTo)) {
if (contentTypeIdTo.equals("OUTLINE_NODE")) {
content.put("contentTypeId", "OUTLINE_NODE");
} else if (contentTypeIdTo.equals("PAGE_NODE")) {
content.put("contentTypeId", "SUBPAGE_NODE");
} else
content.put("contentTypeId", "PAGE_NODE");
}
*/
content.set("dataResourceId", null);
content.set("lastModifiedDate", UtilDateTime.nowTimestamp());
@@ -1028,61 +953,6 @@ public class ContentManagementServices {
return result;
}
/*
public static Map<String, Object> updateLeafChange(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
Map result = new HashMap<String, Object>();
Delegator delegator = dctx.getDelegator();
List typeList = (List)context.get("typeList");
if (typeList == null)
typeList = UtilMisc.toList("PUBLISH_LINK", "SUB_CONTENT");
String contentId = (String)context.get("contentId");
try {
GenericValue thisContent = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
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();
String mode = (String)context.get("mode");
if (mode != null && mode.equalsIgnoreCase("remove")) {
subLeafCount *= -1;
} else {
// 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 listFiltered = EntityQuery.use(delegator).from("ContentAssoc").where(mainCondition).cache().filterByDate().queryList();
Iterator iter = listFiltered.iterator();
while (iter.hasNext()) {
GenericValue contentAssoc = (GenericValue)iter.next();
String subContentId = contentAssoc.getString("contentId");
GenericValue contentTo = EntityQuery.use(delegator).from("Content").where("contentId", subContentId).cache().queryOne();
Integer childBranchCount = (Integer)contentTo.get("childBranchCount");
int branchCount = (childBranchCount == null) ? 1 : childBranchCount.intValue();
if (mode != null && mode.equalsIgnoreCase("remove"))
branchCount += -1;
else
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 result;
}
*/
/**
* This service changes the contentTypeId of the current content and its children depending on the pageMode.
@@ -1222,23 +1092,13 @@ public class ContentManagementServices {
visitedSet.add(contentId);
}
}
// String contentTypeId = content.getString("contentTypeId");
String newContentTypeId = "SUBPAGE_NODE";
// if (contentTypeId == null || contentTypeId.equals("DOCUMENT")) {
// newContentTypeId = "SUBPAGE_NODE";
// } 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<GenericValue> kids = ContentWorker.getAssociatedContent(content, "from", UtilMisc.toList("SUB_CONTENT"), null, null, null);
for (GenericValue kidContent : kids) {
updatePageNodeChildren(kidContent, context);
}
//}
}
public static void updateOutlineNodeChildren(GenericValue content, boolean forceOutline, Map<String, Object> context) throws GenericEntityException {
@@ -1275,7 +1135,6 @@ public class ContentManagementServices {
content.store();
if (contentTypeId == null || contentTypeId.equals("DOCUMENT") || contentTypeId.equals("OUTLINE_NODE")) {
//if (contentTypeId == null || contentTypeId.equals("DOCUMENT")) {
List<GenericValue> kids = ContentWorker.getAssociatedContent(content, "from", UtilMisc.toList("SUB_CONTENT"), null, null, null);
for (GenericValue kidContent : kids) {
updateOutlineNodeChildren(kidContent, forceOutline, context);
@@ -1334,8 +1193,6 @@ public class ContentManagementServices {
content.set("childBranchCount", Long.valueOf(0));
}
//content.store();
return result;
}
@@ -1656,8 +1513,6 @@ public class ContentManagementServices {
return result;
}
/**
*/
public static Map<String, Object> persistContentWithRevision(DispatchContext dctx, Map<String, ? extends Object> context) {
Map<String, Object> result = null;
Delegator delegator = dctx.getDelegator();
@@ -249,7 +249,6 @@ public final class ContentManagementWorker {
}
}
} else {
//useCached = false;
usePassed = false;
}
}
@@ -298,7 +297,6 @@ public final class ContentManagementWorker {
targetOperationList = StringUtil.split(permittedOperations, "|");
}
Map<String, Object> results = null;
//if (Debug.infoOn()) Debug.logInfo("in getPermittedPublishPoints, content:" + content, module);
results = EntityPermissionChecker.checkPermission(content, statusId, userLogin, passedPurposes, targetOperationList, roles, delegator, security, entityAction);
String permissionStatus = (String)results.get("permissionStatus");
if (permissionStatus != null && permissionStatus.equalsIgnoreCase("granted")) {
@@ -328,7 +326,6 @@ public final class ContentManagementWorker {
GenericValue webSitePublishPoint = null;
for (GenericValue contentAssoc : relatedPubPts) {
String pub = (String)contentAssoc.get("contentId");
//webSitePublishPoint = EntityQuery.use(delegator).from("WebSitePublishPoint").where("contentId", pub).cache().queryOne();
webSitePublishPoint = getWebSitePublishPoint(delegator, pub, false);
allPublishPoints.add(webSitePublishPoint);
}
@@ -416,7 +413,6 @@ public final class ContentManagementWorker {
if (webSitePublishPoint == null) {
webSitePublishPoint = delegator.makeValue("WebSitePublishPoint", UtilMisc.toMap("contentId", contentId));
}
//if (Debug.infoOn()) Debug.logInfo("in getWebSitePublishPoint, contentId:" + contentId, module);
webSitePublishPoint = overrideWebSitePublishPoint(delegator, webSitePublishPoint);
cachedWebSitePublishPoints.put(contentId, webSitePublishPoint);
}
@@ -427,9 +423,7 @@ public final class ContentManagementWorker {
String contentId = passedValue.getString("contentId");
GenericValue webSitePublishPoint = passedValue;
String contentIdTo = getParentWebSitePublishPointId(delegator, contentId);
//if (Debug.infoOn()) Debug.logInfo("in overrideWebSitePublishPoint, contentIdTo:" + contentIdTo, module);
if (contentIdTo != null) {
//webSitePublishPoint = getWebSitePublishPoint(delegator, contentIdTo, false);
webSitePublishPoint = EntityQuery.use(delegator).from("WebSitePublishPoint").where("contentId", contentIdTo).cache().queryOne();
if (webSitePublishPoint != null) {
webSitePublishPoint = GenericValue.create(webSitePublishPoint);
@@ -462,27 +456,14 @@ public final class ContentManagementWorker {
public static GenericValue getStaticValue(Delegator delegator, String parentPlaceholderId, String webSitePublishPointId, boolean ignoreCache) throws GenericEntityException {
GenericValue webSitePublishPoint = null;
// GenericValue staticValue = null;
if (!ignoreCache) {
Map<String, Object> subStaticValueMap = cachedStaticValues.get(parentPlaceholderId);
if (subStaticValueMap == null) {
subStaticValueMap = new HashMap<String, Object>();
cachedStaticValues.put(parentPlaceholderId, subStaticValueMap);
}
//Map staticValueMap = (GenericValue)cachedStaticValues.get(web);
}
/*
if (webSitePublishPoint == null) {
webSitePublishPoint = EntityQuery.use(delegator).from("WebSitePublishPoint").where("contentId", contentId).queryOne();
// If no webSitePublishPoint exists, still try to look for parent by making a dummy value
if (webSitePublishPoint == null) {
webSitePublishPoint = delegator.makeValue("WebSitePublishPoint", UtilMisc.toMap("contentId", contentId));
}
webSitePublishPoint = overrideStaticValues(delegator, webSitePublishPoint);
cachedWebSitePublishPoints.put(contentId, webSitePublishPoint);
}
*/
return webSitePublishPoint;
}
@@ -490,14 +471,10 @@ public final class ContentManagementWorker {
// Set up one map with all the top-level publish points (to which only one sub point can be attached to)
// and another map (publishPointMapAll) that points to one of the top-level points.
List<GenericValue> allPublishPointList = getAllPublishPoints(delegator, rootPubId);
//if (Debug.infoOn()) Debug.logInfo("in getPublishLinks, allPublishPointList:" + allPublishPointList, module);
List<String []> publishPointList = getPermittedPublishPoints(delegator, allPublishPointList, userLogin, security , permittedAction, permittedOperations, passedRoles);
Map<String, Object> publishPointMap = new HashMap<String, Object>();
Map<String, Object> publishPointMapAll = new HashMap<String, Object>();
for (String [] arr : publishPointList) {
//GenericValue webSitePublishPoint = (GenericValue)it.next();
//String contentId = (String)webSitePublishPoint.get("contentId");
//String description = (String)webSitePublishPoint.get("description");
String contentId = arr[0];
String description = arr[1];
List<Object []> subPointList = new LinkedList<Object[]>();
@@ -507,9 +484,6 @@ public final class ContentManagementWorker {
publishPointMapAll.put(contentId, contentId);
List<GenericValue> subPublishPointList = getAllPublishPoints(delegator, contentId);
for (GenericValue webSitePublishPoint2 : subPublishPointList) {
//String [] arr2 = (String [])it2.next();
//String contentId2 = (String)arr2[0];
//String description2 = (String)arr2[1];
String contentId2 = (String)webSitePublishPoint2.get("contentId");
String description2 = (String)webSitePublishPoint2.get("templateTitle");
publishPointMapAll.put(contentId2, contentId);
@@ -518,7 +492,6 @@ public final class ContentManagementWorker {
subPointList.add(subArr2);
}
}
/* */
List<GenericValue> assocValueList = null;
try {
assocValueList = EntityQuery.use(delegator).from("ContentAssoc")
@@ -531,7 +504,6 @@ public final class ContentManagementWorker {
String contentIdTo = contentAssoc.getString("contentIdTo");
String topContentId = (String)publishPointMapAll.get(contentIdTo);
Object [] subArr = (Object [])publishPointMap.get(topContentId);
//if (Debug.infoOn()) Debug.logInfo("in getPublishLinks, subArr:" + Arrays.asList(subArr) , module);
if (contentIdTo.equals(topContentId)) {
subArr[3] = contentAssoc.get("fromDate");
} else {
@@ -563,8 +535,6 @@ public final class ContentManagementWorker {
try {
List<String> assocTypes = UtilMisc.toList("AUTHOR");
List<String> contentTypes = null;
// String fromDate = null;
// String thruDate = null;
Map<String, Object> results = ContentServicesComplex.getAssocAndContentAndDataResourceCacheMethod(delegator, contentId, null, "To", null, null, assocTypes, contentTypes, Boolean.TRUE, null, null);
List<GenericValue> valueList = UtilGenerics.checkList(results.get("entityList"));
if (valueList.size() > 0) {
@@ -572,7 +542,6 @@ public final class ContentManagementWorker {
authorContent = delegator.makeValue("Content");
authorContent.setPKFields(value);
authorContent.setNonPKFields(value);
//if (Debug.infoOn()) Debug.logInfo("in getAuthorContent, authorContent:" + authorContent, module);
}
} catch (GenericEntityException e) {
} catch (MiniLangException e2) {
@@ -601,7 +570,6 @@ public final class ContentManagementWorker {
targetOperationList = StringUtil.split(permittedOperations, "|");
}
Map<String, Object> results = null;
//if (Debug.infoOn()) Debug.logInfo("in getPermittedDepartmentPoints, content:" + content, module);
results = EntityPermissionChecker.checkPermission(content, statusId, userLogin, passedPurposes, targetOperationList, roles, delegator, security, entityAction);
String permissionStatus = (String)results.get("permissionStatus");
if (permissionStatus != null && permissionStatus.equalsIgnoreCase("granted")) {
@@ -121,7 +121,6 @@ In order ta make this service active add the following to the service definition
if (counterLine > 1) {
size = line.length();
String check = "\\", checkSubContent = ",", contentName = "", contentNameInprogress = "", data = line.substring(3, size);
//Debug.logInfo("======Data======"+data);
size = data.length();
for (int index = 0; index< size; index++) {//start character in line
@@ -178,7 +177,6 @@ In order ta make this service active add the following to the service definition
delegator.create(Entity);
hasFolder = false;
} else {
//Debug.logInfo("Content Name = [ " + contentId + "] already exist.");//ShoW log file
hasFolder = true;
}
//Relation Content
@@ -261,7 +259,6 @@ In order ta make this service active add the following to the service definition
boolean contentNameMatch = false;
if (subContents.charAt(index) == check.charAt(0)) {//store data
contentName = contentName + contentNameInprogress;
//Debug.logInfo("subcontentName---->"+contentName);
if (contentName.length()>100) {
contentName = contentName.substring(0,100);
}
@@ -286,7 +283,6 @@ In order ta make this service active add the following to the service definition
Map<String,Object> data = new HashMap<String, Object>();
data.put("userLogin", userLogin);
String dataResourceId = dispatcher.runSync("createDataResource", data).get("dataResourceId").toString();
//Debug.logInfo("==dataResourceId" + dataResourceId);
//create Content
contentId = delegator.getNextSeqId("Content");
@@ -348,7 +344,6 @@ In order ta make this service active add the following to the service definition
Map<String,Object> data = new HashMap<String, Object>();
data.put("userLogin", userLogin);
String dataResourceId = dispatcher.runSync("createDataResource",data).get("dataResourceId").toString();
//Debug.logInfo("==dataResourceId" + dataResourceId);
//create Content
contentId = delegator.getNextSeqId("Content");
@@ -266,10 +266,6 @@ public class CmsEvents {
response.setStatus(statusCode);
// 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);
try {
Writer writer = response.getWriter();
// TODO: replace "screen" to support dynamic rendering of different output
@@ -140,7 +140,6 @@ public class CompDocEvents {
public static String genCompDocPdf(HttpServletRequest request, HttpServletResponse response) {
String responseStr = "success";
//ByteBuffer byteBuffer = null;
HttpSession session = request.getSession();
GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");
ServletContext servletContext = session.getServletContext();
@@ -193,14 +192,6 @@ public class CompDocEvents {
ByteArrayInputStream bais = new ByteArrayInputStream(outByteBuffer.array());
/*
try {
FileOutputStream fos = new FileOutputStream(FileUtil.getFile("/home/byersa/pdftest.pdf"));
fos.write(outByteBuffer.getBytes());
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
*/
try {
UtilHttp.streamContentToBrowser(response, bais, outByteBuffer.limit(), contentType);
} catch (IOException e) {
@@ -211,7 +202,6 @@ public class CompDocEvents {
}
public static String genContentPdf(HttpServletRequest request, HttpServletResponse response) {
String responseStr = "success";
//ByteBuffer byteBuffer = null;
HttpSession session = request.getSession();
GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");
ServletContext servletContext = session.getServletContext();
@@ -264,15 +254,6 @@ public class CompDocEvents {
ByteArrayInputStream bais = new ByteArrayInputStream(outByteBuffer.array());
/*
try {
FileOutputStream fos = new FileOutputStream(FileUtil.getFile("/home/byersa/pdftest.pdf"));
fos.write(outByteBuffer.getBytes());
fos.close();
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
*/
try {
UtilHttp.streamContentToBrowser(response, bais, outByteBuffer.limit(), contentType);
} catch (IOException e) {
@@ -77,7 +77,6 @@ public class CompDocServices {
Locale locale = (Locale)context.get("locale");
GenericValue userLogin = (GenericValue)context.get("userLogin");
String contentId = (String)context.get("contentId");
//String instanceContentId = null;
if (UtilValidate.isNotEmpty(contentId)) {
try {
@@ -105,8 +104,6 @@ public class CompDocServices {
contentId = (String) persistContentResult.get("contentId");
result.putAll(persistContentResult);
//request.setAttribute("contentId", contentId);
// Update ContentRevision and ContentRevisonItem
Map<String, Object> contentRevisionMap = new HashMap<String, Object>();
contentRevisionMap.put("itemContentId", contentId);
@@ -160,14 +157,10 @@ public class CompDocServices {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Document document = new Document();
document.setPageSize(PageSize.LETTER);
//Rectangle rect = document.getPageSize();
//PdfWriter writer = PdfWriter.getInstance(document, baos);
PdfCopy writer = new PdfCopy(document, baos);
document.open();
int pgCnt = 0;
for (GenericValue contentAssocRevisionItemView : compDocParts) {
//String thisContentId = contentAssocRevisionItemView.getString("contentId");
//String thisContentRevisionSeqId = contentAssocRevisionItemView.getString("maxRevisionSeqId");
String thisDataResourceId = contentAssocRevisionItemView.getString("dataResourceId");
GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", thisDataResourceId).queryOne();
String inputMimeType = null;
@@ -250,7 +243,6 @@ public class CompDocServices {
int n = reader.getNumberOfPages();
for (int i=0; i < n; i++) {
PdfImportedPage pg = writer.getImportedPage(reader, i + 1);
//cb.addTemplate(pg, left, height * pgCnt);
writer.addPage(pg);
pgCnt++;
}
@@ -292,12 +284,8 @@ public class CompDocServices {
GenericValue userLogin = (GenericValue) context.get("userLogin");
try {
//Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
//ByteArrayOutputStream baos = new ByteArrayOutputStream();
Document document = new Document();
document.setPageSize(PageSize.LETTER);
//Rectangle rect = document.getPageSize();
//PdfCopy writer = new PdfCopy(document, baos);
document.open();
GenericValue dataResource = null;
@@ -53,7 +53,6 @@ public class ContentEvents {
* @return String specifying the exit status of this event
*/
public static String updateAllContentKeywords(HttpServletRequest request, HttpServletResponse response) {
//String errMsg = "";
Delegator delegator = (Delegator) request.getAttribute("delegator");
Security security = (Security) request.getAttribute("security");
@@ -98,7 +97,6 @@ public class ContentEvents {
try {
ContentKeywordIndex.indexKeywords(content, "Y".equals(doAll));
} catch (GenericEntityException e) {
//request.setAttribute("_ERROR_MESSAGE_", errMsg);
Debug.logWarning("[ContentEvents.updateAllContentKeywords] Could not create content-keyword (write error); message: " + e.getMessage(), module);
errConts++;
}
@@ -178,17 +178,6 @@ public class ContentKeywordIndex {
addWeightedKeywordSourceString(dataResource, "dataResourceName", strings);
addWeightedKeywordSourceString(dataResource, "objectInfo", strings);
}
/*List<GenericValue> contentDataResourceViews = EntityQuery.use(delegator).from("ContentDataResourceView").where("contentId", contentId).queryList();
for (GenericValue contentDataResourceView: contentDataResourceViews) {
int weight = 1;
addWeightedDataResourceString(contentDataResourceView, weight, strings, delegator, content);
List<GenericValue> alternateViews = contentDataResourceView.getRelated("ContentAssocDataResourceViewTo", UtilMisc.toMap("caContentAssocTypeId", "ALTERNATE_LOCALE"), UtilMisc.toList("-caFromDate"), false);
alternateViews = EntityUtil.filterByDate(alternateViews, UtilDateTime.nowTimestamp(), "caFromDate", "caThruDate", true);
for (GenericValue thisView: alternateViews) {
addWeightedDataResourceString(thisView, weight, strings, delegator, content);
}
}*/
if (UtilValidate.isNotEmpty(strings)) {
for (String str: strings) {
@@ -171,7 +171,6 @@ public class ContentMapFacade implements Map<Object, Object> {
}
public Set<Object> keySet() {
// Debug.logWarning("This method [keySet()] is not completely implemented in ContentMapFacade", module);
return UtilGenerics.checkSet(mapKeySet);
}
@@ -270,7 +269,6 @@ public class ContentMapFacade implements Map<Object, Object> {
}
}
String contextLink = rh.makeLink(request, response, contentUri, true, false, true);
// Debug.logInfo("Made link to content with ID [" + this.contentId + "]: " + contextLink, module);
return contextLink;
} else {
return this.contentId;
@@ -142,7 +142,6 @@ public class ContentPermissionServices {
// so I had to write this code to handle both list and strings
List<String> passedPurposes = UtilGenerics.checkList(context.get("contentPurposeList"));
String contentPurposeString = (String) context.get("contentPurposeString");
//Debug.logInfo("contentPurposeString(b):" + contentPurposeString, "");
if (UtilValidate.isNotEmpty(contentPurposeString)) {
List<String> purposesFromString = StringUtil.split(contentPurposeString, "|");
if (passedPurposes == null) {
@@ -155,11 +154,8 @@ public class ContentPermissionServices {
// 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<String> targetOperations = UtilGenerics.checkList(context.get("targetOperationList"));
//Debug.logInfo("targetOperations(b):" + targetOperations, "");
String targetOperationString = (String) context.get("targetOperationString");
//Debug.logInfo("targetOperationString(b):" + targetOperationString, "");
if (UtilValidate.isNotEmpty(targetOperationString)) {
List<String> operationsFromString = StringUtil.split(targetOperationString, "|");
if (targetOperations == null) {
@@ -167,12 +163,10 @@ public class ContentPermissionServices {
}
targetOperations.addAll(operationsFromString);
}
//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<String> passedRoles = UtilGenerics.checkList(context.get("roleTypeList"));
if (passedRoles == null) passedRoles = new LinkedList<String>();
String roleTypeString = (String) context.get("roleTypeString");
@@ -287,9 +281,6 @@ public class ContentPermissionServices {
"ContentContentToOrFromIsNull",
UtilMisc.toMap("contentTo", contentTo, "contentFrom", contentFrom), locale));
}
// boolean isMatch = false;
// boolean isMatchTo = false;
// boolean isMatchFrom = false;
Map<String, Object> permResults = new HashMap<String, Object>();
// Use the purposes from the from entity for both cases.
@@ -284,8 +284,6 @@ public class ContentSearch {
dynamicViewEntity.addAlias("CNT", "contentId", null, null, null, Boolean.valueOf(contentIdGroupBy), null);
EntityCondition whereCondition = EntityCondition.makeCondition(entityConditionList, EntityOperator.AND);
// Debug.logInfo("ContentSearch, whereCondition = " + whereCondition.toString(), module);
EntityListIterator eli = null;
try {
eli = EntityQuery.use(delegator)
@@ -313,19 +311,6 @@ public class ContentSearch {
try {
boolean hasResults = false;
Object initialResult = null;
/* this method has been replaced by the following to address issue with SAP DB and possibly other DBs
if (resultOffset != null) {
Debug.logInfo("Before relative, current index=" + eli.currentIndex(), module);
hasResults = eli.relative(resultOffset.intValue());
} else {
initialResult = eli.next();
if (initialResult != null) {
hasResults = true;
}
}
*/
initialResult = eli.next();
if (initialResult != null) {
hasResults = true;
@@ -375,21 +360,6 @@ public class ContentSearch {
} else {
duplicatesFound++;
}
/*
StringBuilder lineMsg = new StringBuilder("Got search result line: ");
Iterator<String> fieldsToSelectIter = fieldsToSelect.iterator();
while (fieldsToSelectIter.hasNext()) {
String fieldName = fieldsToSelectIter.next();
lineMsg.append(fieldName);
lineMsg.append("=");
lineMsg.append(searchResult.get(fieldName));
if (fieldsToSelectIter.hasNext()) {
lineMsg.append(", ");
}
}
Debug.logInfo(lineMsg.toString(), module);
*/
}
if (searchResult != null) {
@@ -228,16 +228,6 @@ public class ContentServices {
* reflection performance penalty.
*/
public static Map<String, Object> createContent(DispatchContext dctx, Map<String, ? extends Object> context) {
/*
context.put("entityOperation", "_CREATE");
List targetOperationList = ContentWorker.prepTargetOperationList(context, "_CREATE");
List contentPurposeList = ContentWorker.prepContentPurposeList(context);
context.put("targetOperationList", targetOperationList);
context.put("contentPurposeList", contentPurposeList); // for checking permissions
//context.put("skipPermissionCheck", null);
*/
Map<String, Object> result = createContentMethod(dctx, context);
return result;
}
@@ -261,7 +251,6 @@ public class ContentServices {
Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
String contentId = (String) context.get("contentId");
//String contentTypeId = (String) context.get("contentTypeId");
if (UtilValidate.isEmpty(contentId)) {
contentId = delegator.getNextSeqId("Content");
@@ -386,31 +375,6 @@ public class ContentServices {
contentIdFrom = contentId;
}
/*
String deactivateExisting = (String) context.get("deactivateExisting");
if (deactivateExisting != null && deactivateExisting.equalsIgnoreCase("true")) {
Map andMap = new HashMap<String, Object>();
andMap.put("contentIdTo", contentIdTo);
andMap.put("contentAssocTypeId", context.get("contentAssocTypeId"));
String mapKey = (String) context.get("mapKey");
if (UtilValidate.isNotEmpty(mapKey)) {
andMap.put("mapKey", mapKey);
}
if (Debug.infoOn()) Debug.logInfo("DEACTIVATING CONTENTASSOC andMap: " + andMap, null);
List assocList = EntityQuery.use(delegator).from("ContentAssoc").where(andMap).queryList();
Iterator iter = assocList.iterator();
while (iter.hasNext()) {
GenericValue val = (GenericValue) iter.next();
if (Debug.infoOn()) Debug.logInfo("DEACTIVATING CONTENTASSOC val: " + val, null);
val.set("thruDate", UtilDateTime.nowTimestamp());
val.store();
}
}
*/
GenericValue contentAssoc = delegator.makeValue("ContentAssoc");
contentAssoc.put("contentId", contentIdFrom);
contentAssoc.put("contentIdTo", contentIdTo);
@@ -492,8 +456,6 @@ public class ContentServices {
result.put("contentIdFrom", contentIdFrom);
result.put("fromDate", contentAssoc.get("fromDate"));
result.put("contentAssocTypeId", contentAssoc.get("contentAssocTypeId"));
//Debug.logInfo("result:" + result, module);
//Debug.logInfo("contentAssoc:" + contentAssoc, module);
return result;
}
@@ -731,15 +693,9 @@ public class ContentServices {
GenericValue pk = delegator.makeValue("ContentAssoc");
pk.setAllFields(context, false, null, Boolean.TRUE);
pk.setAllFields(context, false, "ca", Boolean.TRUE);
//String contentIdFrom = (String) context.get("contentId");
//String contentIdTo = (String) context.get("contentIdTo");
//String contentId = (String) context.get("contentId");
//String contentAssocTypeId = (String) context.get("contentAssocTypeId");
//Timestamp fromDate = (Timestamp) context.get("fromDate");
GenericValue contentAssoc = null;
try {
//contentAssoc = EntityQuery.use(delegator).from("ContentAssoc").where("contentId", contentId, "contentIdTo", contentIdTo, "contentAssocTypeId", contentAssocTypeId, "fromDate", fromDate).queryOne();
contentAssoc = EntityQuery.use(delegator).from("ContentAssoc").where(pk).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, "Entity Error:" + e.getMessage(), module);
@@ -837,12 +793,10 @@ public class ContentServices {
List<GenericValue> relatedAssocs = EntityQuery.use(delegator).from("ContentAssoc")
.where(assocExprList)
.orderBy("fromDate").filterByDate().queryList();
//if (Debug.infoOn()) Debug.logInfo("in deactivateAssocs, relatedAssocs:" + relatedAssocs, module);
for (GenericValue val : relatedAssocs) {
val.set("thruDate", nowTimestamp);
val.store();
//if (Debug.infoOn()) Debug.logInfo("in deactivateAssocs, val:" + val, module);
}
results.put("deactivatedList", relatedAssocs);
} catch (GenericEntityException e) {
@@ -863,8 +817,6 @@ public class ContentServices {
Map<String,Object> templateContext = UtilGenerics.checkMap(context.get("templateContext"));
String contentId = (String) context.get("contentId");
// Timestamp fromDate = (Timestamp) context.get("fromDate");
// GenericValue userLogin = (GenericValue) context.get("userLogin");
if (templateContext != null && UtilValidate.isEmpty(contentId)) {
contentId = (String) templateContext.get("contentId");
@@ -873,10 +825,6 @@ public class ContentServices {
if (templateContext != null && UtilValidate.isEmpty(mapKey)) {
mapKey = (String) templateContext.get("mapKey");
}
//String subContentId = (String) context.get("subContentId");
//if (templateContext != null && UtilValidate.isEmpty(subContentId)) {
//subContentId = (String) templateContext.get("subContentId");
//}
String mimeTypeId = (String) context.get("mimeTypeId");
if (templateContext != null && UtilValidate.isEmpty(mimeTypeId)) {
mimeTypeId = (String) templateContext.get("mimeTypeId");
@@ -924,7 +872,6 @@ public class ContentServices {
Writer out = (Writer) context.get("outWriter");
Map<String,Object> templateContext = UtilGenerics.checkMap(context.get("templateContext"));
//GenericValue userLogin = (GenericValue)context.get("userLogin");
String contentId = (String) context.get("contentId");
if (templateContext != null && UtilValidate.isEmpty(contentId)) {
contentId = (String) templateContext.get("contentId");
@@ -997,12 +944,6 @@ public class ContentServices {
if (Debug.infoOn()) Debug.logInfo("in publishContent, statusId:" + statusId + " contentStatusId:" + contentStatusId + " privilegeEnumId:" + privilegeEnumId + " contentPrivilegeEnumId:" + contentPrivilegeEnumId, module);
// Don't do anything if link was already there
if (!isPublished) {
//Map thisResults = dispatcher.runSync("deactivateAssocs", mapIn);
//String errorMsg = ServiceUtil.getErrorMessage(thisResults);
//if (UtilValidate.isNotEmpty(errorMsg)) {
//Debug.logError("Problem running deactivateAssocs. " + errorMsg, "ContentServices");
//return ServiceUtil.returnError(errorMsg);
//}
content.put("privilegeEnumId", privilegeEnumId);
content.put("statusId", statusId);
content.store();
@@ -1066,7 +1007,6 @@ public class ContentServices {
for (Map.Entry<String, Object> entry : entrySet) {
String key = entry.getKey();
if (key.startsWith(prefix)) {
// String keyBase = key.substring(prefix.length());
Object value = entry.getValue();
mapOut.put(key, value);
}
@@ -74,7 +74,6 @@ public class ContentServicesComplex {
String contentId = (String)context.get("contentId");
String direction = (String)context.get("direction");
String mapKey = (String)context.get("mapKey");
// Boolean nullThruDatesOnly = (Boolean)context.get("nullThruDatesOnly");
Map<String, Object> results = getAssocAndContentAndDataResourceMethod(delegator, contentId, mapKey, direction, fromDate, thruDate, fromDateStr, thruDateStr, assocTypes, contentTypes);
return results;
}
@@ -115,7 +114,6 @@ public class ContentServicesComplex {
}
if (thruDate != null) {
List<EntityExpr> thruList = new LinkedList<EntityExpr>();
//thruDate = UtilDateTime.getDayStart(thruDate, daysLater);
EntityExpr thruExpr = EntityCondition.makeCondition("caThruDate", EntityOperator.LESS_THAN, thruDate);
thruList.add(thruExpr);
@@ -386,7 +386,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
.orderBy("-fromDate").cache(cache).filterByDate().queryFirst();
if (subContent == null) {
//throw new GeneralException("No sub-content found with map-key [" + mapKey + "] for content [" + contentId + "]");
Debug.logWarning("No sub-content found with map-key [" + mapKey + "] for content [" + contentId + "]", module);
} else {
String subContentId = subContent.getString("contentIdTo");
@@ -455,7 +454,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
}
public static void traverse(Delegator delegator, GenericValue content, Timestamp fromDate, Timestamp thruDate, Map<String, Object> whenMap, int depthIdx, Map<String, Object> masterNode, String contentAssocTypeId, List<GenericValue> pickList, String direction) {
//String startContentAssocTypeId = null;
String contentTypeId = null;
String contentId = null;
try {
@@ -488,7 +486,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
Map<String, Object> context = new HashMap<String, Object>();
context.put("content", content);
context.put("contentAssocTypeId", contentAssocTypeId);
//context.put("related", related);
context.put("purposes", purposes);
context.put("topics", topics);
context.put("keywords", keywords);
@@ -521,7 +518,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
for (GenericValue assocValue : relatedAssocs) {
contentAssocTypeId = (String) assocValue.get("contentAssocTypeId");
assocContext.put("contentAssocTypeId", contentAssocTypeId);
//assocContext.put("contentTypeId", assocValue.get("contentTypeId"));
assocContext.put("parentContent", content);
String assocRelation = null;
// This needs to be the opposite
@@ -611,7 +607,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
idx++;
continue;
}
// String contentAssocTypeId = (String)currentNode.get("contentAssocTypeId");
nodeTrail.add(currentNode);
ContentWorker.traceNodeTrail("16",nodeTrail);
Boolean isPick = (Boolean)currentNode.get("isPick");
@@ -690,7 +685,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
String contentTypeId = (String) ctx.get("contentTypeId");
String mapKey = (String) ctx.get("mapKey");
String parentContentId = (String) parentContent.get("contentId");
//if (Debug.infoOn()) Debug.logInfo("traverse, contentAssocTypeId:" + contentAssocTypeId,null);
Map<String, Object> whenMap = UtilGenerics.checkMap(ctx.get("whenMap"));
List<Map<String, Object>> kids = new LinkedList<Map<String,Object>>();
currentNode.put("kids", kids);
@@ -698,8 +692,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
if (UtilValidate.isEmpty(direction)) {
direction = "From";
}
// Timestamp fromDate = (Timestamp) ctx.get("fromDate");
// Timestamp thruDate = (Timestamp) ctx.get("thruDate");
List<String> assocTypeList = StringUtil.split(contentAssocTypeId, " ");
List<String> contentTypeList = StringUtil.split(contentTypeId, " ");
@@ -714,13 +706,9 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
throw new RuntimeException(e2.getMessage());
}
List<GenericValue> relatedViews = UtilGenerics.checkList(results.get("entityList"));
//if (Debug.infoOn()) Debug.logInfo("traverse, relatedViews:" + relatedViews,null);
for (GenericValue assocValue : relatedViews) {
Map<String, Object> thisNode = ContentWorker.makeNode(assocValue);
checkConditions(delegator, thisNode, null, whenMap);
// boolean isReturnBeforePick = booleanDataType(thisNode.get("isReturnBeforePick"));
// boolean isReturnAfterPick = booleanDataType(thisNode.get("isReturnAfterPick"));
// boolean isFollow = booleanDataType(thisNode.get("isFollow"));
boolean isPick = booleanDataType(thisNode.get("isPick"));
kids.add(thisNode);
if (isPick) {
@@ -848,7 +836,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
thruDate = UtilDateTime.toTimestamp(strThruDate);
}
List<GenericValue> assocs = getContentAssocsWithId(delegator, origContentId, fromDate, thruDate, linkDir, assocTypes);
//if (Debug.infoOn()) Debug.logInfo(" origContentId:" + origContentId + " linkDir:" + linkDir + " assocTypes:" + assocTypes, "");
return assocs;
}
@@ -870,7 +857,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
}
if (thruDate != null) {
List<EntityExpr> thruList = new LinkedList<EntityExpr>();
//thruDate = UtilDateTime.getDayStart(thruDate, daysLater);
EntityExpr thruExpr = EntityCondition.makeCondition("thruDate", EntityOperator.LESS_THAN, thruDate);
thruList.add(thruExpr);
@@ -1003,7 +989,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
contentIdOtherField = "contentId";
}
//if (Debug.infoOn()) Debug.logInfo("getContentAncestry, contentId:" + contentId, "");
try {
GenericValue contentAssoc = EntityQuery.use(delegator).from("ContentAssoc")
.where(contentIdField, contentId, "contentAssocTypeId", contentAssocTypeId)
@@ -1067,7 +1052,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
}
public static GenericValue getSubContent(Delegator delegator, String contentId, String mapKey, String subContentId, GenericValue userLogin, List<String> assocTypes, Timestamp fromDate) throws IOException {
//GenericValue content = null;
GenericValue view = null;
try {
if (subContentId == null) {
@@ -1096,7 +1080,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
}
public static GenericValue getSubContentCache(Delegator delegator, String contentId, String mapKey, String subContentId, GenericValue userLogin, List<String> assocTypes, Timestamp fromDate, Boolean nullThruDatesOnly, String contentAssocPredicateId) throws GenericEntityException {
//GenericValue content = null;
GenericValue view = null;
if (UtilValidate.isEmpty(subContentId)) {
view = getSubContentCache(delegator, contentId, mapKey, userLogin, assocTypes, fromDate, nullThruDatesOnly, contentAssocPredicateId);
@@ -1107,7 +1090,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
}
public static GenericValue getSubContentCache(Delegator delegator, String contentId, String mapKey, GenericValue userLogin, List<String> assocTypes, Timestamp fromDate, Boolean nullThruDatesOnly, String contentAssocPredicateId) throws GenericEntityException {
//GenericValue content = null;
GenericValue view = null;
if (contentId == null) {
Debug.logError("ContentId is null", module);
@@ -1151,7 +1133,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
} else {
passedGlobalNodeTrail = new LinkedList<Map<String,Object>>();
}
//if (Debug.infoOn()) Debug.logInfo("in getCurrentContent, passedGlobalNodeTrail(3):" + passedGlobalNodeTrail , module);
int sz = passedGlobalNodeTrail.size();
if (sz > 0) {
Map<String, Object> nd = passedGlobalNodeTrail.get(sz - 1);
@@ -1161,10 +1142,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
viewContentId = (String)currentContent.get("contentId");
}
//if (Debug.infoOn()) Debug.logInfo("in getCurrentContent, currentContent(3):" + currentContent , module);
//if (Debug.infoOn()) Debug.logInfo("getCurrentContent, contentId:" + contentId, "");
//if (Debug.infoOn()) Debug.logInfo("getCurrentContent, subContentId:" + subContentId, "");
//if (Debug.infoOn()) Debug.logInfo("getCurrentContent, viewContentId:" + viewContentId, "");
if (UtilValidate.isNotEmpty(subContentId)) {
ctx.put("subContentId", subContentId);
ctx.put("contentId", null);
@@ -1178,7 +1155,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
return currentContent;
}
}
//if (Debug.infoOn()) Debug.logInfo("getCurrentContent(2), contentId:" + contentId + " viewContentId:" + viewContentId + " subContentId:" + subContentId, "");
if (UtilValidate.isNotEmpty(contentId) || UtilValidate.isNotEmpty(subContentId)) {
try {
currentContent = ContentWorker.getSubContentCache(delegator, contentId, mapKey, subContentId, userLogin, assocTypes, fromDate, nullThruDatesOnly, contentAssocPredicateId);
@@ -1190,7 +1166,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
}
ctx.put("globalNodeTrail", passedGlobalNodeTrail);
ctx.put("indent", Integer.valueOf(sz));
//if (Debug.infoOn()) Debug.logInfo("getCurrentContent, currentContent:" + currentContent, "");
return currentContent;
}
@@ -1236,14 +1211,12 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
ctx.put("sections", sections);
List<Object> topics = getTopics(thisContent);
ctx.put("topics", topics);
//Debug.logInfo("buildPickContext, ctx:" + ctx, "");
return ctx;
}
public static void checkConditions(Delegator delegator, Map<String, Object> trailNode, Map<String, Object> contentAssoc, Map<String, Object> whenMap) {
Map<String, Object> context = new HashMap<String, Object>();
GenericValue content = (GenericValue)trailNode.get("value");
// String contentId = (String)trailNode.get("contentId");
if (contentAssoc == null && content != null && (content.getEntityName().indexOf("Assoc") >= 0)) {
contentAssoc = delegator.makeValue("ContentAssoc");
try {
@@ -1254,7 +1227,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
context.put("mapKey", contentAssoc.get("mapKey"));
} catch (MiniLangException e) {
Debug.logError(e.getMessage(), module);
//throw new GeneralException(e.getMessage());
}
} else {
context.put("contentAssocTypeId", null);
@@ -1356,7 +1328,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
Debug.logInfo("recorder(0):" + recorder, "");
if (recorder != null && recorder.isOn()) {
String permissionMessage = recorder.toHtml();
//Debug.logInfo("permissionMessage(0):" + permissionMessage, "");
errorMessage += " \n " + permissionMessage;
}
return errorMessage;
@@ -1512,7 +1483,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
}
} catch (GenericEntityException e) {
Debug.logError(e.getMessage(), module);
//throw new GeneralException(e.getMessage());
}
}
}
@@ -1658,32 +1628,6 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
}
public static void traceNodeTrail(String lbl, List<Map<String, Object>> nodeTrail) {
/*
if (!Debug.verboseOn()) {
return;
}
if (nodeTrail == null) {
return;
}
String s = "";
int sz = nodeTrail.size();
s = "nTsz:" + sz;
if (sz > 0) {
Map cN = (Map)nodeTrail.get(sz - 1);
if (cN != null) {
String cid = (String)cN.get("contentId");
s += " cN[" + cid + "]";
List kids = (List)cN.get("kids");
int kSz = (kids == null) ? 0 : kids.size();
s += " kSz:" + kSz;
Boolean isPick = (Boolean)cN.get("isPick");
s += " isPick:" + isPick;
Boolean isFollow = (Boolean)cN.get("isFollow");
s += " isFollow:" + isFollow;
Boolean isReturnAfterPick = (Boolean)cN.get("isReturnAfterPick");
s += " isReturnAfterPick:" + isReturnAfterPick;
}
}
*/
}
}
@@ -161,27 +161,19 @@ public class PermissionRecorder {
permCheckResults.add(currentContentMap);
String s = null;
if (targetOperations != null) {
//if (Debug.infoOn()) Debug.logInfo("startMatchGroup, targetOperations:" + targetOperations, module);
s = targetOperations.toString();
//if (Debug.infoOn()) Debug.logInfo("startMatchGroup, targetOperations(string):" + s, module);
currentContentMap.put("contentOperationId", s);
}
if (purposes != null) {
//if (Debug.infoOn()) Debug.logInfo("startMatchGroup, purposes:" + purposes, module);
s = purposes.toString();
//if (Debug.infoOn()) Debug.logInfo("startMatchGroup, purposes(string):" + s, module);
currentContentMap.put("contentPurposeTypeId", s);
}
if (roles != null) {
//if (Debug.infoOn()) Debug.logInfo("startMatchGroup, roles:" + roles, module);
s = roles.toString();
//if (Debug.infoOn()) Debug.logInfo("startMatchGroup, roles(string):" + s, module);
currentContentMap.put("roleTypeId", s);
}
if (targStatusList != null) {
//if (Debug.infoOn()) Debug.logInfo("startMatchGroup, targStatusList:" + targStatusList, module);
s = targStatusList.toString();
//if (Debug.infoOn()) Debug.logInfo("startMatchGroup, targStatusList(string):" + s, module);
currentContentMap.put("statusId", s);
}
List<Map<String, Object>> checkResultList = new LinkedList<Map<String,Object>>();
@@ -190,7 +182,6 @@ public class PermissionRecorder {
currentContentMap.put("checkResultList", checkResultList);
currentContentMap.put("matches", null);
currentContentId = contentId;
//if (Debug.infoOn()) Debug.logInfo("startMatchGroup, currentContentMap:" + currentContentMap, module);
}
public void record(GenericValue purposeOp, boolean targetOpCond, boolean purposeCond, boolean statusCond, boolean privilegeCond, boolean roleCond) {
@@ -203,7 +194,6 @@ public class PermissionRecorder {
map.put("contentId", currentContentId);
List<Map<String, Object>> checkResultList = UtilGenerics.checkList(currentContentMap.get("checkResultList"));
checkResultList.add(map);
//if (Debug.infoOn()) Debug.logInfo("record, map:" + map, module);
}
public String toHtml() {
@@ -215,7 +205,6 @@ public class PermissionRecorder {
sb.append(".headr {background-color:white; font-weight:bold; font-family:Verdana,Arial,sans-serif; font-size:12px; }");
sb.append("</style>");
//if (Debug.infoOn()) Debug.logInfo("toHtml, style:" + sb.toString(), module);
sb.append("<table border=\"1\" >");
// Do header row
sb.append("<tr>");
@@ -224,7 +213,6 @@ public class PermissionRecorder {
sb.append("Content Id");
sb.append("</td>");
//if (Debug.infoOn()) Debug.logInfo("renderResultRowHtml, (1):" + sb.toString(), module);
for (int i=0; i < fieldTitles.length; i++) {
String opField = fieldTitles[i];
sb.append("<td class=\"headr\">");
@@ -245,14 +233,12 @@ public class PermissionRecorder {
StringBuilder sb = new StringBuilder();
List<Map<String, Object>> resultList = UtilGenerics.checkList(cMap.get("checkResultList"));
for (Map<String, Object> rMap : resultList) {
//if (Debug.infoOn()) Debug.logInfo("renderCCMapHtml, (1):" + rMap, module);
sb.append(renderResultRowHtml(rMap, cMap));
}
return sb.toString();
}
//public static final String [] opFields = { "contentPurposeTypeId", "contentOperationId", "roleTypeId", "statusId", "privilegeEnumId"};
public String renderResultRowHtml(Map<String, Object> rMap, Map<String, Object> currentContentResultMap) {
StringBuilder sb = new StringBuilder();
@@ -281,7 +267,6 @@ public class PermissionRecorder {
sb.append("<td class=\"target\" >&nbsp;</td>");
sb.append("</tr>");
//if (Debug.infoOn()) Debug.logInfo("renderResultRowHtml, (2):" + sb.toString(), module);
// Do UUT row
sb.append("<tr>");
@@ -297,16 +282,13 @@ public class PermissionRecorder {
if (!bool.booleanValue())
isPass = false;
sb.append("<td class=\"" + cls + "\">");
//if (Debug.infoOn()) Debug.logInfo("renderResultRowHtml, (2b):" + sb.toString(), module);
s = (String)rMap.get(opField);
//if (Debug.infoOn()) Debug.logInfo("renderResultRowHtml, (s):" + s, module);
sb.append(s);
sb.append("</td>");
}
String passFailCls = (isPass) ? "pass" : "fail";
sb.append("<td class=\"" + passFailCls +"\">" + passFailCls.toUpperCase() + "</td>");
sb.append("</tr>");
//if (Debug.infoOn()) Debug.logInfo("renderResultRowHtml, (3):" + sb.toString(), module);
return sb.toString();
}
@@ -85,7 +85,6 @@ public class UploadContentAndImage {
Debug.logError("[UploadContentAndImage.uploadContentAndImage] " + e4.getMessage(), module);
return "error";
}
//if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]lst " + lst, module);
if (lst.size() == 0) {
String errMsg = UtilProperties.getMessage(UploadContentAndImage.err_resource, "uploadContentAndImage.no_files_uploaded", locale);
@@ -100,7 +99,6 @@ public class UploadContentAndImage {
byte[] imageBytes = {};
for (int i = 0; i < lst.size(); i++) {
fi = lst.get(i);
//String fn = fi.getName();
String fieldName = fi.getFieldName();
if (fi.isFormField()) {
String fieldStr = fi.getString();
@@ -138,7 +136,6 @@ public class UploadContentAndImage {
ftlContext.put("description", passedParams.get("description"));
ftlContext.put("privilegeEnumId", passedParams.get("privilegeEnumId"));
String drid = (String)passedParams.get("dataResourceId");
//if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]drid:" + drid, module);
ftlContext.put("dataResourceId", drid);
ftlContext.put("dataResourceTypeId", null); // inhibits persistence of DataResource, because it already exists
String contentIdTo = (String)passedParams.get("contentIdTo");
@@ -194,7 +191,6 @@ public class UploadContentAndImage {
String ftlDataResourceId = drid;
if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]ftlContentId:" + ftlContentId, module);
//if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]ftlDataResourceId:" + ftlDataResourceId, module);
// Create or update summary text subContent
if (passedParams.containsKey("summaryData")) {
Map<String, Object> sumContext = new HashMap<String, Object>();
@@ -204,7 +200,6 @@ public class UploadContentAndImage {
sumContext.put("contentTypeId", "DOCUMENT");
sumContext.put("statusId", passedParams.get("statusId"));
sumContext.put("contentPurposeList", UtilMisc.toList("SUMMARY"));
//sumContext.put("contentPurposeList", contentPurposeList);
sumContext.put("targetOperationList",targetOperationList);
sumContext.put("contentName", passedParams.get("contentName"));
sumContext.put("description", passedParams.get("description"));
@@ -233,7 +228,6 @@ public class UploadContentAndImage {
txtContext.put("ownerContentId", ftlContentId);
txtContext.put("contentTypeId", "DOCUMENT");
txtContext.put("statusId", passedParams.get("statusId"));
//txtContext.put("contentPurposeList", contentPurposeList);
txtContext.put("contentPurposeList", UtilMisc.toList("MAIN_ARTICLE"));
txtContext.put("targetOperationList",targetOperationList);
txtContext.put("contentName", passedParams.get("contentName"));
@@ -269,9 +263,6 @@ public class UploadContentAndImage {
imgContext.put("privilegeEnumId", passedParams.get("privilegeEnumId"));
imgContext.put("targetOperationList",targetOperationList);
imgContext.put("dataResourceId", passedParams.get("imgDataResourceId"));
//String dataResourceTypeId = (String)passedParams.get("dataResourceTypeId");
//if (UtilValidate.isEmpty(dataResourceTypeId))
//dataResourceTypeId = "IMAGE_OBJECT";
String dataResourceTypeId = "IMAGE_OBJECT";
imgContext.put("dataResourceTypeId", dataResourceTypeId);
imgContext.put("contentIdTo", ftlContentId);
@@ -279,7 +270,6 @@ public class UploadContentAndImage {
imgContext.put("imageData", imageBytes);
imgContext.put("mapKey", "IMAGE");
imgContext.put("dataTemplateTypeId", "NONE");
// String rootDir = request.getSession().getServletContext().getRealPath("/");
imgContext.put("rootDir", "rootDir");
if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]imgContext " + imgContext, module);
Map<String, Object> imgResults = dispatcher.runSync("persistContentAndAssoc", imgContext);
@@ -298,7 +288,6 @@ public class UploadContentAndImage {
long currentAuthorAssocCount = EntityQuery.use(delegator).from("ContentAssoc")
.where("contentId", ftlContentId, "contentIdTo", userLoginId, "contentAssocTypeId", "AUTHOR")
.filterByDate().queryCount();
//if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]currentAuthorAssocList " + currentAuthorAssocList, module);
if (currentAuthorAssocCount == 0) {
// Don't want to bother with permission checking on this association
GenericValue authorAssoc = delegator.makeValue("ContentAssoc");
@@ -322,7 +311,6 @@ public class UploadContentAndImage {
String newTrail = passedParams.get("nodeTrailCsv") + "," + ftlContentId;
request.setAttribute("nodeTrailCsv", newTrail);
request.setAttribute("passedParams", passedParams);
//if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]newTrail: " + newTrail, module);
TransactionUtil.commit();
} catch (Exception e) {
Debug.logError(e, "[UploadContentAndImage] " , module);
@@ -344,7 +332,6 @@ public class UploadContentAndImage {
GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");
ServletFileUpload dfu = new ServletFileUpload(new DiskFileItemFactory(10240, FileUtil.getFile("runtime/tmp")));
//if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]DiskFileUpload " + dfu, module);
List<FileItem> lst = null;
try {
lst = UtilGenerics.checkList(dfu.parseRequest(request));
@@ -353,7 +340,6 @@ public class UploadContentAndImage {
Debug.logError("[UploadContentAndImage.uploadContentAndImage] " + e4.getMessage(), module);
return "error";
}
//if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]lst " + lst, module);
if (lst.size() == 0) {
request.setAttribute("_ERROR_MESSAGE_", "No files uploaded");
@@ -368,7 +354,6 @@ public class UploadContentAndImage {
passedParams.put("userLogin", userLogin);
for (int i = 0; i < lst.size(); i++) {
fi = lst.get(i);
//String fn = fi.getName();
String fieldName = fi.getFieldName();
if (fi.isFormField()) {
String fieldStr = fi.getString();
@@ -491,9 +476,6 @@ public class UploadContentAndImage {
ftlContext.put("textData", passedParams.get("textData" + suffix));
byte[] bytes = (byte[])passedParams.get("imageData" + suffix);
ftlContext.put("imageData", bytes);
//if (Debug.infoOn()) Debug.logInfo("[UploadContentStuff]byteBuffer:" + bytes, module);
//contentAssocDataResourceViewFrom.setAllFields(ftlContext2, true, null, null);
//ftlContext.putAll(ftlContext2);
if (Debug.infoOn()) {
Debug.logInfo("[UploadContentStuff]ftlContext:" + ftlContext, module);
}
@@ -186,9 +186,6 @@ public class DataResourceWorker implements org.apache.ofbiz.widget.content.Data
*/
// TODO: This method is not used and should be removed. amb
public static String uploadAndStoreImage(HttpServletRequest request, String idField, String uploadField) {
//Delegator delegator = (Delegator) request.getAttribute("delegator");
//String idFieldValue = null;
ServletFileUpload fu = new ServletFileUpload(new DiskFileItemFactory(10240, FileUtil.getFile("runtime/tmp")));
List<FileItem> lst = null;
Locale locale = UtilHttp.getLocale(request);
@@ -218,7 +215,6 @@ public class DataResourceWorker implements org.apache.ofbiz.widget.content.Data
byte[] imageBytes = null;
for (int i = 0; i < lst.size(); i++) {
fi = lst.get(i);
//String fn = fi.getName();
String fieldName = fi.getFieldName();
if (fi.isFormField()) {
String fieldStr = fi.getString();
@@ -342,7 +338,6 @@ public class DataResourceWorker implements org.apache.ofbiz.widget.content.Data
String dataResourceId = dataResource.getString("dataResourceId");
GenericValue imageDataResource = EntityQuery.use(delegator).from("ImageDataResource").where("dataResourceId", dataResourceId).queryOne();
if (imageDataResource != null) {
//b = (byte[]) imageDataResource.get("imageData");
b = imageDataResource.getBytes("imageData");
}
return b;
@@ -454,10 +449,8 @@ public class DataResourceWorker implements org.apache.ofbiz.widget.content.Data
String mimeType = null;
if (view != null)
mimeType = view.getString("drMimeTypeId");
//if (Debug.infoOn()) Debug.logInfo("getDataResourceMimeType, mimeType(2):" + mimeType, "");
if (UtilValidate.isEmpty(mimeType) && UtilValidate.isNotEmpty(dataResourceId)) {
GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).cache().queryOne();
//if (Debug.infoOn()) Debug.logInfo("getDataResourceMimeType, dataResource(2):" + dataResource, "");
mimeType = dataResource.getString("mimeTypeId");
}
@@ -953,7 +946,6 @@ public class DataResourceWorker implements org.apache.ofbiz.widget.content.Data
Debug.logError(" in renderDataResourceAsHtml(CONTEXT_FILE), got exception:" + e.getMessage(), module);
}
UtilIO.copy(in, true, out);
//out.flush();
}
}
@@ -293,7 +293,6 @@ public class DataServices {
* A service wrapper for the updateDataResourceMethod method. Forces permissions to be checked.
*/
public static Map<String, Object> updateDataResource(DispatchContext dctx, Map<String, ? extends Object> context) {
//context.put("skipPermissionCheck", null);
Map<String, Object> result = updateDataResourceMethod(dctx, context);
return result;
}
@@ -398,9 +397,7 @@ public class DataServices {
public static Map<String, Object> updateFileMethod(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = new HashMap<String, Object>();
//GenericValue fileText = null;
Locale locale = (Locale) context.get("locale");
//String dataResourceId = (String) dataResource.get("dataResourceId");
String dataResourceTypeId = (String) context.get("dataResourceTypeId");
String objectInfo = (String) context.get("objectInfo");
String textData = (String) context.get("textData");
@@ -490,7 +487,6 @@ public class DataServices {
templateContext = new HashMap<String, Object>();
}
// GenericValue view = (GenericValue) context.get("subContentDataResourceView");
Writer outWriter = new StringWriter();
DataResourceWorker.renderDataResourceAsText(delegator, dataResourceId, outWriter, templateContext, locale, mimeTypeId, true);
try {
@@ -555,7 +551,6 @@ public class DataServices {
byte[] imageBytes = byteBuffer.array();
try {
GenericValue imageDataResource = delegator.makeValue("ImageDataResource", UtilMisc.toMap("dataResourceId", dataResourceId));
//imageDataResource.set("imageData", imageBytes);
imageDataResource.setBytes("imageData", imageBytes);
if (Debug.infoOn()) {
Debug.logInfo("imageDataResource(C):" + imageDataResource, module);
@@ -585,7 +580,6 @@ public class DataServices {
public static Map<String, Object> createBinaryFileMethod(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = new HashMap<String, Object>();
GenericValue dataResource = (GenericValue) context.get("dataResource");
//String dataResourceId = (String) dataResource.get("dataResourceId");
String dataResourceTypeId = (String) dataResource.get("dataResourceTypeId");
String objectInfo = (String) dataResource.get("objectInfo");
byte [] imageData = (byte []) context.get("imageData");
@@ -642,7 +636,6 @@ public class DataServices {
public static Map<String, Object> updateBinaryFileMethod(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = new HashMap<String, Object>();
GenericValue dataResource = (GenericValue) context.get("dataResource");
//String dataResourceId = (String) dataResource.get("dataResourceId");
String dataResourceTypeId = (String) dataResource.get("dataResourceTypeId");
String objectInfo = (String) dataResource.get("objectInfo");
byte [] imageData = (byte []) context.get("imageData");
@@ -66,7 +66,6 @@ public class LayoutEvents {
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
HttpSession session = request.getSession();
Map<String, Object> uploadResults = LayoutWorker.uploadImageAndParameters(request, "imageData");
//Debug.logVerbose("in createLayoutImage(java), uploadResults:" + uploadResults, "");
Map<String, Object> formInput = UtilGenerics.checkMap(uploadResults.get("formInput"));
Map<String, Object> context = new HashMap<String, Object>();
ByteBuffer byteWrap = (ByteBuffer) uploadResults.get("imageData");
@@ -75,9 +74,7 @@ public class LayoutEvents {
request.setAttribute("_ERROR_MESSAGE_", errMsg);
return "error";
}
//Debug.logVerbose("in createLayoutImage, byteWrap(0):" + byteWrap, module);
String imageFileName = (String) uploadResults.get("imageFileName");
//Debug.logVerbose("in createLayoutImage(java), context:" + context, "");
String imageFileNameExt = null;
if (UtilValidate.isNotEmpty(imageFileName)) {
int pos = imageFileName.lastIndexOf(".");
@@ -114,14 +111,12 @@ public class LayoutEvents {
}
Map<String, Object> 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)) {
Map<String, Object> context2 = new HashMap<String, Object>();
context2.put("activeContentId", activeContentId);
//context2.put("dataResourceId", dataResourceId);
context2.put("contentAssocTypeId", result.get("contentAssocTypeId"));
context2.put("fromDate", result.get("fromDate"));
@@ -132,12 +127,10 @@ public class LayoutEvents {
context2.put("contentIdTo", formInput.get("contentIdTo"));
context2.put("mapKey", formInput.get("mapKey"));
//Debug.logVerbose("in createLayoutImage, context2:" + context2, module);
dispatcher.runSync("deactivateAssocs", context2);
}
GenericValue dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId).queryOne();
//Debug.logVerbose("in createLayoutImage, dataResource:" + dataResource, module);
// Use objectInfo field to store the name of the file, since there is no
// place in ImageDataResource for it.
if (dataResource != null) {
@@ -148,7 +141,6 @@ public class LayoutEvents {
// See if this needs to be a create or an update procedure
GenericValue imageDataResource = EntityQuery.use(delegator).from("ImageDataResource").where("dataResourceId", dataResourceId).queryOne();
//Debug.logVerbose("in createLayoutImage, imageDataResource(0):" + imageDataResource, module);
if (imageDataResource == null) {
imageDataResource = delegator.makeValue("ImageDataResource", UtilMisc.toMap("dataResourceId", dataResourceId));
imageDataResource.set("imageData", byteWrap.array());
@@ -201,7 +193,6 @@ public class LayoutEvents {
// place in ImageDataResource for it.
Debug.logVerbose("in createLayoutImage(java), imageFileName:" + imageFileName, "");
if (dataResource != null) {
//dataResource.set("objectInfo", imageFileName);
dataResource.setNonPKFields(context);
dataResource.store();
}
@@ -248,24 +239,6 @@ public class LayoutEvents {
String contentId = (String) paramMap.get("contentId");
context.put("userLogin", session.getAttribute("userLogin"));
/*
// If contentId is missing
if (UtilValidate.isEmpty(contentId)) {
// Look for an existing associated Content
try {
GenericValue dataResourceContentView = EntityQuery.use(delegator).from("DataResourceContentView")
.where("dataResourceId", dataResourceId)
.queryFirst();
if (dataResourceContentView != null) {
contentId = dataResourceContentView.getString("coContentId");
}
} catch (GenericEntityException e) {
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
return "error";
}
// Else, create and associate a Content
}
*/
if (UtilValidate.isNotEmpty(contentId)) {
context.put("contentId", contentId);
context.put("contentIdTo", contentIdTo);
@@ -274,11 +247,9 @@ public class LayoutEvents {
try {
Map<String, Object> result = dispatcher.runSync("persistContentAndAssoc", context);
//Debug.logVerbose("in replaceSubContent, result:" + result, module);
request.setAttribute("contentId", contentIdTo);
Map<String, Object> context2 = new HashMap<String, Object>();
context2.put("activeContentId", contentId);
//context2.put("dataResourceId", dataResourceId);
context2.put("contentAssocTypeId", "SUB_CONTENT");
context2.put("fromDate", result.get("fromDate"));
@@ -288,7 +259,6 @@ public class LayoutEvents {
context2.put("contentIdTo", contentIdTo);
context2.put("mapKey", mapKey);
//Debug.logVerbose("in replaceSubContent, context2:" + context2, module);
dispatcher.runSync("deactivateAssocs", context2);
} catch (GenericServiceException e) {
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
@@ -498,14 +468,12 @@ public class LayoutEvents {
request.setAttribute("currentEntityName", "SubContentDataResourceId");
Map<String, Object> context2 = new HashMap<String, Object>();
context2.put("activeContentId", contentId);
//context2.put("dataResourceId", dataResourceId);
context2.put("contentAssocTypeId", "SUB_CONTENT");
context2.put("fromDate", result.get("fromDate"));
context2.put("contentIdTo", contentIdTo);
context2.put("mapKey", mapKey);
context2.put("userLogin", userLogin);
//Debug.logVerbose("in replaceSubContent, context2:" + context2, module);
dispatcher.runSync("deactivateAssocs", context2);
} catch (GenericServiceException e) {
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
@@ -519,8 +487,6 @@ public class LayoutEvents {
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
HttpSession session = request.getSession();
Map<String, Object> paramMap = UtilHttp.getParameterMap(request);
// String contentIdTo = (String) paramMap.get("contentIdTo");
// String mapKey = (String) paramMap.get("mapKey");
Map<String, Object> context = new HashMap<String, Object>();
List<Object> errorMessages = null;
Locale loc = (Locale) request.getSession().getServletContext().getAttribute("locale");
@@ -561,18 +527,6 @@ public class LayoutEvents {
request.setAttribute("contentId", contentId);
request.setAttribute("drDataResourceId", dataResourceId);
request.setAttribute("currentEntityName", "SubContentDataResourceId");
/*
Map context2 = new HashMap<String, Object>();
context2.put("activeContentId", contentId);
//context2.put("dataResourceId", dataResourceId);
context2.put("contentAssocTypeId", "SUB_CONTENT");
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) {
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
return "error";
@@ -53,8 +53,6 @@ public final class LayoutWorker {
* and the binary data to be in a field id'd by uploadField.
*/
public static Map<String, Object> uploadImageAndParameters(HttpServletRequest request, String uploadField) {
//Debug.logVerbose("in uploadAndStoreImage", "");
Locale locale = UtilHttp.getLocale(request);
Map<String, Object> results = new HashMap<String, Object>();
@@ -72,7 +70,6 @@ public final class LayoutWorker {
String errMsg = UtilProperties.getMessage(err_resource,
"layoutEvents.no_files_uploaded", locale);
request.setAttribute("_ERROR_MESSAGE_", errMsg);
//Debug.logWarning("[DataEvents.uploadImage] No files uploaded", module);
return ServiceUtil.returnError(UtilProperties.getMessage(err_resource,
"layoutEvents.no_files_uploaded", locale));
}
@@ -88,7 +85,6 @@ public final class LayoutWorker {
if (fi.isFormField()) {
formInput.put(fieldName, fieldStr);
request.setAttribute(fieldName, fieldStr);
//Debug.logVerbose("in uploadAndStoreImage, fieldName:" + fieldName + " fieldStr:" + fieldStr, "");
}
if (fieldName.equals(uploadField)) {
imageFi = fi;
@@ -101,7 +97,6 @@ public final class LayoutWorker {
String errMsg = UtilProperties.getMessage(err_resource,
"layoutEvents.image_null", UtilMisc.toMap("imageFi", imageFi), locale);
request.setAttribute("_ERROR_MESSAGE_", errMsg);
//Debug.logWarning("[DataEvents.uploadImage] imageFi(" + imageFi + ") is null", module);
return null;
}
@@ -109,8 +104,6 @@ public final class LayoutWorker {
ByteBuffer byteWrap = ByteBuffer.wrap(imageBytes);
results.put("imageData", byteWrap);
results.put("imageFileName", imageFi.getName());
//Debug.logVerbose("in uploadAndStoreImage, results:" + results, "");
return results;
}
@@ -36,12 +36,10 @@ public class OpenOfficeByteArrayOutputStream extends ByteArrayOutputStream imple
public OpenOfficeByteArrayOutputStream() {
super();
// TODO Auto-generated constructor stub
}
public OpenOfficeByteArrayOutputStream(int arg0) {
super(arg0);
// TODO Auto-generated constructor stub
}
@@ -71,7 +71,6 @@ public class OpenOfficeServices {
Map results = ServiceUtil.returnSuccess();
Delegator delegator = dctx.getDelegator();
XMultiComponentFactory xmulticomponentfactory = null;
//String uniqueSeqNum = delegator.getNextSeqId("OOTempDir");
Timestamp ts = UtilDateTime.nowTimestamp();
Random random = new Random(ts.getTime());
String uniqueSeqNum = Integer.toString(Math.abs(random.nextInt()));
@@ -95,11 +94,6 @@ public class OpenOfficeServices {
byte[] inByteArray = inByteBuffer.array();
// 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 = EntityUtilProperties.getPropertyValue("content", "content.temp.dir", delegator);
fileIn = new File(tempDir + fileInName);
FileOutputStream fos = new FileOutputStream(fileIn);
@@ -312,11 +306,6 @@ public class OpenOfficeServices {
propertyvalue[ 0 ] = new PropertyValue();
propertyvalue[ 0 ].Name = "Hidden";
propertyvalue[ 0 ].Value = Boolean.valueOf(true);
//TODO: Hardcoding opening word documents -- this will need to change.
//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);
@@ -329,12 +318,7 @@ public class OpenOfficeServices {
propertyvalue[ 0 ] = new PropertyValue();
propertyvalue[ 0 ].Name = "URL";
propertyvalue[ 0 ].Value = stringOriginalFile;
// Setting the filter name
//propertyvalue[ 1 ] = new PropertyValue();
//propertyvalue[ 1 ].Name = "FilterName";
//propertyvalue[ 1 ].Value = context.get("convertFilterName");
XFrame frame = desktop.getCurrentFrame();
//XFrame frame = (XFrame) UnoRuntime.queryInterface(XFrame.class, desktop);
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);
@@ -346,11 +330,6 @@ public class OpenOfficeServices {
propertyvalue[ 0 ] = new PropertyValue();
propertyvalue[ 0 ].Name = "Overwrite";
propertyvalue[ 0 ].Value = Boolean.valueOf(true);
// Setting the filter name
//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);
@@ -97,19 +97,6 @@ public final class OpenOfficeWorker{
// Create a service manager from the initial object
xmulticomponentfactory = (XMultiComponentFactory) UnoRuntime.queryInterface(XMultiComponentFactory.class, objectInitial);
} catch (Exception e) {
// TODO: None of this works. Need a programmable start solution.
//String ooxvfb = UtilProperties.getPropertyValue("openoffice-uno", "oo.start.xvfb");
//String ooexport = UtilProperties.getPropertyValue("openoffice-uno", "oo.start.export");
// String oosoffice = UtilProperties.getPropertyValue("openoffice-uno", "oo.start.soffice");
//Process procXvfb = Runtime.getRuntime().exec(ooxvfb);
//Process procExport = Runtime.getRuntime().exec(ooexport);
/*
Process procSoffice = Runtime.getRuntime().exec(oosoffice);
Thread.sleep(3000);
objectInitial = xurlresolver.resolve("uno:socket,host=" + host + ",port=" + port + ";urp;StarOffice.ServiceManager");
xmulticomponentfactory = (XMultiComponentFactory) UnoRuntime.queryInterface(XMultiComponentFactory.class, objectInitial);
Debug.logInfo("soffice started. " + procSoffice, module);
*/
String errMsg = "Error connecting to OpenOffice with host [" + host + "] and port [" + port + "]: " + e.toString();
Debug.logError(e, errMsg, module);
throw new IllegalArgumentException(errMsg);
@@ -145,18 +132,9 @@ public final class OpenOfficeWorker{
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];
Debug.logInfo(s, module);
/*
if (s.toLowerCase().indexOf("filter") >= 0) {
Debug.logInfo("FILTER: " + s, module);
}
if (s.toLowerCase().indexOf("desktop") >= 0) {
Debug.logInfo("DESKTOP: " + s, module);
}
*/
}
List filterNameList = UtilMisc.toListArray(filterNames);
@@ -180,7 +158,6 @@ public final class OpenOfficeWorker{
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);
@@ -222,8 +199,6 @@ public final class OpenOfficeWorker{
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);
@@ -255,7 +230,6 @@ public final class OpenOfficeWorker{
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
@@ -303,7 +277,6 @@ public final class OpenOfficeWorker{
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);
@@ -127,9 +127,6 @@ public class PdfSurveyServices {
} else if (type == AcroFields.FIELD_TYPE_LIST || type == AcroFields.FIELD_TYPE_COMBO) {
surveyQuestion.set("surveyQuestionTypeId", "OPTION");
// TODO: handle these specially with the acroFields.getListOptionDisplay (and getListOptionExport?)
/*String[] listOptionDisplayArray = acroFields.getListOptionDisplay(fieldName);
String[] listOptionExportArray = acroFields.getListOptionExport(fieldName);
Debug.logInfo("listOptionDisplayArray: " + listOptionDisplayArray + "; listOptionExportArray: " + listOptionExportArray, module);*/
} else {
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);
@@ -166,14 +163,6 @@ public class PdfSurveyServices {
// 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())) {
PdfObject tuValue = dict.get(new PdfName("/TU"));
annotation = tuValue.toString();
}
*/
PdfObject typeValue = null;
PdfObject tuValue = null;
@@ -186,7 +175,6 @@ public class PdfSurveyServices {
} else if ("/TU".equals(dictKeyName.toString())) {
tuValue = dictObject;
}
//Debug.logInfo("AcroForm widget fieldName[" + fieldName + "] dictKey[" + dictKeyName.toString() + "] dictValue[" + dictObject.toString() + "]", module);
}
if (tuValue != null && typeValue != null && "/Annot".equals(typeValue.toString())) {
annotation = tuValue.toString();
@@ -243,7 +231,6 @@ public class PdfSurveyServices {
Delegator delegator = dctx.getDelegator();
String partyId = (String)context.get("partyId");
String surveyId = (String)context.get("surveyId");
//String contentId = (String)context.get("contentId");
surveyResponseId = (String)context.get("surveyResponseId");
if (UtilValidate.isNotEmpty(surveyResponseId)) {
GenericValue surveyResponse = EntityQuery.use(delegator).from("SurveyResponse").where("surveyResponseId", surveyResponseId).queryOne();
@@ -267,7 +254,6 @@ public class PdfSurveyServices {
s.setFormFlattening(true);
for (String fieldName : hm.keySet()) {
//AcroFields.Item item = fs.getFieldItem(fieldName);
//int type = fs.getFieldType(fieldName);
String value = fs.getField(fieldName);
GenericValue surveyQuestionAndAppl = EntityQuery.use(delegator).from("SurveyQuestionAndAppl")
.where("surveyId", surveyId,
@@ -318,11 +304,6 @@ public class PdfSurveyServices {
Map<String, Object> map = UtilGenerics.checkMap(fs.getFields());
s.setFormFlattening(true);
// Debug code to get the values for setting TDP
// String[] sa = fs.getAppearanceStates("TDP");
// for (int i=0;i<sa.length;i++)
// Debug.logInfo("Appearance="+sa[i]);
for (String fieldName : map.keySet()) {
String parmValue = fs.getField(fieldName);
acroFieldMap.put(fieldName, parmValue);
@@ -359,11 +340,6 @@ public class PdfSurveyServices {
Map<String, Object> map = UtilGenerics.checkMap(fs.getFields());
s.setFormFlattening(true);
// Debug code to get the values for setting TDP
// String[] sa = fs.getAppearanceStates("TDP");
// for (int i=0;i<sa.length;i++)
// Debug.logInfo("Appearance="+sa[i]);
for (String fieldName : map.keySet()) {
String fieldValue = fs.getField(fieldName);
Object obj = acroFieldMap.get(fieldName);
@@ -414,7 +390,6 @@ public class PdfSurveyServices {
public static Map<String, Object> buildPdfFromSurveyResponse(DispatchContext dctx, Map<String, ? extends Object> rcontext) {
Map<String, Object> context = UtilMisc.makeMapWritable(rcontext);
Delegator delegator = dctx.getDelegator();
//LocalDispatcher dispatcher = dctx.getDispatcher();
Map<String, Object> results = ServiceUtil.returnSuccess();
String surveyResponseId = (String)context.get("surveyResponseId");
String contentId = (String)context.get("contentId");
@@ -484,7 +459,6 @@ public class PdfSurveyServices {
*/
public static Map<String, Object> buildSurveyQuestionsAndAnswers(DispatchContext dctx, Map<String, ? extends Object> context) {
Delegator delegator = dctx.getDelegator();
//LocalDispatcher dispatcher = dctx.getDispatcher();
Map<String, Object> results = ServiceUtil.returnSuccess();
String surveyResponseId = (String)context.get("surveyResponseId");
List<Object> qAndA = new LinkedList<Object>();
@@ -424,7 +424,6 @@ public class SurveyWrapper {
TransactionUtil.commit(beganTransaction);
} catch (GenericEntityException e) {
throw new SurveyWrapperException(e);
//Debug.logError(e, "Could not commit transaction: " + e.toString(), module);
}
}
return resp;
@@ -571,7 +570,6 @@ public class SurveyWrapper {
TransactionUtil.commit(beganTransaction);
} catch (GenericEntityException e) {
throw new SurveyWrapperException(e);
//Debug.logError(e, "Could not commit transaction: " + e.toString(), module);
}
}
}
@@ -631,7 +629,6 @@ public class SurveyWrapper {
TransactionUtil.commit(beganTransaction);
} catch (GenericEntityException e) {
throw new SurveyWrapperException(e);
//Debug.logError(e, "Could not commit transaction: " + e.toString(), module);
}
}
@@ -711,7 +708,6 @@ public class SurveyWrapper {
TransactionUtil.commit(beganTransaction);
} catch (GenericEntityException e) {
throw new SurveyWrapperException(e);
//Debug.logError(e, "Could not commit transaction: " + e.toString(), module);
}
}
@@ -96,8 +96,6 @@ public class CheckPermissionTransform implements TemplateTransformModel {
final String mode = (String)templateCtx.get("mode");
final String quickCheckContentId = (String)templateCtx.get("quickCheckContentId");
final Map<String, Object> savedValues = new HashMap<String, Object>();
//Debug.logInfo("in CheckPermission, contentId(1):" + templateCtx.get("contentId"),"");
//Debug.logInfo("in CheckPermission, subContentId(1):" + templateCtx.get("subContentId"),"");
return new LoopWriter(out) {
@@ -114,11 +112,6 @@ public class CheckPermissionTransform implements TemplateTransformModel {
@Override
public int onStart() throws TemplateModelException, IOException {
List<Map<String, ? extends Object>> trail = UtilGenerics.checkList(templateCtx.get("globalNodeTrail"));
//String trailCsv = ContentWorker.nodeTrailToCsv(trail);
//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");
@@ -129,17 +122,12 @@ public class CheckPermissionTransform implements TemplateTransformModel {
} catch (GeneralException e) {
throw new RuntimeException("Error getting current content. " + e.toString());
}
// final GenericValue view = val;
currentContent = val;
if (currentContent != null) {
//Debug.logInfo("in CheckPermission, currentContent(0):" + currentContent.get("contentId"),"");
}
if (currentContent == null) {
currentContent = delegator.makeValue("Content");
currentContent.put("ownerContentId", templateCtx.get("ownerContentId"));
}
//Debug.logInfo("in CheckPermission, currentContent(1):" + currentContent.get("contentId"),"");
Security security = null;
if (request != null) {
@@ -166,8 +154,6 @@ public class CheckPermissionTransform implements TemplateTransformModel {
}
List<String> targetOperationList = StringUtil.split(targetOperation, "|");
if (targetOperationList.size() == 0) {
//Debug.logInfo("in CheckPermission, entityOperation:" + entityOperation,"");
//Debug.logInfo("in CheckPermission, templateCtx:" + templateCtx,"");
throw new IOException("targetOperationList has zero size.");
}
List<String> roleList = new LinkedList<String>();
@@ -185,10 +171,8 @@ public class CheckPermissionTransform implements TemplateTransformModel {
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, "");
if (recorder != null) {
String permissionMessage = recorder.toHtml();
//Debug.logInfo("permissionMessage(0):" + permissionMessage, "");
errorMessage += " \n " + permissionMessage;
}
templateCtx.put("permissionErrorMsg", errorMessage);
@@ -41,7 +41,6 @@ import org.apache.ofbiz.service.LocalDispatcher;
import freemarker.core.Environment;
import freemarker.template.TemplateTransformModel;
//import com.clarkware.profiler.Profiler;
/**
* EditRenderSubContentCacheTransform - Freemarker Transform for URLs (links)
*
@@ -145,13 +144,9 @@ public class EditRenderSubContentCacheTransform implements TemplateTransformMode
public void close() throws IOException {
FreeMarkerWorker.reloadValues(templateCtx, savedValues, env);
String wrappedContent = buf.toString();
// String editTemplate = (String)templateCtx.get("editTemplate");
// if (editTemplate != null && editTemplate.equalsIgnoreCase("true")) {
String wrapTemplateId = (String)templateCtx.get("wrapTemplateId");
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) {
@@ -173,9 +168,7 @@ public class EditRenderSubContentCacheTransform implements TemplateTransformMode
String mimeTypeId = (String)templateCtx.get("mimeTypeId");
Locale locale = null;
try {
//if (Debug.infoOn()) Debug.logInfo("in Edit(0), before calling renderContentAsTextCache, wrapTemplateId: ." + wrapTemplateId , module);
ContentWorker.renderContentAsText(dispatcher, delegator, wrapTemplateId, out, templateRoot, locale, mimeTypeId, null, null, true);
//if (Debug.infoOn()) Debug.logInfo("in Edit(0), after calling renderContentAsTextCache, wrapTemplateId: ." + wrapTemplateId , module);
} catch (IOException e) {
Debug.logError(e, "Error rendering content" + e.getMessage(), module);
throw new IOException("Error rendering content" + e.toString());
@@ -96,7 +96,6 @@ public class EditRenderSubContentTransform implements TemplateTransformModel {
final Delegator delegator = FreeMarkerWorker.getWrappedObject("delegator", env);
final GenericValue userLogin = FreeMarkerWorker.getWrappedObject("userLogin", env);
GenericValue subContentDataResourceViewTemp = FreeMarkerWorker.getWrappedObject("subContentDataResourceView", env);
//final HttpServletRequest request = FreeMarkerWorker.getWrappedObject("request", env);
ctx.put("mapKey", mapKey);
ctx.put("subDataResourceTypeIdTemp", subDataResourceTypeIdTemp);
@@ -110,7 +109,6 @@ public class EditRenderSubContentTransform implements TemplateTransformModel {
// is gotten here and made available to underlying transforms to save overall
// processing time.
GenericValue parentContent = null;
//ctx.put("userLogin", userLogin);
List<String> assocTypes = UtilMisc.toList("SUB_CONTENT");
Timestamp fromDate = UtilDateTime.nowTimestamp();
if (subContentDataResourceViewTemp == null) {
@@ -149,19 +147,15 @@ public class EditRenderSubContentTransform implements TemplateTransformModel {
ctx.put("drDataResourceId", dataResourceIdTemp);
ctx.put("subContentDataResourceView", subContentDataResourceView);
ctx.put("mimeTypeId", mimeTypeIdTemp);
//request.setAttribute("drDataResourceId", subContentDataResourceView.get("drDataResourceId"));
} else {
ctx.put("subContentId", null);
ctx.put("drDataResourceId", null);
ctx.put("subContentDataResourceView", null);
ctx.put("mimeTypeId", null);
//request.setAttribute("drDataResourceId", null);
}
final String dataResourceId = dataResourceIdTemp;
final String subContentIdSub = subContentIdSubTemp;
//final GenericValue finalSubContentView = subContentDataResourceView;
//final GenericValue content = parentContent;
final Map<String, Object> templateContext = ctx;
final String mimeTypeId = mimeTypeIdTemp;
final String subDataResourceTypeId = subDataResourceTypeIdTemp;
@@ -184,8 +178,6 @@ public class EditRenderSubContentTransform implements TemplateTransformModel {
if (editTemplate != null && editTemplate.equalsIgnoreCase("true")) {
if (UtilValidate.isNotEmpty(wrapTemplateId)) {
templateContext.put("wrappedFTL", wrappedFTL);
//ServletContext servletContext = (ServletContext)request.getSession().getServletContext();
//String rootDir = servletContext.getRealPath("/");
templateContext.put("webSiteId", webSiteId);
templateContext.put("https", https);
templateContext.put("rootDir", rootDir);
@@ -79,10 +79,8 @@ public class InjectNodeTrailCsvTransform implements TemplateTransformModel {
final StringBuilder buf = new StringBuilder();
final Environment env = Environment.getCurrentEnvironment();
final Map<String, Object> templateCtx = FreeMarkerWorker.getWrappedObject("context", env);
//FreeMarkerWorker.convertContext(templateCtx);
final Delegator delegator = FreeMarkerWorker.getWrappedObject("delegator", env);
final HttpServletRequest request = FreeMarkerWorker.getWrappedObject("request", env);
//final GenericValue userLogin = FreeMarkerWorker.getWrappedObject("userLogin", env);
FreeMarkerWorker.getSiteParameters(request, templateCtx);
FreeMarkerWorker.overrideWithArgs(templateCtx, args);
@@ -109,11 +107,9 @@ public class InjectNodeTrailCsvTransform implements TemplateTransformModel {
if (Debug.infoOn()) Debug.logInfo("in InjectNodeTrailCsv(0), trail:"+trail,module);
// This will build a nodeTrail if none exists
// Maybe only contentId or subContentId are passed in
//GenericValue currentValue = getCurrentContent(delegator, trail, userLogin, templateCtx, nullThruDatesOnly, contentAssocPredicateId);
String redo = (String)templateCtx.get("redo");
if (UtilValidate.isEmpty(trail) || (redo != null && redo.equalsIgnoreCase("true"))) {
// String thisContentId = null;
String subContentId = (String)templateCtx.get("subContentId");
if (Debug.infoOn()) Debug.logInfo("in InjectNodeTrailCsv(0), subContentId:"+subContentId,module);
String contentId = (String)templateCtx.get("contentId");
@@ -138,8 +134,6 @@ public class InjectNodeTrailCsvTransform implements TemplateTransformModel {
if (Debug.infoOn()) Debug.logInfo("in InjectNodeTrailCsv(0), csvTrail:"+csvTrail,module);
} else {
// Build nodeTrail if one does not exist
//if (Debug.infoOn()) Debug.logInfo("in InjectNodeTrailCsv, trail:"+trail,module);
//if (Debug.infoOn()) Debug.logInfo("in InjectNodeTrailCsv, passedCsv:"+passedCsv,module);
if (UtilValidate.isNotEmpty(passedCsv)) {
csvTrail = passedCsv;
int lastComma = passedCsv.lastIndexOf(",");
@@ -167,7 +161,6 @@ public class InjectNodeTrailCsvTransform implements TemplateTransformModel {
csvTrail = ContentWorker.nodeTrailToCsv(trail);
}
}
//if (Debug.infoOn()) Debug.logInfo("in InjectNodeTrailCsv, csvTrail:"+csvTrail,module);
templateCtx.put("nodeTrailCsv", csvTrail);
return TransformControl.EVALUATE_BODY;
}
@@ -86,7 +86,6 @@ public class LimitedSubContentCacheTransform implements TemplateTransformModel {
@SuppressWarnings("unchecked")
public Writer getWriter(final Writer out, Map args) {
//Profiler.begin("Limited");
final StringBuilder buf = new StringBuilder();
final Environment env = Environment.getCurrentEnvironment();
final Map<String, Object> templateRoot = FreeMarkerWorker.createEnvironmentMap(env);
@@ -134,12 +133,6 @@ public class LimitedSubContentCacheTransform implements TemplateTransformModel {
String limitSize = (String) templateRoot.get("limitSize");
final int returnLimit = Integer.parseInt(limitSize);
// limitMode will be "random" to begin with
// String limitMode = (String) templateRoot.get("limitMode");
// final GenericValue userLogin = FreeMarkerWorker.getWrappedObject("userLogin", env);
// List<Map<String, ? extends Object>> globalNodeTrail = UtilGenerics.checkList(templateRoot.get("globalNodeTrail"));
// String strNullThruDatesOnly = (String) templateRoot.get("nullThruDatesOnly");
// Boolean nullThruDatesOnly = (strNullThruDatesOnly != null && strNullThruDatesOnly.equalsIgnoreCase("true")) ? Boolean.TRUE : Boolean.FALSE;
String orderBy = (String) templateRoot.get("orderBy");
// NOTE this was looking for subContentId, but that doesn't make ANY sense, so changed to contentId
@@ -148,10 +141,7 @@ public class LimitedSubContentCacheTransform implements TemplateTransformModel {
templateRoot.put("contentId", null);
templateRoot.put("subContentId", null);
// final String contentIdTo = contentId;
Map<String, Object> results = null;
//if (Debug.infoOn()) Debug.logInfo("in LimitedSubContentCache(0), assocTypes ." + assocTypes, module);
String contentAssocPredicateId = (String) templateRoot.get("contentAssocPredicateId");
try {
results = ContentServicesComplex.getAssocAndContentAndDataResourceCacheMethod(delegator, contentId, null, "From", fromDate, null, assocTypes, null, Boolean.TRUE, contentAssocPredicateId, orderBy);
@@ -162,15 +152,12 @@ public class LimitedSubContentCacheTransform implements TemplateTransformModel {
}
List<GenericValue> longList = UtilGenerics.checkList(results.get("entityList"));
templateRoot.put("entityList", longList);
//if (Debug.infoOn()) Debug.logInfo("in limited, longList:" + longList , "");
return new LoopWriter(out) {
@Override
public void write(char cbuf[], int off, int len) {
buf.append(cbuf, off, len);
//StringBuilder ctxBuf = (StringBuilder) templateRoot.get("buf");
//ctxBuf.append(cbuf, off, len);
}
@Override
@@ -180,11 +167,7 @@ public class LimitedSubContentCacheTransform implements TemplateTransformModel {
@Override
public int onStart() throws TemplateModelException, IOException {
// List<Map<String, ? extends Object>> globalNodeTrail = UtilGenerics.checkList(templateRoot.get("globalNodeTrail"));
// String trailCsv = ContentWorker.nodeTrailToCsv(globalNodeTrail);
boolean inProgress = false;
//if (Debug.infoOn()) Debug.logInfo("in limited, returnLimit:" + returnLimit , "");
//if (Debug.infoOn()) Debug.logInfo("in limited, pickedEntityIds:" + pickedEntityIds , "");
if (pickedEntityIds.size() < returnLimit) {
inProgress = getNextMatchingEntity(templateRoot, delegator, env);
}
@@ -204,9 +187,6 @@ public class LimitedSubContentCacheTransform implements TemplateTransformModel {
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 , "");
boolean inProgress = false;
if (pickedEntityIds.size() < returnLimit) {
inProgress = getNextMatchingEntity(templateRoot, delegator, env);
@@ -225,18 +205,9 @@ public class LimitedSubContentCacheTransform implements TemplateTransformModel {
FreeMarkerWorker.reloadValues(templateRoot, savedValuesUp, env);
String wrappedContent = buf.toString();
out.write(wrappedContent);
//try {
//Profiler.end("Limited");
//FileOutputStream fw = new FileOutputStream(FileUtil.getFile("/usr/local/agi/ofbiz/hot-deploy/sfmp/misc/profile.data"));
//Profiler.print(fw);
//fw.close();
//} catch (IOException e) {
//Debug.logError("[PROFILER] " + e.getMessage(),"");
//}
}
public boolean prepCtx(Delegator delegator, Map<String, Object> ctx, Environment env, GenericValue view) throws GeneralException {
// String dataResourceId = (String) view.get("drDataResourceId");
String subContentIdSub = (String) view.get("contentId");
// This order is taken so that the dataResourceType can be overridden in the transform arguments.
String subDataResourceTypeId = (String) ctx.get("subDataResourceTypeId");
@@ -257,10 +228,8 @@ public class LimitedSubContentCacheTransform implements TemplateTransformModel {
GenericValue assocContent = null;
ContentWorker.checkConditions(delegator, trailNode, assocContent, whenMap);
Boolean isReturnBeforeObj = (Boolean) trailNode.get("isReturnBefore");
// Boolean isReturnAfterObj = (Boolean) trailNode.get("isReturnAfter");
Boolean isPickObj = (Boolean) trailNode.get("isPick");
Boolean isFollowObj = (Boolean) trailNode.get("isFollow");
//if (Debug.infoOn()) Debug.logInfo("in LimitedSubContentCache, isReturnBeforeObj" + isReturnBeforeObj + " isPickObj:" + isPickObj + " isFollowObj:" + isFollowObj + " isReturnAfterObj:" + isReturnAfterObj, module);
if ((isReturnBeforeObj == null || !isReturnBeforeObj.booleanValue()) && ((isPickObj != null &&
isPickObj.booleanValue()) || (isFollowObj != null && isFollowObj.booleanValue()))) {
List<Map<String, ? extends Object>> globalNodeTrail = UtilGenerics.checkList(ctx.get("globalNodeTrail"));
@@ -271,7 +240,6 @@ public class LimitedSubContentCacheTransform implements TemplateTransformModel {
ctx.put("globalNodeTrail", globalNodeTrail);
String csvTrail = ContentWorker.nodeTrailToCsv(globalNodeTrail);
ctx.put("nodeTrailCsv", csvTrail);
//if (Debug.infoOn()) Debug.logInfo("prepCtx, csvTrail(2):" + csvTrail, "");
int indentSz = globalNodeTrail.size();
ctx.put("indent", Integer.valueOf(indentSz));
@@ -300,9 +268,7 @@ public class LimitedSubContentCacheTransform implements TemplateTransformModel {
while (pickEntity == null && lst.size() > 0) {
double randomValue = Math.random();
//if (Debug.infoOn()) Debug.logInfo("in limited, randomValue:" + randomValue , "");
int idx = (int) (lst.size() * randomValue);
//if (Debug.infoOn()) Debug.logInfo("in limited, idx:" + idx , "");
pickEntity = lst.get(idx);
String pickEntityId = pickEntity.getString("contentId");
if (pickedEntityIds.get(pickEntityId) == null) {
@@ -181,10 +181,7 @@ public class LoopSubContentTransform implements TemplateTransformModel {
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<String, Object> results = ContentServicesComplex.getAssocAndContentAndDataResourceMethod(delegator, thisContentId, thisMapKey, null, fromDate, null, null, null, assocTypes, null);
List<GenericValue> entityList = UtilGenerics.checkList(results.get("entityList"));
templateCtx.put("entityList", entityList);
@@ -46,8 +46,6 @@ import freemarker.template.TemplateTransformModel;
public class RenderContentAndSubContent implements TemplateTransformModel {
public static final String module = RenderContentAndSubContent.class.getName();
// public static final String [] upSaveKeyNames = {"globalNodeTrail"};
// public static final String [] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale", "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly", "globalNodeTrail"};
@SuppressWarnings("unchecked")
public Writer getWriter(final Writer out, Map args) {
@@ -55,18 +53,13 @@ public class RenderContentAndSubContent implements TemplateTransformModel {
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> envMap = FreeMarkerWorker.createEnvironmentMap(env);
final MapStack<String> templateRoot = MapStack.create();
((MapStack)templateRoot).push(envMap);
if (Debug.verboseOn()) Debug.logVerbose("in RenderContentAndSubContent, contentId(0):" + templateRoot.get("contentId"), module);
FreeMarkerWorker.getSiteParameters(request, templateRoot);
// final Map savedValuesUp = new HashMap<String, Object>();
// FreeMarkerWorker.saveContextValues(templateRoot, upSaveKeyNames, savedValuesUp);
FreeMarkerWorker.overrideWithArgs(templateRoot, args);
// final Map<String, Object> savedValues = new HashMap<String, Object>();
return new Writer(out) {
@Override
@@ -81,7 +74,6 @@ public class RenderContentAndSubContent implements TemplateTransformModel {
@Override
public void close() throws IOException {
renderSubContent();
//if (Debug.verboseOn()) Debug.logVerbose("in Render(2), globalNodeTrail ." + getWrapped(env, "globalNodeTrail") , module);
}
public void renderSubContent() throws IOException {
@@ -96,38 +88,16 @@ public class RenderContentAndSubContent implements TemplateTransformModel {
if (Debug.verboseOn()) Debug.logVerbose("in RenderContentAndSubContent, contentId(2):" + templateRoot.get("contentId"), module);
if (Debug.verboseOn()) Debug.logVerbose("in RenderContentAndSubContent, subContentId(2):" + templateRoot.get("subContentId"), module);
//if (thisView != null) {
try {
String contentId = (String)templateRoot.get("contentId");
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.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);
// List assocList = null;
// if (UtilValidate.isNotEmpty(contentAssocTypeId)) {
// assocList = UtilMisc.toList(contentAssocTypeId);
// }
// GenericValue content = ContentWorker.getSubContent(delegator, contentId, mapKey, null, null, assocList, null);
// if (content != null) {
// contentId = content.getString("contentId");
// } else {
// contentId = null;
// }
} else if (contentId != null) {
ContentWorker.renderContentAsText(dispatcher, delegator, contentId, out, templateRoot, locale, mimeTypeId, null, null, 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);
@@ -59,8 +59,6 @@ public class RenderContentAsText implements TemplateTransformModel {
@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);
@@ -76,58 +74,12 @@ public class RenderContentAsText implements TemplateTransformModel {
if (Debug.verboseOn()) {
Debug.logVerbose("in RenderSubContent, contentId(2):" + templateRoot.get("contentId"), module);
}
// not used yet: final GenericValue userLogin = FreeMarkerWorker.getWrappedObject("userLogin", env);
// not used yet: List trail = (List)templateRoot.get("globalNodeTrail");
//if (Debug.infoOn()) Debug.logInfo("in Render(0), globalNodeTrail ." + trail , module);
// not used yet: String contentAssocPredicateId = (String)templateRoot.get("contentAssocPredicateId");
// not used yet: String strNullThruDatesOnly = (String)templateRoot.get("nullThruDatesOnly");
// not used yet: Boolean nullThruDatesOnly = (strNullThruDatesOnly != null && strNullThruDatesOnly.equalsIgnoreCase("true")) ? Boolean.TRUE :Boolean.FALSE;
final String thisContentId = (String)templateRoot.get("contentId");
final String xmlEscape = (String)templateRoot.get("xmlEscape");
final boolean directAssocMode = UtilValidate.isNotEmpty(thisContentId) ? true : false;
if (Debug.verboseOn()) {
Debug.logVerbose("in Render(0), directAssocMode ." + directAssocMode , module);
}
/*
if (Debug.infoOn()) Debug.logInfo("in Render(0), thisSubContentId ." + thisSubContentId , module);
String thisSubContentId = (String)templateRoot.get("subContentId");
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>();
@@ -149,7 +101,6 @@ public class RenderContentAsText implements TemplateTransformModel {
Debug.logVerbose("Render close, globalNodeTrail(2a):" + ContentWorker.nodeTrailToCsv(globalNodeTrail), "");
}
renderSubContent();
//if (Debug.verboseOn()) Debug.logVerbose("in Render(2), globalNodeTrail ." + getWrapped(env, "globalNodeTrail") , module);
}
public void renderSubContent() throws IOException {
@@ -162,26 +113,10 @@ public class RenderContentAsText implements TemplateTransformModel {
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.verboseOn()) {
Debug.logVerbose("in Render(3), editRequestName ." + editRequestName , module);
}
/*
GenericValue thisView = null;
if (view != null) {
thisView = view;
} else if (passedGlobalNodeTrail.size() > 0) {
Map map = (Map)passedGlobalNodeTrail.get(passedGlobalNodeTrail.size() - 1);
if (Debug.infoOn()) Debug.logInfo("in Render(3), map ." + map , module);
if (map != null)
thisView = (GenericValue)map.get("value");
}
if (Debug.verboseOn()) Debug.logVerbose("in RenderSubContent, subContentId:" + templateRoot.get("subContentId"), module);
if (Debug.verboseOn()) Debug.logVerbose("in RenderSubContent, contentId:" + templateRoot.get("contentId"), module);
*/
if (UtilValidate.isNotEmpty(editRequestName)) {
String editStyle = getEditStyle();
@@ -193,7 +128,6 @@ public class RenderContentAsText implements TemplateTransformModel {
Debug.logVerbose("in RenderSubContent, subContentId(2):" + templateRoot.get("subContentId"), module);
}
FreeMarkerWorker.saveContextValues(templateRoot, saveKeyNames, savedValues);
//if (thisView != null) {
try {
String txt = ContentWorker.renderContentAsText(dispatcher, delegator, thisContentId, templateRoot, locale, mimeTypeId, true);
if ("true".equals(xmlEscape)) {
@@ -202,7 +136,6 @@ public class RenderContentAsText implements TemplateTransformModel {
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();
Debug.logError(e, errMsg, module);
@@ -215,7 +148,6 @@ public class RenderContentAsText implements TemplateTransformModel {
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 {
@@ -130,7 +130,6 @@ public class RenderContentTransform implements TemplateTransformModel {
}
public void closeEditWrap(Writer out, String editRequestName) throws IOException {
// StringBuilder sb = new StringBuilder();
String fullRequest = editRequestName;
String delim = "?";
if (UtilValidate.isNotEmpty(thisContentId)) {
@@ -42,7 +42,6 @@ import org.apache.ofbiz.service.LocalDispatcher;
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 implements TemplateTransformModel {
@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 implements TemplateTransformModel {
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 implements TemplateTransformModel {
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 implements TemplateTransformModel {
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 implements TemplateTransformModel {
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 implements TemplateTransformModel {
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 implements TemplateTransformModel {
} 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 implements TemplateTransformModel {
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 implements TemplateTransformModel {
}
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() {
@@ -57,31 +57,23 @@ public class RenderSubContentCacheTransform implements TemplateTransformModel {
@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 RenderSubContentCacheTransform implements TemplateTransformModel {
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 RenderSubContentCacheTransform implements TemplateTransformModel {
@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 RenderSubContentCacheTransform implements TemplateTransformModel {
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 RenderSubContentCacheTransform implements TemplateTransformModel {
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 RenderSubContentCacheTransform implements TemplateTransformModel {
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 RenderSubContentCacheTransform implements TemplateTransformModel {
}
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;
@@ -74,7 +74,6 @@ public class RenderSubContentTransform implements TemplateTransformModel {
@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 implements TemplateTransformModel {
}
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 implements TemplateTransformModel {
}
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 implements TemplateTransformModel {
} 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);
@@ -43,7 +43,6 @@ import freemarker.template.TemplateModelException;
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 TraverseSubContentCacheTransform implements TemplateTransformModel
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 TraverseSubContentCacheTransform implements TemplateTransformModel
} 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 TraverseSubContentCacheTransform implements TemplateTransformModel
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 TraverseSubContentCacheTransform implements TemplateTransformModel
@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 TraverseSubContentCacheTransform implements TemplateTransformModel
@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 TraverseSubContentCacheTransform implements TemplateTransformModel
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 TraverseSubContentCacheTransform implements TemplateTransformModel
@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 TraverseSubContentCacheTransform implements TemplateTransformModel
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 TraverseSubContentCacheTransform implements TemplateTransformModel
} 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);
}
@@ -85,32 +85,10 @@ public class TraverseSubContentTransform implements TemplateTransformModel {
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 implements TemplateTransformModel {
@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 implements TemplateTransformModel {
@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 implements TemplateTransformModel {
@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 implements TemplateTransformModel {
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 implements TemplateTransformModel {
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 implements TemplateTransformModel {
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 implements TemplateTransformModel {
}
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 implements TemplateTransformModel {
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();
@@ -41,7 +41,6 @@ import org.apache.ofbiz.service.LocalDispatcher;
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 WrapSubContentCacheTransform implements TemplateTransformModel {
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 WrapSubContentCacheTransform implements TemplateTransformModel {
} 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 WrapSubContentCacheTransform implements TemplateTransformModel {
}
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 WrapSubContentCacheTransform implements TemplateTransformModel {
@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 WrapSubContentCacheTransform implements TemplateTransformModel {
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 WrapSubContentCacheTransform implements TemplateTransformModel {
throw new IOException("Error rendering content" + e2.toString());
}
FreeMarkerWorker.reloadValues(templateCtx, savedValuesUp, env);
//if (Debug.infoOn()) Debug.logInfo("in Wrap(2), savedValuesUp ." + savedValuesUp , module);
}
}
};