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

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

Introduction

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

Prototype

public static long getLong(ServiceContext serviceContext, String param, long defaultValue) 

Source Link

Document

Returns the service context parameter value as a long.

Usage

From source file:com.cd.learning.hook.MBUtil.java

License:Open Source License

public static long getCategoryId(HttpServletRequest request, MBCategory category) {

    long categoryId = MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID;

    if (category != null) {
        categoryId = category.getCategoryId();
    }/*from w w w . j a v a  2  s  .  com*/

    categoryId = ParamUtil.getLong(request, "mbCategoryId", categoryId);

    return categoryId;
}

From source file:com.cd.learning.hook.MBUtil.java

License:Open Source License

public static long getCategoryId(HttpServletRequest request, MBMessage message) {

    long categoryId = MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID;

    if (message != null) {
        categoryId = message.getCategoryId();
    }/*from  w  w w.j a  va  2  s  .co  m*/

    categoryId = ParamUtil.getLong(request, "mbCategoryId", categoryId);

    return categoryId;
}

From source file:com.commsen.liferay.multidevice.rules.DeviceRulesProviderImpl.java

License:Open Source License

protected void saveRule(PortletRequest request, List<String> errorMessages) {

    Rule themeRule;/*  w w w  .  j a v  a  2 s  .  c o  m*/
    try {
        themeRule = RuleLocalServiceUtil.createRule(CounterLocalServiceUtil.increment(Rule.class.getName()));
    } catch (SystemException e) {
        errorMessages.add("failed-to-create-rule");
        log.error("Failed to create device rule!", e);
        return;
    }

    // rule context
    themeRule.setCompanyId(PortalUtil.getCompanyId(request));
    themeRule.setGroupId(ParamUtil.getLong(request, PARAM_LIVE_GROUP_ID, 0));
    themeRule.setLayoutId(ParamUtil.getLong(request, PARAM_LAYPOUT_ID, 0));

    // rule parameters
    boolean emptyRule = true;

    String tmp = ParamUtil.getString(request, PARAM_BRAND, null);
    if (!StringUtils.isBlank(tmp)) {
        emptyRule = false;
        themeRule.setBrand(tmp);
    }
    tmp = ParamUtil.getString(request, PARAM_MODEL, null);
    if (!StringUtils.isBlank(tmp)) {
        emptyRule = false;
        themeRule.setModel(tmp);
    }
    tmp = ParamUtil.getString(request, PARAM_OS, null);
    if (!StringUtils.isBlank(tmp)) {
        emptyRule = false;
        themeRule.setOs(tmp);
    }
    tmp = ParamUtil.getString(request, PARAM_OS_VERSION, null);
    if (!StringUtils.isBlank(tmp)) {
        emptyRule = false;
        themeRule.setOsVersion(tmp);
    }
    tmp = ParamUtil.getString(request, PARAM_BROWSER, null);
    if (!StringUtils.isBlank(tmp)) {
        emptyRule = false;
        themeRule.setBrowser(tmp);
    }
    tmp = ParamUtil.getString(request, PARAM_BROWSER_VERSION, null);
    if (!StringUtils.isBlank(tmp)) {
        emptyRule = false;
        themeRule.setBrowserVersion(tmp);
    }
    tmp = ParamUtil.getString(request, PARAM_POINTING_METHOD, null);
    if (!StringUtils.isBlank(tmp)) {
        emptyRule = false;
        themeRule.setPointingMethod(tmp);
    }
    tmp = ParamUtil.getString(request, PARAM_IS_TABLET, null);
    if ("yes".equalsIgnoreCase(tmp)) {
        emptyRule = false;
        themeRule.setTablet(Boolean.TRUE.toString());
    } else if ("no".equalsIgnoreCase(tmp)) {
        emptyRule = false;
        themeRule.setTablet(Boolean.FALSE.toString());
    }
    tmp = ParamUtil.getString(request, PARAM_HAS_QWERTY_KEYBOARD, null);
    if ("yes".equalsIgnoreCase(tmp)) {
        emptyRule = false;
        themeRule.setQwertyKeyboad(Boolean.TRUE.toString());
    } else if ("no".equalsIgnoreCase(tmp)) {
        emptyRule = false;
        themeRule.setQwertyKeyboad(Boolean.FALSE.toString());
    }

    if (emptyRule) {
        errorMessages.add("rule-is-empty");
        log.error("Rule is empty. Not saved!");
        return;
    }

    String action = ParamUtil.getString(request, PARAM_RULE_ACTION, ChangeThemeAction.NAME);
    if (ChangeThemeAction.NAME.equalsIgnoreCase(action)) {
        themeRule.setAction(ChangeThemeAction.NAME);
        String themeId = ParamUtil.getString(request, PARAM_DYNAMIC_THEME_ID);
        String colorSchemeId = ParamUtil.getString(request, PARAM_DYNAMIC_COLOR_SCHEME_ID);
        themeRule.setThemeId(themeId);
        themeRule.setColorSchemeId(colorSchemeId);
    }

    if (RedirectAction.NAME.equalsIgnoreCase(action)) {
        themeRule.setAction(RedirectAction.NAME);
        String redirectRuleURL = ParamUtil.getString(request, PARAM_REDIRECT_RULE_URL);
        themeRule.setUrl(redirectRuleURL);
    }

    int priority = ParamUtil.getInteger(request, PARAM_RULE_PRIORITY, 100);
    themeRule.setPriority(priority);

    // save
    try {
        RuleLocalServiceUtil.addRule(themeRule);
    } catch (SystemException e) {
        errorMessages.add("failed-to-save-rule");
        log.error("Failed to save theme rule!", e);
        return;
    }

}

