]> git.mxchange.org Git - addressbook-mailer-ejb.git/blobdiff - src/java/org/mxchange/jcontacts/contact/AddressbookAdminContactSessionBean.java
Please cherry-pick:
[addressbook-mailer-ejb.git] / src / java / org / mxchange / jcontacts / contact / AddressbookAdminContactSessionBean.java
diff --git a/src/java/org/mxchange/jcontacts/contact/AddressbookAdminContactSessionBean.java b/src/java/org/mxchange/jcontacts/contact/AddressbookAdminContactSessionBean.java
deleted file mode 100644 (file)
index baff654..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2016, 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontacts.contact;
-
-import java.text.MessageFormat;
-import java.util.GregorianCalendar;
-import javax.ejb.Stateless;
-import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
-import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
-
-/**
- * An administrative contact EJB
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "adminContact", description = "An administrative contact EJB")
-public class AddressbookAdminContactSessionBean extends BaseAddressbookDatabaseBean implements AdminContactSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 542_145_347_916L;
-
-       /**
-        * Default constructor
-        */
-       public AddressbookAdminContactSessionBean () {
-               // Call super constructor
-               super();
-       }
-
-       @Override
-       public Contact addContact (final Contact contact) throws ContactAlreadyAddedException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addContact: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
-
-               // Is the instance set?
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() != null) {
-                       // Should be null
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} - is not null", contact.getContactId())); //NOI18N
-               }
-
-               // Set created timestamp
-               contact.setContactCreated(new GregorianCalendar());
-
-               // Set all created timestamps, if instance is there
-               this.setAllContactPhoneEntriesCreated(contact);
-
-               // Persist it
-               this.getEntityManager().persist(contact);
-
-               // Flush it to get contactId set
-               this.getEntityManager().flush();
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addContact: contact.contactId={1} after persisting - EXIT!", this.getClass().getSimpleName(), contact.getContactId())); //NOI18N
-
-               // Return it
-               return contact;
-       }
-
-       @Override
-       public void deleteContactData (final Contact contact) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteContactData: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
-
-               // Is the instance set?
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // Should not be null
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
-               }
-
-               // Merge it to get a managed entity back
-               Contact managedContact = this.getEntityManager().getReference(contact.getClass(), contact.getContactId());
-
-               // Remove it from database
-               this.getEntityManager().remove(managedContact);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteContactData: EXIT!", this.getClass().getSimpleName())); //NOI18N
-       }
-
-}