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:com.stoxx.portlet.manageusers.controller.ManageUsersController.java

@RenderMapping(params = "action=staffRoles")
public String updateRoleAssignmentForStaff(@ModelAttribute("staffRoleModel") UserModel userModel,
        RenderRequest renderRequest, RenderResponse renderResponse, Model model) {
    log.info("Inside user updateRoleAssignmentForStaff  method>>>> ");
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    try {/*from  w  ww. j  a v a2 s.  c om*/
        log.info("the updated roles checked are" + userModel.getRolesAssigned());
        log.info("the User id " + userModel.getLiferayUserId());
        List<Role> rolelist = RoleLocalServiceUtil.getUserRelatedRoles(userModel.getLiferayUserId(),
                themeDisplay.getScopeGroupId());
        List<String> userRoles = new ArrayList<String>();
        for (Role role : rolelist) {
            userRoles.add(role.getName());
        }
        userModel.setUserRoles(userRoles);
        List<String> assignedUserRoleNames = new ArrayList<String>();
        List<String> assignedUnsetUserRoleNames = new ArrayList<String>();
        List<String> selectedUserRoles = new ArrayList<String>();
        assignedUserRoleNames = assignRoles(userModel, assignedUserRoleNames);
        assignedUnsetUserRoleNames = unsetRoles(userModel, assignedUnsetUserRoleNames);
        addRole(userModel, themeDisplay, assignedUserRoleNames);
        removeRole(userModel, themeDisplay, assignedUnsetUserRoleNames);
        List<Role> allRoleslist = RoleLocalServiceUtil.getTypeRoles(RoleConstants.TYPE_REGULAR);
        List<Role> rolelist1 = RoleLocalServiceUtil.getUserRelatedRoles(userModel.getLiferayUserId(),
                themeDisplay.getScopeGroupId());
        List<String> userRoles1 = new ArrayList<String>();
        List<String> allRoles = new ArrayList<String>();
        List<String> inheritedRoleNames = new ArrayList<String>();
        log.info("inheritedRoleNames size before is >>>>" + inheritedRoleNames.size());
        for (Role role : rolelist1) {
            userRoles1.add(role.getName());
        }
        for (Role role : allRoleslist) {
            if (GetterUtil
                    .getBoolean(role.getExpandoBridge().getAttribute(ROLE_CUSTOM_FIELD)) == Boolean.TRUE) {
                allRoles.add(role.getName());
            }
        }
        User user = UserLocalServiceUtil.fetchUser(userModel.getLiferayUserId());
        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());
            }
        }
        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(userRoles1);
        userModel.setAllUserRoles(allRoles);
        userModel.setLiferayUserId(userModel.getLiferayUserId());
        userModel.setInheritedRoles(inheritedRoleNames);
        selectedUserRoles.addAll(userRoles1);
        selectedUserRoles.addAll(inheritedRoleNames);
        userModel.setSelectedUserRoles(selectedUserRoles);
        SessionMessages.add(renderRequest, "roles-updated");
    } catch (Exception e) {
        log.error(SYSTEM_EXCEPTION, e);
    }
    model.addAttribute("staffRoleModel", userModel);
    return SHOW_STAFF_ROLE;

}

From source file:com.vportal.portal.servlet.PortalSessionListener.java

License:Open Source License

