Example usage for com.liferay.portal.kernel.util Constants DEACTIVATE

List of usage examples for com.liferay.portal.kernel.util Constants DEACTIVATE

Introduction

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

Prototype

String DEACTIVATE

To view the source code for com.liferay.portal.kernel.util Constants DEACTIVATE.

Click Source Link

Usage

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

public static ActionAccountOperation buildAccountActionOperation(ActionPhaseParameters app)
        throws PortalException, SystemException {
    ActionAccountOperation operation = null;

    String command = ParamUtil.getString(app.getRequest(), Constants.CMD, AccountOperationBuilder.DEFAULT);
    if (Constants.ADD.equals(command)) {
        operation = AccountOperationBuilder.buildAddAccountActionOperation(app);

    } else if (Constants.UPDATE.equals(command)) {
        operation = AccountOperationBuilder.buildUpdateAccountActionOperation(app);

    } else if (Constants.DEACTIVATE.equals(command) || MyAccountConstants.CANCEL_DEACTIVATION.equals(command)) {
        operation = AccountOperationBuilder.buildDeactivateAccountOperation(app);

    } else if (Constants.RESTORE.equals(command) || MyAccountConstants.CANCEL_ACTIVATION.equals(command)) {
        operation = AccountOperationBuilder.buildActivateAccountOperation(app);

    } else if (Constants.DELETE.equals(command)) {
        operation = AccountOperationBuilder.buildDeleteAccountActionOperation(app);

    } else {/*from w  ww .j  av  a2  s .  c  o m*/
        operation = new DefaultAccountActionOperation(app);

    }
    return operation;
}

From source file:com.liferay.portlet.sites.action.EditGroupAction.java

License:Open Source License

@Override
public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    String redirect = ParamUtil.getString(actionRequest, "redirect");

    try {/*from w  ww .  ja v  a  2 s  .  c o  m*/
        String closeRedirect = ParamUtil.getString(actionRequest, "closeRedirect");

        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            Object[] returnValue = updateGroup(actionRequest);

            Group group = (Group) returnValue[0];
            String oldFriendlyURL = (String) returnValue[1];
            String oldStagingFriendlyURL = (String) returnValue[2];
            long newRefererPlid = (Long) returnValue[3];

            redirect = HttpUtil.setParameter(redirect, "doAsGroupId", group.getGroupId());
            redirect = HttpUtil.setParameter(redirect, "refererPlid", newRefererPlid);

            closeRedirect = updateCloseRedirect(closeRedirect, group, themeDisplay, oldFriendlyURL,
                    oldStagingFriendlyURL);
        } else if (cmd.equals(Constants.DEACTIVATE) || cmd.equals(Constants.RESTORE)) {

            updateActive(actionRequest, cmd);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteGroup(actionRequest);
        }

        if (Validator.isNotNull(closeRedirect)) {
            SessionMessages.add(actionRequest,
                    portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_CLOSE_REDIRECT, closeRedirect);
        }

        sendRedirect(actionRequest, actionResponse, redirect);
    } catch (Exception e) {
        if (e instanceof NoSuchGroupException || e instanceof PrincipalException) {

            SessionErrors.add(actionRequest, e.getClass().getName());

            setForward(actionRequest, "portlet.sites_admin.error");
        } else if (e instanceof AssetCategoryException || e instanceof AssetTagException
                || e instanceof DuplicateGroupException || e instanceof GroupFriendlyURLException
                || e instanceof GroupNameException || e instanceof LayoutSetVirtualHostException
                || e instanceof RemoteExportException || e instanceof RemoteOptionsException
                || e instanceof RequiredGroupException || e instanceof SystemException) {

            SessionErrors.add(actionRequest, e.getClass().getName(), e);

            if (cmd.equals(Constants.DEACTIVATE) || cmd.equals(Constants.DELETE)
                    || cmd.equals(Constants.RESTORE)) {

                if (Validator.isNotNull(redirect)) {
                    actionResponse.sendRedirect(redirect);
                }
            }
        } else {
            throw e;
        }
    }
}

