public Collection<SearchResult> getArticleSearchResults(
      String folder, List<String> categories, IWContext iwc) {
    if (folder == null) {
      return null;
    }
    if (iwc == null) {
      iwc = IWContext.getInstance();
      if (iwc == null) {
        return null;
      }
    }

    IWTimestamp oldest = null;

    if (this.numberOfDaysDisplayed > 0) {
      oldest = IWTimestamp.RightNow();
      oldest.addDays(-this.numberOfDaysDisplayed);
    }

    IWSlideSession session = null;
    try {
      session = (IWSlideSession) IBOLookup.getSessionInstance(iwc, IWSlideSession.class);
    } catch (IBOLookupException e) {
      e.printStackTrace();
      return null;
    }
    String webDavUri = null;
    try {
      webDavUri = session.getWebdavServerURI();
    } catch (RemoteException e) {
      e.printStackTrace();
    }
    if (webDavUri != null) {
      if (folder.startsWith(webDavUri)) {
        folder = folder.substring(webDavUri.length());
      }
      if (folder.startsWith(CoreConstants.SLASH)) {
        folder = folder.substring(1);
      }
    }
    SearchRequest articleSearch = null;
    try {
      articleSearch = getSearchRequest(folder, iwc.getCurrentLocale(), oldest, categories);
    } catch (SearchException e) {
      e.printStackTrace();
      return null;
    }
    ContentSearch searchBusiness = new ContentSearch(iwc.getIWMainApplication());
    searchBusiness.setToUseRootAccessForSearch(true);
    searchBusiness.setToUseDescendingOrder(true);
    Search search = searchBusiness.createSearch(articleSearch);
    return search.getSearchResults();
  }
 @SuppressWarnings("unchecked")
 protected <T extends IBOSession> T getSessionInstance(
     IWUserContext iwuc, Class<? extends IBOSession> sessionBeanClass) {
   try {
     return (T)
         IBOLookup.getSessionInstance(
             iwuc,
             sessionBeanClass); //	Casting is needed to avoid stupid compilation error in Maven 2
   } catch (Exception e) {
     LOGGER.log(Level.WARNING, "Error getting session instance: " + sessionBeanClass);
   }
   return null;
 }
 public void reset() {
   getChildren().clear();
   setInitialized(false);
   IWContext iwc = IWContext.getInstance();
   try {
     WebDAVMetadataResource resource =
         (WebDAVMetadataResource) IBOLookup.getSessionInstance(iwc, WebDAVMetadataResource.class);
     resource.clear();
   } catch (IBOLookupException e) {
     throw new RuntimeException(e);
   } catch (RemoteException e) {
     throw new RuntimeException(e);
   }
 }
  public void saveCategoriesSettings() {
    if (this.resourcePath == null) {
      throw new RuntimeException("resourcePath is null");
    }

    IWContext iwc = CoreUtil.getIWContext();

    //	Save the selection of categories to the article
    String categories = getEnabledCategories(iwc);

    try {
      WebDAVMetadataResource resource =
          (WebDAVMetadataResource) IBOLookup.getSessionInstance(iwc, WebDAVMetadataResource.class);
      resource.setCategories(resourcePath, categories.toString(), getSetCategoriesOnParent());
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
 /**
  * Gets the set categories, either from the resourcePath property or the setCategories property
  *
  * @return
  */
 private Collection<String> getSetCategoriesList() {
   if (this.resourcePath != null) {
     IWContext iwuc = IWContext.getInstance();
     try {
       WebDAVMetadataResource resource =
           (WebDAVMetadataResource)
               IBOLookup.getSessionInstance(iwuc, WebDAVMetadataResource.class);
       return resource.getCategories(this.resourcePath);
     } catch (IBOLookupException e) {
       throw new RuntimeException(e);
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
   } else if (this.setCategories != null) {
     return CategoryBean.getCategoriesFromString(this.setCategories);
   }
   return null;
 }
 protected SchoolCommuneSession getSchoolCommuneSession(IWContext iwc) throws RemoteException {
   return (SchoolCommuneSession) IBOLookup.getSessionInstance(iwc, SchoolCommuneSession.class);
 }