package nl.mawoo.smokesignal.protocol;

import com.google.gson.Gson;
import nl.mawoo.smokesignal.protocol.models.MessageObject;
import org.apache.log4j.Logger;

/**
 * {message}
 *
 * @author Bob van der Valk
 */
public class MessageProtocol {
    private static Logger logger = Logger.getLogger(MessageProtocol.class);
    private MessageObject messageObject;

    public MessageProtocol(MessageObject messageObject) {
        this.messageObject = messageObject;
    }

    public String constructJsonMessage() {
        Gson gson = new Gson();
        return gson.toJson(messageObject);
    }
}

@@ -132,31 +132,141 @@
 ort 
-org.apache.log4j.Logger
+nl.mawoo.smokesignal.protocol.validation.MD5Generator;%0Aimport org.apache.log4j.Logger;%0A%0Aimport java.security.NoSuchAlgorithmException
 ;%0A%0A/
@@ -574,16 +574,646 @@
 %0A    %7D%0A%0A
+    /**%0A     * This method generates a message that can be send through the correct protocol%0A     * @return String with md5~%7Bjson%7D%0A     */%0A    public String constructMessage() %7B%0A        String json = constructJson();%0A        MD5Generator md5Generator = new MD5Generator(json);%0A        String md5 = null;%0A        try %7B%0A            md5 = md5Generator.generateMd5();%0A        %7D catch (NoSuchAlgorithmException e) %7B%0A            logger.error(%22Cannot parse json to md5%22, e);%0A        %7D%0A        return md5 +%22~%22+ json;%0A    %7D%0A%0A    /**%0A     * This class converts a messageObject to a json format.%0A     * @return String in json format%0A     */%0A
     publ
@@ -1235,23 +1235,16 @@
 ructJson
-Message
 () %7B%0A   

finish outgoing message protocol