Search in sources :

Example 1 with FolderResponse

use of org.syncany.operations.daemon.messages.api.FolderResponse in project syncany by syncany.

the class CommandLineClient method handleRestResponse.

private int handleRestResponse(Command command, HttpResponse httpResponse) throws Exception {
    logger.log(Level.FINE, "Received HttpResponse: " + httpResponse);
    String responseStr = IOUtils.toString(httpResponse.getEntity().getContent());
    logger.log(Level.FINE, "Responding to message with responseString: " + responseStr);
    Response response = XmlMessageFactory.toResponse(responseStr);
    if (response instanceof FolderResponse) {
        FolderResponse folderResponse = (FolderResponse) response;
        command.printResults(folderResponse.getResult());
        return 0;
    } else if (response instanceof AlreadySyncingResponse) {
        out.println("Daemon is already syncing, please retry later.");
        return 1;
    } else if (response instanceof BadRequestResponse) {
        out.println(response.getMessage());
        return 1;
    }
    return 1;
}
Also used : AlreadySyncingResponse(org.syncany.operations.daemon.messages.AlreadySyncingResponse) FolderResponse(org.syncany.operations.daemon.messages.api.FolderResponse) BadRequestResponse(org.syncany.operations.daemon.messages.BadRequestResponse) HttpResponse(org.apache.http.HttpResponse) Response(org.syncany.operations.daemon.messages.api.Response) BadRequestResponse(org.syncany.operations.daemon.messages.BadRequestResponse) AlreadySyncingResponse(org.syncany.operations.daemon.messages.AlreadySyncingResponse) FolderResponse(org.syncany.operations.daemon.messages.api.FolderResponse)

Aggregations

HttpResponse (org.apache.http.HttpResponse)1 AlreadySyncingResponse (org.syncany.operations.daemon.messages.AlreadySyncingResponse)1 BadRequestResponse (org.syncany.operations.daemon.messages.BadRequestResponse)1 FolderResponse (org.syncany.operations.daemon.messages.api.FolderResponse)1 Response (org.syncany.operations.daemon.messages.api.Response)1