private static String[] _findThreadPriority(
      double value, ThemeDisplay themeDisplay, String[] priorities) {

    for (int i = 0; i < priorities.length; i++) {
      String[] priority = StringUtil.split(priorities[i]);

      try {
        String priorityName = priority[0];
        String priorityImage = priority[1];
        double priorityValue = GetterUtil.getDouble(priority[2]);

        if (value == priorityValue) {
          if (!priorityImage.startsWith(Http.HTTP)) {
            priorityImage = themeDisplay.getPathThemeImages() + priorityImage;
          }

          return new String[] {priorityName, priorityImage};
        }
      } catch (Exception e) {
        _log.error("Unable to determine thread priority", e);
      }
    }

    return null;
  }
  protected DelayDuration parseDelay(Element delayElement) {
    if (delayElement == null) {
      return null;
    }

    double duration = GetterUtil.getDouble(delayElement.elementText("duration"));
    DurationScale durationScale = DurationScale.parse(delayElement.elementText("scale"));

    return new DelayDuration(duration, durationScale);
  }
  protected String getDDMContentSummary(
      Document document,
      Locale snippetLocale,
      PortletRequest portletRequest,
      PortletResponse portletResponse) {

    String content = StringPool.BLANK;

    if ((portletRequest == null) || (portletResponse == null)) {
      return content;
    }

    try {
      String articleId = document.get(Field.ARTICLE_ID);
      long groupId = GetterUtil.getLong(document.get(Field.GROUP_ID));
      double version = GetterUtil.getDouble(document.get(Field.VERSION));
      PortletRequestModel portletRequestModel =
          new PortletRequestModel(portletRequest, portletResponse);
      ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

      JournalArticleDisplay articleDisplay =
          _journalContent.getDisplay(
              groupId,
              articleId,
              version,
              null,
              Constants.VIEW,
              LocaleUtil.toLanguageId(snippetLocale),
              1,
              portletRequestModel,
              themeDisplay);

      content = articleDisplay.getDescription();

      content = HtmlUtil.replaceNewLine(content);

      if (Validator.isNull(content)) {
        content = HtmlUtil.extractText(articleDisplay.getContent());
      }
    } catch (Exception e) {
      if (_log.isDebugEnabled()) {
        _log.debug(e, e);
      }
    }

    return content;
  }
    private Object _getTypedValue(String value) {
      if (this == Type.BOOLEAN) {
        return GetterUtil.getBoolean(value);
      } else if (this == Type.BYTE) {
        return new java.lang.Byte(value).byteValue();
      } else if (this == Type.CHARACTER) {
        return value.charAt(0);
      } else if (this == Type.DOUBLE) {
        return GetterUtil.getDouble(value);
      } else if (this == Type.FLOAT) {
        return GetterUtil.getFloat(value);
      } else if (this == Type.INTEGER) {
        return GetterUtil.getInteger(value);
      } else if (this == Type.LONG) {
        return GetterUtil.getLong(value);
      } else if (this == Type.SHORT) {
        return GetterUtil.getShort(value);
      }

      return value;
    }
  public static Serializable getAttributeFromStringArray(int type, String[] attribute) {

    if (ArrayUtil.isEmpty(attribute)) {
      return null;
    }

    if (type == ExpandoColumnConstants.BOOLEAN) {
      return GetterUtil.getBoolean(attribute[0]);
    } else if (type == ExpandoColumnConstants.BOOLEAN_ARRAY) {
      return GetterUtil.getBooleanValues(attribute);
    } else if (type == ExpandoColumnConstants.DATE) {
      return GetterUtil.getDate(attribute[0], _getDateFormat());
    } else if (type == ExpandoColumnConstants.DATE_ARRAY) {
      return GetterUtil.getDateValues(attribute, _getDateFormat());
    } else if (type == ExpandoColumnConstants.DOUBLE) {
      return GetterUtil.getDouble(attribute[0]);
    } else if (type == ExpandoColumnConstants.DOUBLE_ARRAY) {
      return GetterUtil.getDoubleValues(attribute);
    } else if (type == ExpandoColumnConstants.FLOAT) {
      return GetterUtil.getFloat(attribute[0]);
    } else if (type == ExpandoColumnConstants.FLOAT_ARRAY) {
      return GetterUtil.getFloatValues(attribute);
    } else if (type == ExpandoColumnConstants.INTEGER) {
      return GetterUtil.getInteger(attribute[0]);
    } else if (type == ExpandoColumnConstants.INTEGER_ARRAY) {
      return GetterUtil.getIntegerValues(attribute);
    } else if (type == ExpandoColumnConstants.LONG) {
      return GetterUtil.getLong(attribute[0]);
    } else if (type == ExpandoColumnConstants.LONG_ARRAY) {
      return GetterUtil.getLongValues(attribute);
    } else if (type == ExpandoColumnConstants.SHORT) {
      return GetterUtil.getShort(attribute[0]);
    } else if (type == ExpandoColumnConstants.SHORT_ARRAY) {
      return GetterUtil.getShortValues(attribute);
    } else if (type == ExpandoColumnConstants.STRING) {
      return attribute[0];
    } else {
      return attribute;
    }
  }
