Ejemplo n.º 1
0
  private static Map<String, String> _getOrderProducts(JSONObject jsonObject) {

    JSONObject productsJSONObject = jsonObject.getJSONObject("productsJSONObject");

    if (productsJSONObject == null) {
      return null;
    }

    Map<String, String> sortedMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);

    Iterator<String> itr = productsJSONObject.keys();

    while (itr.hasNext()) {
      String key = itr.next();

      sortedMap.put(key, productsJSONObject.getString(key));
    }

    return sortedMap;
  }
  protected void addLayoutColumnPortlet(
      Layout layout, String columnId, JSONObject portletJSONObject) throws Exception {

    LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();

    String rootPortletId = portletJSONObject.getString("portletId");

    if (Validator.isNull(rootPortletId)) {
      throw new ImporterException("portletId is not specified");
    }

    String portletId = layoutTypePortlet.addPortletId(userId, rootPortletId, columnId, -1, false);

    JSONObject portletPreferencesJSONObject = portletJSONObject.getJSONObject("portletPreferences");

    if ((portletPreferencesJSONObject == null) || (portletPreferencesJSONObject.length() == 0)) {

      return;
    }

    PortletPreferences portletSetup =
        PortletPreferencesFactoryUtil.getLayoutPortletSetup(layout, portletId);

    Iterator<String> iterator = portletPreferencesJSONObject.keys();

    while (iterator.hasNext()) {
      String key = iterator.next();

      String value = portletPreferencesJSONObject.getString(key);

      if (rootPortletId.equals(PortletKeys.JOURNAL_CONTENT) && key.equals("articleId")) {

        value = getJournalArticleId(value);
      }

      portletSetup.setValue(key, value);
    }

    portletSetup.store();
  }