@Override
  public List<LabsNews> getAllNews() throws ClientException {
    List<LabsNews> listNews = new ArrayList<LabsNews>();
    CoreSession session = getSession();
    DocumentModelList listDoc = null;
    Sorter pageNewsSorter = new PageNewsSorter();
    if (session.hasPermission(doc.getRef(), SecurityConstants.WRITE)) {
      listDoc =
          session.getChildren(
              doc.getRef(), LabsSiteConstants.Docs.LABSNEWS.type(), null, null, pageNewsSorter);
    } else {
      listDoc =
          session.getChildren(
              doc.getRef(),
              LabsSiteConstants.Docs.LABSNEWS.type(),
              null,
              new PageNewsFilter(Calendar.getInstance()),
              pageNewsSorter);
    }

    for (DocumentModel doc : listDoc) {
      LabsNews news = Tools.getAdapter(LabsNews.class, doc, session);
      listNews.add(news);
    }
    return listNews;
  }
Example #2
0
  @Override
  public void initialize(Object... args) {
    super.initialize(args);
    site = Tools.getAdapter(LabsSite.class, doc, ctx.getCoreSession());

    ctx.setProperty("site", site);
  }
Example #3
0
  @SuppressWarnings("unchecked")
  @Override
  public <A> A getAdapter(Class<A> adapter) {
    if (adapter.equals(Page.class)) {
      try {
        return (A) Tools.getAdapter(Page.class, site.getIndexDocument(), ctx.getCoreSession());
      } catch (ClientException e) {

      }
    }
    return super.getAdapter(adapter);
  }
Example #4
0
 @Override
 public Object doGet() {
   try {
     return redirect(
         getPath()
             + '/'
             + URIUtils.quoteURIPathComponent(
                 (new org.nuxeo.common.utils.Path(
                             Tools.getAdapter(
                                     SiteDocument.class,
                                     site.getIndexDocument(),
                                     ctx.getCoreSession())
                                 .getResourcePath())
                         .removeFirstSegments(1))
                     .toString(),
                 false));
   } catch (HomePageException e) {
     throw WebException.wrap(e);
   } catch (ClientException e) {
     throw WebException.wrap(e);
   }
 }
 @Override
 public List<LabsNews> getTopNews(int pMaxNews) throws ClientException {
   List<LabsNews> listNews = new ArrayList<LabsNews>();
   DocumentModelList listDoc = null;
   Sorter pageNewsSorter = new PageNewsSorter();
   CoreSession session = getSession();
   listDoc =
       session.getChildren(
           doc.getRef(),
           LabsSiteConstants.Docs.LABSNEWS.type(),
           null,
           new PageNewsFilter(Calendar.getInstance()),
           pageNewsSorter);
   int nb = 0;
   for (DocumentModel doc : listDoc) {
     if (nb >= pMaxNews) {
       break;
     }
     LabsNews news = Tools.getAdapter(LabsNews.class, doc, session);
     listNews.add(news);
     nb++;
   }
   return listNews;
 }
Example #6
0
 public List<LabsNews> getNews(String pRef) throws ClientException {
   CoreSession session = getCoreSession();
   DocumentModel pageNews = session.getDocument(new IdRef(pRef));
   return Tools.getAdapter(PageNews.class, pageNews, session).getAllNews();
 }
Example #7
0
 public List<DocumentModel> getDeletedDocs() throws ClientException {
   return Tools.getAdapter(LabsSite.class, doc, ctx.getCoreSession()).getAllDeletedDocs();
 }