From source file:com.liferay.portlet.usersadmin.action.EditUserAction.java

License:Open Source License

@Override
public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    try {/*from w  w w . ja  v a2 s  . c  o m*/
        User user = null;
        String oldScreenName = StringPool.BLANK;
        String oldLanguageId = StringPool.BLANK;

        if (cmd.equals(Constants.ADD)) {
            user = addUser(actionRequest);
        } else if (cmd.equals(Constants.DEACTIVATE) || cmd.equals(Constants.DELETE)
                || cmd.equals(Constants.RESTORE)) {

            deleteUsers(actionRequest);
        } else if (cmd.equals("deleteRole")) {
            deleteRole(actionRequest);
        } else if (cmd.equals(Constants.UPDATE)) {
            Object[] returnValue = updateUser(actionRequest, actionResponse);

            user = (User) returnValue[0];
            oldScreenName = ((String) returnValue[1]);
            oldLanguageId = ((String) returnValue[2]);
        } else if (cmd.equals("unlock")) {
            user = updateLockout(actionRequest);
        }

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

        String redirect = ParamUtil.getString(actionRequest, "redirect");

        if (user != null) {
            if (Validator.isNotNull(oldScreenName)) {

                // This will fix the redirect if the user is on his personal
                // my account page and changes his screen name. A redirect
                // that references the old screen name no longer points to a
                // valid screen name and therefore needs to be updated.

                Group group = user.getGroup();

                if (group.getGroupId() == themeDisplay.getScopeGroupId()) {
                    Layout layout = themeDisplay.getLayout();

                    String friendlyURLPath = group.getPathFriendlyURL(layout.isPrivateLayout(), themeDisplay);

                    String oldPath = friendlyURLPath + StringPool.SLASH + oldScreenName;
                    String newPath = friendlyURLPath + StringPool.SLASH + user.getScreenName();

                    redirect = StringUtil.replace(redirect, oldPath, newPath);

                    redirect = StringUtil.replace(redirect, HttpUtil.encodeURL(oldPath),
                            HttpUtil.encodeURL(newPath));
                }
            }

            if (Validator.isNotNull(oldLanguageId) && themeDisplay.isI18n()) {

                String i18nLanguageId = user.getLanguageId();
                int pos = i18nLanguageId.indexOf(CharPool.UNDERLINE);

                if (pos != -1) {
                    i18nLanguageId = i18nLanguageId.substring(0, pos);
                }

                String i18nPath = StringPool.SLASH + i18nLanguageId;

                redirect = StringUtil.replace(redirect, themeDisplay.getI18nPath(), i18nPath);
            }

            redirect = HttpUtil.setParameter(redirect, actionResponse.getNamespace() + "p_u_i_d",
                    user.getUserId());
        }

        Group scopeGroup = themeDisplay.getScopeGroup();

        if (scopeGroup.isUser()) {
            try {
                UserLocalServiceUtil.getUserById(scopeGroup.getClassPK());
            } catch (NoSuchUserException nsue) {
                redirect = HttpUtil.setParameter(redirect, "doAsGroupId", 0);
                redirect = HttpUtil.setParameter(redirect, "refererPlid", 0);
            }
        }

        sendRedirect(actionRequest, actionResponse, redirect);
    } catch (Exception e) {
        if (e instanceof NoSuchUserException || e instanceof PrincipalException) {

            SessionErrors.add(actionRequest, e.getClass().getName());

            setForward(actionRequest, "portlet.users_admin.error");
        } else if (e instanceof AddressCityException || e instanceof AddressStreetException
                || e instanceof AddressZipException || e instanceof CompanyMaxUsersException
                || e instanceof ContactBirthdayException || e instanceof ContactFirstNameException
                || e instanceof ContactFullNameException || e instanceof ContactLastNameException
                || e instanceof DuplicateUserEmailAddressException
                || e instanceof DuplicateUserScreenNameException || e instanceof EmailAddressException
                || e instanceof GroupFriendlyURLException || e instanceof NoSuchCountryException
                || e instanceof NoSuchListTypeException || e instanceof NoSuchRegionException
                || e instanceof PhoneNumberException || e instanceof RequiredUserException
                || e instanceof ReservedUserEmailAddressException
                || e instanceof ReservedUserScreenNameException || e instanceof UserEmailAddressException
                || e instanceof UserIdException || e instanceof UserPasswordException
                || e instanceof UserReminderQueryException || e instanceof UserScreenNameException
                || e instanceof UserSmsException || e instanceof WebsiteURLException) {

            if (e instanceof NoSuchListTypeException) {
                NoSuchListTypeException nslte = (NoSuchListTypeException) e;

                SessionErrors.add(actionRequest, e.getClass().getName() + nslte.getType());
            } else {
                SessionErrors.add(actionRequest, e.getClass().getName(), e);
            }

            if (e instanceof RequiredUserException) {
                String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect"));

                if (Validator.isNotNull(redirect)) {
                    actionResponse.sendRedirect(redirect);
                }
            }
        } else {
            throw e;
        }
    }
}

