public static List<String> makeBestTrailElementsForTrail(HttpServletRequest request,Delegator delegator,String categoryId,String productId){
  List<String> trail=CategoryWorker.getTrail(request);
  List<String> trailElements=null;
  if (categoryId != null) {
    if (trail == null || trail.size() < 1) {
      ;
    }
 else {
      ListIterator<String> li=trail.listIterator(trail.size());
      while (li.hasPrevious()) {
        String trailCatId=li.previous();
        if (categoryId.equals(trailCatId)) {
          trailElements=FastList.newInstance();
          trailElements.add(categoryId);
          break;
        }
      }
      if (trailElements == null) {
        li=trail.listIterator(trail.size());
        while (li.hasPrevious()) {
          String trailCatId=li.previous();
          if (CategoryWorker.isCategoryChildOf(request,trailCatId,categoryId)) {
            trailElements=FastList.newInstance();
            trailElements.add(trailCatId);
            trailElements.add(categoryId);
            break;
          }
        }
      }
    }
  }
 else {
    if (trail == null || trail.size() < 1) {
      ;
    }
 else {
      ListIterator<String> li=trail.listIterator(trail.size());
      while (li.hasPrevious()) {
        String trailCatId=li.previous();
        if (CategoryWorker.isCategoryContainsProduct(request,trailCatId,productId)) {
          trailElements=FastList.newInstance();
          trailElements.add(trailCatId);
          break;
        }
      }
    }
  }
  return trailElements;
}

public static List < String > makeBestTrailElementsForTrail ( HttpServletRequest request , Delegator delegator , String categoryId , String productId ) { List < String > trail = CategoryWorker . getTrail ( request ) ; List < String > trailElements = null ; if ( categoryId != null ) { if ( trail == null || trail . size ( ) < 1 ) { ; } else { ListIterator < String > li = trail . listIterator ( trail . size ( ) ) ; while ( li . hasPrevious ( ) ) { String trailCatId = li . previous ( ) ; if ( categoryId . equals ( trailCatId ) ) { trailElements = FastList . newInstance ( ) ; trailElements . add ( categoryId ) ; break ; } } if ( trailElements == null ) { li = trail . listIterator ( trail . size ( ) ) ; while ( li . hasPrevious ( ) ) { String trailCatId = li . previous ( ) ; if ( CategoryWorker . isCategoryChildOf ( request , trailCatId , categoryId ) ) { trailElements = FastList . newInstance ( ) ; trailElements . add ( trailCatId ) ; trailElements . add ( categoryId ) ; break ; } } } } } else { if ( trail == null || trail . size ( ) < 1 ) { ; } else { ListIterator < String > li = trail . listIterator ( trail . size ( ) ) ; while ( li . hasPrevious ( ) ) { String trailCatId = li . previous ( ) ; if ( CategoryWorker . isCategoryContainsProduct ( request , trailCatId , productId ) ) { trailElements = FastList . newInstance ( ) ; trailElements . add ( trailCatId ) ; break ; } } } } return trailElements ; }
scipio : tries to see if the passed product or category can be integrated in the current / given trail . if it can , returns a list of trailelements that can be passed to # updaterequestandtrail which will merge them together . < p > if an appropriate list of trail elements can ' t be made ( a brand new one will be required ) , returns null . < p > fixme : this still does not always produce the most appropriate default trail ; it only helps in some simple cases where current trail already contains the current product or category .
