@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;
  }
예제 #2
0
파일: Site.java 프로젝트: nuxeo/lm-labs
  @Override
  public void initialize(Object... args) {
    super.initialize(args);
    site = Tools.getAdapter(LabsSite.class, doc, ctx.getCoreSession());

    ctx.setProperty("site", site);
  }
예제 #3
0
파일: Site.java 프로젝트: nuxeo/lm-labs
  @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);
  }
예제 #4
0
파일: Site.java 프로젝트: nuxeo/lm-labs
 @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;
 }
예제 #6
0
파일: Site.java 프로젝트: nuxeo/lm-labs
 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();
 }
예제 #7
0
파일: Site.java 프로젝트: nuxeo/lm-labs
 public List<DocumentModel> getDeletedDocs() throws ClientException {
   return Tools.getAdapter(LabsSite.class, doc, ctx.getCoreSession()).getAllDeletedDocs();
 }