From source file:com.liferay.portlet.usersadmin.action.EditUserAction.java

License:Open Source License

protected void deleteUsers(ActionRequest actionRequest) throws Exception {
    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    long[] deleteUserIds = StringUtil.split(ParamUtil.getString(actionRequest, "deleteUserIds"), 0L);

    for (int i = 0; i < deleteUserIds.length; i++) {
        if (cmd.equals(Constants.DEACTIVATE) || cmd.equals(Constants.RESTORE)) {

            int status = WorkflowConstants.STATUS_APPROVED;

            if (cmd.equals(Constants.DEACTIVATE)) {
                status = WorkflowConstants.STATUS_INACTIVE;
            }/*  www  .  j  av  a 2 s.  c o m*/

            UserServiceUtil.updateStatus(deleteUserIds[i], status);
        } else {
            UserServiceUtil.deleteUser(deleteUserIds[i]);
        }
    }
}

From source file:com.liferay.portlet.workflowdefinitions.action.EditWorkflowDefinitionAction.java

License:Open Source License

@Override
public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    try {/*from   w ww . j av a 2 s . com*/
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            updateWorkflowDefinition(actionRequest);
        } else if (cmd.equals(Constants.DEACTIVATE) || cmd.equals(Constants.DELETE)
                || cmd.equals(Constants.RESTORE)) {

            deleteWorkflowDefinition(actionRequest);
        }

        sendRedirect(actionRequest, actionResponse);
    } catch (Exception e) {
        if (e instanceof WorkflowDefinitionFileException) {
            SessionErrors.add(actionRequest, e.getClass().getName());
        } else if (e instanceof WorkflowException) {
            SessionErrors.add(actionRequest, e.getClass().getName());

            setForward(actionRequest, "portlet.workflow_definitions.error");
        } else {
            throw e;
        }
    }
}

From source file:com.liferay.portlet.workflowdefinitions.action.EditWorkflowDefinitionAction.java

License:Open Source License

protected void deleteWorkflowDefinition(ActionRequest actionRequest) throws Exception {

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

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

    String name = ParamUtil.getString(actionRequest, "name");
    int version = ParamUtil.getInteger(actionRequest, "version");

    if (cmd.equals(Constants.DEACTIVATE) || cmd.equals(Constants.RESTORE)) {
        boolean active = !cmd.equals(Constants.DEACTIVATE);

        WorkflowDefinitionManagerUtil.updateActive(themeDisplay.getCompanyId(), themeDisplay.getUserId(), name,
                version, active);//from  w ww . ja  v a 2 s . c  o  m
    } else {
        WorkflowDefinitionManagerUtil.undeployWorkflowDefinition(themeDisplay.getCompanyId(),
                themeDisplay.getUserId(), name, version);
    }
}

