Search in sources :

Example 1 with ImmutablePair

use of org.eclipse.scout.rt.platform.util.ImmutablePair in project scout.rt by eclipse.

the class HtmlDocumentParser method getScriptAndFingerprint.

/**
 * Returns the external script name including a content-based fingerprint.
 */
protected Pair<HttpCacheObject, String> getScriptAndFingerprint(String internalPath) throws IOException {
    ScriptFileLoader scriptLoader = createScriptFileLoader();
    HttpCacheKey cacheKey = scriptLoader.createCacheKey(internalPath);
    HttpCacheObject script = m_cache.get(cacheKey);
    if (script == null) {
        // cache miss: try to load script
        script = scriptLoader.loadResource(cacheKey);
    }
    if (script == null) {
        // script not found -> no fingerprint
        LOG.warn("Failed to locate script referenced in html file '{}': {}", m_params.getHtmlPath(), internalPath);
        return null;
    }
    String fingerprint = Long.toHexString(script.getResource().getFingerprint());
    return new ImmutablePair<>(script, fingerprint);
}
Also used : ImmutablePair(org.eclipse.scout.rt.platform.util.ImmutablePair) HttpCacheKey(org.eclipse.scout.rt.server.commons.servlet.cache.HttpCacheKey) HttpCacheObject(org.eclipse.scout.rt.server.commons.servlet.cache.HttpCacheObject)

Example 2 with ImmutablePair

use of org.eclipse.scout.rt.platform.util.ImmutablePair in project scout.rt by eclipse.

the class BinaryResourceUrlUtility method extractFilenameWithFingerprint.

public static Pair<String, Long> extractFilenameWithFingerprint(String filenameWithFingerprint) {
    Matcher m = REGEX_FINGERPRINT_PATTERN.matcher(filenameWithFingerprint);
    m.find();
    String fingerprintString = m.group(1);
    String filename = m.group(2);
    Long fingerprint = 0L;
    if (StringUtility.hasText(fingerprintString)) {
        fingerprint = Long.valueOf(fingerprintString);
    }
    return new ImmutablePair<>(filename, fingerprint);
}
Also used : ImmutablePair(org.eclipse.scout.rt.platform.util.ImmutablePair) Matcher(java.util.regex.Matcher)

Aggregations

ImmutablePair (org.eclipse.scout.rt.platform.util.ImmutablePair)2 Matcher (java.util.regex.Matcher)1 HttpCacheKey (org.eclipse.scout.rt.server.commons.servlet.cache.HttpCacheKey)1 HttpCacheObject (org.eclipse.scout.rt.server.commons.servlet.cache.HttpCacheObject)1