Beispiel #1
0
 private void blockUnlessChangeOccurs(String sitemapname, String pageId) {
   Sitemap sitemap = getSitemap(sitemapname);
   if (sitemap != null) {
     if (pageId.equals(sitemap.getName())) {
       waitForChanges(sitemap.getChildren());
     } else {
       Widget pageWidget = itemUIRegistry.getWidget(sitemap, pageId);
       if (pageWidget instanceof LinkableWidget) {
         EList<Widget> children = itemUIRegistry.getChildren((LinkableWidget) pageWidget);
         waitForChanges(children);
       }
     }
   }
 }
Beispiel #2
0
  private SitemapDTO createSitemapBean(
      String sitemapName, Sitemap sitemap, URI uri, Locale locale) {
    SitemapDTO bean = new SitemapDTO();

    bean.name = sitemapName;
    bean.icon = sitemap.getIcon();
    bean.label = sitemap.getLabel();

    bean.link =
        UriBuilder.fromUri(uri)
            .path(SitemapResource.PATH_SITEMAPS)
            .path(bean.name)
            .build()
            .toASCIIString();
    bean.homepage =
        createPageBean(
            sitemap.getName(),
            sitemap.getLabel(),
            sitemap.getIcon(),
            sitemap.getName(),
            sitemap.getChildren(),
            true,
            false,
            uri,
            locale);
    return bean;
  }
Beispiel #3
0
 public Collection<SitemapDTO> getSitemapBeans(URI uri) {
   Collection<SitemapDTO> beans = new LinkedList<SitemapDTO>();
   logger.debug(
       "Received HTTP GET request at '{}'.", UriBuilder.fromUri(uri).build().toASCIIString());
   for (SitemapProvider provider : sitemapProviders) {
     for (String modelName : provider.getSitemapNames()) {
       Sitemap sitemap = provider.getSitemap(modelName);
       if (sitemap != null) {
         SitemapDTO bean = new SitemapDTO();
         bean.name = modelName;
         bean.icon = sitemap.getIcon();
         bean.label = sitemap.getLabel();
         bean.link = UriBuilder.fromUri(uri).path(bean.name).build().toASCIIString();
         bean.homepage = new PageDTO();
         bean.homepage.link = bean.link + "/" + sitemap.getName();
         beans.add(bean);
       }
     }
   }
   return beans;
 }
Beispiel #4
0
 private PageDTO getPageBean(String sitemapName, String pageId, URI uri, Locale locale) {
   Sitemap sitemap = getSitemap(sitemapName);
   if (sitemap != null) {
     if (pageId.equals(sitemap.getName())) {
       return createPageBean(
           sitemapName,
           sitemap.getLabel(),
           sitemap.getIcon(),
           sitemap.getName(),
           sitemap.getChildren(),
           false,
           isLeaf(sitemap.getChildren()),
           uri,
           locale);
     } else {
       Widget pageWidget = itemUIRegistry.getWidget(sitemap, pageId);
       if (pageWidget instanceof LinkableWidget) {
         EList<Widget> children = itemUIRegistry.getChildren((LinkableWidget) pageWidget);
         PageDTO pageBean =
             createPageBean(
                 sitemapName,
                 itemUIRegistry.getLabel(pageWidget),
                 itemUIRegistry.getCategory(pageWidget),
                 pageId,
                 children,
                 false,
                 isLeaf(children),
                 uri,
                 locale);
         EObject parentPage = pageWidget.eContainer();
         while (parentPage instanceof Frame) {
           parentPage = parentPage.eContainer();
         }
         if (parentPage instanceof Widget) {
           String parentId = itemUIRegistry.getWidgetId((Widget) parentPage);
           pageBean.parent = getPageBean(sitemapName, parentId, uri, locale);
           pageBean.parent.widgets = null;
           pageBean.parent.parent = null;
         } else if (parentPage instanceof Sitemap) {
           pageBean.parent = getPageBean(sitemapName, sitemap.getName(), uri, locale);
           pageBean.parent.widgets = null;
         }
         return pageBean;
       } else {
         if (logger.isDebugEnabled()) {
           if (pageWidget == null) {
             logger.debug(
                 "Received HTTP GET request at '{}' for the unknown page id '{}'.", uri, pageId);
           } else {
             logger.debug(
                 "Received HTTP GET request at '{}' for the page id '{}'. "
                     + "This id refers to a non-linkable widget and is therefore no valid page id.",
                 uri,
                 pageId);
           }
         }
         throw new WebApplicationException(404);
       }
     }
   } else {
     logger.info(
         "Received HTTP GET request at '{}' for the unknown sitemap '{}'.", uri, sitemapName);
     throw new WebApplicationException(404);
   }
 }