コード例 #1
0
  public List<KBArticle> getKBArticles(
      long[] resourcePrimKeys, int status, OrderByComparator orderByComparator)
      throws SystemException {

    List<KBArticle> kbArticles = new ArrayList<KBArticle>();

    Long[][] params = new Long[][] {ArrayUtil.toArray(resourcePrimKeys)};

    while ((params = KnowledgeBaseUtil.getParams(params[0])) != null) {
      List<KBArticle> curKBArticles = null;

      if (status == WorkflowConstants.STATUS_ANY) {
        curKBArticles = kbArticlePersistence.findByR_L(ArrayUtil.toArray(params[1]), true);
      } else if (status == WorkflowConstants.STATUS_APPROVED) {
        curKBArticles = kbArticlePersistence.findByR_M(ArrayUtil.toArray(params[1]), true);
      } else {
        curKBArticles = kbArticlePersistence.findByR_S(ArrayUtil.toArray(params[1]), status);
      }

      kbArticles.addAll(curKBArticles);
    }

    if (orderByComparator != null) {
      kbArticles = ListUtil.sort(kbArticles, orderByComparator);
    } else {
      kbArticles = KnowledgeBaseUtil.sort(resourcePrimKeys, kbArticles);
    }

    return new UnmodifiableList<KBArticle>(kbArticles);
  }
コード例 #2
0
  public static String getStringFromAttribute(int type, Serializable attribute) {

    if (attribute == null) {
      return StringPool.BLANK;
    }

    if ((type == ExpandoColumnConstants.BOOLEAN)
        || (type == ExpandoColumnConstants.DOUBLE)
        || (type == ExpandoColumnConstants.FLOAT)
        || (type == ExpandoColumnConstants.INTEGER)
        || (type == ExpandoColumnConstants.LONG)
        || (type == ExpandoColumnConstants.SHORT)) {

      return String.valueOf(attribute);
    } else if ((type == ExpandoColumnConstants.BOOLEAN_ARRAY)
        || (type == ExpandoColumnConstants.DOUBLE_ARRAY)
        || (type == ExpandoColumnConstants.FLOAT_ARRAY)
        || (type == ExpandoColumnConstants.INTEGER_ARRAY)
        || (type == ExpandoColumnConstants.LONG_ARRAY)
        || (type == ExpandoColumnConstants.SHORT_ARRAY)
        || (type == ExpandoColumnConstants.STRING_ARRAY)) {

      return StringUtil.merge(ArrayUtil.toStringArray((Object[]) attribute));
    } else if (type == ExpandoColumnConstants.DATE) {
      DateFormat dateFormat = _getDateFormat();

      return dateFormat.format((Date) attribute);
    } else if (type == ExpandoColumnConstants.DATE_ARRAY) {
      return StringUtil.merge(ArrayUtil.toStringArray((Date[]) attribute, _getDateFormat()));
    } else {
      return attribute.toString();
    }
  }
コード例 #3
0
  private static List<String> _getDependencies(String bundleId, List<String> dependencies) {

    if (!ArrayUtil.contains(PropsValues.JAVASCRIPT_BUNDLE_IDS, bundleId)) {
      return dependencies;
    }

    String[] bundleDependencies =
        PropsUtil.getArray(PropsKeys.JAVASCRIPT_BUNDLE_DEPENDENCIES, new Filter(bundleId));

    for (String bundleDependency : bundleDependencies) {
      String[] bundleDependencyDependencies =
          PropsUtil.getArray(
              PropsKeys.JAVASCRIPT_BUNDLE_DEPENDENCIES, new Filter(bundleDependency));

      if (!ArrayUtil.contains(bundleDependencyDependencies, bundleId)) {
        _getDependencies(bundleDependency, dependencies);
      }

      dependencies.add(bundleDependency);
    }

    dependencies.add(bundleId);

    return dependencies;
  }
