예제 #1
0
  private static boolean _isDatabaseConfigured(UnicodeProperties unicodeProperties) {

    String defaultDriverClassName = unicodeProperties.get(PropsKeys.JDBC_DEFAULT_DRIVER_CLASS_NAME);
    String defaultPassword = unicodeProperties.get(PropsKeys.JDBC_DEFAULT_PASSWORD);
    String defaultURL = unicodeProperties.get(PropsKeys.JDBC_DEFAULT_URL);
    String defaultUsername = unicodeProperties.get(PropsKeys.JDBC_DEFAULT_USERNAME);

    if (PropsValues.JDBC_DEFAULT_DRIVER_CLASS_NAME.equals(defaultDriverClassName)
        && PropsValues.JDBC_DEFAULT_PASSWORD.equals(defaultPassword)
        && PropsValues.JDBC_DEFAULT_URL.equals(defaultURL)
        && PropsValues.JDBC_DEFAULT_USERNAME.equals(defaultUsername)) {

      return true;
    }

    return false;
  }
예제 #2
0
  protected boolean isCacheableData(long companyId, HttpServletRequest request) {

    try {
      if (_pattern == _PATTERN_RESOURCE) {
        return true;
      }

      long plid =
          getPlid(
              companyId,
              request.getPathInfo(),
              request.getServletPath(),
              ParamUtil.getLong(request, "p_l_id"));

      if (plid <= 0) {
        return false;
      }

      Layout layout = LayoutLocalServiceUtil.getLayout(plid);

      if (!layout.isTypePortlet()) {
        return false;
      }

      UnicodeProperties properties = layout.getTypeSettingsProperties();

      for (int i = 0; i < 10; i++) {
        String columnId = "column-" + i;

        String settings = properties.getProperty(columnId, StringPool.BLANK);

        if (!isCacheableColumn(companyId, settings)) {
          return false;
        }
      }

      String columnIdsString = properties.get(LayoutTypePortletConstants.NESTED_COLUMN_IDS);

      if (columnIdsString != null) {
        String[] columnIds = StringUtil.split(columnIdsString);

        for (String columnId : columnIds) {
          String settings = properties.getProperty(columnId, StringPool.BLANK);

          if (!isCacheableColumn(companyId, settings)) {
            return false;
          }
        }
      }

      return true;
    } catch (Exception e) {
      return false;
    }
  }
  public boolean evaluateRule(MDRRule mdrRule, ThemeDisplay themeDisplay) {
    Device device = themeDisplay.getDevice();

    if (device == null) {
      return false;
    }

    UnicodeProperties typeSettingsProperties = mdrRule.getTypeSettingsProperties();

    boolean result = true;

    String os = typeSettingsProperties.get("os");

    if (Validator.isNotNull(os)) {
      String[] operatingSystems = StringUtil.split(os);

      if (ArrayUtil.contains(operatingSystems, device.getOS())) {
        result = true;
      } else {
        result = false;
      }
    }

    String tablet = typeSettingsProperties.get("tablet");

    if (Validator.isNotNull(tablet)) {
      boolean tabletBoolean = GetterUtil.getBoolean(tablet);

      if (result && (tabletBoolean == device.isTablet())) {
        result = true;
      } else {
        result = false;
      }
    }

    return result;
  }
  protected void doAddAttributes(Document document, ExpandoBridge expandoBridge) {

    List<ExpandoColumn> expandoColumns =
        ExpandoColumnLocalServiceUtil.getDefaultTableColumns(
            expandoBridge.getCompanyId(), expandoBridge.getClassName());

    if ((expandoColumns == null) || expandoColumns.isEmpty()) {
      return;
    }

    List<ExpandoColumn> indexedColumns = new ArrayList<>();

    for (ExpandoColumn expandoColumn : expandoColumns) {
      UnicodeProperties properties = expandoColumn.getTypeSettingsProperties();

      int indexType = GetterUtil.getInteger(properties.get(ExpandoColumnConstants.INDEX_TYPE));

      if (indexType != ExpandoColumnConstants.INDEX_TYPE_NONE) {
        indexedColumns.add(expandoColumn);
      }
    }

    if (indexedColumns.isEmpty()) {
      return;
    }

    List<ExpandoValue> expandoValues =
        ExpandoValueLocalServiceUtil.getRowValues(
            expandoBridge.getCompanyId(),
            expandoBridge.getClassName(),
            ExpandoTableConstants.DEFAULT_TABLE_NAME,
            expandoBridge.getClassPK(),
            QueryUtil.ALL_POS,
            QueryUtil.ALL_POS);

    for (ExpandoColumn expandoColumn : indexedColumns) {
      try {
        addAttribute(document, expandoColumn, expandoValues);
      } catch (Exception e) {
        _log.error("Indexing " + expandoColumn.getName(), e);
      }
    }
  }
  @Override
  public String getActualURL(
      long companyId,
      long groupId,
      boolean privateLayout,
      String mainPath,
      String friendlyURL,
      Map<String, String[]> params,
      Map<String, Object> requestContext)
      throws PortalException {

    String urlTitle =
        friendlyURL.substring(JournalArticleConstants.CANONICAL_URL_SEPARATOR.length());

    JournalArticle journalArticle =
        _journalArticleLocalService.getArticleByUrlTitle(groupId, urlTitle);

    Layout layout = getJournalArticleLayout(groupId, privateLayout, friendlyURL);

    String layoutActualURL = PortalUtil.getLayoutActualURL(layout, mainPath);

    InheritableMap<String, String[]> actualParams = new InheritableMap<>();

    if (params != null) {
      actualParams.setParentMap(params);
    }

    UnicodeProperties typeSettingsProperties = layout.getTypeSettingsProperties();

    String defaultAssetPublisherPortletId =
        typeSettingsProperties.get(LayoutTypePortletConstants.DEFAULT_ASSET_PUBLISHER_PORTLET_ID);

    String currentDefaultAssetPublisherPortletId = defaultAssetPublisherPortletId;

    if (Validator.isNull(defaultAssetPublisherPortletId)) {
      PortletInstance portletInstance =
          new PortletInstance(AssetPublisherPortletKeys.ASSET_PUBLISHER);

      defaultAssetPublisherPortletId = portletInstance.getPortletInstanceKey();
    }

    HttpServletRequest request = (HttpServletRequest) requestContext.get("request");

    if (Validator.isNull(currentDefaultAssetPublisherPortletId)) {
      String actualPortletAuthenticationToken =
          AuthTokenUtil.getToken(request, layout.getPlid(), defaultAssetPublisherPortletId);

      actualParams.put("p_p_auth", new String[] {actualPortletAuthenticationToken});
    }

    actualParams.put("p_p_id", new String[] {defaultAssetPublisherPortletId});
    actualParams.put("p_p_lifecycle", new String[] {"0"});

    if (Validator.isNull(currentDefaultAssetPublisherPortletId)) {
      actualParams.put("p_p_state", new String[] {WindowState.MAXIMIZED.toString()});
    }

    actualParams.put("p_p_mode", new String[] {"view"});
    actualParams.put("p_j_a_id", new String[] {String.valueOf(journalArticle.getId())});

    String namespace = PortalUtil.getPortletNamespace(defaultAssetPublisherPortletId);

    actualParams.put(namespace + "mvcPath", new String[] {"/view_content.jsp"});

    AssetRendererFactory<?> assetRendererFactory =
        AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(
            JournalArticle.class.getName());

    actualParams.put(namespace + "type", new String[] {assetRendererFactory.getType()});

    actualParams.put(namespace + "urlTitle", new String[] {journalArticle.getUrlTitle()});

    String queryString = HttpUtil.parameterMapToString(actualParams, false);

    if (layoutActualURL.contains(StringPool.QUESTION)) {
      layoutActualURL = layoutActualURL + StringPool.AMPERSAND + queryString;
    } else {
      layoutActualURL = layoutActualURL + StringPool.QUESTION + queryString;
    }

    Locale locale = PortalUtil.getLocale(request);

    PortalUtil.addPageSubtitle(journalArticle.getTitle(locale), request);
    PortalUtil.addPageDescription(journalArticle.getDescription(locale), request);

    List<AssetTag> assetTags =
        _assetTagLocalService.getTags(
            JournalArticle.class.getName(), journalArticle.getPrimaryKey());

    if (!assetTags.isEmpty()) {
      PortalUtil.addPageKeywords(ListUtil.toString(assetTags, AssetTag.NAME_ACCESSOR), request);
    }

    return layoutActualURL;
  }