import java.util.GregorianCalendar;
import javax.ejb.Stateless;
import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
+import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
/**
*/
private static final long serialVersionUID = 18_597_165_817_401_853L;
+ @Override
+ public void deleteFaxData (final DialableFaxNumber faxNumber) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: faxNumber={1} - CALLED!", this.getClass().getSimpleName(), faxNumber));
+
+ // Is all data set
+ if (null == faxNumber) {
+ // Not set, throw NPE
+ throw new NullPointerException("faxNumber is null"); //NOI18N
+ } else if (faxNumber.getPhoneId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N
+ } else if (faxNumber.getPhoneId() < 1) {
+ // Invalid number
+ throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid", faxNumber.getPhoneId())); //NOI18N
+ } else if (faxNumber.getPhoneCountry()== null) {
+ // Throw NPE
+ throw new NullPointerException("faxNumber.phoneCountry is null"); //NOI18N
+ } else if (faxNumber.getPhoneCountry().getCountryId()== null) {
+ // ... throw again
+ throw new NullPointerException("faxNumber.phoneCountry.countryId is null"); //NOI18N
+ } else if (faxNumber.getPhoneCountry().getCountryId() < 1) {
+ // Id not valid
+ throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneCountry.countryId={0} is not valid.", faxNumber.getPhoneCountry().getCountryId())); //NOI18N
+ } else if (faxNumber.getPhoneNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("faxNumber.phoneNumber is null"); //NOI18N
+ } else if (faxNumber.getPhoneNumber() < 1) {
+ // Throw NPE again
+ throw new NullPointerException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid.", faxNumber.getPhoneNumber())); //NOI18N
+ }
+
+ // Merge it to get a managed entity back
+ DialableFaxNumber managedNumber = this.getEntityManager().getReference(faxNumber.getClass(), faxNumber.getPhoneId());
+
+ // Remove it from database
+ this.getEntityManager().remove(managedNumber);
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: EXIT!", this.getClass().getSimpleName()));
+ }
+
+ @Override
+ public void deleteLandLineData (final DialableLandLineNumber landLineNumber) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: landLineNumber={1} - CALLED!", this.getClass().getSimpleName(), landLineNumber));
+
+ // Is all data set
+ if (null == landLineNumber) {
+ // Not set, throw NPE
+ throw new NullPointerException("landLineNumber is null"); //NOI18N
+ } else if (landLineNumber.getPhoneId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
+ } else if (landLineNumber.getPhoneId() < 1) {
+ // Invalid number
+ throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", landLineNumber.getPhoneId())); //NOI18N
+ } else if (landLineNumber.getPhoneCountry()== null) {
+ // Throw NPE
+ throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18N
+ } else if (landLineNumber.getPhoneCountry().getCountryId()== null) {
+ // ... throw again
+ throw new NullPointerException("landLineNumber.phoneCountry.countryId is null"); //NOI18N
+ } else if (landLineNumber.getPhoneCountry().getCountryId() < 1) {
+ // Id not valid
+ throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneCountry.countryId={0} is not valid.", landLineNumber.getPhoneCountry().getCountryId())); //NOI18N
+ } else if (landLineNumber.getPhoneNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18N
+ } else if (landLineNumber.getPhoneNumber() < 1) {
+ // Throw NPE again
+ throw new NullPointerException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid.", landLineNumber.getPhoneNumber())); //NOI18N
+ }
+
+ // Merge it to get a managed entity back
+ DialableLandLineNumber managedNumber = this.getEntityManager().getReference(landLineNumber.getClass(), landLineNumber.getPhoneId());
+
+ // Remove it from database
+ this.getEntityManager().remove(managedNumber);
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: EXIT!", this.getClass().getSimpleName()));
+ }
+
@Override
public void deleteMobileData (final DialableMobileNumber mobileNumber) {
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: EXIT!", this.getClass().getSimpleName()));
}
+ @Override
+ public DialableFaxNumber updateFaxData (DialableFaxNumber faxNumber) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public DialableLandLineNumber updateLandLineData (DialableLandLineNumber landLineNumber) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
@Override
public DialableMobileNumber updateMobileData (final DialableMobileNumber mobileNumber) {
// Trace message
return user;
}
+ @Override
+ public void deleteUser (final User user, final String userDeleteReason) throws UserNotFoundException {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteUser: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
+
+ // user should not be null
+ if (null == user) {
+ // Abort here
+ throw new NullPointerException("user is null"); //NOI18N
+ } else if (user.getUserId() == null) {
+ // Id is set
+ throw new NullPointerException("user.userId is null"); //NOI18N
+ } else if (user.getUserId() < 1) {
+ // Not valid id number
+ throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
+ } else if (user.getUserContact() == null) {
+ // Throw NPE again
+ throw new NullPointerException("user.userContact is null"); //NOI18N
+ } else if (user.getUserContact().getContactId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("user.userContact.contactId is null"); //NOI18N
+ } else if (user.getUserContact().getContactId() < 1) {
+ // Not valid id number
+ throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is not valid", user.getUserContact().getContactId())); //NOI18N
+ } else if (user.getUserAccountStatus() == null) {
+ // Throw NPE again
+ throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
+ } else if (!this.userBean.ifUserExists(user)) {
+ // Name already found
+ throw new UserNotFoundException(user);
+ }
+
+ // Get a managed instance
+ User managedUser = this.getManagedUser(user);
+
+ // Should be found!
+ assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
+
+ // Delete it
+ this.getEntityManager().remove(managedUser);
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteUser: EXIT!", this.getClass().getSimpleName())); //NOI18N
+ }
+
@Override
public User linkUser (final User user) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException {
// Trace message
}
@Override
- public PasswordHistory updateUserPassword (final User user) throws UserNotFoundException, UserStatusUnconfirmedException, UserStatusLockedException {
+ public PasswordHistory updateUserPassword (final User user, final String baseUrl) throws UserNotFoundException, UserStatusUnconfirmedException, UserStatusLockedException {
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: user={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), user, baseUrl)); //NOI18N
// user should not be null
if (null == user) {
} else if (!this.ifUserExists(user)) {
// User does not exist
throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
+ } else if (null == baseUrl) {
+ // Abort here
+ throw new NullPointerException("password is null"); //NOI18N
+ } else if (baseUrl.isEmpty()) {
+ // Abort here
+ throw new IllegalArgumentException("password is empty"); //NOI18N
}
// Call other method