Exemple #6
0
 public double getDouble(String key) {
   return GetterUtil.getDouble(getString(key));
 }
  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()));
  }
  public static double getDouble(ServiceContext serviceContext, String param) {

    return GetterUtil.getDouble(serviceContext.getAttribute(param));
  }
  public static double getDouble(PortletRequest portletRequest, String param) {

    return GetterUtil.getDouble(portletRequest.getParameter(param));
  }
 public static double getDouble(HttpServletRequest request, String param) {
   return GetterUtil.getDouble(request.getParameter(param));
 }
  protected void readModelResource(String servletContextName, Element modelResourceElement) {

    String name = modelResourceElement.elementTextTrim("model-name");

    Element portletRefElement = modelResourceElement.element("portlet-ref");

    for (Element portletNameElement : portletRefElement.elements("portlet-name")) {

      String portletName = portletNameElement.getTextTrim();

      if (servletContextName != null) {
        portletName = portletName.concat(PortletConstants.WAR_SEPARATOR).concat(servletContextName);
      }

      portletName = JS.getSafeName(portletName);

      // Reference for a portlet to child models

      Set<String> modelResources = _portletModelResources.get(portletName);

      if (modelResources == null) {
        modelResources = new HashSet<String>();

        _portletModelResources.put(portletName, modelResources);
      }

      modelResources.add(name);

      // Reference for a model to parent portlets

      Set<String> portletResources = _modelPortletResources.get(name);

      if (portletResources == null) {
        portletResources = new HashSet<String>();

        _modelPortletResources.put(name, portletResources);
      }

      portletResources.add(portletName);

      // Reference for a model to root portlets

      boolean root = GetterUtil.getBoolean(modelResourceElement.elementText("root"));

      if (root) {
        _portletRootModelResource.put(portletName, name);
      }
    }

    double weight = GetterUtil.getDouble(modelResourceElement.elementTextTrim("weight"), 100);

    _modelResourceWeights.put(name, weight);

    List<String> supportsActions =
        readSupportsActions(modelResourceElement, _modelResourceActions, name);

    checkModelActions(supportsActions);

    setActions(_modelResourceActions, name, supportsActions);

    readGroupDefaultActions(modelResourceElement, _modelResourceGroupDefaultActions, name);

    List<String> guestDefaultActions =
        readGuestDefaultActions(modelResourceElement, _modelResourceGuestDefaultActions, name);

    readGuestUnsupportedActions(
        modelResourceElement, _modelResourceGuestUnsupportedActions, name, guestDefaultActions);

    setActions(_modelResourceGuestDefaultActions, name, guestDefaultActions);

    readOwnerDefaultActions(modelResourceElement, _modelResourceOwnerDefaultActions, name);
  }
  public static Tuple parseMethod(String xml) throws IOException {
    XMLStreamReader xmlStreamReader = null;

    try {
      XMLInputFactory xmlInputFactory = StAXReaderUtil.getXMLInputFactory();

      xmlStreamReader = xmlInputFactory.createXMLStreamReader(new UnsyncStringReader(xml));

      xmlStreamReader.nextTag();
      xmlStreamReader.nextTag();
      xmlStreamReader.next();

      String methodName = xmlStreamReader.getText();
      List<Object> arguments = new ArrayList<Object>();

      xmlStreamReader.nextTag();

      String name = xmlStreamReader.getLocalName();

      while (!name.equals("methodCall")) {
        xmlStreamReader.nextTag();

        name = xmlStreamReader.getLocalName();

        if (name.equals("param")) {
          xmlStreamReader.nextTag();

          name = xmlStreamReader.getLocalName();

          int event = xmlStreamReader.next();

          if (event == XMLStreamConstants.START_ELEMENT) {
            name = xmlStreamReader.getLocalName();

            xmlStreamReader.next();

            String text = xmlStreamReader.getText();

            if (name.equals("string")) {
              arguments.add(text);
            } else if (name.equals("int") || name.equals("i4")) {
              arguments.add(GetterUtil.getInteger(text));
            } else if (name.equals("double")) {
              arguments.add(GetterUtil.getDouble(text));
            } else if (name.equals("boolean")) {
              arguments.add(GetterUtil.getBoolean(text));
            } else {
              throw new IOException("XML-RPC not implemented for " + name);
            }

            xmlStreamReader.nextTag();
            xmlStreamReader.nextTag();
            xmlStreamReader.nextTag();
          } else {
            String text = xmlStreamReader.getText();

            arguments.add(text);

            xmlStreamReader.nextTag();
            xmlStreamReader.nextTag();
          }

          name = xmlStreamReader.getLocalName();
        }
      }

      return new Tuple(methodName, arguments.toArray());
    } catch (Exception e) {
      throw new IOException(e.getMessage());
    } finally {
      if (xmlStreamReader != null) {
        try {
          xmlStreamReader.close();
        } catch (Exception e) {
        }
      }
    }
  }
