Example usage for com.liferay.portal.kernel.util PrefsPropsUtil getInteger

List of usage examples for com.liferay.portal.kernel.util PrefsPropsUtil getInteger

Introduction

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

Prototype

public static int getInteger(String name, int defaultValue) 

Source Link

Usage

From source file:com.liferay.content.targeting.util.ContentTargetingUtil.java

License:Open Source License

public static long[] getSharedContentSiteGroupIds(long companyId, long groupId, long userId)
        throws PortalException, SystemException {

    Set<Group> groups = new LinkedHashSet<Group>();

    Group siteGroup = doGetCurrentSiteGroup(groupId);

    if (siteGroup != null) {

        // Current site

        groups.add(siteGroup);// w w  w .  j  av a  2 s  . co  m

        // Layout scopes

        groups.addAll(GroupLocalServiceUtil.getGroups(siteGroup.getCompanyId(), Layout.class.getName(),
                siteGroup.getGroupId()));
    }

    // Administered sites

    if (PrefsPropsUtil.getBoolean(companyId, PropsKeys.SITES_CONTENT_SHARING_THROUGH_ADMINISTRATORS_ENABLED)) {

        LinkedHashMap<String, Object> groupParams = new LinkedHashMap<String, Object>();

        groupParams.put("site", Boolean.TRUE);
        groupParams.put("usersGroups", userId);

        groups.addAll(GroupLocalServiceUtil.search(companyId, null, null, groupParams, QueryUtil.ALL_POS,
                QueryUtil.ALL_POS, null));
    }

    // Descendant sites

    groups.addAll(getDescendants(siteGroup, true));

    // Ancestor sites and global site

    int sitesContentSharingWithChildrenEnabled = PrefsPropsUtil.getInteger(companyId,
            PropsKeys.SITES_CONTENT_SHARING_WITH_CHILDREN_ENABLED);

    if (sitesContentSharingWithChildrenEnabled != Sites.CONTENT_SHARING_WITH_CHILDREN_DISABLED) {

        groups.addAll(doGetAncestorSiteGroups(groupId, true));
    }

    long[] groupIds = new long[groups.size()];

    int i = 0;

    for (Group group : groups) {
        groupIds[i++] = group.getGroupId();
    }

    return groupIds;
}

From source file:com.liferay.site.admin.web.internal.portlet.SiteAdminPortlet.java

License:Open Source License