From source file:com.dtt.portal.adminvbpq.search.VanBanDisplayTerms.java

License:Open Source License

public VanBanDisplayTerms(PortletRequest portletRequest) {
    super(portletRequest);

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

    Date now = new Date();

    Calendar startCalendar = Calendar.getInstance();
    startCalendar.set(Calendar.DATE, 1);
    startCalendar.set(Calendar.MONTH, 0);

    Calendar endCalendar = Calendar.getInstance();
    endCalendar.setTime(now);/*w  w w  . j  a  v a  2  s . c om*/

    SimpleDateFormat sdf = new SimpleDateFormat(VanBanPhapQuyUtils.FORMAT_DATE_PATTERN);

    groupId = ParamUtil.getLong(portletRequest, GROUP_ID, themeDisplay.getScopeGroupId());

    coQuanBanHanhId = ParamUtil.getLong(portletRequest, CO_QUAN_BAN_HANH_ID);

    if (coQuanBanHanhId > 0) {
        setCoQuanBanHanhIds(new long[] { coQuanBanHanhId });
    } else {
        setCoQuanBanHanhIds(null);
    }

    linhVucVanBanId = ParamUtil.getLong(portletRequest, LINH_VUC_VAN_BAN_ID);

    if (linhVucVanBanId > 0) {
        setLinhVucVanBanIds(new long[] { linhVucVanBanId });
    } else {
        setLinhVucVanBanIds(null);
    }

    loaiVanBanId = ParamUtil.getLong(portletRequest, LOAI_VAN_BAN_ID);

    if (loaiVanBanId > 0) {
        setLoaiVanBanIds(new long[] { loaiVanBanId });
    } else {
        setLoaiVanBanIds(null);
    }

    startDate = ParamUtil.getString(portletRequest, START_DATE, sdf.format(startCalendar.getTime()));

    startDateObj = VanBanPhapQuyUtils.parseStringToDate(startDate);

    endDate = ParamUtil.getString(portletRequest, END_DATE, sdf.format(endCalendar.getTime()));

    endDateObj = VanBanPhapQuyUtils.parseStringToDate(endDate);

    status = ParamUtil.getInteger(portletRequest, STATUS, -1);

    if (status < 0) {
        setStatusObj(null);
    } else {
        setStatusObj(status);
    }
}

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

private static FamilyMember getSpouseFromRequest(PortletRequest actionRequest)
        throws PortalException, SystemException {
    FamilyMember spouse = new FamilyMemberClp();

    spouse.setFirstName(ParamUtil.getString(actionRequest, "spouseFirstName", StringPool.BLANK));
    spouse.setLastName(ParamUtil.getString(actionRequest, "spouseLastName", StringPool.BLANK).trim());
    spouse.setCNP(ParamUtil.getString(actionRequest, "spouseCNP", StringPool.BLANK));
    spouse.setType(MyAccountConstants.SPOUSE);
    spouse.setMemberId(ParamUtil.getLong(actionRequest, "spouseId", 0l));
    spouse.setUserBelongsId(PortalUtil.getUserId(actionRequest));
    spouse.setNumar(StringPool.BLANK);/*  w w  w.  j av  a2  s . c o m*/
    spouse.setSeries(StringPool.BLANK);

    return !UserFamilyHandler.isFamilyMemberEmpty(spouse) ? spouse : null;
}

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