From source file:com.liferay.users.admin.web.internal.portlet.action.EditUserMVCActionCommand.java

License:Open Source License

protected void deleteUsers(ActionRequest actionRequest) throws Exception {
    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    long[] deleteUserIds = StringUtil.split(ParamUtil.getString(actionRequest, "deleteUserIds"), 0L);

    for (long deleteUserId : deleteUserIds) {
        if (cmd.equals(Constants.DEACTIVATE) || cmd.equals(Constants.RESTORE)) {

            int status = WorkflowConstants.STATUS_APPROVED;

            if (cmd.equals(Constants.DEACTIVATE)) {
                status = WorkflowConstants.STATUS_INACTIVE;
            }//w  w w .  j  a  va  2 s  . c om

            _userService.updateStatus(deleteUserId, status, new ServiceContext());
        } else {
            _userService.deleteUser(deleteUserId);
        }
    }
}

From source file:com.liferay.users.admin.web.internal.portlet.action.EditUserMVCActionCommand.java

License:Open Source License

@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    actionRequest = _wrapActionRequest(actionRequest);

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    try {/*  w ww  . j  a  va2 s .  co m*/
        User user = null;
        String oldScreenName = StringPool.BLANK;
        boolean updateLanguageId = false;

        if (cmd.equals(Constants.ADD)) {
            user = addUser(actionRequest);
        } else if (cmd.equals(Constants.DEACTIVATE) || cmd.equals(Constants.DELETE)
                || cmd.equals(Constants.RESTORE)) {

            deleteUsers(actionRequest);
        } else if (cmd.equals("deleteRole")) {
            deleteRole(actionRequest);
        } else if (cmd.equals(Constants.UPDATE)) {
            Object[] returnValue = updateUser(actionRequest, actionResponse);

            user = (User) returnValue[0];
            oldScreenName = (String) returnValue[1];
            updateLanguageId = (Boolean) returnValue[2];
        } else if (cmd.equals("unlock")) {
            user = updateLockout(actionRequest);
        }

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

        String redirect = ParamUtil.getString(actionRequest, "redirect");

        if (user != null) {
            if (Validator.isNotNull(oldScreenName)) {

                // This will fix the redirect if the user is on his personal
                // my account page and changes his screen name. A redirect
                // that references the old screen name no longer points to a
                // valid screen name and therefore needs to be updated.

                Group group = user.getGroup();

                if (group.getGroupId() == themeDisplay.getScopeGroupId()) {
                    Layout layout = themeDisplay.getLayout();

                    String friendlyURLPath = group.getPathFriendlyURL(layout.isPrivateLayout(), themeDisplay);

                    String oldPath = friendlyURLPath + StringPool.SLASH + oldScreenName;
                    String newPath = friendlyURLPath + StringPool.SLASH + user.getScreenName();

                    redirect = StringUtil.replace(redirect, oldPath, newPath);

                    redirect = StringUtil.replace(redirect, URLCodec.encodeURL(oldPath),
                            URLCodec.encodeURL(newPath));
                }
            }

            if (updateLanguageId && themeDisplay.isI18n()) {
                String i18nLanguageId = user.getLanguageId();

                int pos = i18nLanguageId.indexOf(CharPool.UNDERLINE);

                if (pos != -1) {
                    i18nLanguageId = i18nLanguageId.substring(0, pos);
                }

                String i18nPath = StringPool.SLASH + i18nLanguageId;

                redirect = StringUtil.replace(redirect, themeDisplay.getI18nPath(), i18nPath);
            }

            redirect = http.setParameter(redirect, actionResponse.getNamespace() + "p_u_i_d", user.getUserId());
        }

        Group scopeGroup = themeDisplay.getScopeGroup();

        if (scopeGroup.isUser() && (userLocalService.fetchUserById(scopeGroup.getClassPK()) == null)) {

            redirect = http.setParameter(redirect, "doAsGroupId", 0);
            redirect = http.setParameter(redirect, "refererPlid", 0);
        }

        sendRedirect(actionRequest, actionResponse, redirect);
    } catch (Exception e) {
        String mvcPath = "/edit_user.jsp";

        if (e instanceof NoSuchUserException || e instanceof PrincipalException) {

            SessionErrors.add(actionRequest, e.getClass());

            mvcPath = "/error.jsp";
        } else if (e instanceof AssetCategoryException || e instanceof AssetTagException
                || e instanceof CompanyMaxUsersException || e instanceof ContactBirthdayException
                || e instanceof ContactNameException || e instanceof GroupFriendlyURLException
                || e instanceof MembershipPolicyException || e instanceof NoSuchListTypeException
                || e instanceof RequiredUserException || e instanceof UserEmailAddressException
                || e instanceof UserFieldException || e instanceof UserIdException
                || e instanceof UserReminderQueryException || e instanceof UserScreenNameException) {

            if (e instanceof NoSuchListTypeException) {
                NoSuchListTypeException nslte = (NoSuchListTypeException) e;

                Class<?> clazz = e.getClass();

                SessionErrors.add(actionRequest, clazz.getName() + nslte.getType());
            } else {
                SessionErrors.add(actionRequest, e.getClass(), e);
            }

            if (e instanceof CompanyMaxUsersException || e instanceof RequiredUserException) {

                String redirect = portal.escapeRedirect(ParamUtil.getString(actionRequest, "redirect"));

                if (Validator.isNotNull(redirect)) {
                    sendRedirect(actionRequest, actionResponse, redirect);

                    return;
                }
            }
        } else {
            throw e;
        }

        actionResponse.setRenderParameter("mvcPath", mvcPath);
    }
}

