Package net.sf.chellow.monad

Examples of net.sf.chellow.monad.UserException


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


    Long participantId = inv.getLong("participant-id");
    Boolean isCore = inv.getBoolean("is-core");
    String name = inv.getString("name");
    Date startDate = inv.getDateTime("start");
    if (!inv.isValid()) {
      throw new UserException(document());
    }
    NonCoreContract contract = NonCoreContract.insertNonCoreContract(null,
        isCore, Participant.getParticipant(participantId), name,
        HhStartDate.roundDown(startDate), null, "", null, "");
    Hiber.commit();
View Full Code Here

    Hiber.setReadWrite();
    String name = inv.getString("name");
    Date startDate = inv.getDate("start");

    if (!inv.isValid()) {
      throw new UserException(document());
    }
    DnoContract contract = dno.insertContract(null, name, new HhStartDate(
        startDate), null, "", null, "");
    Hiber.commit();
    inv.sendSeeOther(contract.getEditUri());
View Full Code Here

  public void httpPost(Invocation inv) throws HttpException {
    Hiber.setReadWrite();
    Date startDate = inv.getDateTime("start");
    if (!inv.isValid()) {
      throw new UserException(document());
    }
    try {
      RateScript rateScript = contract.insertRateScript(null, HhStartDate
          .roundDown(startDate), "");
      Hiber.commit();
View Full Code Here

  public void httpPost(Invocation inv) throws HttpException {
    FileItem fileItem = inv.getFileItem("import-file");
    GeneralImport process;

    if (!inv.isValid()) {
      throw new UserException(document());
    }
    try {
      long processId = processSerial++;
      try {
        String fileName = fileItem.getName();
        int idx = fileName.indexOf(".");
        if (idx == -1) {
          throw new UserException(
              "The file name must contain a '.' character.");
        }
        String extension = fileName.substring(idx + 1);
        if (extension.length() != 3) {
          throw new UserException("The file name extension '" + extension
              + "' must be 3 characters long.");
        }
        process = new GeneralImport(getEditUri().resolve(
            new UriPathElement(Long.toString(processId))).append(
            "/"), fileItem.getInputStream(), extension);
View Full Code Here

      inv.sendSeeOther(Chellow.NON_CORE_SERVICES_INSTANCE.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

      String script) throws HttpException {
    setStartDate(startDate);
    setFinishDate(finishDate);
    if (finishDate != null
        && startDate.getDate().after(finishDate.getDate())) {
      throw new UserException(
          "The start date can't be after the finish date");
    }
    PythonInterpreter interp = new PythonInterpreter();
    try {
      interp.compile(script);
    } catch (Throwable e) {
      throw new UserException(HttpException.getStackTraceString(e));
    }
    setScript(script);
  }
View Full Code Here

    internalUpdate(startDate, finishDate, script);
    if (previousRateScript != null) {
      if (!previousRateScript.getStartDate().getDate()
          .before(startDate.getDate())) {
        throw new UserException(
            "The start date must be after the start date of the previous rate script.");
      }
      previousRateScript.internalUpdate(
          previousRateScript.getStartDate(), startDate.getPrevious(),
          previousRateScript.getScript());
    }
    if (nextRateScript != null) {
      if (finishDate == null) {
        throw new UserException(
            "The finish date must be before the finish date of the next rate script.");
      }
      if (nextRateScript.getFinishDate() != null
          && !finishDate.getDate().before(
              nextRateScript.getFinishDate().getDate())) {
        throw new UserException(
            "The finish date must be before the finish date of the next rate script.");
      }
      nextRateScript.internalUpdate(finishDate.getNext(),
          nextRateScript.getFinishDate(), nextRateScript.getScript());
    }
View Full Code Here

      String script = inv.getString("script");
      Date startDate = inv.getDateTime("start");
      HhStartDate finishDate = null;
      boolean hasFinished = inv.getBoolean("has-finished");
      if (!inv.isValid()) {
        throw new UserException(document());
      }
      script = script.replace("\r", "").replace("\t", "    ");
      if (hasFinished) {
        Date finishDateRaw = inv.getDateTime("finish");
        if (!inv.isValid()) {
          throw new UserException(document());
        }
        finishDate = HhStartDate.roundDown(finishDateRaw);
      }
      try {
        update(HhStartDate.roundDown(startDate), finishDate, script);
View Full Code Here

    Invocable invocableEngine = null;
    try {
      scriptEngine.eval(script);
      invocableEngine = (Invocable) scriptEngine;
    } catch (ScriptException e) {
      throw new UserException(e.getMessage());
    }
    return invocableEngine;
  }
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.