Пример #1
0
  protected void collectSupportedPublishingEvents(
      ServiceReference<Portlet> serviceReference, com.liferay.portal.model.Portlet portletModel) {

    Set<QName> publishingEvents = new HashSet<>();

    PortletApp portletApp = portletModel.getPortletApp();

    List<String> supportedPublishingEvents =
        StringPlus.asList(serviceReference.getProperty("javax.portlet.supported-publishing-event"));

    for (String supportedPublishingEvent : supportedPublishingEvents) {
      String name = supportedPublishingEvent;
      String qname = null;

      String[] parts = StringUtil.split(supportedPublishingEvent, StringPool.SEMICOLON);

      if (parts.length == 2) {
        name = parts[0];
        qname = parts[1];
      }

      QName qName = getQName(name, qname, portletApp.getDefaultNamespace());

      publishingEvents.add(qName);
    }

    portletModel.setPublishingEvents(publishingEvents);
  }
Пример #2
0
  protected void collectPortletModes(
      ServiceReference<Portlet> serviceReference, com.liferay.portal.model.Portlet portletModel) {

    Map<String, Set<String>> portletModes = new HashMap<>();

    portletModes.put(
        ContentTypes.TEXT_HTML, SetUtil.fromArray(new String[] {toLowerCase(PortletMode.VIEW)}));

    List<String> portletModesStrings =
        StringPlus.asList(serviceReference.getProperty("javax.portlet.portlet-mode"));

    for (String portletModesString : portletModesStrings) {
      String[] portletModesStringParts = StringUtil.split(portletModesString, CharPool.SEMICOLON);

      if (portletModesStringParts.length != 2) {
        continue;
      }

      String mimeType = portletModesStringParts[0];

      Set<String> mimeTypePortletModes = new HashSet<>();

      mimeTypePortletModes.add(toLowerCase(PortletMode.VIEW));
      mimeTypePortletModes.addAll(toLowerCaseSet(portletModesStringParts[1]));

      portletModes.put(mimeType, mimeTypePortletModes);
    }

    portletModel.setPortletModes(portletModes);
  }
Пример #3
0
  protected void collectSupportedPublicRenderParameters(
      ServiceReference<Portlet> serviceReference, com.liferay.portal.model.Portlet portletModel) {

    Set<PublicRenderParameter> publicRenderParameters = new HashSet<>();

    PortletApp portletApp = portletModel.getPortletApp();

    List<String> supportedPublicRenderParameters =
        StringPlus.asList(
            serviceReference.getProperty("javax.portlet.supported-public-render-parameter"));

    for (String supportedPublicRenderParameter : supportedPublicRenderParameters) {

      String name = supportedPublicRenderParameter;
      String qname = null;

      String[] parts = StringUtil.split(supportedPublicRenderParameter, StringPool.SEMICOLON);

      if (parts.length == 2) {
        name = parts[0];
        qname = parts[1];
      }

      QName qName = getQName(name, qname, portletApp.getDefaultNamespace());

      PublicRenderParameter publicRenderParameter =
          new PublicRenderParameterImpl(name, qName, portletApp);

      publicRenderParameters.add(publicRenderParameter);
    }

    portletModel.setPublicRenderParameters(publicRenderParameters);
  }
Пример #4
0
  protected void collectSecurityRoleRefs(
      ServiceReference<Portlet> serviceReference, com.liferay.portal.model.Portlet portletModel) {

    Set<String> unlinkedRoles = new HashSet<>();

    List<String> roleRefs =
        StringPlus.asList(serviceReference.getProperty("javax.portlet.security-role-ref"));

    if (roleRefs.isEmpty()) {
      roleRefs.add("administrator");
      roleRefs.add("guest");
      roleRefs.add("power-user");
      roleRefs.add("user");
    }

    for (String roleRef : roleRefs) {
      for (String curRoleRef : StringUtil.split(roleRef)) {
        unlinkedRoles.add(curRoleRef);
      }
    }

    portletModel.setUnlinkedRoles(unlinkedRoles);

    portletModel.linkRoles();
  }
