Example usage for com.liferay.portal.kernel.util ArrayUtil remove

List of usage examples for com.liferay.portal.kernel.util ArrayUtil remove

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util ArrayUtil remove.

Prototype

public static <T> T[] remove(T[] array, T value) 

Source Link

Usage

From source file:com.liferay.asset.publisher.web.portlet.action.AssetPublisherConfigurationAction.java

License:Open Source License

protected void removeScope(ActionRequest actionRequest, PortletPreferences preferences) throws Exception {

    String[] scopeIds = preferences.getValues("scopeIds",
            new String[] { AssetPublisherUtil.SCOPE_ID_GROUP_PREFIX + GroupConstants.DEFAULT });

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

    scopeIds = ArrayUtil.remove(scopeIds, scopeId);

    if (scopeId.startsWith(AssetPublisherUtil.SCOPE_ID_PARENT_GROUP_PREFIX)) {

        scopeId = scopeId.substring("Parent".length());

        scopeIds = ArrayUtil.remove(scopeIds, scopeId);
    }//from w  w w. j  av a2  s .c  o m

    preferences.setValues("scopeIds", scopeIds);
}

From source file:com.liferay.asset.test.util.BaseAssetSearchTestCase.java

License:Open Source License

@Test
public void testClassName2() throws Exception {
    long[] classNameIds = AssetRendererFactoryRegistryUtil.getClassNameIds(TestPropsValues.getCompanyId());

    classNameIds = ArrayUtil.remove(classNameIds, PortalUtil.getClassNameId(getBaseModelClass()));

    AssetEntryQuery assetEntryQuery = AssetEntryQueryTestUtil.createAssetEntryQuery(_group1.getGroupId(),
            classNameIds);/* w  w w .  ja  va 2s.c o  m*/

    testClassNames(assetEntryQuery, 0);
}

From source file:com.liferay.content.targeting.internal.PortalPreferencesUserSegmentSimulator.java

License:Open Source License

@Override
public void removeUserSegmentId(long userSegmentId, HttpServletRequest request, HttpServletResponse response) {

    long userId = PortalUtil.getUserId(request);

    PortalPreferences preferences = getPortalPreferences(userId);

    String[] simulatedUserSegmentIds = preferences.getValues("content-targeting", "simulatedUserSegmentIds",
            new String[0]);

    simulatedUserSegmentIds = ArrayUtil.remove(simulatedUserSegmentIds, String.valueOf(userSegmentId));

    preferences.setValues("content-targeting", "simulatedUserSegmentIds", simulatedUserSegmentIds);

    if (simulatedUserSegmentIds.length == 0) {
        preferences.setValue("content-targeting", "simulation", String.valueOf(false));
    }/*from w  w  w  . ja  v a  2  s .  c o m*/
}

From source file:com.liferay.content.targeting.portlet.util.UserSegmentQueryRule.java

License:Open Source License

protected long[] validateUserSegmentAssetCategoryIds(long[] userSegmentAssetCategoryIds) {

    if (Validator.isNull(userSegmentAssetCategoryIds)) {
        return userSegmentAssetCategoryIds;
    }/*  w w w. ja  v  a 2s  .co m*/

    long[] validatedUserSegmentAssetCategoryIds = userSegmentAssetCategoryIds;

    for (long userSegmentAssetCategoryId : userSegmentAssetCategoryIds) {
        try {
            AssetCategory assetCategory = AssetCategoryLocalServiceUtil
                    .fetchAssetCategory(userSegmentAssetCategoryId);

            if (assetCategory == null) {
                validatedUserSegmentAssetCategoryIds = ArrayUtil.remove(validatedUserSegmentAssetCategoryIds,
                        userSegmentAssetCategoryId);
            }
        } catch (Exception e) {
        }
    }

    return validatedUserSegmentAssetCategoryIds;
}

From source file:com.liferay.contenttargeting.internal.PortalPreferencesUserSegmentSimulator.java

License:Open Source License

@Override
public void removeUserSegmentId(long userSegmentId, HttpServletRequest request, HttpServletResponse response) {

    long userId = PortalUtil.getUserId(request);

    PortalPreferences preferences = getPortalPreferences(userId);

    String[] simulatedUserSegmentIds = preferences.getValues("content-targeting", "simulatedUserSegmentIds",
            new String[0]);

    simulatedUserSegmentIds = ArrayUtil.remove(simulatedUserSegmentIds, String.valueOf(userSegmentId));

    preferences.setValues("content-targeting", "simulatedUserSegmentIds", simulatedUserSegmentIds);
}

