Header and footer Dynamically Changing but we are passing the Static URL access from GWT

103 views Asked by At

We are maintaining the Static URL in the xml file the same is getting reading in the java filter file. URL hit may vary from Locale but currently I want for India location.

I am keep on reloading the same Page but header and Footer URL is getting changed as some other countries URL. Not able to understand how its getting changed.

Below is the code for the filtering from xml file,

try{
Map<String, String> configData = null;
            configData = EcomConfigService.getConfigurationDataForLocale(
                    httpReq, locale);
    // Here Locale will be loaded Example: INDIA as the country
            String proxy = "";
            String port = "";
            String gwtShfFlag = "";
            int shfTimeOutValue;
            if (configData != null) {
                proxy = configData.get("proxy");
                port = configData.get("port");
                gwtShfFlag = configData.get("gwtShfFlag");
                //Setted the gwtShfFlag as "TRUE"
                shfTimeOutValue = Integer.parseInt(configData.get("shf_timeout"));
                logger.info("gwtShfFlag:: " + gwtShfFlag);
                logger.info("SHF Timeout Value in Milliseconds:: " + shfTimeOutValue);
                if(gwtShfFlag != null && gwtShfFlag.equalsIgnoreCase("true")){
                    HEADER_URL=configData.get("gwt_shared_header");//Loading the Header URL
                    FOOTER_URL=configData.get("gwt_shared_footer"); //Loading the Footer URL
                    HEADER_RESPONSIVE_URL=configData.get("gwt_shared_responsive_header"); //Static Header URL from GWT for INDIA 
                    FOOTER_RESPONSIVE_URL=configData.get("gwt_shared_responsive_footer"); //Static Footer URL from GWT for INDIA 
                    Proxy proxyTemp = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(
                        proxy, Integer.parseInt(port)));
                // Open connection and get response for Header.
                URL urlH = new URL(HEADER_URL);
                URLConnection conH = urlH.openConnection(proxyTemp);
                conH.setConnectTimeout(shfTimeOutValue);
                conH.setReadTimeout(shfTimeOutValue);
                InputStream isH = conH.getInputStream();
                BufferedReader brH = new BufferedReader(new InputStreamReader(isH));
                StringBuilder sbH = new StringBuilder();
                    while ((inputLineH = brH.readLine()) != null) {
                        sbH.append(inputLineH);
                    }

                // Open connection and get response for Footer.
                URL urlF = new URL(FOOTER_URL);
                URLConnection conF = urlF.openConnection(proxyTemp);
                conF.setConnectTimeout(shfTimeOutValue);
                conF.setReadTimeout(shfTimeOutValue);
                InputStream isF = conF.getInputStream();
                BufferedReader brF = new BufferedReader(new InputStreamReader(isF));
                StringBuilder sbF = new StringBuilder();
                    while ((inputLineF = brF.readLine()) != null) {
                        sbF.append(inputLineF);
                    }

                URL urlRH = new URL(HEADER_RESPONSIVE_URL);
                URLConnection conRH = urlRH.openConnection(proxyTemp);
                conRH.setConnectTimeout(shfTimeOutValue);
                conRH.setReadTimeout(shfTimeOutValue);
                InputStream isRH = conRH.getInputStream();
                BufferedReader brRH = new BufferedReader(new InputStreamReader(isRH));
                StringBuilder sbRH = new StringBuilder();
                    while ((inputLineRH = brRH.readLine()) != null) {
                        sbRH.append(inputLineRH);
                    }

                URL urlRF = new URL(FOOTER_RESPONSIVE_URL);
                URLConnection conRF = urlRF.openConnection(proxyTemp);
                conRF.setConnectTimeout(shfTimeOutValue);
                conRF.setReadTimeout(shfTimeOutValue);
                InputStream isRF = conRF.getInputStream();
                BufferedReader brRF = new BufferedReader(new InputStreamReader(isRF));
                StringBuilder sbRF = new StringBuilder();
                    while ((inputLineRF = brRF.readLine()) != null) {
                        sbRF.append(inputLineRF);
                    }

                // Set header and footer response in request scope.
                httpReq.setAttribute("inputLineH", sbH.toString());
                httpReq.setAttribute("inputLineF", sbF.toString());
                httpReq.setAttribute("inputLineRH", sbRH.toString());
                httpReq.setAttribute("inputLineRF", sbRF.toString());
                Locales locales = localeList;
                    if (locales != null) {
                        for (Locale local : locales.getLocale()) {
                            String localeId = local.getLocaleId();
                            if ((localeId == locale) || (localeId.equals(locale))) {
                                if(local.getEnabled()){
                                    logger.info("locale_id:: " + localeId);
                                    logger.info("locale Enabled():: " + local.getEnabled());
                                    List<Section> sections = local.getSections().getSection();
                                    logger.info("sections:: " + sections.size());
                                    httpReq.setAttribute("shfSections", sections);
                                }

                            }
                        }
                    }
                isH.close();
                brH.close();
                isF.close();
                brF.close();
                isRH.close();
                brRH.close();
                brRF.close();
                isRF.close();
                    }
            }
        } catch (Exception exception) {
            logger.error("An Exception occured while calling the SHF urls"
                    + exception.getMessage());
        }
        chain.doFilter(request, response);
    }
0

There are 0 answers