Search in sources :

Example 1 with ParseException

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());
    }
}
Also used : CreateResult(org.activityinfo.shared.command.result.CreateResult) JAXBException(javax.xml.bind.JAXBException) UserDatabase(org.activityinfo.server.database.hibernate.entity.UserDatabase) ParseException(org.activityinfo.shared.exception.ParseException) ReportDefinition(org.activityinfo.server.database.hibernate.entity.ReportDefinition)

Aggregations

JAXBException (javax.xml.bind.JAXBException)1 ReportDefinition (org.activityinfo.server.database.hibernate.entity.ReportDefinition)1 UserDatabase (org.activityinfo.server.database.hibernate.entity.UserDatabase)1 CreateResult (org.activityinfo.shared.command.result.CreateResult)1 ParseException (org.activityinfo.shared.exception.ParseException)1