From source file:com.liferay.document.library.web.internal.display.context.logic.DLPortletInstanceSettingsHelper.java

License:Open Source License

public String[] getEntryColumns() {
    DLPortletInstanceSettings dlPortletInstanceSettings = _dlRequestHelper.getDLPortletInstanceSettings();

    String[] entryColumns = dlPortletInstanceSettings.getEntryColumns();

    String portletName = _dlRequestHelper.getPortletName();

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

        entryColumns = ArrayUtil.append(entryColumns, "action");
    }//from   www . j a v  a  2s.  co  m

    return entryColumns;
}

From source file:com.liferay.document.library.web.internal.display.context.logic.DLPortletInstanceSettingsHelper.java

License:Open Source License

public String[] getFileEntryColumns() {
    DLPortletInstanceSettings dlPortletInstanceSettings = _dlRequestHelper.getDLPortletInstanceSettings();

    String[] fileEntryColumns = dlPortletInstanceSettings.getFileEntryColumns();

    if (!isShowActions()) {
        fileEntryColumns = ArrayUtil.remove(fileEntryColumns, "action");
    }/*from  ww w  .  j av  a 2 s. c  om*/

    return fileEntryColumns;
}

From source file:com.liferay.document.library.web.internal.display.context.logic.DLPortletInstanceSettingsHelper.java

License:Open Source License

public String[] getFolderColumns() {
    DLPortletInstanceSettings dlPortletInstanceSettings = _dlRequestHelper.getDLPortletInstanceSettings();

    String[] folderColumns = dlPortletInstanceSettings.getFolderColumns();

    if (!isShowActions()) {
        folderColumns = ArrayUtil.remove(folderColumns, "action");
    }/*from  ww  w  .jav  a 2s  .c  o m*/

    return folderColumns;
}

From source file:com.liferay.journal.web.internal.portlet.JournalPortlet.java

License:Open Source License

public void removeAddMenuFavItem(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    PortalPreferences portalPreferences = PortletPreferencesFactoryUtil.getPortalPreferences(actionRequest);

    String key = JournalPortletUtil.getAddMenuFavItemKey(actionRequest, actionResponse);

    String[] addMenuFavItems = portalPreferences.getValues(JournalPortletKeys.JOURNAL, key);

    portalPreferences.setValues(JournalPortletKeys.JOURNAL, key,
            ArrayUtil.remove(addMenuFavItems, ddmStructureKey));

    SessionMessages.add(actionRequest,//  w w  w.j  a  v  a 2  s. c  o m
            _portal.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET,
            JournalPortletKeys.JOURNAL);
}

From source file:com.liferay.portlet.PortletRequestImpl.java

License:Open Source License

protected void mergePublicRenderParameters(DynamicServletRequest dynamicRequest, PortletPreferences preferences,
        long plid) {

    Enumeration<PublicRenderParameter> publicRenderParameters = Collections
            .enumeration(_portlet.getPublicRenderParameters());

    while (publicRenderParameters.hasMoreElements()) {
        PublicRenderParameter publicRenderParameter = publicRenderParameters.nextElement();

        String ignoreKey = PublicRenderParameterConfiguration.getIgnoreKey(publicRenderParameter);

        boolean ignoreValue = GetterUtil.getBoolean(preferences.getValue(ignoreKey, null));

        if (ignoreValue) {
            continue;
        }//from www  .j a  v a2  s. com

        String mappingKey = PublicRenderParameterConfiguration.getMappingKey(publicRenderParameter);

        String mappingValue = GetterUtil.getString(preferences.getValue(mappingKey, null));

        HttpServletRequest request = (HttpServletRequest) dynamicRequest.getRequest();

        String[] newValues = request.getParameterValues(mappingValue);

        if ((newValues != null) && (newValues.length != 0)) {
            newValues = ArrayUtil.remove(newValues, StringPool.NULL);
        }

        String name = publicRenderParameter.getIdentifier();

        if ((newValues == null) || (newValues.length == 0)) {
            QName qName = publicRenderParameter.getQName();

            String[] values = _publicRenderParameters.get(PortletQNameUtil.getPublicRenderParameterName(qName));

            if ((values) == null || (values.length == 0) || (Validator.isNull(values[0]))) {

                continue;
            }

            if (dynamicRequest.getParameter(name) == null) {
                dynamicRequest.setParameterValues(name, values);
            }
        } else {
            dynamicRequest.setParameterValues(name, newValues);
        }
    }
}