Skip to content

fetchSerializationPolicyName not working with GWT 2.7 #43

@GoogleCodeExporter

Description

@GoogleCodeExporter
Hi,
It appears that GWT 2.7: 
- generates cache.js files instead of cache.html
- first cache file does not include SerializationPolicyName (user.agent ie8)
Please correct me if I'm wrong.

I made the following quick adjustements to the code to to get it working with 
2.7:

    public static Map<String, String> fetchSerializationPolicyName(
            String moduleBaseURL) throws IOException {
        Map<String, String> result = new HashMap<String, String>();

        moduleBaseURL = moduleBaseURL.trim(); // remove outer trim just in case
        String[] urlparts = moduleBaseURL.split("/");
        String moduleNoCacheJs = urlparts[urlparts.length - 1] + ".nocache.js"; // get

        String responseText = "";
        responseText = getResposeText(moduleBaseURL + moduleNoCacheJs);
        // parse the .nocache.js for list of Permutation name
        // Permutation name is 32 chars surrounded by apostrophe
        String regex = "\'([A-Z0-9]){32}\'";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(responseText);
        //5A-Lab change to support GWT 2.7
        while (matcher.find() && result.size()==0) {
            String permutationFile = matcher.group();
            permutationFile = permutationFile.replace("\'", "");

            //5A-Lab change to support GWT 2.7
            permutationFile += ".cache.js";
            responseText = getResposeText(moduleBaseURL + permutationFile);
            //5A-Lab change to support GWT 2.7
            Matcher cacheFileMatcher = pattern.matcher(responseText);
            int i = 0;
            while (cacheFileMatcher.find() && result.size()==0) {
                String policyName = cacheFileMatcher.group();
                policyName = policyName.replace("\'", "");
                if (0 == i++) {
                    // The first one is the permutation name
                    continue;
                }
                responseText = getResposeText(moduleBaseURL + policyName
                        + GWT_PRC_POLICY_FILE_EXT);
                result.putAll(parsePolicyName(policyName,
                        new ByteArrayInputStream(responseText.getBytes("UTF8"))));
            }
        }

        if (result.size() == 0) {
            logger.warning("No RemoteService fetched from server");
        } else {
            dumpRemoteService(result);
        }

        return result;
    }



Original issue reported on code.google.com by davorin....@5a-lab.com on 27 Nov 2014 at 9:39

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions