<%
var log = new Log();

var caramel = require('caramel');
var profile = require('/controllers/my-profile/profileClient.jag');
var util = require("util/utility.jag");
include("util/constants.jag");

var i18n = util.initI18N();

function doRender(){

    try{
        require('authenticationHandler.jag');

    }catch(e){
        log.error(e);
        response.sendRedirect("login.jag?e=1&error=AuthenticationFail");
        return;
    }

    try{
        var userName = session.get(LOGGED_IN_USER);
        var profileData  = profile.getUserProfile(userName, 'default');

        caramel.render({
            profile: profileData,
            messages : i18n.localize("messages"),
            error: util.getSuccessErrorJson(request, i18n)
        });

    }catch(e){
        log.error(e);
        response.sendRedirect("index.jag?e=1&error=service_invok_error");

    }
}

doRender();
%>