Example usage for com.liferay.portal.kernel.util PropsUtil getArray

List of usage examples for com.liferay.portal.kernel.util PropsUtil getArray

Introduction

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

Prototype

public static String[] getArray(String key) 

Source Link

Usage

From source file:br.com.thiagomoreira.liferay.plugins.ReplaceThemeIdsAction.java

License:Apache License

public void run(String[] companyIds) throws ActionException {
    String[] oldThemeIdPatterns = PropsUtil.getArray("replace.themeIds.old");
    String[] newThemeIdPatterns = PropsUtil.getArray("replace.themeIds.new");

    for (int i = 0; i < newThemeIdPatterns.length; i++) {
        String oldThemeIdPattern = oldThemeIdPatterns[i];
        String newThemeIdPattern = newThemeIdPatterns[i];

        if (Validator.isNotNull(oldThemeIdPattern) && Validator.isNotNull(newThemeIdPattern)
                && !oldThemeIdPattern.equals(newThemeIdPattern)) {
            try {
                updateLayouts(oldThemeIdPattern, newThemeIdPattern);
            } catch (Exception ex) {
                throw new ActionException(ex);
            }/*w  w  w.j a  v a2s .co  m*/
        }
    }
}

From source file:com.commsen.liferay.wurfl.LiferayWURFLHolder.java

License:Open Source License

public void init() {
    String mainFile = PropsUtil.get(WURFL_MAIN);
    if (StringUtils.isBlank(mainFile)) {
        mainFile = PropsUtil.get(WURFL_MAIN_DEFAULT);
        if (StringUtils.isBlank(mainFile)) {
            _log.warn("Wurfl NOT initialised! Plase set '" + WURFL_MAIN + "' property!");
            return;
        }/*  w  w w.  java  2  s.  co  m*/
    }

    String[] patchFiles = PropsUtil.getArray(WURFL_PATCHES);
    if (patchFiles == null || patchFiles.length == 0) {
        patchFiles = PropsUtil.getArray(WURFL_PATCHES_DEFAULT);
    }

    wurflHolder = new CustomWURFLHolder(mainFile, patchFiles);
    _log.debug("Wurfl initialised!");
}

From source file:com.liferay.asset.publisher.web.display.context.AssetPublisherDisplayContext.java

License:Open Source License

public String getSocialBookmarksDisplayStyle() {
    if (_socialBookmarksDisplayStyle != null) {
        return _socialBookmarksDisplayStyle;
    }/*  w  ww .  j  a  v  a  2  s .c  o  m*/

    _socialBookmarksDisplayStyle = _portletPreferences.getValue("socialBookmarksDisplayStyle", null);

    if (Validator.isNull(_socialBookmarksDisplayStyle)) {
        String[] socialBookmarksDisplayStyles = PropsUtil.getArray(PropsKeys.SOCIAL_BOOKMARK_DISPLAY_STYLES);

        _socialBookmarksDisplayStyle = socialBookmarksDisplayStyles[0];
    }

    return _socialBookmarksDisplayStyle;
}

From source file:com.liferay.lms.service.impl.LmsPrefsLocalServiceImpl.java

License:Open Source License

