AdminServiceBase.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::admins::AdminService
* STEREOTYPE: Service
*/
package org.andromda.samples.carrental.admins;
import java.security.Principal;
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>AdminService</code>,
* provides access to all services and entities referenced by this service.
* </p>
*
* @see AdminService
*/
public abstract class AdminServiceBase
implements AdminService
{
private AdministratorDao administratorDao;
/**
* Sets the reference to <code>administrator</code>'s DAO.
* @param administratorDaoIn
*/
public void setAdministratorDao(AdministratorDao administratorDaoIn)
{
this.administratorDao = administratorDaoIn;
}
/**
* Gets the reference to <code>administrator</code>'s DAO.
* @return administratorDao
*/
protected AdministratorDao getAdministratorDao()
{
return this.administratorDao;
}
/**
* {@inheritDoc}
*/
@Override
public String authenticateAsAdministrator(final String name, final String accountNo, final String password)
throws AdminException
{
if (name == null || name.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.admins.AdminService.authenticateAsAdministrator(String name, String accountNo, String password) - 'name' can not be null or empty");
}
if (accountNo == null || accountNo.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.admins.AdminService.authenticateAsAdministrator(String name, String accountNo, String password) - 'accountNo' can not be null or empty");
}
if (password == null || password.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.admins.AdminService.authenticateAsAdministrator(String name, String accountNo, String password) - 'password' can not be null or empty");
}
try
{
return this.handleAuthenticateAsAdministrator(name, accountNo, password);
}
catch (AdminException ex)
{
throw ex;
}
catch (Throwable th)
{
throw new AdminServiceException(
"Error performing 'AdminService.authenticateAsAdministrator(String name, String accountNo, String password)' --> " + th,
th);
}
}
/**
* Performs the core logic for {@link #authenticateAsAdministrator(String, String, String)}
* @param name String <p>
TODO: Model Documentation for name
</p>
* @param accountNo String <p>
TODO: Model Documentation for accountNo
</p>
* @param password String <p>
TODO: Model Documentation for password
</p>
* @return String
* @throws Exception
*/
protected abstract String handleAuthenticateAsAdministrator(String name, String accountNo, String password)
throws Exception;
/**
* {@inheritDoc}
*/
@Override
public String createAdministrator(final String name, final String accountNo, final String password)
throws AdminException
{
if (name == null || name.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.admins.AdminService.createAdministrator(String name, String accountNo, String password) - 'name' can not be null or empty");
}
if (accountNo == null || accountNo.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.admins.AdminService.createAdministrator(String name, String accountNo, String password) - 'accountNo' can not be null or empty");
}
if (password == null || password.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.admins.AdminService.createAdministrator(String name, String accountNo, String password) - 'password' can not be null or empty");
}
try
{
return this.handleCreateAdministrator(name, accountNo, password);
}
catch (AdminException ex)
{
throw ex;
}
catch (Throwable th)
{
throw new AdminServiceException(
"Error performing 'AdminService.createAdministrator(String name, String accountNo, String password)' --> " + th,
th);
}
}
/**
* Performs the core logic for {@link #createAdministrator(String, String, String)}
* @param name String <p>
TODO: Model Documentation for name
</p>
* @param accountNo String <p>
TODO: Model Documentation for accountNo
</p>
* @param password String <p>
TODO: Model Documentation for password
</p>
* @return String
* @throws Exception
*/
protected abstract String handleCreateAdministrator(String name, String accountNo, 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
}