Пример #5
0
  protected void collectApplicationTypes(
      ServiceReference<Portlet> serviceReference, com.liferay.portal.model.Portlet portletModel) {

    Set<ApplicationType> applicationTypes = new HashSet<>();

    List<String> applicationTypeValues =
        StringPlus.asList(get(serviceReference, "application-type"));

    for (String applicationTypeValue : applicationTypeValues) {
      try {
        ApplicationType applicationType = ApplicationType.parse(applicationTypeValue);

        applicationTypes.add(applicationType);
      } catch (IllegalArgumentException iae) {
        _log.error("Application type " + applicationTypeValue);

        continue;
      }
    }

    if (applicationTypes.isEmpty()) {
      applicationTypes.add(ApplicationType.WIDGET);
    }

    portletModel.setApplicationTypes(applicationTypes);
  }
    @Override
    public IndexerPostProcessor addingService(
        ServiceReference<IndexerPostProcessor> serviceReference) {

      Registry registry = RegistryUtil.getRegistry();

      IndexerPostProcessor indexerPostProcessor = registry.getService(serviceReference);

      List<String> indexerClassNames =
          StringPlus.asList(serviceReference.getProperty("indexer.class.name"));

      for (String indexerClassName : indexerClassNames) {
        Indexer indexer = IndexerRegistryUtil.getIndexer(indexerClassName);

        if (indexer == null) {
          _log.error("No indexer for " + indexerClassName + " was found");

          continue;
        }

        indexer.registerIndexerPostProcessor(indexerPostProcessor);
      }

      return indexerPostProcessor;
    }
Пример #7
0
  @Reference(unbind = "-")
  protected void setHttpServiceRuntime(
      HttpServiceRuntime httpServiceRuntime, Map<String, Object> properties) {

    List<String> httpServiceEndpoints =
        StringPlus.asList(properties.get(HttpServiceRuntimeConstants.HTTP_SERVICE_ENDPOINT));

    if (!httpServiceEndpoints.isEmpty()) {
      _httpServiceEndpoint = httpServiceEndpoints.get(0);
    }
  }
    @Override
    public Object addingService(ServiceReference<Object> serviceReference) {
      List<String> authTokenIgnoreActions =
          StringPlus.asList(serviceReference.getProperty(PropsKeys.AUTH_TOKEN_IGNORE_ACTIONS));

      _portletCSRFWhitelistActions.addAll(authTokenIgnoreActions);

      Registry registry = RegistryUtil.getRegistry();

      return registry.getService(serviceReference);
    }
Пример #9
0
  protected void collectWindowStates(
      ServiceReference<Portlet> serviceReference, com.liferay.portal.model.Portlet portletModel) {

    Map<String, Set<String>> windowStates = new HashMap<>();

    windowStates.put(
        ContentTypes.TEXT_HTML,
        SetUtil.fromArray(
            new String[] {
              toLowerCase(LiferayWindowState.EXCLUSIVE),
              toLowerCase(LiferayWindowState.POP_UP),
              toLowerCase(WindowState.MAXIMIZED),
              toLowerCase(WindowState.MINIMIZED),
              toLowerCase(WindowState.NORMAL)
            }));

    List<String> windowStatesStrings =
        StringPlus.asList(serviceReference.getProperty("javax.portlet.window-state"));

    for (String windowStatesString : windowStatesStrings) {
      String[] windowStatesStringParts = StringUtil.split(windowStatesString, CharPool.SEMICOLON);

      if (windowStatesStringParts.length != 2) {
        continue;
      }

      String mimeType = windowStatesStringParts[0];

      Set<String> mimeTypeWindowStates = new HashSet<>();

      mimeTypeWindowStates.add(toLowerCase(WindowState.NORMAL));

      Set<String> windowStatesSet = toLowerCaseSet(windowStatesStringParts[1]);

      if (windowStatesSet.isEmpty()) {
        mimeTypeWindowStates.add(toLowerCase(LiferayWindowState.EXCLUSIVE));
        mimeTypeWindowStates.add(toLowerCase(LiferayWindowState.POP_UP));
        mimeTypeWindowStates.add(toLowerCase(WindowState.MAXIMIZED));
        mimeTypeWindowStates.add(toLowerCase(WindowState.MINIMIZED));
      } else {
        mimeTypeWindowStates.addAll(windowStatesSet);
      }

      windowStates.put(mimeType, mimeTypeWindowStates);
    }

    portletModel.setWindowStates(windowStates);
  }
