Search in sources :

Example 1 with GenericResponse

use of org.nzbhydra.GenericResponse in project nzbhydra2 by theotherp.

the class Sabnzbd method checkConnection.

@Override
public GenericResponse checkConnection() {
    logger.debug("Checking connection");
    UriComponentsBuilder baseUrl = getBaseUrl();
    try {
        restTemplate.exchange(baseUrl.queryParam("mode", "get_cats").toUriString(), HttpMethod.GET, null, CategoriesResponse.class);
        logger.info("Connection check with sabnzbd using URL {} successful", baseUrl.toUriString());
        return new GenericResponse(true, null);
    } catch (RestClientException e) {
        logger.info("Connection check with sabnzbd using URL {} failed: {}", baseUrl.toUriString(), e.getMessage());
        return new GenericResponse(false, e.getMessage());
    }
}
Also used : GenericResponse(org.nzbhydra.GenericResponse) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) RestClientException(org.springframework.web.client.RestClientException)

Example 2 with GenericResponse

use of org.nzbhydra.GenericResponse in project nzbhydra2 by theotherp.

the class NzbGet method checkConnection.

@Override
public GenericResponse checkConnection() {
    logger.debug("Checking connection");
    try {
        boolean successful = client.invoke("writelog", new Object[] { "INFO", "NZBHydra 2 connected to test connection" }, Boolean.class);
        logger.info("Connection check to NZBGet using URL {} successful", downloaderConfig.getUrl());
        return new GenericResponse(successful, null);
    } catch (Throwable e) {
        logger.error("Connection check to NZBGet using URL {} failed", downloaderConfig.getUrl());
        return new GenericResponse(false, e.getMessage());
    }
}
Also used : GenericResponse(org.nzbhydra.GenericResponse)

Aggregations

GenericResponse (org.nzbhydra.GenericResponse)2 RestClientException (org.springframework.web.client.RestClientException)1 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)1