Project

General

Profile

« Previous | Next » 

Revision 57912

More thorought implementation for the email notifications when registering/updating repositories

View differences:

RepositoryServiceImpl.java
500 500
                    , ResponseEntity.class);
501 501

  
502 502
            if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
503
                emailUtils.sendUserUpdateRepositoryEmail(repository, authentication);
504
                emailUtils.sendAdminUpdateRepositoryEmail(repository, authentication);
503
                emailUtils.sendUserUpdateRepositoryInfoEmail(repository, authentication);
504
                emailUtils.sendAdminUpdateRepositoryInfoEmail(repository, authentication);
505 505
            } else
506 506
                LOGGER.debug(responseEntity.getBody().toString());
507 507

  
......
552 552
    public RepositoryInterface addRepositoryInterface(String datatype,
553 553
                                                      String repoId,
554 554
                                                      String registeredBy,
555
                                                      RepositoryInterface repositoryInterface) throws JSONException, ResourceNotFoundException, ValidatorServiceException {
555
                                                      RepositoryInterface repositoryInterface) throws Exception {
556 556
        try {
557 557
            Repository e = this.getRepositoryById(repoId);
558 558
            repositoryInterface = createRepositoryInterface(e,repositoryInterface,datatype);
......
564 564
                    .encode();
565 565

  
566 566
            HttpEntity<String> httpEntity = new HttpEntity <> (json_interface,httpHeaders);
567
            restTemplate.postForObject(uriComponents.toUri(),httpEntity,String.class);
568
            submitInterfaceValidation(e, registeredBy, repositoryInterface, false);
569 567

  
570
            return repositoryInterface;
571 568

  
569
            ResponseEntity responseEntity = restTemplate.postForObject(uriComponents.toUri(),httpEntity,ResponseEntity.class);
570

  
571
            if(responseEntity.getStatusCode().equals(HttpStatus.OK)) {
572
                emailUtils.sendAdminRegisterInterfaceEmail(e, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
573
                emailUtils.sendUserRegisterInterfaceEmail(e, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
574

  
575
                submitInterfaceValidation(e, registeredBy, repositoryInterface, false);
576
                return repositoryInterface;
577
            } else {
578
                LOGGER.debug(responseEntity.getBody().toString());
579
                throw new Exception("Registering" + baseAddress + " returned " + responseEntity.getStatusCode());
580
            }
581

  
572 582
        } catch (JSONException | ValidatorServiceException e) {
573 583
            LOGGER.debug("Exception on addRepositoryInterface" , e);
574 584
            emailUtils.reportException(e);
......
584 594
        this.updateBaseUrl(repoId,repositoryInterface.getId(),repositoryInterface.getBaseUrl());
585 595
        this.updateCompliance(repoId,repositoryInterface.getId(),repositoryInterface.getCompliance());
586 596
        this.updateValidationSet(repoId,repositoryInterface.getId(),repositoryInterface.getAccessSet());
597

  
598
        Repository e = this.getRepositoryById(repoId);
599
        emailUtils.sendAdminUpdateInterfaceEmail(e, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
600
        emailUtils.sendUserUpdateInterfaceEmail(e, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
587 601
        submitInterfaceValidation(getRepositoryById(repoId),registeredBy,repositoryInterface,true);
602

  
588 603
        return repositoryInterface;
589 604
    }
590 605

  

Also available in: Unified diff