コード例 #1
0
 @Override
 @PlusTransactional
 public ResponseEvent<List<AuthDomainSummary>> getDomains(
     RequestEvent<ListAuthDomainCriteria> req) {
   List<AuthDomain> authDomains =
       daoFactory.getAuthDao().getAuthDomains(req.getPayload().maxResults());
   return ResponseEvent.response(AuthDomainSummary.from(authDomains));
 }
コード例 #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);
    }
  }
コード例 #3
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);
    }
  }
コード例 #4
0
 private void ensureUniqueDomainName(String domainName) {
   if (!daoFactory.getAuthDao().isUniqueAuthDomainName(domainName)) {
     throw OpenSpecimenException.userError(AuthProviderErrorCode.DUP_DOMAIN_NAME);
   }
 }