コード例 #4
0
  protected String getDisplayStyle(HttpServletRequest request, String[] displayViews) {

    PortalPreferences portalPreferences =
        PortletPreferencesFactoryUtil.getPortalPreferences(request);

    String displayStyle = ParamUtil.getString(request, "displayStyle");

    if (Validator.isNull(displayStyle)) {
      JournalWebConfiguration journalWebConfiguration =
          (JournalWebConfiguration) _request.getAttribute(JournalWebConfiguration.class.getName());

      displayStyle =
          portalPreferences.getValue(
              JournalPortletKeys.JOURNAL,
              "display-style",
              journalWebConfiguration.defaultDisplayView());
    } else {
      if (ArrayUtil.contains(displayViews, displayStyle)) {
        portalPreferences.setValue(JournalPortletKeys.JOURNAL, "display-style", displayStyle);

        request.setAttribute(WebKeys.SINGLE_PAGE_APPLICATION_CLEAR_CACHE, Boolean.TRUE);
      }
    }

    if (!ArrayUtil.contains(displayViews, displayStyle)) {
      displayStyle = displayViews[0];
    }

    return displayStyle;
  }
コード例 #5
0
  public void editRoleAssignments(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    long roleId = ParamUtil.getLong(actionRequest, "roleId");
    Role role = RoleLocalServiceUtil.getRole(roleId);

    if (role.getName().equals(RoleConstants.OWNER)) {
      throw new RoleAssignmentException(role.getName());
    }

    long[] addUserIds = StringUtil.split(ParamUtil.getString(actionRequest, "addUserIds"), 0L);
    long[] removeUserIds =
        StringUtil.split(ParamUtil.getString(actionRequest, "removeUserIds"), 0L);

    if (!ArrayUtil.isEmpty(addUserIds) || !ArrayUtil.isEmpty(removeUserIds)) {

      UserServiceUtil.addRoleUsers(roleId, addUserIds);
      UserServiceUtil.unsetRoleUsers(roleId, removeUserIds);
    }

    long[] addGroupIds = StringUtil.split(ParamUtil.getString(actionRequest, "addGroupIds"), 0L);
    long[] removeGroupIds =
        StringUtil.split(ParamUtil.getString(actionRequest, "removeGroupIds"), 0L);

    if (!ArrayUtil.isEmpty(addGroupIds) || !ArrayUtil.isEmpty(removeGroupIds)) {

      GroupServiceUtil.addRoleGroups(roleId, addGroupIds);
      GroupServiceUtil.unsetRoleGroups(roleId, removeGroupIds);
    }
  }
コード例 #6
0
  public List<KBArticle> getKBArticleAndAllDescendants(
      long resourcePrimKey, int status, OrderByComparator orderByComparator)
      throws SystemException {

    List<KBArticle> kbArticles = getKBArticles(new long[] {resourcePrimKey}, status, null);

    kbArticles = ListUtil.copy(kbArticles);

    Long[][] params = new Long[][] {new Long[] {resourcePrimKey}};

    while ((params = KnowledgeBaseUtil.getParams(params[0])) != null) {
      List<KBArticle> curKBArticles = null;

      if (status == WorkflowConstants.STATUS_ANY) {
        curKBArticles = kbArticlePersistence.findByP_L(ArrayUtil.toArray(params[1]), true);
      } else if (status == WorkflowConstants.STATUS_APPROVED) {
        curKBArticles = kbArticlePersistence.findByP_M(ArrayUtil.toArray(params[1]), true);
      } else {
        curKBArticles = kbArticlePersistence.findByP_S(ArrayUtil.toArray(params[1]), status);
      }

      kbArticles.addAll(curKBArticles);

      long[] resourcePrimKeys =
          StringUtil.split(ListUtil.toString(curKBArticles, "resourcePrimKey"), 0L);

      params[0] = ArrayUtil.append(params[0], ArrayUtil.toArray(resourcePrimKeys));
    }

    if (orderByComparator != null) {
      kbArticles = ListUtil.sort(kbArticles, orderByComparator);
    }

    return new UnmodifiableList<KBArticle>(kbArticles);
  }
