List of usage examples for com.liferay.portal.kernel.exception NoSuchListTypeException getType
public String getType()
From source file:com.liferay.users.admin.web.internal.portlet.action.EditOrganizationMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try {/*from w w w .j a v a 2 s. c o m*/ Organization organization = null; if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { organization = updateOrganization(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deleteOrganizations(actionRequest); } String redirect = ParamUtil.getString(actionRequest, "redirect"); if (organization != null) { redirect = _http.setParameter(redirect, actionResponse.getNamespace() + "organizationId", organization.getOrganizationId()); } sendRedirect(actionRequest, actionResponse, redirect); } catch (Exception e) { String mvcPath = "/edit_organization.jsp"; if (e instanceof NoSuchOrganizationException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass()); mvcPath = "/error.jsp"; } else if (e instanceof AssetCategoryException || e instanceof AssetTagException) { SessionErrors.add(actionRequest, e.getClass(), e); } else if (e instanceof AddressCityException || e instanceof AddressStreetException || e instanceof AddressZipException || e instanceof DuplicateOrganizationException || e instanceof EmailAddressException || e instanceof NoSuchCountryException || e instanceof NoSuchListTypeException || e instanceof NoSuchRegionException || e instanceof OrganizationNameException || e instanceof OrganizationParentException || e instanceof PhoneNumberException || e instanceof PhoneNumberExtensionException || e instanceof RequiredOrganizationException || e instanceof WebsiteURLException) { 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()); } if (e instanceof RequiredOrganizationException) { String redirect = _portal.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); long organizationId = ParamUtil.getLong(actionRequest, "organizationId"); if (organizationId > 0) { redirect = _http.setParameter(redirect, actionResponse.getNamespace() + "organizationId", organizationId); } if (Validator.isNotNull(redirect)) { sendRedirect(actionRequest, actionResponse, redirect); return; } } } else { throw e; } actionResponse.setRenderParameter("mvcPath", mvcPath); } }
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 {/*from w ww . j a v a2s . com*/ 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); } }