Пример #10
0
  protected void collectSupportedProcessingEvents(
      ServiceReference<Portlet> serviceReference, com.liferay.portal.model.Portlet portletModel) {

    Set<QName> processingEvents = new HashSet<>();

    PortletApp portletApp = portletModel.getPortletApp();

    List<String> supportedProcessingEvents =
        StringPlus.asList(serviceReference.getProperty("javax.portlet.supported-processing-event"));

    for (String supportedProcessingEvent : supportedProcessingEvents) {
      String name = supportedProcessingEvent;
      String qname = null;

      String[] parts = StringUtil.split(supportedProcessingEvent, StringPool.SEMICOLON);

      if (parts.length == 2) {
        name = parts[0];
        qname = parts[1];
      }

      QName qName = getQName(name, qname, portletApp.getDefaultNamespace());

      processingEvents.add(qName);

      Set<EventDefinition> eventDefinitions = portletApp.getEventDefinitions();

      for (EventDefinition eventDefinition : eventDefinitions) {
        Set<QName> qNames = eventDefinition.getQNames();

        if (qNames.contains(qName)) {
          processingEvents.addAll(qNames);
        }
      }
    }

    portletModel.setProcessingEvents(processingEvents);
  }
Пример #11
0
  protected void collectLiferayFeatures(
      ServiceReference<Portlet> serviceReference, com.liferay.portal.model.Portlet portletModel) {

    portletModel.setActionTimeout(
        GetterUtil.getInteger(
            get(serviceReference, "action-timeout"), portletModel.getActionTimeout()));
    portletModel.setActionURLRedirect(
        GetterUtil.getBoolean(
            get(serviceReference, "action-url-redirect"), portletModel.getActionURLRedirect()));
    portletModel.setActive(
        GetterUtil.getBoolean(get(serviceReference, "active"), portletModel.isActive()));
    portletModel.setAddDefaultResource(
        GetterUtil.getBoolean(
            get(serviceReference, "add-default-resource"), portletModel.isAddDefaultResource()));
    portletModel.setAjaxable(
        GetterUtil.getBoolean(get(serviceReference, "ajaxable"), portletModel.isAjaxable()));

    Set<String> autopropagatedParameters =
        SetUtil.fromCollection(
            StringPlus.asList(get(serviceReference, "autopropagated-parameters")));

    portletModel.setAutopropagatedParameters(autopropagatedParameters);

    portletModel.setControlPanelEntryWeight(
        GetterUtil.getDouble(
            get(serviceReference, "control-panel-entry-weight"),
            portletModel.getControlPanelEntryWeight()));
    portletModel.setCssClassWrapper(
        GetterUtil.getString(
            get(serviceReference, "css-class-wrapper"), portletModel.getCssClassWrapper()));
    portletModel.setFacebookIntegration(
        GetterUtil.getString(
            get(serviceReference, "facebook-integration"), portletModel.getFacebookIntegration()));
    portletModel.setFooterPortalCss(StringPlus.asList(get(serviceReference, "footer-portal-css")));
    portletModel.setFooterPortalJavaScript(
        StringPlus.asList(get(serviceReference, "footer-portal-javascript")));
    portletModel.setFooterPortletCss(
        StringPlus.asList(get(serviceReference, "footer-portlet-css")));
    portletModel.setFooterPortletJavaScript(
        StringPlus.asList(get(serviceReference, "footer-portlet-javascript")));
    portletModel.setFriendlyURLMapping(
        GetterUtil.getString(
            get(serviceReference, "friendly-url-mapping"), portletModel.getFriendlyURLMapping()));
    portletModel.setFriendlyURLRoutes(
        GetterUtil.getString(
            get(serviceReference, "friendly-url-routes"), portletModel.getFriendlyURLRoutes()));
    portletModel.setHeaderPortalCss(StringPlus.asList(get(serviceReference, "header-portal-css")));
    portletModel.setHeaderPortalJavaScript(
        StringPlus.asList(get(serviceReference, "header-portal-javascript")));
    portletModel.setHeaderPortletCss(
        StringPlus.asList(get(serviceReference, "header-portlet-css")));
    portletModel.setHeaderPortletJavaScript(
        StringPlus.asList(get(serviceReference, "header-portlet-javascript")));
    portletModel.setIcon(
        GetterUtil.getString(get(serviceReference, "icon"), portletModel.getIcon()));
    portletModel.setInclude(
        GetterUtil.getBoolean(get(serviceReference, "include"), portletModel.isInclude()));
    portletModel.setInstanceable(
        GetterUtil.getBoolean(
            get(serviceReference, "instanceable"), portletModel.isInstanceable()));
    portletModel.setLayoutCacheable(
        GetterUtil.getBoolean(
            get(serviceReference, "layout-cacheable"), portletModel.isLayoutCacheable()));
    portletModel.setMaximizeEdit(
        GetterUtil.getBoolean(
            get(serviceReference, "maximize-edit"), portletModel.isMaximizeEdit()));
    portletModel.setMaximizeHelp(
        GetterUtil.getBoolean(
            get(serviceReference, "maximize-help"), portletModel.isMaximizeHelp()));
    portletModel.setParentStrutsPath(
        GetterUtil.getString(
            get(serviceReference, "parent-struts-path"), portletModel.getParentStrutsPath()));
    portletModel.setPopUpPrint(
        GetterUtil.getBoolean(get(serviceReference, "pop-up-print"), portletModel.isPopUpPrint()));
    portletModel.setPreferencesCompanyWide(
        GetterUtil.getBoolean(
            get(serviceReference, "preferences-company-wide"),
            portletModel.isPreferencesCompanyWide()));
    portletModel.setPreferencesOwnedByGroup(
        GetterUtil.getBoolean(
            get(serviceReference, "preferences-owned-by-group"),
            portletModel.isPreferencesOwnedByGroup()));
    portletModel.setPreferencesUniquePerLayout(
        GetterUtil.getBoolean(
            get(serviceReference, "preferences-unique-per-layout"),
            portletModel.isPreferencesUniquePerLayout()));
    portletModel.setPrivateRequestAttributes(
        GetterUtil.getBoolean(
            get(serviceReference, "private-request-attributes"),
            portletModel.isPrivateRequestAttributes()));
    portletModel.setPrivateSessionAttributes(
        GetterUtil.getBoolean(
            get(serviceReference, "private-session-attributes"),
            portletModel.isPrivateSessionAttributes()));
    portletModel.setRemoteable(
        GetterUtil.getBoolean(get(serviceReference, "remoteable"), portletModel.isRemoteable()));
    portletModel.setRenderTimeout(
        GetterUtil.getInteger(
            get(serviceReference, "render-timeout"), portletModel.getRenderTimeout()));
    portletModel.setRenderWeight(
        GetterUtil.getInteger(
            get(serviceReference, "render-weight"), portletModel.getRenderWeight()));

    if (!portletModel.isAjaxable() && (portletModel.getRenderWeight() < 1)) {

      portletModel.setRenderWeight(1);
    }

    boolean defaultRequiresNamespacedParameters =
        GetterUtil.getBoolean(
            get(serviceReference, "requires-namespaced-parameters"),
            portletModel.isRequiresNamespacedParameters());

    portletModel.setRequiresNamespacedParameters(
        GetterUtil.getBoolean(
            serviceReference.getProperty("requires-namespaced-parameters"),
            defaultRequiresNamespacedParameters));

    portletModel.setRestoreCurrentView(
        GetterUtil.getBoolean(
            get(serviceReference, "restore-current-view"), portletModel.isRestoreCurrentView()));
    portletModel.setScopeable(
        GetterUtil.getBoolean(get(serviceReference, "scopeable"), portletModel.isScopeable()));
    portletModel.setShowPortletAccessDenied(
        GetterUtil.getBoolean(
            get(serviceReference, "show-portlet-access-denied"),
            portletModel.isShowPortletAccessDenied()));
    portletModel.setShowPortletInactive(
        GetterUtil.getBoolean(
            get(serviceReference, "show-portlet-inactive"), portletModel.isShowPortletInactive()));
    portletModel.setSocialInteractionsConfiguration(
        GetterUtil.getBoolean(
            get(serviceReference, "social-interactions-configuration"),
            portletModel.isSocialInteractionsConfiguration()));
    portletModel.setStrutsPath(
        GetterUtil.getString(get(serviceReference, "struts-path"), portletModel.getStrutsPath()));
    portletModel.setSystem(
        GetterUtil.getBoolean(get(serviceReference, "system"), portletModel.isSystem()));
    portletModel.setUseDefaultTemplate(
        GetterUtil.getBoolean(
            get(serviceReference, "use-default-template"), portletModel.isUseDefaultTemplate()));
    portletModel.setUserPrincipalStrategy(
        GetterUtil.getString(
            get(serviceReference, "user-principal-strategy"),
            portletModel.getUserPrincipalStrategy()));
    portletModel.setVirtualPath(
        GetterUtil.getString(get(serviceReference, "virtual-path"), portletModel.getVirtualPath()));
  }