コード例 #7
0
  public String[] getAllAssetTagNames() throws Exception {
    if (_allAssetTagNames == null) {
      ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

      _allAssetTagNames = new String[0];

      String selectionStyle = getSelectionStyle();

      if (selectionStyle.equals("dynamic")) {
        _allAssetTagNames =
            AssetPublisherUtil.getAssetTagNames(
                _portletPreferences, themeDisplay.getScopeGroupId());
      }

      String assetTagName = ParamUtil.getString(_request, "tag");

      if (Validator.isNotNull(assetTagName)) {
        if (selectionStyle.equals("manual")) {
          _allAssetTagNames = ArrayUtil.append(_allAssetTagNames, assetTagName);
        }
      }

      if (isMergeURLTags() || isMergeLayoutTags()) {
        _allAssetTagNames = ArrayUtil.append(_allAssetTagNames, getCompilerTagNames());
      }

      _allAssetTagNames = ArrayUtil.distinct(_allAssetTagNames, new StringComparator());
    }

    return _allAssetTagNames;
  }
コード例 #8
0
  public String getDDLRecordSetDisplayStyle() {
    if (_ddlRecordDisplayStyle == null) {
      PortalPreferences portalPreferences =
          PortletPreferencesFactoryUtil.getPortalPreferences(_ddlRequestHelper.getRenderRequest());

      _ddlRecordDisplayStyle =
          ParamUtil.getString(_ddlRequestHelper.getRenderRequest(), "displayStyle");

      if (Validator.isNull(_ddlRecordDisplayStyle)) {
        _ddlRecordDisplayStyle =
            portalPreferences.getValue(
                DDLPortletKeys.DYNAMIC_DATA_LISTS,
                "display-style",
                _ddlWebConfiguration.defaultDisplayView());
      } else if (ArrayUtil.contains(getDDLRecordSetDisplayViews(), _ddlRecordDisplayStyle)) {

        portalPreferences.setValue(
            DDLPortletKeys.DYNAMIC_DATA_LISTS, "display-style", _ddlRecordDisplayStyle);
      }

      if (!ArrayUtil.contains(getDDLRecordSetDisplayViews(), _ddlRecordDisplayStyle)) {

        _ddlRecordDisplayStyle = getDDLRecordSetDisplayViews()[0];
      }
    }

    return _ddlRecordDisplayStyle;
  }
コード例 #9
0
  public String[] getAllAssetTagNames() throws Exception {
    if (_allAssetTagNames != null) {
      return _allAssetTagNames;
    }

    _allAssetTagNames = new String[0];

    String assetTagName = ParamUtil.getString(_request, "tag");

    String selectionStyle = getSelectionStyle();

    if (selectionStyle.equals("dynamic")) {
      _allAssetTagNames = AssetPublisherUtil.getAssetTagNames(_portletPreferences);
    }

    if (Validator.isNotNull(assetTagName) && !ArrayUtil.contains(_allAssetTagNames, assetTagName)) {

      _allAssetTagNames = ArrayUtil.append(_allAssetTagNames, assetTagName);
    }

    if (isMergeURLTags()) {
      _allAssetTagNames = ArrayUtil.append(_allAssetTagNames, getCompilerTagNames());
    }

    _allAssetTagNames = ArrayUtil.distinct(_allAssetTagNames, new StringComparator());

    return _allAssetTagNames;
  }
