Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions applications/content/servicedef/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,24 +248,6 @@
<attribute mode="OUT" name="entityList" optional="true" type="List"/>
</service>

<service name="traverseContent" auth="false" engine="java" invoke="traverseContent"
location="org.apache.ofbiz.content.content.ContentServices">
<description>Follow a content and return descendants</description>
<attribute mode="IN" name="contentId" optional="false" type="String">
<type-validate>
<fail-property resource="ContentErrorUiLabels" property="ContentRequiredFieldMissingContentId"/>
</type-validate>
</attribute>
<attribute mode="IN" name="fromDateStr" optional="true" type="String"/>
<attribute mode="IN" name="thruDateStr" optional="true" type="String"/>
<attribute mode="IN" name="followWhen" optional="true" type="String"/>
<attribute mode="IN" name="pickWhen" optional="true" type="String"/>
<attribute mode="IN" name="returnBeforePickWhen" optional="true" type="String"/>
<attribute mode="IN" name="returnAfterPickWhen" optional="true" type="String"/>
<attribute mode="IN" name="direction" optional="true" type="String"/>
<attribute mode="OUT" name="pickList" optional="true" type="List"/>
<attribute mode="OUT" name="nodeMap" optional="true" type="Map"/>
</service>
<service name="getContent" engine="java"
location="org.apache.ofbiz.content.ContentManagementServices" invoke="getContent" auth="false">
<description>Get Content of passed contentId</description>
Expand Down Expand Up @@ -364,23 +346,6 @@
<override name="textData" allow-html="any"/>
</service>

<service name="findContentParents" engine="java"
transaction-timeout="7200"
location="org.apache.ofbiz.content.content.ContentServices" invoke="findContentParents" auth="true">
<attribute mode="IN" name="contentId" optional="false" type="String">
<type-validate>
<fail-property resource="ContentErrorUiLabels" property="ContentRequiredFieldMissingContentId"/>
</type-validate>
</attribute>
<attribute mode="IN" name="contentAssocTypeId" optional="false" type="String">
<type-validate>
<fail-property resource="ContentErrorUiLabels" property="ContentRequiredFieldMissingContentAssocTypeId"/>
</type-validate>
</attribute>
<attribute mode="IN" name="direction" optional="true" type="String"/>
<attribute mode="OUT" name="parentList" optional="true" type="List"/>
</service>

<service name="deactivateAssocs" engine="java"
location="org.apache.ofbiz.content.content.ContentServices" invoke="deactivateAssocs" auth="true">
<description>Supply thruDate to all ContentAssoc that come "before" current one</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,107 +123,6 @@ public static Map<String, Object> findRelatedContent(DispatchContext dctx, Map<S
results.put("contentList", permittedList);
return results;
}
/**
* This is a generic service for traversing a Content tree, typical of a blog response tree. It calls the ContentWorker.traverse method.
*/
public static Map<String, Object> findContentParents(DispatchContext dctx, Map<String, ? extends Object> context) {
Map<String, Object> results = new HashMap<>();
List<Object> parentList = new LinkedList<>();
results.put("parentList", parentList);
LocalDispatcher dispatcher = dctx.getDispatcher();
String contentId = (String) context.get("contentId");
String contentAssocTypeId = (String) context.get("contentAssocTypeId");
String direction = (String) context.get("direction");
if (UtilValidate.isEmpty(direction)) {
direction = "To";
}
Map<String, Object> traversMap = new HashMap<>();
traversMap.put("contentId", contentId);
traversMap.put("direction", direction);
traversMap.put("contentAssocTypeId", contentAssocTypeId);
try {
Map<String, Object> thisResults = dispatcher.runSync("traverseContent", traversMap);
if (ServiceUtil.isError(thisResults)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResults));
}
Map<String, Object> nodeMap = UtilGenerics.cast(thisResults.get("nodeMap"));
walkParentTree(nodeMap, parentList);
} catch (GenericServiceException e) {
return ServiceUtil.returnFailure(e.getMessage());
}
return results;
}

private static void walkParentTree(Map<String, Object> nodeMap, List<Object> parentList) {
List<Map<String, Object>> kids = UtilGenerics.cast(nodeMap.get("kids"));
if (UtilValidate.isEmpty(kids)) {
parentList.add(nodeMap.get("contentId"));
} else {
for (Map<String, Object> node : kids) {
walkParentTree(node, parentList);
}
}
}
/**
* This is a generic service for traversing a Content tree, typical of a blog response tree. It calls the ContentWorker.traverse method.
*/
public static Map<String, Object> traverseContent(DispatchContext dctx, Map<String, ? extends Object> context) {
Delegator delegator = dctx.getDelegator();
Map<String, Object> results = new HashMap<>();
Locale locale = (Locale) context.get("locale");

String contentId = (String) context.get("contentId");
String direction = (String) context.get("direction");
if (direction != null && "From".equalsIgnoreCase(direction)) {
direction = "From";
} else {
direction = "To";
}

if (contentId == null) {
contentId = "PUBLISH_ROOT";
}

GenericValue content = null;
try {
content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, "Entity Error:" + e.getMessage(), MODULE);
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentNoContentFound",
UtilMisc.toMap("contentId", contentId), locale));
}

String fromDateStr = (String) context.get("fromDateStr");
String thruDateStr = (String) context.get("thruDateStr");
Timestamp fromDate = null;
if (UtilValidate.isNotEmpty(fromDateStr)) {
fromDate = UtilDateTime.toTimestamp(fromDateStr);
}

Timestamp thruDate = null;
if (UtilValidate.isNotEmpty(thruDateStr)) {
thruDate = UtilDateTime.toTimestamp(thruDateStr);
}

Map<String, Object> whenMap = new HashMap<>();
whenMap.put("followWhen", context.get("followWhen"));
whenMap.put("pickWhen", context.get("pickWhen"));
whenMap.put("returnBeforePickWhen", context.get("returnBeforePickWhen"));
whenMap.put("returnAfterPickWhen", context.get("returnAfterPickWhen"));

String startContentAssocTypeId = (String) context.get("contentAssocTypeId");
if (startContentAssocTypeId != null) {
startContentAssocTypeId = "PUBLISH";
}

Map<String, Object> nodeMap = new HashMap<>();
List<GenericValue> pickList = new LinkedList<>();
ContentWorker.traverse(delegator, content, fromDate, thruDate, whenMap, 0, nodeMap, startContentAssocTypeId, pickList, direction);

results.put("nodeMap", nodeMap);
results.put("pickList", pickList);
return results;
}

/**
* Update a ContentAssoc service. The work is done in a separate method so that complex services that need this
Expand Down
Loading