コード例 #1
0
  @PlusTransactional
  public ResponseEvent<AuthDomainDetail> updateDomain(RequestEvent<AuthDomainDetail> req) {
    try {
      AuthDomainDetail detail = req.getPayload();
      AuthDomain existingDomain = daoFactory.getAuthDao().getAuthDomainByName(detail.getName());
      if (existingDomain == null) {
        throw OpenSpecimenException.userError(AuthProviderErrorCode.DOMAIN_NOT_FOUND);
      }

      AuthDomain authDomain = domainRegFactory.createDomain(detail);
      existingDomain.update(authDomain);

      return ResponseEvent.response(AuthDomainDetail.from(existingDomain));
    } catch (OpenSpecimenException ose) {
      return ResponseEvent.error(ose);
    } catch (Exception e) {
      return ResponseEvent.serverError(e);
    }
  }
コード例 #2
0
  @Override
  @PlusTransactional
  public ResponseEvent<AuthDomainDetail> registerDomain(RequestEvent<AuthDomainDetail> req) {
    try {
      AuthDomainDetail detail = req.getPayload();
      AuthDomain authDomain = domainRegFactory.createDomain(detail);

      ensureUniqueDomainName(authDomain.getName());
      daoFactory.getAuthDao().saveOrUpdate(authDomain);
      return ResponseEvent.response(AuthDomainDetail.from(authDomain));
    } catch (OpenSpecimenException ose) {
      return ResponseEvent.error(ose);
    } catch (Exception e) {
      return ResponseEvent.serverError(e);
    }
  }