Package net.sf.chellow.monad.Invocation

Examples of net.sf.chellow.monad.Invocation.HttpMethod


  public String getServletInfo() {
    return "Chellow electricity billing and reporting.";
  }

  protected void checkPermissions(Invocation inv) throws HttpException {
    HttpMethod method = inv.getMethod();
    String pathInfo = inv.getRequest().getPathInfo();

    if (method.equals(HttpMethod.GET)
        && (pathInfo.equals("/") || pathInfo.startsWith("/style/"))) {
      return;
    }
    User user = inv.getUser();
    if (user == null) {
      user = ImplicitUserSource.getUser(inv);
    }
    if (user == null) {
      try {
        Long userCount = (Long) Hiber.session()
            .createQuery("select count(*) from User user")
            .uniqueResult();
        if (userCount == null
            || userCount == 0
            && InetAddress.getByName(
                inv.getRequest().getRemoteAddr())
                .isLoopbackAddress()) {
          return;
        }
      } catch (UnknownHostException e) {
        throw new InternalException(e);
      }
      throw new UnauthorizedException();
    }
    UserRole role = user.getRole();
    String roleCode = role.getCode();
    if (roleCode.equals(UserRole.VIEWER)) {
      if (pathInfo.startsWith("/reports/")
          && pathInfo.endsWith("/output/")
          && (method.equals(HttpMethod.GET) || method
              .equals(HttpMethod.HEAD))) {
        return;
      }
    } else if (roleCode.equals(UserRole.EDITOR)) {
      return;
    } else if (roleCode.equals(UserRole.PARTY_VIEWER)) {
      if (method.equals(HttpMethod.GET) || method.equals(HttpMethod.HEAD)) {
        Party party = user.getParty();
        char marketRoleCode = party.getRole().getCode();
        if (marketRoleCode == MarketRole.HHDC) {
          Long hhdcContractId = inv.getLong("hhdc-contract-id");
          if (!inv.isValid()) {
View Full Code Here

TOP

Related Classes of net.sf.chellow.monad.Invocation.HttpMethod

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.