Search in sources :

Example 1 with ManagementRequestHandler

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

the class WatchServer method onManagementRequestReceived.

@Subscribe
public void onManagementRequestReceived(ManagementRequest managementRequest) {
    logger.log(Level.INFO, "Received " + managementRequest);
    try {
        ManagementRequestHandler handler = ManagementRequestHandler.createManagementRequestHandler(managementRequest);
        Response response = handler.handleRequest(managementRequest);
        if (response != null) {
            eventBus.post(response);
        }
    } catch (ClassNotFoundException e) {
        // Not logging 'e'!
        logger.log(Level.FINE, "No handler found for management request class " + managementRequest.getClass() + ". Ignoring.");
    } catch (Exception e) {
        logger.log(Level.FINE, "Failed to process request", e);
        eventBus.post(new BadRequestResponse(managementRequest.getId(), "Invalid request."));
    }
}
Also used : AddWatchManagementResponse(org.syncany.operations.daemon.messages.AddWatchManagementResponse) RemoveWatchManagementResponse(org.syncany.operations.daemon.messages.RemoveWatchManagementResponse) ListWatchesManagementResponse(org.syncany.operations.daemon.messages.ListWatchesManagementResponse) BadRequestResponse(org.syncany.operations.daemon.messages.BadRequestResponse) Response(org.syncany.operations.daemon.messages.api.Response) ManagementRequestHandler(org.syncany.operations.daemon.messages.api.ManagementRequestHandler) BadRequestResponse(org.syncany.operations.daemon.messages.BadRequestResponse) ConfigException(org.syncany.config.ConfigException) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

Subscribe (com.google.common.eventbus.Subscribe)1 ConfigException (org.syncany.config.ConfigException)1 AddWatchManagementResponse (org.syncany.operations.daemon.messages.AddWatchManagementResponse)1 BadRequestResponse (org.syncany.operations.daemon.messages.BadRequestResponse)1 ListWatchesManagementResponse (org.syncany.operations.daemon.messages.ListWatchesManagementResponse)1 RemoveWatchManagementResponse (org.syncany.operations.daemon.messages.RemoveWatchManagementResponse)1 ManagementRequestHandler (org.syncany.operations.daemon.messages.api.ManagementRequestHandler)1 Response (org.syncany.operations.daemon.messages.api.Response)1