use of org.jaffa.exceptions.ApplicationException in project jaffa-framework by jaffa-projects.
the class UserRequestMaintenanceTx method create.
// .//GEN-END:_prevalidateCreate_1_be
// .//GEN-BEGIN:_create_1_be
/**
* Persists a new instance of UserRequest.
* @param input The new values for the domain object.
* @throws ApplicationExceptions This will be thrown if the input contains invalid data.
* @throws FrameworkException Indicates some system error.
* @return The object details.
*/
public UserRequestMaintenanceRetrieveOutDto create(UserRequestMaintenanceCreateInDto input) throws FrameworkException, ApplicationExceptions {
UOW uow = null;
try {
// Print Debug Information for the input
if (log.isDebugEnabled())
log.debug("Input: " + (input != null ? input.toString() : null));
// create the UOW
uow = new UOW();
// Preprocess the input
preprocess(uow, input);
// Do not allow a Duplicate record
duplicateCheck(uow, input);
// Validate the foreign objects
validateForeignObjects(uow, input);
// Create the domain object
UserRequest domain = createDomain(uow, input, false);
uow.add(domain);
// Perform post create processing
postCreate(uow, input, domain, false);
// Commit the changes
uow.commit();
// Print Debug Information for the output
if (log.isDebugEnabled())
log.debug("Successfully created the domain object. Now retrieving the object details.");
// Build the outbound dto by performing a retrieve
UserRequestMaintenanceRetrieveInDto retrieveInDto = new UserRequestMaintenanceRetrieveInDto();
retrieveInDto.setHeaderDto(input.getHeaderDto());
retrieveInDto.setRequestId(input.getRequestId());
UserRequestMaintenanceRetrieveOutDto output = retrieve(retrieveInDto);
return output;
} catch (FrameworkException e) {
// If it is, then re-throw as ApplicationsExceptions, else throw the FrameworkException.
if (e.getCause() != null && e.getCause() instanceof ApplicationExceptions) {
throw (ApplicationExceptions) e.getCause();
} else if (e.getCause() != null && e.getCause() instanceof ApplicationException) {
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add((ApplicationException) e.getCause());
throw appExps;
} else
throw e;
} finally {
if (uow != null)
uow.rollback();
}
}
use of org.jaffa.exceptions.ApplicationException in project jaffa-framework by jaffa-projects.
the class FormData method renderTemplate.
public String[] renderTemplate() throws ApplicationExceptions {
if (m_velocityTemplate != null && m_velocityTemplate.length() > 0 && !m_velocityTemplate.startsWith("???")) {
try {
VelocityTemplateHelper vth = new VelocityTemplateHelper();
vth.setDataSource(this);
vth.setTemplate(m_velocityTemplate);
return (vth.renderTemplateLines());
} catch (FormPrintException fpe) {
fpe.printStackTrace();
throw new ApplicationExceptions(new ApplicationException("exception.org.jaffa.modules.printing.services.FormData.VelocityTemplateError") {
});
}
} else {
return (null);
}
}
use of org.jaffa.exceptions.ApplicationException in project jaffa-framework by jaffa-projects.
the class FormDelivery method sendToPrinter.
/**
* Send the generated document to the specified printer
* @param printerId Printer name, should be defined in PrinterDefinitions
* @param copies Number of copies to print
* @param document Source file to print
* @throws ApplicationExceptions Thrown if any funtional issue ocurred when executing
* @throws FrameworkException Thrown if any framework issue ocurred when executing
*/
public static void sendToPrinter(String printerId, int copies, File document) throws FrameworkException, ApplicationExceptions {
UOW uow = new UOW();
try {
// Read the printer definition
PrinterDefinition printer = PrinterDefinition.findByPK(uow, printerId);
if (printer == null) {
log.error("Unknown printer in print request : " + printerId);
throw new ApplicationExceptions(new DomainObjectNotFoundException(PrinterDefinitionMeta.getLabelToken()));
}
PrinterOutputType outputType = printer.getPrinterOutputTypeObject();
// See if this is direct printing
if (Boolean.TRUE.equals(outputType.getDirectPrinting())) {
printDirect(printer, document, copies);
} else {
// Find an external command line that will print this document
String commandLine = null;
String os = System.getProperty("os.name");
for (OutputCommand command : outputType.getOutputCommandArray()) {
if (Pattern.matches(command.getOsPattern(), os)) {
commandLine = command.getCommandLine();
break;
}
}
if (commandLine == null) {
log.error("Can't find matching command line for Output Type " + outputType.getOutputType() + " on OS " + os);
throw new ApplicationExceptions(new DomainObjectNotFoundException(OutputCommandMeta.getLabelToken()));
}
// Now try and print the document with the command
printViaCommand(printer, document, copies, commandLine);
}
} catch (ApplicationException e) {
ApplicationExceptions aes = new ApplicationExceptions();
aes.add(e);
throw aes;
} finally {
if (uow != null)
// This UOW should have not been used for updates!!!
uow.rollback();
}
}
use of org.jaffa.exceptions.ApplicationException in project jaffa-framework by jaffa-projects.
the class FormTemplateMaintenanceTx method prevalidateUpdate.
// .//GEN-END:_retrieve_1_be
// .//GEN-BEGIN:_prevalidateUpdate_1_be
/**
* This method is used to perform prevalidations before updating an existing instance of FormTemplate.
* @param input The new values for the domain object.
* @throws ApplicationExceptions This will be thrown if the input contains invalid data.
* @throws FrameworkException Indicates some system error.
* @return The object details.
*/
public FormTemplateMaintenancePrevalidateOutDto prevalidateUpdate(FormTemplateMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
UOW uow = null;
try {
// Print Debug Information for the input
if (log.isDebugEnabled())
log.debug("Input: " + (input != null ? input.toString() : null));
// create the UOW
uow = new UOW();
// Preprocess the input
preprocess(uow, input);
// Retrieve the object
FormTemplate domain = load(uow, input);
// Validate the foreign objects
validateForeignObjects(uow, input);
// Update the domain object
updateDomain(uow, input, domain, true);
// Build the outbound dto
FormTemplateMaintenancePrevalidateOutDto output = createPrevalidateOutDto(uow, domain, input);
// Print Debug Information for the output
if (log.isDebugEnabled())
log.debug("Output: " + (output != null ? output.toString() : null));
return output;
} catch (FrameworkException e) {
// If it is, then re-throw as ApplicationsExceptions, else throw the FrameworkException.
if (e.getCause() != null && e.getCause() instanceof ApplicationExceptions) {
throw (ApplicationExceptions) e.getCause();
} else if (e.getCause() != null && e.getCause() instanceof ApplicationException) {
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add((ApplicationException) e.getCause());
throw appExps;
} else
throw e;
} finally {
if (uow != null)
uow.rollback();
}
}
use of org.jaffa.exceptions.ApplicationException in project jaffa-framework by jaffa-projects.
the class FormTemplateMaintenanceTx method update.
// .//GEN-END:_prevalidateUpdate_1_be
// .//GEN-BEGIN:_update_1_be
/**
* Updates an existing instance of FormTemplate.
* @param input The new values for the domain object.
* @throws ApplicationExceptions This will be thrown if the input contains invalid data.
* @throws FrameworkException Indicates some system error.
* @return The object details.
*/
public FormTemplateMaintenanceRetrieveOutDto update(FormTemplateMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
UOW uow = null;
try {
// Print Debug Information for the input
if (log.isDebugEnabled())
log.debug("Input: " + (input != null ? input.toString() : null));
// create the UOW
uow = new UOW();
// Preprocess the input
preprocess(uow, input);
// Retrieve the object
FormTemplate domain = load(uow, input);
// Validate the foreign objects
validateForeignObjects(uow, input);
// Update the domain object
updateDomain(uow, input, domain, false);
uow.update(domain);
// Commit the changes
uow.commit();
// Print Debug Information for the output
if (log.isDebugEnabled())
log.debug("Successfully updated the domain object. Now retrieving the object details.");
// Build the outbound dto by performing a retrieve
FormTemplateMaintenanceRetrieveInDto retrieveInDto = new FormTemplateMaintenanceRetrieveInDto();
retrieveInDto.setHeaderDto(input.getHeaderDto());
retrieveInDto.setFormId(input.getFormId());
FormTemplateMaintenanceRetrieveOutDto output = retrieve(retrieveInDto);
return output;
} catch (FrameworkException e) {
// If it is, then re-throw as ApplicationsExceptions, else throw the FrameworkException.
if (e.getCause() != null && e.getCause() instanceof ApplicationExceptions) {
throw (ApplicationExceptions) e.getCause();
} else if (e.getCause() != null && e.getCause() instanceof ApplicationException) {
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add((ApplicationException) e.getCause());
throw appExps;
} else
throw e;
} finally {
if (uow != null)
uow.rollback();
}
}
Aggregations