Пример #1
0
 private static PageBean createPageBean(
     String sitemapName,
     String title,
     String icon,
     String pageId,
     EList<Widget> children,
     boolean drillDown,
     boolean isLeaf,
     URI uri) {
   PageBean bean = new PageBean();
   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;
       WidgetBean subWidget = createWidgetBean(sitemapName, widget, drillDown, uri, widgetId);
       if (subWidget != null) bean.widgets.add(subWidget);
       cntWidget++;
     }
   } else {
     bean.widgets = null;
   }
   return bean;
 }
Пример #2
0
 public static PageBean getPageBean(String sitemapName, String pageId, URI uri) {
   ItemUIRegistry itemUIRegistry = RESTApplication.getItemUIRegistry();
   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);
     } else {
       Widget pageWidget = itemUIRegistry.getWidget(sitemap, pageId);
       if (pageWidget instanceof LinkableWidget) {
         EList<Widget> children = itemUIRegistry.getChildren((LinkableWidget) pageWidget);
         PageBean pageBean =
             createPageBean(
                 sitemapName,
                 itemUIRegistry.getLabel(pageWidget),
                 itemUIRegistry.getIcon(pageWidget),
                 pageId,
                 children,
                 false,
                 isLeaf(children),
                 uri);
         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);
           pageBean.parent.widgets = null;
           pageBean.parent.parent = null;
         } else if (parentPage instanceof Sitemap) {
           pageBean.parent = getPageBean(sitemapName, sitemap.getName(), uri);
           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);
   }
 }