use of org.activityinfo.shared.exception.ParseException in project activityinfo by bedatadriven.
the class CreateReportHandler method execute.
@Override
public CommandResult execute(CreateReport cmd, User user) throws CommandException {
// verify that the XML is valid
try {
reportDef = new ReportDefinition();
// TODO should allow null to xml field
String xml = ReportParserJaxb.createXML(cmd.getReport());
reportDef.setXml(xml);
if (cmd.getDatabaseId() != null) {
reportDef.setDatabase(em.getReference(UserDatabase.class, cmd.getDatabaseId()));
}
reportDef.setTitle(cmd.getReport().getTitle());
reportDef.setDescription(cmd.getReport().getDescription());
reportDef.setOwner(user);
reportDef.setVisibility(1);
em.persist(reportDef);
return new CreateResult(reportDef.getId());
} catch (JAXBException e) {
throw new ParseException(e.getMessage());
}
}
Aggregations