Package net.sf.chellow.monad

Examples of net.sf.chellow.monad.UserException


    Hiber.setReadWrite();
    String reference = inv.getString("reference");
    String description = inv.getString("description");

    if (!inv.isValid()) {
      throw new UserException(document());
    }
    Document doc = document();
    Batch batch = null;
    try {
      batch = contract.insertBatch(reference, description);
View Full Code Here


public class Mtc extends PersistentEntity {
  static public Mtc getMtc(Dno dno, String code)
      throws HttpException {
    Mtc mtc = findMtc(dno, code);
    if (mtc == null) {
      throw new UserException("There isn't a meter timeswitch with DNO '"
          + (dno == null ? dno : dno.getCode())
          + "' and Meter Timeswitch Code '" + code + "'");
    }
    return mtc;
  }
View Full Code Here

  }

  static public Mtc getMtc(Long id) throws HttpException {
    Mtc mtc = (Mtc) Hiber.session().get(Mtc.class, id);
    if (mtc == null) {
      throw new UserException(
          "There is no meter timeswitch with that id.");
    }
    return mtc;
  }
View Full Code Here

public class DnoContract extends Contract {
  public static DnoContract getDnoContract(Long id) throws HttpException {
    DnoContract contract = findDnoContract(id);
    if (contract == null) {
      throw new UserException("There isn't a DNO contract with that id.");
    }
    return contract;
  }
View Full Code Here

      inv.sendFound(dno.contractsInstance().getEditUri());
    } else {
      String name = inv.getString("name");
      String chargeScript = inv.getString("charge-script");
      if (!inv.isValid()) {
        throw new UserException(document());
      }
      chargeScript = chargeScript.replace("\r", "").replace("\t", "    ");
      try {
        update(name, chargeScript);
      } catch (HttpException e) {
View Full Code Here

    try {
      Hiber.session().save(report);
      Hiber.flush();
    } catch (ConstraintViolationException e) {
      Hiber.rollBack();
      throw new UserException("There's already a report with that name.");
    }
    return report;
  }
View Full Code Here

        }
      }
    }
    boolean isOdd = id % 2 == 1;
    if (isOdd != isCore) {
      throw new UserException(
          "The ids of core reports must be odd, those of user reports must be even. Report id "
              + id
              + ", Is Odd? "
              + isOdd
              + ", is core? "
View Full Code Here

    try {
      PythonInterpreter interp = new PythonInterpreter();
      interp.compile(script);
      setScript(script);
    } catch (Throwable e) {
      throw new UserException(HttpException.getStackTraceString(e));
    }
    if (template != null && template.trim().length() == 0) {
      template = null;
    }
    setTemplate(template);
View Full Code Here

                  + inv.getRequest().getRemoteAddr())
              .toString());

      interp.exec(script);
    } catch (Throwable e) {
      throw new UserException(e.getMessage() + " "
          + HttpException.getStackTraceString(e));
    } finally {
      interp.cleanup();
    }
  }
View Full Code Here

      String name = inv.getString("name");
      String script = inv.getString("script");
      String template = inv.getString("template");

      if (!inv.isValid()) {
        throw new UserException();
      }
      script = script.replace("\r", "").replace("\t", "    ");
      template = template.length() == 0 ? null : template.replace("\r",
          "").replace("\t", "    ");
      Document doc = MonadUtils.newSourceDocument();
      Element source = doc.getDocumentElement();
      Element scriptElement = doc.createElement("script");
      source.appendChild(scriptElement);
      scriptElement.setTextContent(script);
      source.setAttribute("script", script);
      if (template != null) {
        Element templateElement = doc.createElement("template");
        source.appendChild(templateElement);
        templateElement.setTextContent(template);
      }
      if (!inv.isValid()) {
        Element reportElement = toXml(doc);
        source.appendChild(reportElement);
        throw new UserException(doc);
      }
      try {
        update(name, script, template);
      } catch (UserException e) {
        e.setDocument(doc);
View Full Code Here

TOP

Related Classes of net.sf.chellow.monad.UserException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.