protected Group updateGroup(ActionRequest actionRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long userId = portal.getUserId(actionRequest);

    long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId");

    long parentGroupId = ParamUtil.getLong(actionRequest, "parentGroupSearchContainerPrimaryKeys",
            GroupConstants.DEFAULT_PARENT_GROUP_ID);
    Map<Locale, String> nameMap = null;
    Map<Locale, String> descriptionMap = null;
    int type = 0;
    String friendlyURL = null;/*w w  w  .j av  a 2s  .  c  om*/
    boolean inheritContent = false;
    boolean active = false;
    boolean manualMembership = true;

    int membershipRestriction = GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION;

    boolean actionRequestMembershipRestriction = ParamUtil.getBoolean(actionRequest, "membershipRestriction");

    if (actionRequestMembershipRestriction && (parentGroupId != GroupConstants.DEFAULT_PARENT_GROUP_ID)) {

        membershipRestriction = GroupConstants.MEMBERSHIP_RESTRICTION_TO_PARENT_SITE_MEMBERS;
    }

    ServiceContext serviceContext = ServiceContextFactory.getInstance(Group.class.getName(), actionRequest);

    ServiceContextThreadLocal.pushServiceContext(serviceContext);

    Group liveGroup = null;

    if (liveGroupId <= 0) {

        // Add group

        nameMap = LocalizationUtil.getLocalizationMap(actionRequest, "name");
        descriptionMap = LocalizationUtil.getLocalizationMap(actionRequest, "description");
        type = ParamUtil.getInteger(actionRequest, "type");
        friendlyURL = ParamUtil.getString(actionRequest, "friendlyURL");
        manualMembership = ParamUtil.getBoolean(actionRequest, "manualMembership");
        inheritContent = ParamUtil.getBoolean(actionRequest, "inheritContent");
        active = ParamUtil.getBoolean(actionRequest, "active");

        liveGroup = groupService.addGroup(parentGroupId, GroupConstants.DEFAULT_LIVE_GROUP_ID, nameMap,
                descriptionMap, type, manualMembership, membershipRestriction, friendlyURL, true,
                inheritContent, active, serviceContext);

        LiveUsers.joinGroup(themeDisplay.getCompanyId(), liveGroup.getGroupId(), userId);
    } else {

        // Update group

        liveGroup = groupLocalService.getGroup(liveGroupId);

        nameMap = LocalizationUtil.getLocalizationMap(actionRequest, "name", liveGroup.getNameMap());
        descriptionMap = LocalizationUtil.getLocalizationMap(actionRequest, "description",
                liveGroup.getDescriptionMap());
        type = ParamUtil.getInteger(actionRequest, "type", liveGroup.getType());
        manualMembership = ParamUtil.getBoolean(actionRequest, "manualMembership",
                liveGroup.isManualMembership());
        friendlyURL = ParamUtil.getString(actionRequest, "friendlyURL", liveGroup.getFriendlyURL());
        inheritContent = ParamUtil.getBoolean(actionRequest, "inheritContent", liveGroup.getInheritContent());
        active = ParamUtil.getBoolean(actionRequest, "active", liveGroup.getActive());

        liveGroup = groupService.updateGroup(liveGroupId, parentGroupId, nameMap, descriptionMap, type,
                manualMembership, membershipRestriction, friendlyURL, inheritContent, active, serviceContext);

        if (type == GroupConstants.TYPE_SITE_OPEN) {
            List<MembershipRequest> membershipRequests = membershipRequestLocalService.search(liveGroupId,
                    MembershipRequestConstants.STATUS_PENDING, QueryUtil.ALL_POS, QueryUtil.ALL_POS);

            for (MembershipRequest membershipRequest : membershipRequests) {
                membershipRequestService.updateStatus(membershipRequest.getMembershipRequestId(),
                        themeDisplay.translate("your-membership-has-been-approved"),
                        MembershipRequestConstants.STATUS_APPROVED, serviceContext);

                LiveUsers.joinGroup(themeDisplay.getCompanyId(), membershipRequest.getGroupId(),
                        new long[] { membershipRequest.getUserId() });
            }
        }
    }

    // Settings

    UnicodeProperties typeSettingsProperties = liveGroup.getTypeSettingsProperties();

    String customJspServletContextName = ParamUtil.getString(actionRequest, "customJspServletContextName",
            typeSettingsProperties.getProperty("customJspServletContextName"));

    typeSettingsProperties.setProperty("customJspServletContextName", customJspServletContextName);

    typeSettingsProperties.setProperty("defaultSiteRoleIds",
            ListUtil.toString(getRoles(actionRequest), Role.ROLE_ID_ACCESSOR, StringPool.COMMA));
    typeSettingsProperties.setProperty("defaultTeamIds",
            ListUtil.toString(getTeams(actionRequest), Team.TEAM_ID_ACCESSOR, StringPool.COMMA));

    String[] analyticsTypes = PrefsPropsUtil.getStringArray(themeDisplay.getCompanyId(),
            PropsKeys.ADMIN_ANALYTICS_TYPES, StringPool.NEW_LINE);

    for (String analyticsType : analyticsTypes) {
        if (StringUtil.equalsIgnoreCase(analyticsType, "google")) {
            String googleAnalyticsId = ParamUtil.getString(actionRequest, "googleAnalyticsId",
                    typeSettingsProperties.getProperty("googleAnalyticsId"));

            typeSettingsProperties.setProperty("googleAnalyticsId", googleAnalyticsId);
        } else {
            String analyticsScript = ParamUtil.getString(actionRequest, Sites.ANALYTICS_PREFIX + analyticsType,
                    typeSettingsProperties.getProperty(analyticsType));

            typeSettingsProperties.setProperty(Sites.ANALYTICS_PREFIX + analyticsType, analyticsScript);
        }
    }

    boolean trashEnabled = ParamUtil.getBoolean(actionRequest, "trashEnabled",
            GetterUtil.getBoolean(typeSettingsProperties.getProperty("trashEnabled"), true));

    typeSettingsProperties.setProperty("trashEnabled", String.valueOf(trashEnabled));

    int trashEntriesMaxAgeCompany = PrefsPropsUtil.getInteger(themeDisplay.getCompanyId(),
            PropsKeys.TRASH_ENTRIES_MAX_AGE);

    int trashEntriesMaxAgeGroup = ParamUtil.getInteger(actionRequest, "trashEntriesMaxAge");

    if (trashEntriesMaxAgeGroup <= 0) {
        trashEntriesMaxAgeGroup = GetterUtil.getInteger(
                typeSettingsProperties.getProperty("trashEntriesMaxAge"), trashEntriesMaxAgeCompany);
    }

    if (trashEntriesMaxAgeGroup != trashEntriesMaxAgeCompany) {
        typeSettingsProperties.setProperty("trashEntriesMaxAge",
                String.valueOf(GetterUtil.getInteger(trashEntriesMaxAgeGroup)));
    } else {
        typeSettingsProperties.remove("trashEntriesMaxAge");
    }

    int contentSharingWithChildrenEnabled = ParamUtil.getInteger(actionRequest,
            "contentSharingWithChildrenEnabled",
            GetterUtil.getInteger(typeSettingsProperties.getProperty("contentSharingWithChildrenEnabled"),
                    Sites.CONTENT_SHARING_WITH_CHILDREN_DEFAULT_VALUE));

    typeSettingsProperties.setProperty("contentSharingWithChildrenEnabled",
            String.valueOf(contentSharingWithChildrenEnabled));

    UnicodeProperties formTypeSettingsProperties = PropertiesParamUtil.getProperties(actionRequest,
            "TypeSettingsProperties--");

    typeSettingsProperties.putAll(formTypeSettingsProperties);

    // Virtual hosts

    LayoutSet publicLayoutSet = liveGroup.getPublicLayoutSet();

    String publicVirtualHost = ParamUtil.getString(actionRequest, "publicVirtualHost",
            publicLayoutSet.getVirtualHostname());

    layoutSetService.updateVirtualHost(liveGroup.getGroupId(), false, publicVirtualHost);

    LayoutSet privateLayoutSet = liveGroup.getPrivateLayoutSet();

    String privateVirtualHost = ParamUtil.getString(actionRequest, "privateVirtualHost",
            privateLayoutSet.getVirtualHostname());

    layoutSetService.updateVirtualHost(liveGroup.getGroupId(), true, privateVirtualHost);

    // Staging

    if (liveGroup.hasStagingGroup()) {
        Group stagingGroup = liveGroup.getStagingGroup();

        friendlyURL = ParamUtil.getString(actionRequest, "stagingFriendlyURL", stagingGroup.getFriendlyURL());

        groupService.updateFriendlyURL(stagingGroup.getGroupId(), friendlyURL);

        LayoutSet stagingPublicLayoutSet = stagingGroup.getPublicLayoutSet();

        publicVirtualHost = ParamUtil.getString(actionRequest, "stagingPublicVirtualHost",
                stagingPublicLayoutSet.getVirtualHostname());

        layoutSetService.updateVirtualHost(stagingGroup.getGroupId(), false, publicVirtualHost);

        LayoutSet stagingPrivateLayoutSet = stagingGroup.getPrivateLayoutSet();

        privateVirtualHost = ParamUtil.getString(actionRequest, "stagingPrivateVirtualHost",
                stagingPrivateLayoutSet.getVirtualHostname());

        layoutSetService.updateVirtualHost(stagingGroup.getGroupId(), true, privateVirtualHost);

        UnicodeProperties stagedGroupTypeSettingsProperties = stagingGroup.getTypeSettingsProperties();

        stagedGroupTypeSettingsProperties.putAll(formTypeSettingsProperties);

        groupService.updateGroup(stagingGroup.getGroupId(), stagedGroupTypeSettingsProperties.toString());
    }

    liveGroup = groupService.updateGroup(liveGroup.getGroupId(), typeSettingsProperties.toString());

    // Layout set prototypes

    long privateLayoutSetPrototypeId = ParamUtil.getLong(actionRequest, "privateLayoutSetPrototypeId");
    long publicLayoutSetPrototypeId = ParamUtil.getLong(actionRequest, "publicLayoutSetPrototypeId");

    boolean privateLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(actionRequest,
            "privateLayoutSetPrototypeLinkEnabled", privateLayoutSet.isLayoutSetPrototypeLinkEnabled());
    boolean publicLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(actionRequest,
            "publicLayoutSetPrototypeLinkEnabled", publicLayoutSet.isLayoutSetPrototypeLinkEnabled());

    if ((privateLayoutSetPrototypeId == 0) && (publicLayoutSetPrototypeId == 0)
            && !privateLayoutSetPrototypeLinkEnabled && !publicLayoutSetPrototypeLinkEnabled) {

        long layoutSetPrototypeId = ParamUtil.getLong(actionRequest, "layoutSetPrototypeId");
        int layoutSetVisibility = ParamUtil.getInteger(actionRequest, "layoutSetVisibility");
        boolean layoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(actionRequest,
                "layoutSetPrototypeLinkEnabled", layoutSetPrototypeId > 0);

        if (layoutSetVisibility == _LAYOUT_SET_VISIBILITY_PRIVATE) {
            privateLayoutSetPrototypeId = layoutSetPrototypeId;

            privateLayoutSetPrototypeLinkEnabled = layoutSetPrototypeLinkEnabled;
        } else {
            publicLayoutSetPrototypeId = layoutSetPrototypeId;

            publicLayoutSetPrototypeLinkEnabled = layoutSetPrototypeLinkEnabled;
        }
    }

    if (!liveGroup.isStaged() || liveGroup.isStagedRemotely()) {
        SitesUtil.updateLayoutSetPrototypesLinks(liveGroup, publicLayoutSetPrototypeId,
                privateLayoutSetPrototypeId, publicLayoutSetPrototypeLinkEnabled,
                privateLayoutSetPrototypeLinkEnabled);
    } else {
        SitesUtil.updateLayoutSetPrototypesLinks(liveGroup.getStagingGroup(), publicLayoutSetPrototypeId,
                privateLayoutSetPrototypeId, publicLayoutSetPrototypeLinkEnabled,
                privateLayoutSetPrototypeLinkEnabled);
    }

    themeDisplay.setSiteGroupId(liveGroup.getGroupId());

    return liveGroup;
}