From source file:com.rivetlogic.microsites.util.MicroSitesUtil.java

License:Open Source License

public static void createMicroSite(ActionRequest request) throws Exception {

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

    String cmd = ParamUtil.getString(request, Constants.CMD);

    try {/*w  ww  . j  av a 2s. c  om*/
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            Group group = updateGroup(request);
            long microSiteId = CounterLocalServiceUtil.increment(MicroSite.class.getName());
            MicroSite microSite = MicroSiteLocalServiceUtil.createMicroSite(microSiteId);
            microSite.setCompanyId(themeDisplay.getCompanyId());
            microSite.setUserId(themeDisplay.getUserId());
            microSite.setUserName(themeDisplay.getUser().getScreenName());
            microSite.setCreateDate(new Date());
            microSite.setModifiedDate(new Date());
            microSite.setGroupId(group.getGroupId());
            MicroSiteLocalServiceUtil.updateMicroSite(microSite);
        } else if (cmd.equals(Constants.DEACTIVATE) || cmd.equals(Constants.RESTORE)) {

            updateActive(request, cmd);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteGroups(request);
        }
    } catch (Exception e) {
        if (e instanceof NoSuchGroupException || e instanceof PrincipalException) {

            SessionErrors.add(request, e.getClass());
        } else if (e instanceof AssetCategoryException || e instanceof AssetTagException
                || e instanceof AuthException || e instanceof DuplicateGroupException
                || e instanceof GroupFriendlyURLException || e instanceof GroupNameException
                || e instanceof GroupParentException || e instanceof LayoutSetVirtualHostException
                || e instanceof LocaleException || e instanceof PendingBackgroundTaskException
                || e instanceof RemoteExportException || e instanceof RemoteOptionsException
                || e instanceof RequiredGroupException || e instanceof SystemException) {

            if (e instanceof RemoteAuthException) {
                SessionErrors.add(request, AuthException.class, e);
            } else {
                SessionErrors.add(request, e.getClass(), e);
            }
        } else {
            throw e;
        }
    }
}