public void sessionCreated(HttpSessionEvent event) {

    /*if (PropsValues.SESSION_DISABLED) {
       return;/*from  w w w.j  av  a2 s.  c o  m*/
    }*/
    //hoan
    if (GetterUtil.getBoolean(PropsUtil.get(PropsKeys.SESSION_DISABLED))) {
        return;
    }
    //hoan
    HttpSession ses = event.getSession();

    MethodKey method = new MethodKey("com.liferay.portal.kernel.util.Validator.PortalSessionContext", "put",
            String.class, HttpSession.class);
    Object[] args = new Object[] { ses.getId(), ses };
    //PortalSessionContext.put(ses.getId(), ses);
    try {
        PortalClassInvoker.invoke(false, method, args);
    } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    // Process session created events

    try {
        /*EventsProcessor.process(
        PropsKeys.SERVLET_SESSION_CREATE_EVENTS,
        PropsValues.SERVLET_SESSION_CREATE_EVENTS, ses);*/
        //hoan
        MethodKey methodProcess = new MethodKey("com.liferay.portal.events.EventsProcessorUtil", "process",
                String.class, String.class, HttpSession.class);
        Object[] argsProcess = new Object[] { PropsKeys.SERVLET_SESSION_CREATE_EVENTS,
                PropsUtil.getArray("SERVLET_SESSION_CREATE_EVENTS"), ses };
        PortalClassInvoker.invoke(false, methodProcess, argsProcess);
        /*EventsProcessorUtil.process(
              PropsKeys.SERVLET_SESSION_CREATE_EVENTS,
              PropsValues.SERVLET_SESSION_CREATE_EVENTS, ses);*/
        //hoan      
    } catch (ActionException ae) {
        _log.error(ae, ae);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.vportal.portal.servlet.PortalSessionListener.java

License:Open Source License

public void sessionDestroyed(HttpSessionEvent event) {
    /*if (PropsValues.SESSION_DISABLED) {
    return;// w  w  w . ja va  2 s  . co  m
    }*/
    //hoan
    if (GetterUtil.getBoolean(PropsUtil.get("SESSION_DISABLED"))) {
        return;
    }
    //hoan

    HttpSession ses = event.getSession();

    MethodKey method = new MethodKey("com.liferay.portal.kernel.util.Validator.PortalSessionContext", "remove",
            String.class);
    Object[] args = new Object[] { ses.getId() };
    try {
        PortalClassInvoker.invoke(false, method, args);
    } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    //PortalSessionContext.remove(ses.getId());

    try {
        Long userIdObj = (Long) ses.getAttribute(WebKeys.USER_ID);

        if (userIdObj == null) {
            _log.warn("User id is not in the session");
        } else {
            long userId = userIdObj.longValue();

            if (CompanyThreadLocal.getCompanyId() == 0) {
                setCompanyId(userId);
            }

            //MailSessionLock.cleanUp(ses);
            MethodKey methodSignOut = new MethodKey("com.liferay.portal.liveusers.LiveUsers", "signOut",
                    long.class, String.class, String.class);
            Object[] argsSignOut = new Object[] { CompanyThreadLocal.getCompanyId(), userId, ses.getId() };
            PortalClassInvoker.invoke(false, methodSignOut, argsSignOut);
            //LiveUsers.signOut(CompanyThreadLocal.getCompanyId(), userId, ses.getId());
        }

    } catch (IllegalStateException ise) {
        _log.warn("Please upgrade to a servlet 2.4 compliant container");
    } catch (Exception e) {
        _log.error(e, e);
    }
    //ses.removeAttribute(WebKeys.PORTLET_SESSION_TRACKER);
    //ses.removeAttribute(WebKeys.REVERSE_AJAX);

    //MessagingUtil.closeXMPPConnection(ses);

    // Process session destroyed events

    try {
        /*EventsProcessor.process(
        PropsKeys.SERVLET_SESSION_DESTROY_EVENTS,
        PropsValues.SERVLET_SESSION_DESTROY_EVENTS, ses);*/
        //hoan
        MethodKey methodProcess = new MethodKey("com.liferay.portal.events.EventsProcessorUtil", "process",
                String.class, String.class, HttpSession.class);
        Object[] argsProcess = new Object[] { PropsKeys.SERVLET_SESSION_DESTROY_EVENTS,
                PropsUtil.getArray(PropsKeys.SERVLET_SESSION_DESTROY_EVENTS), ses };
        PortalClassInvoker.invoke(false, methodProcess, argsProcess);

        /*EventsProcessorUtil.process(
              PropsKeys.SERVLET_SESSION_DESTROY_EVENTS,
              PropsValues.SERVLET_SESSION_DESTROY_EVENTS, ses);*/
        //hoan

    } catch (ActionException ae) {
        _log.error(ae, ae);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:de.fhg.fokus.odp.portal.datasets.searchresults.BrowseDataSetsSearchResults.java

/**
 * This method fills {@link #openLicensesId} with open licenses from our
 * property file./*from   ww w.  j  av  a 2s  . c  o m*/
 */
private void fillOpenLicensesId() {
    for (String singleLicense : PropsUtil.getArray("openLicenses")) {
        this.openLicensesId.add(singleLicense);
    }
}