package net.hawkengine.ws;

import net.hawkengine.model.ServiceResult;
import net.hawkengine.model.User;
import net.hawkengine.model.dto.WsContractDto;

public class EndpointConnector {
    public static void passResultToEndpoint(String className, String methodName, ServiceResult serviceResult) {
        WsContractDto contract = new WsContractDto();
        contract.setClassName(className);
        contract.setMethodName(methodName);
        contract.setResult(serviceResult.getObject());
        contract.setError(serviceResult.hasError());
        contract.setErrorMessage(serviceResult.getMessage());

        SessionPool.getInstance().sendToAuthorizedSessions(contract);
    }

    public static void passResultToEndpoint(String className, String methodName, ServiceResult serviceResult, User user) {
        WsContractDto contract = new WsContractDto();
        contract.setClassName(className);
        contract.setMethodName(methodName);
        contract.setResult(serviceResult.getObject());
        contract.setError(serviceResult.hasError());
        contract.setErrorMessage(serviceResult.getMessage());

        SessionPool.getInstance().sendToUserSessions(contract, user);
    }
}

@@ -510,36 +510,58 @@
 .set
-Error(serviceResult.hasError
+NotificationType(serviceResult.getNotificationType
 ());
@@ -1043,36 +1043,58 @@
 .set
-Error(serviceResult.hasError
+NotificationType(serviceResult.getNotificationType
 ());

refactor error property with enum in EndpointConnector #213