Example usage for com.liferay.portal.kernel.util ParamUtil getLongValues

List of usage examples for com.liferay.portal.kernel.util ParamUtil getLongValues

Introduction

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

Prototype

public static long[] getLongValues(ServiceContext serviceContext, String param, long[] defaultValue) 

Source Link

Document

Returns the service context parameter value as a long array.

Usage

From source file:com.evozon.evoportal.myaccount.builder.RequestAccountModelHolderBuilder.java

protected List<String> getUserDepartmentsFromRequest() {
    List<String> userDepartments = new ArrayList<String>();

    try {/*ww  w.  j a  v  a2 s.c om*/
        long[] depIdArray = ParamUtil.getLongValues(request,
                RequestAccountModelHolderBuilder.GROUP_SEARCH_CONTAINER_PRIMARY_KEYS, new long[] {});
        List<Group> groups = GroupLocalServiceUtil.getGroups(depIdArray);
        for (Group group : groups) {
            if (!group.isGuest()) {
                userDepartments.add(group.getName());
            }
        }
    } catch (PortalException e) {
        logger.error("Could not get departments from request.", e);
    } catch (SystemException e) {
        logger.error("Could not get departments from request.", e);
    }

    return userDepartments;
}

From source file:com.evozon.evoportal.my_account.util.MyAccountRequestUtil.java

private static List<String> getUserDepartmentsFromRequest(ActionRequest actionRequest)
        throws PortalException, SystemException {
    List<String> userDepartments = null;

    long[] depIdArray = ParamUtil.getLongValues(actionRequest, "groupsSearchContainerPrimaryKeys",
            new long[] {});
    userDepartments = new ArrayList<String>();
    List<Group> groups = GroupLocalServiceUtil.getGroups(depIdArray);
    for (Group group : groups) {
        if (!group.isGuest()) {
            userDepartments.add(group.getName());
        }//from w  ww  .  j av  a2  s .  co  m
    }

    return userDepartments;
}

From source file:com.evozon.evoportal.my_account.validator.UserAccountValidation.java

public boolean isSitesValid(ActionRequest actionRequest) {
    boolean hasValidSites = true;
    try {// w  w  w  .  j a v  a 2 s  .  c o  m
        long[] groupIdSplit = ParamUtil.getLongValues(actionRequest, "groupsSearchContainerPrimaryKeys",
                new long[] {});

        if (groupIdSplit.length > 0) {
            Set<Long> asSet = SetUtil.fromArray(groupIdSplit);
            long guestGroupId = GroupLocalServiceUtil
                    .getGroup(PortalUtil.getCompanyId(actionRequest), GroupConstants.GUEST).getGroupId();

            if (asSet.contains(guestGroupId)) {
                asSet.remove(guestGroupId);
            }

            if (asSet.isEmpty()) {
                // the user has to be on EvoPortal and at least another
                // department
                logger.warn("At least one department has to be specified besides Evoportal.");
                hasValidSites = false;
            }
        } else {
            logger.debug("No departments are specified.");
            hasValidSites = false;
        }

    } catch (Exception e) {
        logger.error("Error getting new user sites.", e);
    }

    if (!hasValidSites) {
        SessionErrors.add(actionRequest, NO_DEPARTMENT_DETECTED);
    }

    return hasValidSites;
}

From source file:com.liferay.tool.datamanipulator.context.RequestContext.java

License:Open Source License

public long[] getLongValues(String key) {
    if (_parameters.containsKey(key)) {
        return (long[]) _parameters.get(key);
    }// w  ww .j a  v  a2s  .c o  m

    return ParamUtil.getLongValues(_uploadRequest, key, new long[0]);
}