private void setActivities(LmsPrefs lmsPrefs) throws SystemException {
    if (lmsPrefs.getActivities() == null || lmsPrefs.getActivities().length() == 0) {
        LearningActivityTypeRegistry learningActivityTypeRegistry = new LearningActivityTypeRegistry();
        java.util.List<LearningActivityType> lats = learningActivityTypeRegistry.getLearningActivityTypes();
        java.util.Map<Long, LearningActivityType> mapLats = new java.util.HashMap<Long, LearningActivityType>();

        for (LearningActivityType lat : lats) {
            mapLats.put(lat.getTypeId(), lat);
        }/*from   ww  w. ja  va  2s  . c o  m*/

        java.util.List<Long> actids = new java.util.ArrayList<Long>();
        if (PropsUtil.contains("lms.learningactivity.order.default")) {
            String[] defaultOrderArray = PropsUtil.getArray("lms.learningactivity.order.default");
            if (Validator.isNotNull(defaultOrderArray)) {
                for (int i = 0; i < defaultOrderArray.length; i++) {
                    String defaultOrderActIdString = defaultOrderArray[i];
                    if (Validator.isNumber(defaultOrderActIdString)) {
                        Long defaultOrderActId = Long.valueOf(defaultOrderActIdString);
                        if (defaultOrderActId >= 0 && mapLats.get(defaultOrderActId) != null) {
                            actids.add(defaultOrderActId);
                        }
                    }
                }
            }
        }

        for (int i = 0; i < lats.size(); i++) {
            Long typeId = lats.get(i).getTypeId();
            if (!actids.contains(typeId)) {
                actids.add(typeId);
            }
        }
        lmsPrefs.setActivities(StringUtil.merge(actids));
        lmsPrefsPersistence.update(lmsPrefs, true);
    }
}

From source file:com.liferay.marketplace.app.manager.web.internal.portlet.MarketplaceAppManagerPortlet.java

License:Open Source License

protected void doInstallSourceForgeApp(String path, ActionRequest actionRequest) throws Exception {

    String[] sourceForgeMirrors = PropsUtil.getArray(PropsKeys.SOURCE_FORGE_MIRRORS);

    for (int i = 0; i < sourceForgeMirrors.length; i++) {
        try {// w w  w.  j a  v  a2s . c om
            String url = sourceForgeMirrors[i] + path;

            boolean failOnError = false;

            if ((i + 1) == sourceForgeMirrors.length) {
                failOnError = true;
            }

            int responseCode = doInstallRemoteApp(url, actionRequest, failOnError);

            if (responseCode == HttpServletResponse.SC_OK) {
                return;
            }
        } catch (MalformedURLException murle) {
            SessionErrors.add(actionRequest, "invalidUrl", murle);
        }
    }
}

From source file:com.liferay.marketplace.appmanager.portlet.AppManagerPortlet.java

License:Open Source License

protected void doInstallSourceForgeApp(String path, UploadPortletRequest uploadPortletRequest,
        ActionRequest actionRequest) throws Exception {

    String[] sourceForgeMirrors = PropsUtil.getArray(PropsKeys.SOURCE_FORGE_MIRRORS);

    for (int i = 0; i < sourceForgeMirrors.length; i++) {
        try {// ww  w. ja v  a2 s . c  om
            String url = sourceForgeMirrors[i] + path;

            boolean failOnError = false;

            if ((i + 1) == sourceForgeMirrors.length) {
                failOnError = true;
            }

            int responseCode = doInstallRemoteApp(url, uploadPortletRequest, actionRequest, failOnError);

            if (responseCode == HttpServletResponse.SC_OK) {
                return;
            }
        } catch (MalformedURLException murle) {
            SessionErrors.add(actionRequest, "invalidUrl", murle);
        }
    }
}

From source file:com.liferay.marketplace.bundle.BundleManager.java

License:Open Source License

protected String getInstallDirName() throws Exception {
    String[] autoDeployDirNames = PropsUtil.getArray(PropsKeys.MODULE_FRAMEWORK_AUTO_DEPLOY_DIRS);

    if (ArrayUtil.isEmpty(autoDeployDirNames)) {
        throw new AutoDeployException(
                "The portal property \"" + PropsKeys.MODULE_FRAMEWORK_AUTO_DEPLOY_DIRS + "\" is not set");
    }//from w  ww . j a v  a  2  s. c  om

    String autoDeployDirName = autoDeployDirNames[0];

    for (String curDirName : autoDeployDirNames) {
        if (curDirName.endsWith("/marketplace")) {
            autoDeployDirName = curDirName;

            break;
        }
    }

    return autoDeployDirName;
}

From source file:com.liferay.taglib.ui.SocialBookmarkTag.java

License:Open Source License