コード例 #10
0
  protected static String exportLinksToLayout(PortletDataContext portletDataContext, String content)
      throws Exception {

    List<String> oldLinksToLayout = new ArrayList<String>();
    List<String> newLinksToLayout = new ArrayList<String>();

    Matcher matcher = _exportLinksToLayoutPattern.matcher(content);

    while (matcher.find()) {
      long layoutId = GetterUtil.getLong(matcher.group(1));

      String type = matcher.group(2);

      boolean privateLayout = type.startsWith("private");

      try {
        Layout layout =
            LayoutLocalServiceUtil.getLayout(
                portletDataContext.getScopeGroupId(), privateLayout, layoutId);

        String oldLinkToLayout = matcher.group(0);

        StringBundler sb = new StringBundler(5);

        sb.append(type);
        sb.append(StringPool.AT);
        sb.append(layout.getUuid());
        sb.append(StringPool.AT);
        sb.append(layout.getFriendlyURL());

        String newLinkToLayout = StringUtil.replace(oldLinkToLayout, type, sb.toString());

        oldLinksToLayout.add(oldLinkToLayout);
        newLinksToLayout.add(newLinkToLayout);
      } catch (Exception e) {
        if (_log.isDebugEnabled() || _log.isWarnEnabled()) {
          String message =
              "Unable to get layout with ID "
                  + layoutId
                  + " in group "
                  + portletDataContext.getScopeGroupId();

          if (_log.isWarnEnabled()) {
            _log.warn(message);
          } else {
            _log.debug(message, e);
          }
        }
      }
    }

    content =
        StringUtil.replace(
            content,
            ArrayUtil.toStringArray(oldLinksToLayout.toArray()),
            ArrayUtil.toStringArray(newLinksToLayout.toArray()));

    return content;
  }
コード例 #11
0
  public static void updateOAuthConsumers(
      ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long[] oAuthConsumerIds = ParamUtil.getLongValues(actionRequest, "oAuthConsumerId");

    String gadgetKey = ParamUtil.getString(actionRequest, "gadgetKey");
    String[] serviceNames = ParamUtil.getParameterValues(actionRequest, "serviceName");
    String[] consumerKeys = ParamUtil.getParameterValues(actionRequest, "consumerKey");
    String[] consumerSecrets = ParamUtil.getParameterValues(actionRequest, "consumerSecret");
    String[] keyTypes = ParamUtil.getParameterValues(actionRequest, "keyType");

    if ((serviceNames.length == 0) && (keyTypes.length != 0)) {
      serviceNames = new String[] {StringPool.BLANK};
    }

    for (int i = 0; i < serviceNames.length; i++) {
      String consumerKey = (String) ArrayUtil.getValue(consumerKeys, i);

      String consumerSecret = (String) ArrayUtil.getValue(consumerSecrets, i);

      if (Validator.isNull(consumerKey)) {
        consumerKey = StringPool.BLANK;
      }

      if (Validator.isNull(consumerSecret)) {
        consumerSecret = StringPool.BLANK;
      }

      if (oAuthConsumerIds[i] <= 0) {
        OAuthConsumerLocalServiceUtil.addOAuthConsumer(
            themeDisplay.getCompanyId(),
            gadgetKey,
            serviceNames[i],
            consumerKey,
            consumerSecret,
            keyTypes[i]);
      } else {
        OAuthConsumerLocalServiceUtil.updateOAuthConsumer(
            oAuthConsumerIds[i],
            consumerKey,
            consumerSecret,
            keyTypes[i],
            StringPool.BLANK,
            StringPool.BLANK);
      }
    }
  }
コード例 #12
0
  protected Map<String, List<String>> getFolderNameFileEntryNamesMap(ZipReader zipReader) {

    Map<String, List<String>> folderNameFileEntryNamesMap = new TreeMap<String, List<String>>();

    for (String zipEntry : zipReader.getEntries()) {
      String extension = FileUtil.getExtension(zipEntry);

      if (!ArrayUtil.contains(
              PortletPropsValues.MARKDOWN_IMPORTER_ARTICLE_EXTENSIONS,
              StringPool.PERIOD.concat(extension))
          || zipEntry.equals(PortletPropsValues.MARKDOWN_IMPORTER_ARTICLE_HOME)) {

        continue;
      }

      String folderName = zipEntry.substring(0, zipEntry.lastIndexOf(StringPool.SLASH));

      List<String> fileEntryNames = folderNameFileEntryNamesMap.get(folderName);

      if (fileEntryNames == null) {
        fileEntryNames = new ArrayList<String>();
      }

      fileEntryNames.add(zipEntry);

      folderNameFileEntryNamesMap.put(folderName, fileEntryNames);
    }

    return folderNameFileEntryNamesMap;
  }
