package reseau;

/**
 * User: Andréa
 * Date: 23/12/10
 * Time: 03:51
 */
class ProblemMessageFactory extends MessageAbstractFactory {

    @Override
    public Message createMessage(Message.MessageAction action) {
        Message msg = new Message();
        switch (action) {
            case CREATE:
                msg.setMessageAction("POST");
                msg.setMessageURL("/groups/{groupId}/problems");
                break;
            case READ:
                msg.setMessageAction("GET");
                msg.setMessageURL("/groups/{groupId}/problems/{targetId}");
                break;
            case UPDATE:
                msg.setMessageAction("PUT");
                msg.setMessageURL("/groups/{groupId}/problems/{targetId}");
                break;
            case DELETE:
                msg.setMessageAction("DELETE");
                msg.setMessageURL("/groups/{groupId}/problems/{targetId}");
                break;
            case SEND_FILES:
                msg.setMessageAction("POST");
                msg.setMessageURL("/files");
            default:
                throw new IllegalArgumentException("Given message action is not handled by this factory");
        }
        return msg;
    }
}
