Package net.sf.chellow.monad

Examples of net.sf.chellow.monad.UserException


  }

  public void httpPost(Invocation inv) throws HttpException {
    FileItem fileItem = inv.getFileItem("file");
    if (!inv.isValid()) {
      throw new UserException(document());
    }
    try {
      BillImport importare = new BillImport(batch.getId(),
          processSerial++, fileItem);
      importare.start();
View Full Code Here


        Exception nextException = sqle.getNextException();
        if (nextException != null) {
          String message = nextException.getMessage();
          if (message != null
              && message.contains("user_email_address_key")) {
            throw new UserException(
                "There is already a user with this email address.");
          } else {
            throw e;
          }
        } else {
View Full Code Here

      String passwordDigest, UserRole role, Party party)
      throws HttpException {
    setEmailAddress(emailAddress);
    if (password == null) {
      if (passwordDigest == null) {
        throw new UserException(
            "There must be either a password or a password digest.");
      }
    } else {
      if (passwordDigest == null) {
        passwordDigest = digest(password);
      } else {
        throw new UserException(
            "There can't be both a password and password digest.");
      }
    }
    setPasswordDigest(passwordDigest);
    setRole(role);
    if (role.getCode().equals(UserRole.PARTY_VIEWER)) {
      if (party == null) {
        throw new UserException(
            "There must be a party if the role is party-viewer.");
      }
      setParty(party);
    } else {
      setParty(null);
View Full Code Here

      String currentPassword = inv.getString("current-password");
      String newPassword = inv.getString("new-password");
      String confirmNewPassword = inv.getString("confirm-new-password");

      if (!inv.isValid()) {
        throw new UserException(document());
      }
      if (!getPasswordDigest().equals(digest(currentPassword))) {
        throw new UserException("The current password is incorrect.");
      }
      if (!newPassword.equals(confirmNewPassword)) {
        throw new UserException("The new passwords aren't the same.");
      }
      if (newPassword.length() < 6) {
        throw new UserException(
            "The password must be at least 6 characters long.");
      }
      setPasswordDigest(digest(newPassword));
      Hiber.commit();
      inv.sendOk(document("New password set successfully."));
    } else {
      EmailAddress emailAddress = inv.getEmailAddress("email-address");
      Long userRoleId = inv.getLong("user-role-id");
      UserRole userRole = UserRole.getUserRole(userRoleId);
      if (!inv.isValid()) {
        throw new UserException(document());
      }
      Party party = null;
      if (userRole.getCode().equals(UserRole.PARTY_VIEWER)) {
        Long partyId = inv.getLong("party-id");
View Full Code Here

    }
    if (inv.hasParameter("year")) {
      int year = inv.getInteger("year");
      int month = inv.getInteger("month");
      if (!inv.isValid()) {
        throw new UserException(doc);
      }
      cal.set(Calendar.YEAR, year);
      cal.set(Calendar.MONTH, month - 1);
    } else {
      cal.setTime(defaultDate.getDate());
    }
    cal.set(Calendar.DAY_OF_MONTH, 1);
    cal.set(Calendar.HOUR, 0);
    cal.set(Calendar.MINUTE, 30);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    Date startDate;
    try {
      startDate = cal.getTime();
    } catch (IllegalArgumentException e) {
      throw new UserException(doc, "Invalid date. " + e.getMessage());
    }
    source.appendChild(defaultDate.toXml(doc));
    cal.add(Calendar.MONTH, 1);
    cal.add(Calendar.MINUTE, -30);
    Date finishDate = cal.getTime();
    if ((generationFinishDate != null && generationFinishDate.getDate()
        .before(startDate))
        || generationStartDate.getDate().after(finishDate)) {
      throw new UserException(doc,
          "This month doesn't overlap with the generation.");
    }
    for (HhDatum datum : (List<HhDatum>) Hiber
        .session()
        .createQuery(
View Full Code Here

    } else if (inv.hasParameter("insert")) {
      Date startDate = inv.getDateTime("start");
      BigDecimal value = inv.getBigDecimal("value");
      Character status = inv.getCharacter("status");
      if (!inv.isValid()) {
        throw new UserException(doc(inv));
      }
      HhStartDate hhStartDate = new HhStartDate(startDate);
      if (Hiber
          .session()
          .createQuery(
              "from HhDatum datum where datum.channel = :channel and datum.startDate.date = :startDate")
          .setEntity("channel", channel).setTimestamp("startDate",
              hhStartDate.getDate()).uniqueResult() != null) {
        throw new UserException(doc(inv),
            "There's already an HH datum with this time.");
      }
      List<HhDatumRaw> data = new ArrayList<HhDatumRaw>();
      data.add(new HhDatumRaw(channel.getSupplyGeneration().getMpans()
          .iterator().next().getCore().toString(), channel
View Full Code Here

      throw new InternalException(
          "The bill reference parameter is required.");
    }
    this.reference = reference;
    if (accountReference == null) {
      throw new UserException(
          "The accountReference parameter is required.");
    }
    this.accountReference = accountReference;
    if (mpanStrings == null) {
      throw new InternalException(
View Full Code Here

    Date presentDate = inv.getDate("present");
    BigDecimal presentValue = inv.getBigDecimal("present-value");
    Long presentTypeId = inv.getLong("present-type-id");

    if (!inv.isValid()) {
      throw new UserException(document());
    }
    bill.insertRead(Tpr.getTpr(tprCode), coefficient, Units
        .getUnits(unitsStr), meterSerialNumber, mpanStr,
        new HhStartDate(previousDate), previousValue, ReadType
            .getReadType(previousTypeId), new HhStartDate(
View Full Code Here

public class Dno extends Party {
  static public Dno getDno(Long id) throws HttpException {
    Dno dno = (Dno) Hiber.session().get(Dno.class, id);
    if (dno == null) {
      throw new UserException("There is no DNO with the id '" + id + "'.");
    }
    return dno;
  }
View Full Code Here

        .session()
        .createQuery(
            "from Dno dno where dno.participant = :participant and dno.validTo is null")
        .setEntity("participant", participant).uniqueResult();
    if (dno == null) {
      throw new UserException("There is no DNO with the participant '"
          + participant.getCode() + "'.");
    }
    return dno;
  }
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.