コード例 #13
0
  public void updateFileEntryType(
      long userId,
      long fileEntryTypeId,
      String name,
      String description,
      long[] ddmStructureIds,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    DLFileEntryType dlFileEntryType = dlFileEntryTypePersistence.findByPrimaryKey(fileEntryTypeId);

    long ddmStructureId =
        updateDDMStructure(
            userId,
            dlFileEntryType.getUuid(),
            fileEntryTypeId,
            dlFileEntryType.getGroupId(),
            name,
            description,
            serviceContext);

    if (ddmStructureId > 0) {
      ddmStructureIds = ArrayUtil.append(ddmStructureIds, ddmStructureId);
    }

    validate(fileEntryTypeId, dlFileEntryType.getGroupId(), name, ddmStructureIds);

    dlFileEntryType.setModifiedDate(serviceContext.getModifiedDate(null));
    dlFileEntryType.setName(name);
    dlFileEntryType.setDescription(description);

    dlFileEntryTypePersistence.update(dlFileEntryType);

    dlFileEntryTypePersistence.setDDMStructures(fileEntryTypeId, ddmStructureIds);
  }
コード例 #14
0
  @Test
  public void testUnassignUserFromRequiredGroups() throws Exception {
    long[] userIds = addUsers();
    long[] standardGroupIds = addStandardGroups();
    long[] requiredGroupIds = addRequiredGroups();

    User user = UserLocalServiceUtil.getUser(userIds[0]);

    List<Group> groups = user.getGroups();

    Assert.assertEquals(1, groups.size());

    long[] userGroupIds =
        ArrayUtil.append(standardGroupIds, requiredGroupIds, new long[] {user.getGroupId()});

    MembershipPolicyTestUtil.updateUser(
        user, null, null, userGroupIds, null, Collections.<UserGroupRole>emptyList());

    groups = user.getGroups();

    Assert.assertEquals(userGroupIds.length, groups.size());

    MembershipPolicyTestUtil.updateUser(
        user, null, null, requiredGroupIds, null, Collections.<UserGroupRole>emptyList());

    groups = user.getGroups();

    Assert.assertEquals(requiredGroupIds.length, groups.size());
  }
            @Override
            public void map(
                ServiceReference<ModelAdapterBuilder> serviceReference, Emitter<String> emitter) {

              Registry registry = RegistryUtil.getRegistry();

              ModelAdapterBuilder modelAdapterBuilder = registry.getService(serviceReference);

              Type genericInterface =
                  ReflectionUtil.getGenericInterface(
                      modelAdapterBuilder, ModelAdapterBuilder.class);

              if ((genericInterface == null) || !(genericInterface instanceof ParameterizedType)) {

                return;
              }

              ParameterizedType parameterizedType = (ParameterizedType) genericInterface;

              Type[] typeArguments = parameterizedType.getActualTypeArguments();

              if (ArrayUtil.isEmpty(typeArguments) || (typeArguments.length != 2)) {

                return;
              }

              try {
                Class adapteeModelClass = (Class) typeArguments[0];
                Class adaptedModelClass = (Class) typeArguments[1];

                emitter.emit(getKey(adapteeModelClass, adaptedModelClass));
              } catch (ClassCastException cce) {
                return;
              }
            }
