@SuppressWarnings("unchecked")
@Override
public boolean register(String nickname, String email) {
PersistenceManager pm = null;
Contact contact = new Contact(nickname, email, new Date(), true, null);
try {
pm = PMF.get().getPersistenceManager();
String query = "select from " + Contact.class.getName() + " where email == :email";
List<Contact> contactList = (List<Contact>) pm.newQuery(query).execute(email);
if (contactList != null && contactList.size() > 0) {
return false;
}
query = "select from " + Contact.class.getName();
contactList = (List<Contact>) pm.newQuery(query).execute();
contact.setEnable(false);
contact.setStyle("contact_" + contactList.size());
pm.makePersistent(contact);
sendMail(nickname, email);
return true;