use of org.apache.openmeetings.db.entity.user.UserContact in project openmeetings by apache.
the class UserContactDao method add.
public UserContact add(Long userId, Long ownerId, boolean pending) {
try {
UserContact userContact = new UserContact();
userContact.setInserted(new Date());
userContact.setOwner(userDao.get(ownerId));
userContact.setContact(userDao.get(userId));
userContact.setPending(pending);
userContact = update(userContact);
return userContact;
} catch (Exception e) {
log.error("[addUserContact]", e);
}
return null;
}
use of org.apache.openmeetings.db.entity.user.UserContact in project openmeetings by apache.
the class ContactsHelper method addUserToContactList.
public static Object addUserToContactList(long userIdToAdd) {
boolean isContact = get().getBean(UserContactDao.class).isContact(userIdToAdd, getUserId());
if (isContact) {
return "error.contact.added";
}
UserContact contact = get().getBean(UserContactDao.class).add(userIdToAdd, getUserId(), true);
User user = contact.getOwner();
User userToAdd = contact.getContact();
String subj = user.getFirstname() + " " + user.getLastname() + " " + Application.getString("1193");
String message = RequestContactTemplate.getEmail(userToAdd, user);
get().getBean(PrivateMessageDao.class).addPrivateMessage(subj, message, user, userToAdd, userToAdd, true, contact.getId());
if (userToAdd.getAddress() != null) {
get().getBean(MailHandler.class).send(userToAdd.getAddress().getEmail(), subj, message);
}
return contact;
}
use of org.apache.openmeetings.db.entity.user.UserContact in project openmeetings by apache.
the class ContactsHelper method acceptUserContact.
public static Object acceptUserContact(long userContactId) {
UserContactDao dao = get().getBean(UserContactDao.class);
UserContact contact = dao.get(userContactId);
if (contact == null) {
return "error.contact.denied";
}
if (!contact.isPending()) {
return "error.contact.approved";
}
dao.updateContactStatus(userContactId, false);
contact = dao.get(userContactId);
User user = contact.getOwner();
dao.add(user.getId(), getUserId(), false);
if (user.getAddress() != null) {
String message = RequestContactConfirmTemplate.getEmail(contact);
String subj = contact.getContact().getFirstname() + " " + contact.getContact().getLastname() + " " + Application.getString("1198");
get().getBean(PrivateMessageDao.class).addPrivateMessage(subj, message, contact.getContact(), user, user, false, 0L);
get().getBean(MailHandler.class).send(user.getAddress().getEmail(), subj, message);
}
return userContactId;
}
use of org.apache.openmeetings.db.entity.user.UserContact in project openmeetings by apache.
the class TestEmailTemplate method testTemplateGeneration.
@Test
public void testTemplateGeneration() {
User u = new User();
u.setLanguageId(rnd.nextInt(30));
UserContact uc = new UserContact();
uc.setOwner(u);
uc.setContact(new User());
checkTemplate(FeedbackTemplate.getEmail("testuser", "email", "message"));
checkTemplate(InvitationTemplate.getEmail(u, "testuser", "email", "message"));
checkTemplate(RegisterUserTemplate.getEmail("testuser", "email", "message"));
checkTemplate(RequestContactConfirmTemplate.getEmail(uc));
checkTemplate(RequestContactTemplate.getEmail(u, new User()));
checkTemplate(ResetPasswordTemplate.getEmail("link"));
}
use of org.apache.openmeetings.db.entity.user.UserContact in project openmeetings by apache.
the class BackupImport method importContacts.
/*
* ##################### Import User Contacts
*/
private void importContacts(File f) throws Exception {
log.info("Private message folder import complete, starting user contacts import");
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
registry.bind(User.class, new UserConverter(userDao, userMap));
List<UserContact> list = readList(serializer, f, "userContacts.xml", "usercontacts", UserContact.class);
for (UserContact uc : list) {
Long ucId = uc.getId();
UserContact storedUC = userContactDao.get(ucId);
if (storedUC == null && uc.getContact() != null && uc.getContact().getId() != null) {
uc.setId(null);
if (uc.getOwner() != null && uc.getOwner().getId() == null) {
uc.setOwner(null);
}
uc = userContactDao.update(uc);
userContactMap.put(ucId, uc.getId());
}
}
}
Aggregations