コード例 #16
0
  protected void configureHttp(Settings.Builder builder) {
    builder.put("http.enabled", elasticsearchConfiguration.httpEnabled());

    if (!elasticsearchConfiguration.httpEnabled()) {
      return;
    }

    builder.put("http.cors.enabled", elasticsearchConfiguration.httpCORSEnabled());

    if (!elasticsearchConfiguration.httpCORSEnabled()) {
      return;
    }

    builder.put("http.cors.allow-origin", elasticsearchConfiguration.httpCORSAllowOrigin());

    String[] httpCORSConfigurations = elasticsearchConfiguration.httpCORSConfigurations();

    if (ArrayUtil.isEmpty(httpCORSConfigurations)) {
      return;
    }

    for (String httpCORSConfiguration : httpCORSConfigurations) {
      String[] httpCORSConfigurationPair =
          StringUtil.split(httpCORSConfiguration, StringPool.EQUAL);

      if (httpCORSConfigurationPair.length < 2) {
        continue;
      }

      builder.put(httpCORSConfigurationPair[0], httpCORSConfigurationPair[1]);
    }
  }
コード例 #17
0
  protected long[] getLayoutIds(long groupId, boolean privateLayout, String layoutIdsJSON)
      throws Exception {

    if (Validator.isNull(layoutIdsJSON)) {
      return new long[0];
    }

    List<Long> layoutIds = new ArrayList<Long>();

    JSONArray jsonArray = JSONFactoryUtil.createJSONArray(layoutIdsJSON);

    for (int i = 0; i < jsonArray.length(); ++i) {
      JSONObject jsonObject = jsonArray.getJSONObject(i);

      long layoutId = jsonObject.getLong("layoutId");

      if (layoutId > 0) {
        layoutIds.add(layoutId);
      }

      if (jsonObject.getBoolean("includeChildren")) {
        addLayoutIds(layoutIds, groupId, privateLayout, layoutId);
      }
    }

    return ArrayUtil.toArray(layoutIds.toArray(new Long[layoutIds.size()]));
  }
コード例 #18
0
  public DynamicResourceRequest(
      ResourceRequest resourceRequest, Map<String, String[]> params, boolean inherit) {

    super(resourceRequest);

    _params = new HashMap<String, String[]>();
    _inherit = inherit;

    if (params != null) {
      _params.putAll(params);
    }

    if (_inherit && (resourceRequest instanceof DynamicResourceRequest)) {
      DynamicResourceRequest dynamicResourceRequest = (DynamicResourceRequest) resourceRequest;

      setRequest(dynamicResourceRequest.getRequest());

      params = dynamicResourceRequest.getDynamicParameterMap();

      for (Map.Entry<String, String[]> entry : params.entrySet()) {
        String name = entry.getKey();
        String[] oldValues = entry.getValue();

        String[] curValues = _params.get(name);

        if (curValues == null) {
          _params.put(name, oldValues);
        } else {
          String[] newValues = ArrayUtil.append(oldValues, curValues);

          _params.put(name, newValues);
        }
      }
    }
  }
コード例 #19
0
  public void processAction(
      PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    if (!cmd.equals(Constants.UPDATE)) {
      return;
    }

    boolean allAssetVocabularies = ParamUtil.getBoolean(actionRequest, "allAssetVocabularies");
    long[] assetVocabularyIds =
        StringUtil.split(ParamUtil.getString(actionRequest, "assetVocabularyIds"), 0L);

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

    PortletPreferences preferences =
        PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource);

    preferences.setValue("all-asset-vocabularies", String.valueOf(allAssetVocabularies));
    preferences.setValues("asset-vocabulary-ids", ArrayUtil.toStringArray(assetVocabularyIds));

    preferences.store();

    SessionMessages.add(actionRequest, portletConfig.getPortletName() + ".doConfigure");
  }
コード例 #20
0
  @Override
  public void connect() {
    ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder();

    loadOptionalDefaultConfigurations(builder);

    String[] additionalConfigurations = elasticsearchConfiguration.additionalConfigurations();

    if (ArrayUtil.isNotEmpty(additionalConfigurations)) {
      StringBundler sb = new StringBundler(additionalConfigurations.length * 2);

      for (String additionalConfiguration : additionalConfigurations) {
        sb.append(additionalConfiguration);
        sb.append(StringPool.NEW_LINE);
      }

      builder.loadFromSource(sb.toString());
    }

    loadRequiredDefaultConfigurations(builder);

    loadSettingsContributors(builder);

    _client = createClient(builder);
  }