From source file:com.liferay.site.admin.web.internal.servlet.taglib.ui.SiteContentSharingFormNavigatorEntry.java

License:Open Source License

@Override
public boolean isVisible(User user, Group group) {
    if (group == null) {
        return false;
    }/*from w  w  w . j  a  va2  s  .c  om*/

    int contentSharingWithChildrenEnabled = PrefsPropsUtil.getInteger(group.getCompanyId(),
            PropsKeys.SITES_CONTENT_SHARING_WITH_CHILDREN_ENABLED);

    if (contentSharingWithChildrenEnabled == 0) {
        return false;
    }

    return true;
}

From source file:com.liferay.trash.service.test.TrashEntryLocalServiceCheckEntriesTest.java

License:Open Source License

protected Group updateTrashEntriesMaxAge(Group group, int days) throws Exception {

    UnicodeProperties typeSettingsProperties = group.getParentLiveGroupTypeSettingsProperties();

    int companyTrashEntriesMaxAge = PrefsPropsUtil.getInteger(group.getCompanyId(),
            PropsKeys.TRASH_ENTRIES_MAX_AGE);

    if (days > 0) {
        days *= 1440;// w  w  w.  j  av a 2 s .  c  o  m
    } else {
        days = GetterUtil.getInteger(typeSettingsProperties.getProperty("trashEntriesMaxAge"),
                companyTrashEntriesMaxAge);
    }

    if (days != companyTrashEntriesMaxAge) {
        typeSettingsProperties.setProperty("trashEntriesMaxAge", String.valueOf(days));
    } else {
        typeSettingsProperties.remove("trashEntriesMaxAge");
    }

    group.setTypeSettingsProperties(typeSettingsProperties);

    return GroupLocalServiceUtil.updateGroup(group);
}

