private Connection getConnectionOrFail(String connectionId) throws ServiceException { final Connection connection = connectionRepo.findByConnectionId(connectionId); if (connection == null) { throw createInvalidParameterServiceException("connectionId"); } return connection; }
private void validateConnectionId(String connectionId) throws ServiceException { if (StringUtils.hasText(connectionId)) { if (connectionRepo.findByConnectionId(connectionId) != null) { log.warn("ConnectionId {} was not unique", connectionId); throw createAlreadyExistsServiceException("connectionId"); } } else { log.warn("ConnectionId was empty", connectionId); throw createInvalidParameterServiceException("connectionId"); } }
private void validateConnection(Connection connection, RichUserDetails richUserDetails) throws ServiceException { try { validateProviderNsa(connection.getProviderNsa()); validateConnectionId(connection.getConnectionId()); validatePort(connection.getSourceStpId(), "sourceSTP", richUserDetails); validatePort(connection.getDestinationStpId(), "destSTP", richUserDetails); } catch (ServiceException e) { connection.setCurrentState(TERMINATED); connectionRepo.save(connection); throw e; } }