Foren

Overriden CreateAccountMVCActionCommand in login module in liferay 7 GA2

lokesh gorrela, geändert vor 7 Jahren.

Overriden CreateAccountMVCActionCommand in login module in liferay 7 GA2

Regular Member Beiträge: 173 Beitrittsdatum: 09.03.16 Neueste Beiträge
Hi guys,

I overriden CreateAccountMVCActionCommand class in login module in liferay 7.0.1 GA2.

My Implementation code:
@Component(property = { "javax.portlet.name=com_liferay_login_web_portlet_LoginPortlet",
"javax.portlet.name=com_liferay_login_web_portlet_LoginPortlet", "mvc.command.name=/login/create_account",
"service.ranking:Integer=100" }, service = MVCActionCommand.class)
public class EducationYugCreateAccountMVCActionCommand extends BaseMVCActionCommand {
protected void addUser(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
HttpServletRequest request = PortalUtil.getHttpServletRequest(
actionRequest);

HttpSession session = request.getSession();

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

Company company = themeDisplay.getCompany();

boolean autoPassword = true;
String password1 = null;
String password2 = null;
boolean autoScreenName = isAutoScreenName();
String screenName = ParamUtil.getString(actionRequest, "screenName");
String emailAddress = ParamUtil.getString(
actionRequest, "emailAddress");
long facebookId = ParamUtil.getLong(actionRequest, "facebookId");
String openId = ParamUtil.getString(actionRequest, "openId");
String languageId = ParamUtil.getString(actionRequest, "languageId");
String firstName = ParamUtil.getString(actionRequest, "firstName");
String middleName = ParamUtil.getString(actionRequest, "middleName");
String lastName = ParamUtil.getString(actionRequest, "lastName");
long prefixId = ParamUtil.getInteger(actionRequest, "prefixId");
long suffixId = ParamUtil.getInteger(actionRequest, "suffixId");
boolean male = ParamUtil.getBoolean(actionRequest, "male", true);
int birthdayMonth = ParamUtil.getInteger(
actionRequest, "birthdayMonth");
int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay");
int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear");
String jobTitle = ParamUtil.getString(actionRequest, "jobTitle");
long[] groupIds = null;
long[] organizationIds = null;
long[] roleIds = null;
long[] userGroupIds = null;
boolean sendEmail = true;

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

if (PropsValues.LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD) {
autoPassword = false;

password1 = ParamUtil.getString(actionRequest, "password1");
password2 = ParamUtil.getString(actionRequest, "password2");
}

boolean openIdPending = false;

Boolean openIdLoginPending = (Boolean)session.getAttribute(
WebKeys.OPEN_ID_LOGIN_PENDING);

if ((openIdLoginPending != null) && openIdLoginPending.booleanValue() &&
Validator.isNotNull(openId)) {

sendEmail = false;
openIdPending = true;
}

User user = _userService.addUserWithWorkflow(
company.getCompanyId(), autoPassword, password1, password2,
autoScreenName, screenName, emailAddress, facebookId, openId,
LocaleUtil.fromLanguageId(languageId), firstName, middleName,
lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay,
birthdayYear, jobTitle, groupIds, organizationIds, roleIds,
userGroupIds, sendEmail, serviceContext);

if (openIdPending) {
session.setAttribute(
WebKeys.OPEN_ID_LOGIN, Long.valueOf(user.getUserId()));

session.removeAttribute(WebKeys.OPEN_ID_LOGIN_PENDING);
}
else {

// Session messages

if (user.getStatus() == WorkflowConstants.STATUS_APPROVED) {
SessionMessages.add(
request, "userAdded", user.getEmailAddress());
SessionMessages.add(
request, "userAddedPassword",
user.getPasswordUnencrypted());
}
else {
SessionMessages.add(
request, "userPending", user.getEmailAddress());
}
}

// Send redirect

sendRedirect(
actionRequest, actionResponse, themeDisplay, user,
user.getPasswordUnencrypted());

}

@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
System.out.println("Enter into doProcessAction in createAccount");
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

Company company = themeDisplay.getCompany();

if (!company.isStrangers()) {
throw new PrincipalException.MustBeEnabled(company.getCompanyId(), PropsKeys.COMPANY_SECURITY_STRANGERS);
}

String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
System.out.println("cmd in doProcessAction in createAccount:" + cmd);
if (cmd.equals(Constants.ADD)) {
/*
* if (PropssValues.CAPTCHA_CHECK_PORTAL_CREATE_ACCOUNT) {
* CaptchaUtil.check(actionRequest); }
*/

addUser(actionRequest, actionResponse);
}

mvcActionCommand.processAction(actionRequest, actionResponse);
}

public MVCActionCommand getMVCActionCommand() {
return mvcActionCommand;
}

@Reference(target = "(&(mvc.command.name=/login/create_account)(javax.portlet.name=com_liferay_login_web_portlet_LoginPortlet))")
public void setMVCActionCommand(MVCActionCommand mvcActionCommand) {
this.mvcActionCommand = mvcActionCommand;
}

protected MVCActionCommand mvcActionCommand;
private static final boolean _AUTO_SCREEN_NAME = true;
}

In this above code
sendRedirect(
actionRequest, actionResponse, themeDisplay, user,
user.getPasswordUnencrypted());
method is showing below error. Any one knows about this please give replay to me.