コード例 #21
0
  private <T extends ExtRepositoryObjectAdapter<?>> List<T> _filterByMimeType(
      List<T> extRepositoryObjects, String[] mimeTypes) {

    if (ArrayUtil.isEmpty(mimeTypes)) {
      return extRepositoryObjects;
    }

    Set<String> allowedMimeTypes = new HashSet<>(Arrays.asList(mimeTypes));

    List<T> filteredExtRepositoryObjects = new ArrayList<>();

    for (T extRepositoryObject : extRepositoryObjects) {
      if (extRepositoryObject instanceof ExtRepositoryFileEntryAdapter) {
        ExtRepositoryFileEntryAdapter extRepositoryFileEntryAdapter =
            (ExtRepositoryFileEntryAdapter) extRepositoryObject;

        if (allowedMimeTypes.contains(extRepositoryFileEntryAdapter.getMimeType())) {

          filteredExtRepositoryObjects.add(extRepositoryObject);
        }
      }
    }

    return filteredExtRepositoryObjects;
  }
コード例 #22
0
  @Override
  public void removeNestedColumns(String portletNamespace) {
    UnicodeProperties typeSettingsProperties = getTypeSettingsProperties();

    UnicodeProperties newTypeSettingsProperties = new UnicodeProperties();

    for (Map.Entry<String, String> entry : typeSettingsProperties.entrySet()) {

      String key = entry.getKey();

      if (!key.startsWith(portletNamespace)) {
        newTypeSettingsProperties.setProperty(key, entry.getValue());
      }
    }

    Layout layout = getLayout();

    layout.setTypeSettingsProperties(newTypeSettingsProperties);

    String nestedColumnIds =
        GetterUtil.getString(getTypeSettingsProperty(LayoutTypePortletConstants.NESTED_COLUMN_IDS));

    String[] nestedColumnIdsArray =
        ArrayUtil.removeByPrefix(StringUtil.split(nestedColumnIds), portletNamespace);

    setTypeSettingsProperty(
        LayoutTypePortletConstants.NESTED_COLUMN_IDS, StringUtil.merge(nestedColumnIdsArray));
  }
コード例 #23
0
  protected String[][] getCategorySectionLabels() {
    if (_categorySections != null) {
      return _categorySections;
    }

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    String[] categoryKeys = getCategoryKeys();

    String[][] categorySectionLabels = new String[0][];

    for (int i = 0; i < categoryKeys.length; i++) {
      String categoryKey = categoryKeys[i];

      categorySectionLabels =
          ArrayUtil.append(
              categorySectionLabels,
              FormNavigatorEntryUtil.getLabels(
                  _id,
                  categoryKey,
                  themeDisplay.getUser(),
                  _formModelBean,
                  themeDisplay.getLocale()));
    }

    return categorySectionLabels;
  }
コード例 #24
0
  protected void setRequestParameters(
      PortletRequest portletRequest, PortletResponse portletResponse, OAuthRequest oAuthRequest) {

    setBaseRequestParameters(portletRequest, portletResponse, oAuthRequest);

    Map<String, String[]> parameterMap = new HashMap<>();

    MapUtil.copy(portletRequest.getParameterMap(), parameterMap);

    processPortletParameterMap(portletRequest, portletResponse, parameterMap);

    String serverNamespace = getServerNamespace();

    for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
      String key = entry.getKey();
      String[] values = entry.getValue();

      if (key.equals("remoteWindowState")) {
        key = "p_p_state";
      } else {
        key = serverNamespace.concat(key);
      }

      if (ArrayUtil.isEmpty(values) || Validator.isNull(values[0])) {
        continue;
      }

      addOAuthParameter(oAuthRequest, key, values[0]);
    }
  }