Exemple #13
0
  protected void updateFeed(ActionRequest actionRequest) throws Exception {
    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    long groupId = ParamUtil.getLong(actionRequest, "groupId");

    String feedId = ParamUtil.getString(actionRequest, "feedId");
    boolean autoFeedId = ParamUtil.getBoolean(actionRequest, "autoFeedId");

    String name = ParamUtil.getString(actionRequest, "name");
    String description = ParamUtil.getString(actionRequest, "description");
    String type = ParamUtil.getString(actionRequest, "type");
    String structureId = ParamUtil.getString(actionRequest, "structureId");
    String templateId = ParamUtil.getString(actionRequest, "templateId");
    String rendererTemplateId = ParamUtil.getString(actionRequest, "rendererTemplateId");
    int delta = ParamUtil.getInteger(actionRequest, "delta");
    String orderByCol = ParamUtil.getString(actionRequest, "orderByCol");
    String orderByType = ParamUtil.getString(actionRequest, "orderByType");
    String targetLayoutFriendlyUrl = ParamUtil.getString(actionRequest, "targetLayoutFriendlyUrl");
    String targetPortletId = ParamUtil.getString(actionRequest, "targetPortletId");
    String contentField = ParamUtil.getString(actionRequest, "contentField");

    String feedType = RSSUtil.DEFAULT_TYPE;
    double feedVersion = RSSUtil.DEFAULT_VERSION;

    String feedTypeAndVersion = ParamUtil.getString(actionRequest, "feedTypeAndVersion");

    if (Validator.isNotNull(feedTypeAndVersion)) {
      String[] parts = feedTypeAndVersion.split(StringPool.COLON);

      try {
        feedType = parts[0];
        feedVersion = GetterUtil.getDouble(parts[1]);
      } catch (Exception e) {
      }
    } else {
      feedType = ParamUtil.getString(actionRequest, "feedType", feedType);
      feedVersion = ParamUtil.getDouble(actionRequest, "feedVersion", feedVersion);
    }

    ServiceContext serviceContext =
        ServiceContextFactory.getInstance(JournalFeed.class.getName(), actionRequest);

    if (cmd.equals(Constants.ADD)) {

      // Add feed

      JournalFeedServiceUtil.addFeed(
          groupId,
          feedId,
          autoFeedId,
          name,
          description,
          type,
          structureId,
          templateId,
          rendererTemplateId,
          delta,
          orderByCol,
          orderByType,
          targetLayoutFriendlyUrl,
          targetPortletId,
          contentField,
          feedType,
          feedVersion,
          serviceContext);
    } else {

      // Update feed

      JournalFeedServiceUtil.updateFeed(
          groupId,
          feedId,
          name,
          description,
          type,
          structureId,
          templateId,
          rendererTemplateId,
          delta,
          orderByCol,
          orderByType,
          targetLayoutFriendlyUrl,
          targetPortletId,
          contentField,
          feedType,
          feedVersion,
          serviceContext);
    }
  }