Exemplo n.º 1
0
  /** @see com.liferay.portal.model.impl.LayoutTypePortletImpl#getStaticPortlets( String) */
  protected static Portlet getPortlet(long companyId, String portletId) throws Exception {

    Portlet portlet = PortletLocalServiceUtil.getPortletById(companyId, portletId);

    // See LayoutTypePortletImpl#getStaticPortlets for why we only clone
    // non-instanceable portlets

    if (!portlet.isInstanceable()) {
      portlet = (Portlet) portlet.clone();
    }

    portlet.setStatic(true);

    return portlet;
  }
  protected List<Portlet> getStaticPortlets(String position) {
    String[] portletIds = getStaticPortletIds(position);

    List<Portlet> portlets = new ArrayList<>();

    for (String portletId : portletIds) {
      if (Validator.isNull(portletId) || hasNonstaticPortletId(portletId)) {

        continue;
      }

      Portlet portlet = PortletLocalServiceUtil.getPortletById(getCompanyId(), portletId);

      if (portlet != null) {
        Portlet staticPortlet = portlet;

        if (portlet.isInstanceable()) {

          // Instanceable portlets do not need to be cloned because
          // they are already cloned. See the method getPortletById in
          // the class PortletLocalServiceImpl and how it references
          // the method getClonedInstance in the class PortletImpl.

        } else {
          staticPortlet = (Portlet) staticPortlet.clone();
        }

        staticPortlet.setStatic(true);

        if (position.startsWith("layout.static.portlets.start")) {
          staticPortlet.setStaticStart(true);
        }

        portlets.add(staticPortlet);
      }
    }

    return portlets;
  }