コード例 #25
0
  public Boolean isEnableConversions() throws Exception {
    if (_enableConversions == null) {
      _enableConversions = isOpenOfficeServerEnabled() && ArrayUtil.isNotEmpty(getExtensions());
    }

    return _enableConversions;
  }
コード例 #26
0
ファイル: Field.java プロジェクト: tcapener/liferay-portal
 public String getValue() {
   if (ArrayUtil.isNotEmpty(_values)) {
     return _values[0];
   } else {
     return null;
   }
 }
コード例 #27
0
  public String[] getEntryColumns() throws PortalException, SystemException {
    String[] entryColumns = _dlPortletInstanceSettings.getEntryColumns();

    String portletId = _portletDisplay.getId();

    if (!_dlActionsDisplayContext.isShowActions()) {
      entryColumns = ArrayUtil.remove(entryColumns, "action");
    } else if (!portletId.equals(PortletKeys.DOCUMENT_LIBRARY)
        && !portletId.equals(PortletKeys.DOCUMENT_LIBRARY_ADMIN)
        && !ArrayUtil.contains(entryColumns, "action")) {

      entryColumns = ArrayUtil.append(entryColumns, "action");
    }

    return entryColumns;
  }
コード例 #28
0
  private String[] _getWebIds() {
    if (_webIds != null) {
      return _webIds;
    }

    if (Validator.isNull(PropsValues.COMPANY_DEFAULT_WEB_ID)) {
      throw new RuntimeException("Default web id must not be null");
    }

    try {
      List<Company> companies = CompanyLocalServiceUtil.getCompanies(false);

      List<String> webIdsList = new ArrayList<>(companies.size());

      for (Company company : companies) {
        String webId = company.getWebId();

        if (webId.equals(PropsValues.COMPANY_DEFAULT_WEB_ID)) {
          webIdsList.add(0, webId);
        } else {
          webIdsList.add(webId);
        }
      }

      _webIds = webIdsList.toArray(new String[webIdsList.size()]);
    } catch (Exception e) {
      _log.error(e, e);
    }

    if (ArrayUtil.isEmpty(_webIds)) {
      _webIds = new String[] {PropsValues.COMPANY_DEFAULT_WEB_ID};
    }

    return _webIds;
  }
コード例 #29
0
  public void synchronizePage(long folderId, int pageNumber, int messagesPerPage)
      throws PortalException {

    long[] remoteMessageIds = _imapAccessor.getMessageUIDs(folderId, pageNumber, messagesPerPage);

    List<Long> missingRemoteMessageIdsList = new ArrayList<>();

    for (int i = 0; i < remoteMessageIds.length; i++) {
      long remoteMessageId = remoteMessageIds[i];

      try {
        MessageLocalServiceUtil.getMessage(folderId, remoteMessageId);
      } catch (NoSuchMessageException nsme) {
        missingRemoteMessageIdsList.add(remoteMessageId);
      }
    }

    if (!missingRemoteMessageIdsList.isEmpty()) {
      long[] missingRemoteMessageIds =
          ArrayUtil.toArray(
              missingRemoteMessageIdsList.toArray(new Long[missingRemoteMessageIdsList.size()]));

      _imapAccessor.storeEnvelopes(folderId, missingRemoteMessageIds);
    }
  }
コード例 #30
0
  protected void addContext(BooleanQuery contextQuery, SearchContext searchContext)
      throws Exception {

    long[] folderIds = searchContext.getFolderIds();

    if (ArrayUtil.isEmpty(folderIds)) {
      return;
    }

    if (folderIds[0] == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
      return;
    }

    BooleanQuery folderIdsQuery = new BooleanQueryImpl();

    for (long folderId : folderIds) {
      try {
        _dlAppService.getFolder(folderId);
      } catch (Exception e) {
        continue;
      }

      folderIdsQuery.addTerm(Field.FOLDER_ID, folderId);
    }

    contextQuery.add(folderIdsQuery, BooleanClauseOccur.MUST);
  }