Beispiel #1
0
 /**
  * Find category which is already exist.<br>
  * for example: when you are standing in category D in path: Root\A\B\C\D, you do some action (add
  * new category, add question, go out to category C or B) but another moderator delete category C
  * (or B, A). Then this function will be use to find the nearest category with category D (which
  * is exist) and move you into this category.<br>
  * <u>Detail:</u><br>
  * the first, system get category C, if C is exist, you will be moved into C else jump to B and
  * test again.<br>
  * This processing is done until find a category already exist.
  *
  * @param faqService_ FAQ Service
  * @param fAQContainer UIAnswersContainer this component is used to updated data
  * @param sessionProvider SessionProvider
  * @throws Exception
  */
 public static void findCateExist(FAQService faqService_, UIAnswersContainer fAQContainer)
     throws Exception {
   UIBreadcumbs breadcumbs = fAQContainer.findFirstComponentOfType(UIBreadcumbs.class);
   String pathCate = "";
   for (String path : breadcumbs.pathList_.get(breadcumbs.pathList_.size() - 1).split("/")) {
     if (path.equals("FAQService")) {
       pathCate = path;
       continue;
     }
     try {
       faqService_.getCategoryById(path);
       if (pathCate.trim().length() > 0) pathCate += "/";
       pathCate += path;
     } catch (Exception pathExc) {
       UIQuestions questions = fAQContainer.findFirstComponentOfType(UIQuestions.class);
       try {
         breadcumbs.setUpdataPath(pathCate);
       } catch (Exception exc) {
         log.debug("Setting update path fail: " + exc.getMessage(), exc);
       }
       if (pathCate.indexOf("/") > 0) {
         questions.setCategoryId(pathCate.substring(pathCate.lastIndexOf("/") + 1));
       } else {
         questions.categoryId_ = null;
         questions.setListObject();
         // questions.setIsNotChangeLanguage() ;
       }
       fAQContainer.findFirstComponentOfType(UICategories.class).setPathCategory(pathCate);
       break;
     }
   }
 }