001
014
015 package com.liferay.mail.service.impl;
016
017 import com.liferay.mail.NoSuchCyrusUserException;
018 import com.liferay.mail.model.CyrusUser;
019 import com.liferay.mail.model.CyrusVirtual;
020 import com.liferay.mail.service.CyrusService;
021 import com.liferay.mail.service.persistence.CyrusUserUtil;
022 import com.liferay.mail.service.persistence.CyrusVirtualUtil;
023 import com.liferay.portal.kernel.exception.SystemException;
024
025
028 public class CyrusServiceImpl implements CyrusService {
029
030 public void addUser(long userId, String emailAddress, String password)
031 throws SystemException {
032
033
034
035 CyrusUser user = new CyrusUser(userId, password);
036
037 CyrusUserUtil.update(user);
038
039
040
041 CyrusVirtual virtual = new CyrusVirtual(emailAddress, userId);
042
043 CyrusVirtualUtil.update(virtual);
044 }
045
046 public void deleteEmailAddress(long companyId, long userId)
047 throws SystemException {
048
049 CyrusVirtualUtil.removeByUserId(userId);
050 }
051
052 public void deleteUser(long userId) throws SystemException {
053
054
055
056 try {
057 CyrusUserUtil.remove(userId);
058 }
059 catch (NoSuchCyrusUserException nscue) {
060 }
061
062
063
064 CyrusVirtualUtil.removeByUserId(userId);
065 }
066
067 public void updateEmailAddress(
068 long companyId, long userId, String emailAddress)
069 throws SystemException {
070
071 CyrusVirtualUtil.removeByUserId(userId);
072
073 CyrusVirtual virtual = new CyrusVirtual(emailAddress, userId);
074
075 CyrusVirtualUtil.update(virtual);
076 }
077
078 public void updatePassword(long companyId, long userId, String password)
079 throws SystemException {
080
081 CyrusUser user = null;
082
083 try {
084 user = CyrusUserUtil.findByPrimaryKey(userId);
085 }
086 catch (NoSuchCyrusUserException nscue) {
087 user = new CyrusUser(userId, password);
088 }
089
090 user.setPassword(password);
091
092 CyrusUserUtil.update(user);
093 }
094
095 }