Search in sources :

Example 1 with ServiceNotFoundException

use of uk.gov.pay.adminusers.exception.ServiceNotFoundException in project pay-adminusers by alphagov.

the class StripeAgreementService method doCreate.

public void doCreate(String serviceExternalId, InetAddress ipAddress) {
    ServiceEntity serviceEntity = serviceDao.findByExternalId(serviceExternalId).orElseThrow(() -> new ServiceNotFoundException(serviceExternalId));
    if (stripeAgreementDao.findByServiceExternalId(serviceExternalId).isPresent()) {
        throw new StripeAgreementExistsException();
    }
    logger.info(format("Creating stripe agreement for service %s", serviceExternalId));
    ZonedDateTime agreementTime = ZonedDateTime.now(ZoneId.of("UTC"));
    stripeAgreementDao.persist(new StripeAgreementEntity(serviceEntity, ipAddress.getHostAddress(), agreementTime));
}
Also used : StripeAgreementExistsException(uk.gov.pay.adminusers.exception.StripeAgreementExistsException) ZonedDateTime(java.time.ZonedDateTime) ServiceNotFoundException(uk.gov.pay.adminusers.exception.ServiceNotFoundException) StripeAgreementEntity(uk.gov.pay.adminusers.persistence.entity.StripeAgreementEntity) ServiceEntity(uk.gov.pay.adminusers.persistence.entity.ServiceEntity)

Aggregations

ZonedDateTime (java.time.ZonedDateTime)1 ServiceNotFoundException (uk.gov.pay.adminusers.exception.ServiceNotFoundException)1 StripeAgreementExistsException (uk.gov.pay.adminusers.exception.StripeAgreementExistsException)1 ServiceEntity (uk.gov.pay.adminusers.persistence.entity.ServiceEntity)1 StripeAgreementEntity (uk.gov.pay.adminusers.persistence.entity.StripeAgreementEntity)1