public String getMergedfile(SmartlingKeyEntry updateEntry) throws IOException, JSONException {


        // for each locale (for the specific project) , get translated file from smartling
        updateEntry.setLocale("es");
        String responseHtml = SmartlingRequestApi.getFileFromSmartling(updateEntry.getFileUri(), updateEntry.getProjectId(), updateEntry.getLocale());
        if (responseHtml.contains("VALIDATION_ERROR"))
            return responseHtml;


        // Get List of updated Strings from App Engine DB
        List<SmartlingKeyEntry> dbFile = getTranslationFromDb(datastore, updateEntry.getProjectId(), updateEntry.getLocale(), updateEntry.getFileUri());
        if (dbFile.isEmpty()) {

            log.info("No Updated Strings for ProjectId:" + updateEntry.getProjectId() + ";File:" + updateEntry.getFileUri() + ";Locale:" + updateEntry.getLocale());
            return responseHtml;
        }


        // build map from Json (smarling)
        HashMap<String, Object> smartlingFile = new ObjectMapper().readValue(responseHtml, HashMap.class);




        for (int i = 0; i < dbFile.size(); i++) {


            String keyInDb = dbFile.get(i).getKey();
            String updatedEngVal = dbFile.get(i).getUpdatedEngVal();
            String tranlatedVal = dbFile.get(i).getTranslationInLocale();



           //String currentValInLocaleFile = (String) smartlingFile.get(keyInDb);
            String currentValInLocaleFile = "new orgenize images";


            if (currentValInLocaleFile == null || currentValInLocaleFile.isEmpty()) {

                String error = "Key:" + keyInDb + " Not found in ProjectId:" + updateEntry.getProjectId() + ", But it's on DB. should we remove from DB???";
                log.severe(error);
                continue;
            }

            if (currentValInLocaleFile.equals(updatedEngVal)) {

                String error = "Key:" + keyInDb + "found in ProjectId:" + updateEntry.getProjectId() + " But Still not translated in locale:" + updateEntry.getLocale() + ".value=" + currentValInLocaleFile;
                smartlingFile.put(keyInDb,tranlatedVal);
                log.info(error);
                continue;
            }

            if (!currentValInLocaleFile.equals(updatedEngVal)) {

                String error = "Key:" + keyInDb + "found in ProjectId:" + updateEntry.getProjectId() + " re-translated in locale:" + updateEntry.getLocale() + ".value=" + currentValInLocaleFile;
                log.info(error);


                // remove from DB !!!
                removeKeyFromDb(datastore, updateEntry.getProjectId(), updateEntry.getLocale(), updateEntry.getFileUri(), keyInDb);
                continue;
            }




        }

        JSONObject returnJson = new JSONObject();

        Iterator it = smartlingFile.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry pairs = (Map.Entry)it.next();
            if (!pairs.getKey().toString().equalsIgnoreCase("smartling"))
                returnJson.put(pairs.getKey().toString() , pairs.getValue().toString());
        }

        return returnJson.toString();

    }