private static List<EvoAddressModel> getAddressesFromRequest(ActionRequest actionRequest) {
    List<EvoAddressModel> addresses = new ArrayList<EvoAddressModel>();

    String primaryIndexAddress = ParamUtil.getString(actionRequest, "addressPrimary", "0");

    String addressesIndexes = ParamUtil.getString(actionRequest, ADDRESSES_INDEXES);
    String[] indexes = addressesIndexes.split(StringPool.COMMA);

    for (String idx : indexes) {
        EvoAddressModel addressModel = new EvoAddressModel();

        String streetName = ParamUtil.getString(actionRequest, "addressStreet1_" + idx, StringPool.BLANK);
        String streetNo = ParamUtil.getString(actionRequest, "addressStreet2_" + idx, StringPool.BLANK);
        String city = ParamUtil.getString(actionRequest, "addressCity" + idx, StringPool.BLANK);

        if (streetName.isEmpty() && streetNo.isEmpty() && city.isEmpty()) {
            continue;
        }/* w  ww .j  a  va2  s .com*/

        String zip = ParamUtil.getString(actionRequest, "addressZip" + idx);
        long regionId = ParamUtil.getLong(actionRequest, "addressRegionId" + idx, 0L);
        long typeId = ParamUtil.getLong(actionRequest, "addressTypeId" + idx, 0L);
        boolean mailing = ParamUtil.getBoolean(actionRequest, "addressMailing" + idx, false);

        addressModel.setStreetName(streetName);
        addressModel.setStreetNumber(streetNo);
        addressModel.setPostalCode(zip);
        addressModel.setRegion(regionId);
        addressModel.setType(typeId);
        addressModel.setCity(city);
        addressModel.setMailing(mailing);
        addressModel.setPrimary(primaryIndexAddress.equals(idx));

        try {
            int countryId = ParamUtil.getInteger(actionRequest, "addressCountryId" + idx);
            if (countryId != 0) {
                Country country = CountryUtil.fetchByPrimaryKey(countryId);
                addressModel.setCountryCode(country.getA2());
            }
        } catch (SystemException e) {
            logger.error("Error fetching address model from request: " + e.getMessage(), e);
        }
        addresses.add(addressModel);
    }

    return addresses;
}

From source file:com.liferay.asset.categories.admin.web.internal.portlet.AssetCategoryAdminPortlet.java

License:Open Source License

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

    long categoryId = ParamUtil.getLong(actionRequest, "categoryId", 0);

    AssetCategory category = _assetCategoryService.fetchCategory(categoryId);

    String[] categoryProperties = getCategoryProperties(actionRequest);

    ServiceContext serviceContext = ServiceContextFactory.getInstance(AssetCategory.class.getName(),
            actionRequest);//from  w ww  .j a  va2 s.c  o m

    _assetCategoryService.updateCategory(categoryId, category.getParentCategoryId(), category.getTitleMap(),
            category.getDescriptionMap(), category.getVocabularyId(), categoryProperties, serviceContext);
}

From source file:com.liferay.asset.categories.admin.web.internal.portlet.configuration.icon.AssetCategoryPermissionsPortletConfigurationIcon.java

License:Open Source License

@Override
public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {

    long categoryId = ParamUtil.getLong(portletRequest, "categoryId", 0);

    if (categoryId <= 0) {
        return StringPool.BLANK;
    }//  ww  w .j a v  a  2 s .c om

    String url = StringPool.BLANK;

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

    AssetCategory assetCategory = _assetCategoryLocalService.fetchCategory(categoryId);

    try {
        url = PermissionsURLTag.doTag(StringPool.BLANK, AssetCategory.class.getName(),
                assetCategory.getTitle(themeDisplay.getLocale()), null,
                String.valueOf(assetCategory.getCategoryId()), LiferayWindowState.POP_UP.toString(), null,
                themeDisplay.getRequest());
    } catch (Exception e) {
    }

    return url;
}

From source file:com.liferay.contacts.contactscenter.portlet.ContactsCenterPortlet.java

License:Open Source License

protected long[] getUserIds(ActionRequest actionRequest) {
    long[] userIds;

    long userId = ParamUtil.getLong(actionRequest, "userId", 0);

    if (userId > 0) {
        userIds = new long[] { userId };
    } else {//  w  w  w. j  av  a 2s .  co m
        userIds = StringUtil.split(ParamUtil.getString(actionRequest, "userIds"), 0L);
    }

    return userIds;
}

From source file:com.liferay.document.library.item.selector.web.internal.display.context.DLItemSelectorViewDisplayContext.java

License:Open Source License

public long getFolderId(HttpServletRequest request) {
    return ParamUtil.getLong(request, "folderId", DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
}