From source file:it.sysdata.mqtt.service.impl.MqttLocalServiceImpl.java

License:Open Source License

@Override
public boolean connect() throws MqttException, SystemException {

    try {// w  ww. j  a  va 2 s  .  co  m
        disconnect();

        String username = PrefsPropsUtil.getString(PortletPropsKeys.MQTT_BROKER_USERNAME,
                PortletPropsValues.MQTT_BROKER_USERNAME);

        String password = PrefsPropsUtil.getString(PortletPropsKeys.MQTT_BROKER_PASSWORD,
                PortletPropsValues.MQTT_BROKER_PASSWORD);

        int keepalive = PrefsPropsUtil.getInteger(PortletPropsKeys.MQTT_BROKER_KEEPALIVE,
                PortletPropsValues.MQTT_BROKER_KEEPALIVE);

        MqttClient client = _getInstance();

        MqttConnectOptions options = new MqttConnectOptions();

        options.setCleanSession(true);
        options.setKeepAliveInterval(keepalive);

        if (Validator.isNotNull(username)) {
            options.setUserName(username);
            options.setPassword(password.toCharArray());
        }

        IMqttToken token = client.connectWithResult(options);

        _log.info("connected: " + client.getServerURI());

        applySubscriptionsList();

        _noRetry();

        // send event to message bus

        _notifyEvent(client, "connect");
    } catch (MqttException e) {
        _log.error(e);

        throw e;
    }

    return isConnected();
}

From source file:org.kisti.edison.science.service.impl.CommonLibLocalServiceImpl.java

License:Open Source License

public int countCommonLib(long companyId, String searchValue) throws SystemException {
    Map<String, Object> searchParam = new HashMap<String, Object>();
    searchParam.put("searchValue", searchValue);
    int cnt = commonLibFinder.countCommonLib(searchParam);

    if (cnt == 0) {
        String headNodeIp = PrefsPropsUtil.getString(companyId, EdisonPropsUtil.LIBRARY_SEARCH_IP);
        int headNodePort = PrefsPropsUtil.getInteger(companyId, EdisonPropsUtil.LIBRARY_SEARCH_PORT);
        String headNodeUserId = PrefsPropsUtil.getString(companyId, EdisonPropsUtil.LIBRARY_SEARCH_ID);
        String headNodePassword = PrefsPropsUtil.getString(companyId, EdisonPropsUtil.LIBRARY_SEARCH_PW);

        this.updateAllLibraries(headNodeIp, headNodePort, headNodeUserId, headNodePassword);

        cnt = commonLibFinder.countCommonLib(searchParam);
    }/*from w  ww . j  a v  a  2s.  co  m*/
    return cnt;
}