@Override
protected String getPage() {
    String[] socialTypes = PropsUtil.getArray(PropsKeys.SOCIAL_BOOKMARK_TYPES);

    if (ArrayUtil.contains(socialTypes, _type)) {
        if (Validator.isNotNull(_jspPath)) {
            return _jspPath;
        } else {/*from   w ww  . j a  va  2s.c o  m*/
            return _PAGE;
        }
    } else {
        return null;
    }
}

From source file:com.liferay.wsrp.bind.V2MarkupServiceImpl.java

License:Open Source License

protected String getWidgetPath(String languageId) {
    HttpServletRequest request = ServletUtil.getRequest();

    String portalURL = PortalUtil.getPortalURL(request);

    StringBundler sb = new StringBundler(5);

    sb.append(portalURL);/*from   ww  w .j a va  2s. c o  m*/
    sb.append(PortalUtil.getPathContext());

    String[] localesEnabled = PropsUtil.getArray(PropsKeys.LOCALES_ENABLED);

    if (ArrayUtil.contains(localesEnabled, languageId)) {
        sb.append(StringPool.SLASH);
        sb.append(languageId);
    }

    sb.append(_PATH_WIDGET);

    return sb.toString();
}

From source file:com.stoxx.portlet.manageusers.controller.ManageUsersController.java

@RenderMapping(params = "action=editUserRole")
public String editStaffAction(@RequestParam String emailAddress,
        @ModelAttribute(USER_MODEL) UserModel userModel, RenderRequest renderRequest,
        RenderResponse renderResponse, Model model) {
    log.info("Inside render phase of showStaffRoles>>>>");
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
    try {//from  w w w. ja  va2s  .  c o  m

        User user = UserLocalServiceUtil.fetchUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress);
        long userId = user.getUserId();
        log.info("the user iod is>>>>>>>>>>>>>>" + userId);
        log.info("the group id is" + themeDisplay.getScopeGroupId());
        List<Role> rolelist1 = RoleLocalServiceUtil.getUserRelatedRoles(userId, themeDisplay.getScopeGroupId());
        List<Role> allRoleslist = RoleLocalServiceUtil.getTypeRoles(RoleConstants.TYPE_REGULAR);
        List<String> userRoles = new ArrayList<String>();
        List<String> allRoles = new ArrayList<String>();
        List<String> inheritedRoleNames = new ArrayList<String>();
        long[] userGroupIds = user.getUserGroupIds();
        log.info("the usergroupIds are  >> " + Arrays.toString(userGroupIds));
        for (long groupName : userGroupIds) {
            long groupId = GroupLocalServiceUtil
                    .getGroup(themeDisplay.getCompanyId(), String.valueOf(groupName)).getGroupId();
            List<Role> roles = RoleLocalServiceUtil.getGroupRoles(groupId);
            for (Role role : roles) {
                inheritedRoleNames.add(role.getName());
            }
        }

        for (Role role : rolelist1) {
            log.info("the role is " + role.getName());
            userRoles.add(role.getName());
        }
        for (Role role : allRoleslist) {
            if (GetterUtil
                    .getBoolean(role.getExpandoBridge().getAttribute(ROLE_CUSTOM_FIELD)) == Boolean.TRUE) {
                allRoles.add(role.getName());
            }
        }
        log.info("inheritedRoleNames size after is >>>>" + inheritedRoleNames.size());

        List<String> roleNamesToIgnore = ListUtil.fromArray(RoleConstants.SYSTEM_ROLES);
        roleNamesToIgnore.addAll(ListUtil.fromArray(PropsUtil.getArray("stoxx.regular.roles.to.ignore")));
        allRoles.removeAll(roleNamesToIgnore);

        userModel.setUserRoles(userRoles);
        userModel.setAllUserRoles(allRoles);
        userModel.setLiferayUserId(userId);
        userModel.setInheritedRoles(inheritedRoleNames);
    } catch (Exception e) {
        log.error(EXCEPTION, e);
    }
    model.addAttribute("staffRoleModel", userModel);
    return SHOW_STAFF_ROLE;
}