public void execute(
     final Params params,
     final RequestHandler.OnErrorListener listener,
     final Map<String, Object> requestMap,
     final Map<String, Object> paramMap) {
   synchronized (handlers) {
     if (position < handlers.length) {
       final RequestHandler handler = handlers[position];
       position++;
       handler.execute(params, listener, requestMap, paramMap, this);
     }
   }
 }
  /** @see edu.harvard.i2b2.crc.delegate.RequestHandlerDelegate#handleRequest(java.lang.String) */
  public String handleRequest(String requestXml, RequestHandler requestHandler)
      throws I2B2Exception {
    String response = null;
    JAXBUtil jaxbUtil = CRCLoaderJAXBUtil.getJAXBUtil();

    try {
      JAXBElement jaxbElement = jaxbUtil.unMashallFromString(requestXml);
      RequestMessageType requestMessageType = (RequestMessageType) jaxbElement.getValue();
      BodyType bodyType = requestMessageType.getMessageBody();

      if (bodyType == null) {
        log.error("null value in body type");
        throw new I2B2Exception("null value in body type");
      }

      // Call PM cell to validate user
      StatusType procStatus = null;
      ProjectType projectType = null;
      String projectId = null;
      SecurityType securityType = null;
      try {

        if (requestMessageType.getMessageHeader() != null) {
          if (requestMessageType.getMessageHeader().getSecurity() != null) {
            securityType = requestMessageType.getMessageHeader().getSecurity();
          }
          projectId = requestMessageType.getMessageHeader().getProjectId();
        }
        if (securityType == null) {
          procStatus = new StatusType();
          procStatus.setType("ERROR");
          procStatus.setValue("Request message missing user/password");
          response =
              I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, bodyType);
          return response;
        }

        PMServiceDriver pmServiceDriver = new PMServiceDriver();
        projectType = pmServiceDriver.checkValidUser(securityType, projectId);
        if (projectType == null) {
          procStatus = new StatusType();
          procStatus.setType("ERROR");
          procStatus.setValue("Invalid user/password for the given domain");
          response =
              I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, bodyType);
          return response;
        }

        log.debug("project name from PM " + projectType.getName());
        log.debug("project id from PM " + projectType.getId());
        if (projectType.getRole().get(0) != null) {
          log.debug("Project role from PM " + projectType.getRole().get(0));
          this.putRoles(
              projectId,
              securityType.getUsername(),
              securityType.getDomain(),
              projectType.getRole());

          Node rootNode = CacheUtil.getCache().getRoot();
          List<String> roles =
              (List<String>)
                  rootNode.get(
                      securityType.getDomain()
                          + "/"
                          + projectId
                          + "/"
                          + securityType.getUsername());
          if (roles != null) {
            System.out.println("roles size !!1 " + roles.size());
          }

        } else {
          log.warn("project role not set for user [" + securityType.getUsername() + "]");
        }

      } catch (AxisFault e) {
        procStatus = new StatusType();
        procStatus.setType("ERROR");
        procStatus.setValue("Could not connect to server");
        response =
            I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, bodyType);
        return response;
      } catch (I2B2Exception e) {
        procStatus = new StatusType();
        procStatus.setType("ERROR");
        procStatus.setValue("Message error connecting Project Management cell");
        response =
            I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, bodyType);
        return response;
      } catch (JAXBUtilException e) {
        procStatus = new StatusType();
        procStatus.setType("ERROR");
        procStatus.setValue("Message error from Project Management cell");
        response =
            I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, bodyType);
        return response;
      }

      JAXBUnWrapHelper unWrapHelper = new JAXBUnWrapHelper();

      BodyType responseBodyType = null;
      if (requestHandler instanceof PublishDataRequestHandler) {

        String irodsStorageResource = null;
        for (ParamType paramType : projectType.getParam()) {

          if (paramType.getName().equalsIgnoreCase("SRBDefaultStorageResource")) {
            irodsStorageResource = paramType.getValue();
            log.debug("param value for SRBDefaultStorageResource" + paramType.getValue());
          }
        }
        ((PublishDataRequestHandler) requestHandler)
            .setIrodsDefaultStorageResource(irodsStorageResource);
      }

      responseBodyType = requestHandler.execute();

      procStatus = new StatusType();
      procStatus.setType("DONE");
      procStatus.setValue("DONE");

      response =
          I2B2MessageResponseFactory.buildResponseMessage(
              requestXml, procStatus, responseBodyType, true);

    } catch (JAXBUtilException e) {
      log.error("JAXBUtil exception", e);
      StatusType procStatus = new StatusType();
      procStatus.setType("ERROR");
      procStatus.setValue(requestXml + "\n\n" + StackTraceUtil.getStackTrace(e));
      try {
        response = I2B2MessageResponseFactory.buildResponseMessage(null, procStatus, null);
      } catch (JAXBUtilException e1) {
        e1.printStackTrace();
      }
    } catch (I2B2Exception e) {
      log.error("I2B2Exception", e);
      StatusType procStatus = new StatusType();
      procStatus.setType("ERROR");
      procStatus.setValue(StackTraceUtil.getStackTrace(e));
      try {
        response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, null);
      } catch (JAXBUtilException e1) {
        e1.printStackTrace();
      }
    } catch (Throwable e) {
      log.error("Throwable", e);
      StatusType procStatus = new StatusType();
      procStatus.setType("ERROR");
      procStatus.setValue(StackTraceUtil.getStackTrace(e));
      try {
        response = I2B2MessageResponseFactory.buildResponseMessage(requestXml, procStatus, null);
      } catch (JAXBUtilException e1) {
        e1.printStackTrace();
      }
    }
    return response;
  }