/**
* Administrative user bean
*/
- @EJB
+ @EJB (lookup = "java:global/pizzaservice-ejb/adminUser!org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote")
private AdminUserSessionBeanRemote adminUserBean;
/**
* Regular user EJB
*/
- @EJB
+ @EJB (lookup = "java:global/pizzaservice-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
private UserSessionBeanRemote userBean;
/**
return confirmationKey;
}
- @Override
- public boolean isEmailAddressRegistered (final User user) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
-
- // Check bean
- assert (this.userBean instanceof UserSessionBeanRemote) : "this.userBean is not set"; //NOI18N
-
- // user should not be null
- if (null == user) {
- // Abort here
- throw new NullPointerException("user is null"); //NOI18N
- }
-
- // Call other bean
- return this.userBean.isEmailAddressRegistered(user);
- }
-
- @Override
- public boolean isUserNameRegistered (final User user) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isUserNameRegistered: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
-
- // Check bean
- assert (this.userBean instanceof UserSessionBeanRemote) : "this.userBean is not set"; //NOI18N
-
- // user should not be null
- if (null == user) {
- // Abort here
- throw new NullPointerException("user is null"); //NOI18N
- }
-
- // Call other bean
- return this.userBean.isUserNameRegistered(user);
- }
-
@Override
public User registerUser (final User user, final String baseUrl, final String randomPassword) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException {
// Trace message
}
// Check if user is registered
- if (this.isUserNameRegistered(user)) {
+ if (this.userBean.isUserNameRegistered(user)) {
// Abort here
throw new UserNameAlreadyRegisteredException(user);
- } else if (this.isEmailAddressRegistered(user)) {
+ } else if (this.userBean.isEmailAddressRegistered(user)) {
// Abort here
throw new EmailAddressAlreadyRegisteredException(user);
}
super(factoryJndi, queueJndi);
}
+ /**
+ * Get back a managed instance from given contact
+ * <p>
+ * @param contact Unmanaged/detached contact instance
+ * <p>
+ * @return Managed contact instance
+ */
+ protected Contact createManaged (final Contact contact) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
+
+ // user should not be null
+ if (null == contact) {
+ // Abort here
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Id is set
+ throw new NullPointerException("contact.contactId is null"); //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Id is set
+ throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is null", contact.getContactId())); //NOI18N
+ }
+
+ // Try to find it (should be there)
+ final Contact managedContact = this.getEntityManager().find(UserContact.class, contact.getContactId());
+
+ // Should be there
+ assert (managedContact instanceof Contact) : "managedContact is null"; //NOI18N
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
+
+ // Return it
+ return managedContact;
+ }
+
+ /**
+ * Get back a managed instance from given country
+ * <p>
+ * @param country Unmanaged/detached country instance
+ * <p>
+ * @return Managed country instance
+ */
+ protected Country createManaged (final Country country) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: country={1} - CALLED!", this.getClass().getSimpleName(), country)); //NOI18N
+
+ // user should not be null
+ if (null == country) {
+ // Abort here
+ throw new NullPointerException("country is null"); //NOI18N
+ } else if (country.getCountryId() == null) {
+ // Id is set
+ throw new NullPointerException("country.countryId is null"); //NOI18N
+ } else if (country.getCountryId() < 1) {
+ // Id is set
+ throw new IllegalArgumentException(MessageFormat.format("country.countryId={0} is null", country.getCountryId())); //NOI18N
+ }
+
+ // Try to find it (should be there)
+ final Country managedCountry = this.getEntityManager().find(CountryData.class, country.getCountryId());
+
+ // Should be there
+ assert (managedCountry instanceof Country) : "managedCountry is null"; //NOI18N
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedCountry={1} - EXIT!", this.getClass().getSimpleName(), managedCountry)); //NOI18N
+
+ // Return it
+ return managedCountry;
+ }
+
+ /**
+ * Get back a managed instance from given basic data
+ * <p>
+ * @param basicData Unmanaged/detached basic data instance
+ * <p>
+ * @return Managed basic data instance
+ */
+ protected BusinessBasicData createManaged (final BusinessBasicData basicData) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: basicData={1} - CALLED!", this.getClass().getSimpleName(), basicData)); //NOI18N
+
+ // user should not be null
+ if (null == basicData) {
+ // Abort here
+ throw new NullPointerException("basicData is null"); //NOI18N
+ } else if (basicData.getBasicDataId() == null) {
+ // Id is set
+ throw new NullPointerException("basicData.basicDataId is null"); //NOI18N
+ } else if (basicData.getBasicDataId() < 1) {
+ // Id is set
+ throw new IllegalArgumentException(MessageFormat.format("basicData.basicDataId={0} is null", basicData.getBasicDataId())); //NOI18N
+ }
+
+ // Try to find it (should be there)
+ final BusinessBasicData managedBasicData = this.getEntityManager().find(CompanyBasicData.class, basicData.getBasicDataId());
+
+ // Should be there
+ assert (managedBasicData instanceof BusinessBasicData) : "managedBasicData is null"; //NOI18N
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedBasicData={1} - EXIT!", this.getClass().getSimpleName(), managedBasicData)); //NOI18N
+
+ // Return it
+ return managedBasicData;
+ }
+
+ /**
+ * Get back a managed instance from given employee
+ * <p>
+ * @param employee Unmanaged/detached employee instance
+ * <p>
+ * @return Managed employee instance
+ */
+ protected Employee createManaged (final Employee employee) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: employee={1} - CALLED!", this.getClass().getSimpleName(), employee)); //NOI18N
+
+ // user should not be null
+ if (null == employee) {
+ // Abort here
+ throw new NullPointerException("employee is null"); //NOI18N
+ } else if (employee.getEmployeeId() == null) {
+ // Id is set
+ throw new NullPointerException("employee.employeeId is null"); //NOI18N
+ } else if (employee.getEmployeeId() < 1) {
+ // Id is set
+ throw new IllegalArgumentException(MessageFormat.format("employee.employeeId={0} is null", employee.getEmployeeId())); //NOI18N
+ }
+
+ // Try to find it (should be there)
+ final Employee managedEmployee = this.getEntityManager().find(CompanyEmployee.class, employee.getEmployeeId());
+
+ // Should be there
+ assert (managedEmployee instanceof Employee) : "managedEmployee is null"; //NOI18N
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedEmployee={1} - EXIT!", this.getClass().getSimpleName(), managedEmployee)); //NOI18N
+
+ // Return it
+ return managedEmployee;
+ }
+
+ /**
+ * Get back a managed instance from given user
+ * <p>
+ * @param user Unmanaged/detached user instance
+ * <p>
+ * @return Managed user instance
+ */
+ protected User createManaged (final User user) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: 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) {
+ // Id is set
+ throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is null", 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#
+ }
+
+ // Try to find it (should be there)
+ final User managedUser = this.getEntityManager().find(LoginUser.class, user.getUserId());
+
+ // Should be there
+ assert (managedUser instanceof User) : "managedUser is null"; //NOI18N
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedUser={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N
+
+ // Return it
+ return managedUser;
+ }
+
/**
* Updates all contact's phone entry's created timestamps
* <p>