Exemplo n.º 1
0
 private PageDTO createPageBean(
     String sitemapName,
     String title,
     String icon,
     String pageId,
     EList<Widget> children,
     boolean drillDown,
     boolean isLeaf,
     URI uri) {
   PageDTO bean = new PageDTO();
   bean.id = pageId;
   bean.title = title;
   bean.icon = icon;
   bean.leaf = isLeaf;
   bean.link =
       UriBuilder.fromUri(uri)
           .path(PATH_SITEMAPS)
           .path(sitemapName)
           .path(pageId)
           .build()
           .toASCIIString();
   if (children != null) {
     int cntWidget = 0;
     for (Widget widget : children) {
       String widgetId = pageId + "_" + cntWidget;
       WidgetDTO subWidget = createWidgetBean(sitemapName, widget, drillDown, uri, widgetId);
       if (subWidget != null) bean.widgets.add(subWidget);
       cntWidget++;
     }
   } else {
     bean.widgets = null;
   }
   return bean;
 }
Exemplo n.º 2
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);
   }
 }