CustomerServiceBase.java
// license-header java merge-point
//
// Attention: Generated code! Do not modify by hand!
// Generated by SpringServiceBase.vsl in andromda-spring-cartridge on 08/18/2014 15:29:44-0400. Do not modify by hand!.
//
/**
* TEMPLATE: SpringServiceBase.vsl in andromda-spring cartridge
* MODEL CLASS: org::andromda::samples::carrental::customers::CustomerService
* STEREOTYPE: Service
*/
package org.andromda.samples.carrental.customers;
import java.security.Principal;
import java.util.Collection;
import java.util.Locale;
import org.andromda.samples.carrental.BeanLocator;
import org.andromda.samples.carrental.PrincipalStore;
import org.springframework.context.MessageSource;
/**
* <p>
* Spring Service base class for <code>CustomerService</code>,
* provides access to all services and entities referenced by this service.
* </p>
*
* @see CustomerService
*/
public abstract class CustomerServiceBase
implements CustomerService
{
private CustomerDao customerDao;
/**
* Sets the reference to <code>customer</code>'s DAO.
* @param customerDaoIn
*/
public void setCustomerDao(CustomerDao customerDaoIn)
{
this.customerDao = customerDaoIn;
}
/**
* Gets the reference to <code>customer</code>'s DAO.
* @return customerDao
*/
protected CustomerDao getCustomerDao()
{
return this.customerDao;
}
private DriverDao driverDao;
/**
* Sets the reference to <code>driver</code>'s DAO.
* @param driverDaoIn
*/
public void setDriverDao(DriverDao driverDaoIn)
{
this.driverDao = driverDaoIn;
}
/**
* Gets the reference to <code>driver</code>'s DAO.
* @return driverDao
*/
protected DriverDao getDriverDao()
{
return this.driverDao;
}
/**
* {@inheritDoc}
*/
@Override
public String createCustomer(final String name, final String customerNo, final String password)
throws CustomerException
{
if (name == null || name.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.customers.CustomerService.createCustomer(String name, String customerNo, String password) - 'name' can not be null or empty");
}
if (customerNo == null || customerNo.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.customers.CustomerService.createCustomer(String name, String customerNo, String password) - 'customerNo' can not be null or empty");
}
if (password == null || password.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.customers.CustomerService.createCustomer(String name, String customerNo, String password) - 'password' can not be null or empty");
}
try
{
return this.handleCreateCustomer(name, customerNo, password);
}
catch (CustomerException ex)
{
throw ex;
}
catch (Throwable th)
{
throw new CustomerServiceException(
"Error performing 'CustomerService.createCustomer(String name, String customerNo, String password)' --> " + th,
th);
}
}
/**
* Performs the core logic for {@link #createCustomer(String, String, String)}
* @param name String <p>
TODO: Model Documentation for name
</p>
* @param customerNo String <p>
TODO: Model Documentation for customerNo
</p>
* @param password String <p>
TODO: Model Documentation for password
</p>
* @return String
* @throws Exception
*/
protected abstract String handleCreateCustomer(String name, String customerNo, String password)
throws Exception;
/**
* {@inheritDoc}
*/
@Override
public String addDriver(final String customerId, final DriverData driverData)
throws CustomerException
{
if (customerId == null || customerId.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.customers.CustomerService.addDriver(String customerId, DriverData driverData) - 'customerId' can not be null or empty");
}
if (driverData == null)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.customers.CustomerService.addDriver(String customerId, DriverData driverData) - 'driverData' can not be null");
}
if (driverData.getName() == null || driverData.getName().trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.customers.CustomerService.addDriver(String customerId, DriverData driverData) - 'driverData.name' can not be null or empty");
}
if (driverData.getSurname() == null || driverData.getSurname().trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.customers.CustomerService.addDriver(String customerId, DriverData driverData) - 'driverData.surname' can not be null or empty");
}
if (driverData.getBirthDate() == null)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.customers.CustomerService.addDriver(String customerId, DriverData driverData) - 'driverData.birthDate' can not be null");
}
if (driverData.getLicenseNo() == null || driverData.getLicenseNo().trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.customers.CustomerService.addDriver(String customerId, DriverData driverData) - 'driverData.licenseNo' can not be null or empty");
}
if (driverData.getLicenseIssuedBy() == null || driverData.getLicenseIssuedBy().trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.customers.CustomerService.addDriver(String customerId, DriverData driverData) - 'driverData.licenseIssuedBy' can not be null or empty");
}
try
{
return this.handleAddDriver(customerId, driverData);
}
catch (CustomerException ex)
{
throw ex;
}
catch (Throwable th)
{
throw new CustomerServiceException(
"Error performing 'CustomerService.addDriver(String customerId, DriverData driverData)' --> " + th,
th);
}
}
/**
* Performs the core logic for {@link #addDriver(String, DriverData)}
* @param customerId String <p>
TODO: Model Documentation for customerId
</p>
* @param driverData DriverData <p>
TODO: Model Documentation for driverData
</p>
* @return String
* @throws Exception
*/
protected abstract String handleAddDriver(String customerId, DriverData driverData)
throws Exception;
/**
* {@inheritDoc}
*/
@Override
public Collection searchAllCustomers()
throws CustomerException
{
try
{
return this.handleSearchAllCustomers();
}
catch (CustomerException ex)
{
throw ex;
}
catch (Throwable th)
{
throw new CustomerServiceException(
"Error performing 'CustomerService.searchAllCustomers()' --> " + th,
th);
}
}
/**
* Performs the core logic for {@link #searchAllCustomers()}
* @return Collection
* @throws Exception
*/
protected abstract Collection handleSearchAllCustomers()
throws Exception;
/**
* {@inheritDoc}
*/
@Override
public String authenticateAsCustomer(final String customerNo, final String password)
throws CustomerException
{
if (customerNo == null || customerNo.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.customers.CustomerService.authenticateAsCustomer(String customerNo, String password) - 'customerNo' can not be null or empty");
}
if (password == null || password.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.customers.CustomerService.authenticateAsCustomer(String customerNo, String password) - 'password' can not be null or empty");
}
try
{
return this.handleAuthenticateAsCustomer(customerNo, password);
}
catch (CustomerException ex)
{
throw ex;
}
catch (Throwable th)
{
throw new CustomerServiceException(
"Error performing 'CustomerService.authenticateAsCustomer(String customerNo, String password)' --> " + th,
th);
}
}
/**
* Performs the core logic for {@link #authenticateAsCustomer(String, String)}
* @param customerNo String <p>
TODO: Model Documentation for customerNo
</p>
* @param password String <p>
TODO: Model Documentation for password
</p>
* @return String
* @throws Exception
*/
protected abstract String handleAuthenticateAsCustomer(String customerNo, String password)
throws Exception;
/**
* Gets the current <code>principal</code> if one has been set,
* otherwise returns <code>null</code>.
*
* @return the current principal
*/
protected Principal getPrincipal()
{
return PrincipalStore.get();
}
/**
* Gets the message source available to this service.
* @return MessageSource
*/
protected MessageSource getMessages()
{
return (MessageSource)
BeanLocator.instance().getBean("messageSource");
}
/**
* Gets the message having the given <code>key</code> in the underlying message bundle.
*
* @param key the key of the message in the messages.properties message bundle.
* @return String
*/
protected String getMessage(final String key)
{
return this.getMessages().getMessage(key, null, null);
}
/**
* Gets the message having the given <code>key</code> and <code>arguments</code> in the
* underlying message bundle.
*
* @param key the key of the message in the messages.properties message bundle.
* @param arguments any arguments to substitute when resolving the message.
* @return String
*/
protected String getMessage(final String key, final Object[] arguments)
{
return this.getMessages().getMessage(key, arguments, null);
}
/**
* Gets the message having the given <code>key</code> using the given <code>arguments</code>
* for the given <code>locale</code>.
*
* @param key the key of the message in the messages.properties message bundle.
* @param arguments any arguments to substitute when resolving the message.
* @param locale the locale of the messages to retrieve.
* @return String
*/
protected String getMessage(
final String key, final Object[] arguments,
final Locale locale)
{
return this.getMessages().getMessage(key, arguments, locale);
}
// spring-service-base merge-point
}