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.bean.IdentifiableBean;
024 import com.liferay.portal.kernel.exception.SystemException;
025 import com.liferay.portal.kernel.security.pacl.DoPrivileged;
026
027
030 @DoPrivileged
031 public class CyrusServiceImpl implements CyrusService, IdentifiableBean {
032
033 @Override
034 public void addUser(long userId, String emailAddress, String password)
035 throws SystemException {
036
037
038
039 CyrusUser user = new CyrusUser(userId, password);
040
041 CyrusUserUtil.update(user);
042
043
044
045 CyrusVirtual virtual = new CyrusVirtual(emailAddress, userId);
046
047 CyrusVirtualUtil.update(virtual);
048 }
049
050 @Override
051 public void deleteEmailAddress(long companyId, long userId)
052 throws SystemException {
053
054 CyrusVirtualUtil.removeByUserId(userId);
055 }
056
057 @Override
058 public void deleteUser(long userId) throws SystemException {
059
060
061
062 try {
063 CyrusUserUtil.remove(userId);
064 }
065 catch (NoSuchCyrusUserException nscue) {
066 }
067
068
069
070 CyrusVirtualUtil.removeByUserId(userId);
071 }
072
073 @Override
074 public String getBeanIdentifier() {
075 return _beanIdentifier;
076 }
077
078 @Override
079 public void setBeanIdentifier(String beanIdentifier) {
080 _beanIdentifier = beanIdentifier;
081 }
082
083 @Override
084 public void updateEmailAddress(
085 long companyId, long userId, String emailAddress)
086 throws SystemException {
087
088 CyrusVirtualUtil.removeByUserId(userId);
089
090 CyrusVirtual virtual = new CyrusVirtual(emailAddress, userId);
091
092 CyrusVirtualUtil.update(virtual);
093 }
094
095 @Override
096 public void updatePassword(long companyId, long userId, String password)
097 throws SystemException {
098
099 CyrusUser user = null;
100
101 try {
102 user = CyrusUserUtil.findByPrimaryKey(userId);
103 }
104 catch (NoSuchCyrusUserException nscue) {
105 user = new CyrusUser(userId, password);
106 }
107
108 user.setPassword(password);
109
110 CyrusUserUtil.update(user);
111 }
112
113 private String _beanIdentifier;
114
115 }