@@ -123,107 +123,6 @@ public static Map<String, Object> findRelatedContent(DispatchContext dctx, Map<S
123123 results .put ("contentList" , permittedList );
124124 return results ;
125125 }
126- /**
127- * This is a generic service for traversing a Content tree, typical of a blog response tree. It calls the ContentWorker.traverse method.
128- */
129- public static Map <String , Object > findContentParents (DispatchContext dctx , Map <String , ? extends Object > context ) {
130- Map <String , Object > results = new HashMap <>();
131- List <Object > parentList = new LinkedList <>();
132- results .put ("parentList" , parentList );
133- LocalDispatcher dispatcher = dctx .getDispatcher ();
134- String contentId = (String ) context .get ("contentId" );
135- String contentAssocTypeId = (String ) context .get ("contentAssocTypeId" );
136- String direction = (String ) context .get ("direction" );
137- if (UtilValidate .isEmpty (direction )) {
138- direction = "To" ;
139- }
140- Map <String , Object > traversMap = new HashMap <>();
141- traversMap .put ("contentId" , contentId );
142- traversMap .put ("direction" , direction );
143- traversMap .put ("contentAssocTypeId" , contentAssocTypeId );
144- try {
145- Map <String , Object > thisResults = dispatcher .runSync ("traverseContent" , traversMap );
146- if (ServiceUtil .isError (thisResults )) {
147- return ServiceUtil .returnError (ServiceUtil .getErrorMessage (thisResults ));
148- }
149- Map <String , Object > nodeMap = UtilGenerics .cast (thisResults .get ("nodeMap" ));
150- walkParentTree (nodeMap , parentList );
151- } catch (GenericServiceException e ) {
152- return ServiceUtil .returnFailure (e .getMessage ());
153- }
154- return results ;
155- }
156-
157- private static void walkParentTree (Map <String , Object > nodeMap , List <Object > parentList ) {
158- List <Map <String , Object >> kids = UtilGenerics .cast (nodeMap .get ("kids" ));
159- if (UtilValidate .isEmpty (kids )) {
160- parentList .add (nodeMap .get ("contentId" ));
161- } else {
162- for (Map <String , Object > node : kids ) {
163- walkParentTree (node , parentList );
164- }
165- }
166- }
167- /**
168- * This is a generic service for traversing a Content tree, typical of a blog response tree. It calls the ContentWorker.traverse method.
169- */
170- public static Map <String , Object > traverseContent (DispatchContext dctx , Map <String , ? extends Object > context ) {
171- Delegator delegator = dctx .getDelegator ();
172- Map <String , Object > results = new HashMap <>();
173- Locale locale = (Locale ) context .get ("locale" );
174-
175- String contentId = (String ) context .get ("contentId" );
176- String direction = (String ) context .get ("direction" );
177- if (direction != null && "From" .equalsIgnoreCase (direction )) {
178- direction = "From" ;
179- } else {
180- direction = "To" ;
181- }
182-
183- if (contentId == null ) {
184- contentId = "PUBLISH_ROOT" ;
185- }
186-
187- GenericValue content = null ;
188- try {
189- content = EntityQuery .use (delegator ).from ("Content" ).where ("contentId" , contentId ).queryOne ();
190- } catch (GenericEntityException e ) {
191- Debug .logError (e , "Entity Error:" + e .getMessage (), MODULE );
192- return ServiceUtil .returnError (UtilProperties .getMessage (RESOURCE , "ContentNoContentFound" ,
193- UtilMisc .toMap ("contentId" , contentId ), locale ));
194- }
195-
196- String fromDateStr = (String ) context .get ("fromDateStr" );
197- String thruDateStr = (String ) context .get ("thruDateStr" );
198- Timestamp fromDate = null ;
199- if (UtilValidate .isNotEmpty (fromDateStr )) {
200- fromDate = UtilDateTime .toTimestamp (fromDateStr );
201- }
202-
203- Timestamp thruDate = null ;
204- if (UtilValidate .isNotEmpty (thruDateStr )) {
205- thruDate = UtilDateTime .toTimestamp (thruDateStr );
206- }
207-
208- Map <String , Object > whenMap = new HashMap <>();
209- whenMap .put ("followWhen" , context .get ("followWhen" ));
210- whenMap .put ("pickWhen" , context .get ("pickWhen" ));
211- whenMap .put ("returnBeforePickWhen" , context .get ("returnBeforePickWhen" ));
212- whenMap .put ("returnAfterPickWhen" , context .get ("returnAfterPickWhen" ));
213-
214- String startContentAssocTypeId = (String ) context .get ("contentAssocTypeId" );
215- if (startContentAssocTypeId != null ) {
216- startContentAssocTypeId = "PUBLISH" ;
217- }
218-
219- Map <String , Object > nodeMap = new HashMap <>();
220- List <GenericValue > pickList = new LinkedList <>();
221- ContentWorker .traverse (delegator , content , fromDate , thruDate , whenMap , 0 , nodeMap , startContentAssocTypeId , pickList , direction );
222-
223- results .put ("nodeMap" , nodeMap );
224- results .put ("pickList" , pickList );
225- return results ;
226- }
227126
228127 /**
229128 * Update a ContentAssoc service. The work is done in a separate method so that complex services that need this
0 commit comments