Example usage for com.liferay.portal.kernel.model ContactConstants DEFAULT_PARENT_CONTACT_ID

List of usage examples for com.liferay.portal.kernel.model ContactConstants DEFAULT_PARENT_CONTACT_ID

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model ContactConstants DEFAULT_PARENT_CONTACT_ID.

Prototype

long DEFAULT_PARENT_CONTACT_ID

To view the source code for com.liferay.portal.kernel.model ContactConstants DEFAULT_PARENT_CONTACT_ID.

Click Source Link

Usage

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

License:Open Source License

private void _updateContact(User user, String facebookSn, String jabberSn, String skypeSn, String smsSn,
        String twitterSn) throws Exception {

    facebookSn = StringUtil.toLowerCase(StringUtil.trim(facebookSn));
    jabberSn = StringUtil.toLowerCase(StringUtil.trim(jabberSn));
    skypeSn = StringUtil.toLowerCase(StringUtil.trim(skypeSn));
    twitterSn = StringUtil.toLowerCase(StringUtil.trim(twitterSn));

    if (Validator.isNotNull(smsSn) && !Validator.isEmailAddress(smsSn)) {
        throw new UserSmsException.MustBeEmailAddress(smsSn);
    }//from ww  w  .  j  a v  a  2s  .c om

    Contact contact = user.fetchContact();

    if (contact == null) {
        contact = _contactLocalService.createContact(user.getContactId());

        contact.setCompanyId(user.getCompanyId());
        contact.setUserName(StringPool.BLANK);
        contact.setClassName(User.class.getName());
        contact.setClassPK(user.getUserId());

        Company company = _companyLocalService.getCompany(user.getCompanyId());

        contact.setAccountId(company.getAccountId());

        contact.setParentContactId(ContactConstants.DEFAULT_PARENT_CONTACT_ID);
    }

    contact.setFacebookSn(facebookSn);
    contact.setJabberSn(jabberSn);
    contact.setSkypeSn(skypeSn);
    contact.setSmsSn(smsSn);
    contact.setTwitterSn(twitterSn);

    _contactLocalService.updateContact(contact);
}