@Override
  @PlusTransactional
  public ResponseEvent<DpRequirementDetail> updateRequirement(
      RequestEvent<DpRequirementDetail> req) {
    try {
      AccessCtrlMgr.getInstance().ensureUserIsAdmin();

      Long dpReqId = req.getPayload().getId();
      DpRequirement existing = getDprDao().getById(dpReqId);
      if (existing == null) {
        return ResponseEvent.userError(DpRequirementErrorCode.NOT_FOUND);
      }

      DpRequirement newDpr = dprFactory.createDistributionProtocolRequirement(req.getPayload());
      OpenSpecimenException ose = new OpenSpecimenException(ErrorType.USER_ERROR);
      ensureUniqueReqConstraints(existing, newDpr, ose);
      ose.checkAndThrow();

      existing.update(newDpr);
      getDprDao().saveOrUpdate(existing);
      return ResponseEvent.response(DpRequirementDetail.from(existing));
    } catch (OpenSpecimenException ose) {
      return ResponseEvent.error(ose);
    } catch (Exception e) {
      return ResponseEvent.serverError(e);
    }
  }
  @Override
  @PlusTransactional
  public ResponseEvent<DpRequirementDetail> createRequirement(
      RequestEvent<DpRequirementDetail> req) {
    try {
      AccessCtrlMgr.getInstance().ensureUserIsAdmin();

      DpRequirement dpr = dprFactory.createDistributionProtocolRequirement(req.getPayload());

      OpenSpecimenException ose = new OpenSpecimenException(ErrorType.USER_ERROR);
      ensureUniqueReqConstraints(null, dpr, ose);
      ose.checkAndThrow();

      getDprDao().saveOrUpdate(dpr);
      return ResponseEvent.response(DpRequirementDetail.from(dpr));
    } catch (OpenSpecimenException ose) {
      return ResponseEvent.error(ose);
    } catch (Exception e) {
      return ResponseEvent.serverError(e);
    }
  }