Package com.lbslocal.api.control

Source Code of com.lbslocal.api.control.ControlAPI

package com.lbslocal.api.control;


import com.lbslocal.api.objects.TokenValidated;
import com.lbslocal.api.proxy.Proxy;
import com.lbslocal.api.utils.Common;
import com.lbslocal.cc.common.Functions;
import com.lbslocal.master.common.ConfigurationManager;

public class ControlAPI {

   
  public static String getLBSAPI(Proxy proxy, TokenValidated tokenValidated) {
    ConfigurationManager cm = ConfigurationManager.getInstance();
   
    String API_VERSION = com.lbslocal.api.utils.ConfigurationManager.getInstance().getAppSettings("M_VERSION");
      String AKAMAI_VERSION = com.lbslocal.api.utils.ConfigurationManager.getInstance().getAppSettings("M_MAP_VERSION");
     
      String SERVICES_SERVER = cm.getAppSettings("M_SERVER");
      String MAP_SERVER = cm.getAppSettings("M_MAP_SERVER");
      String API_JSCRIPT_SERVER = cm.getAppSettings("M_SERVER_API_GZ");
      String MAQUINA = cm.getAppSettings("MAQUINA");
      String SCR_SERVER = cm.getAppSettings("M_SCR_SERVER");
      String MAP_SERVER_DG = cm.getAppSettings("M_MAP_SERVER_DG");
   
      ControlTraffic ct = ControlTraffic.getInstance();
     
    String mTrafficUpdate = ct.getTraffic();
   
        String replaceMapServer = "\\#", replaceServerAPI = "imak1";
        if (tokenValidated.getUser().toLowerCase() == "telelistas") { replaceMapServer = "t\\#"; replaceServerAPI = "imakt1"; }
        if (tokenValidated.getUser().toLowerCase() == "microsoft") { replaceMapServer = "m\\#"; replaceServerAPI = "imakm1"; }

        StringBuilder sRet = new StringBuilder("/* MaplinkAPI version:");
        try
        {
           
            sRet.append(API_VERSION);
            sRet.append(" */var LBSV = '" + API_VERSION + "'; var ___LBSAPI = {url:document.URL.split('?')[0], AppServer:'http://");
            sRet.append(SERVICES_SERVER);
            sRet.append("', MapServer:\"");
            sRet.append(MAP_SERVER.replace("#", replaceMapServer));
            sRet.append("\", TrafficInfo:");
            sRet.append(mTrafficUpdate);
            sRet.append(", UserKey:'");
            sRet.append(proxy.GetKey());
            sRet.append("', Scheme:'http");
            sRet.append("', ServicePage:'apisvc', MapVersion:");
            sRet.append(AKAMAI_VERSION);
            sRet.append(", MapDGServer:\"");
            sRet.append(MAP_SERVER_DG);
            sRet.append("\", MapType:");
            sRet.append(tokenValidated.getClientType());
            sRet.append(",TimeTraffic:'");
            sRet.append(Common.GetDateTimeTrafficTiles());
            sRet.append("', Machine:'");
            sRet.append(MAQUINA);
            sRet.append("', TypeParam:'");
           
            switch (tokenValidated.getClientType())
            {
                case 20: sRet.append("w="); break; // Webraska
                case 6: sRet.append("g="); break; // Geomarketing
                case 9: sRet.append("r="); break; // Rodoviario
                default: sRet.append("d="); break; // Decarta
            }
            sRet.append(AKAMAI_VERSION);
            sRet.append("', CurrentMap:null}, M_SCR_SERVER = \"" + SCR_SERVER + "\";");

            String url = "http://" + API_JSCRIPT_SERVER.replace("imak1", replaceServerAPI) + "/apigz?v=" + proxy.GetVersion()  + "&Mversion=" + API_VERSION + "&engine=" + proxy.GetEngine();
           
            sRet.append("document.write('<' + 'script src=\"");
            sRet.append(url);
            sRet.append("\" type=\"text/javascript\"><' + '/script>');");

        }
        catch (Exception e)
        {
            sRet.append("e.Message :" + e.getMessage() + "\");");
        }


        // ID 44 = getMapLinkAPI
        Functions.gravarLogUnique(tokenValidated.getId(), 44, 0, System.currentTimeMillis(), 0);

        return sRet.toString();
  }
}
TOP

Related Classes of com.lbslocal.api.control.ControlAPI

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.