public MetaMetadata getMediaMM(ParsedURL purl, String tagName) { MetaMetadata result = null; if (purl != null && !purl.isFile()) { result = mediaRepositoryByURL.get(purl.noAnchorNoQueryPageString()); if (result == null) { String protocolStrippedURL = purl.toString().split("://")[1]; String key = purl.url().getProtocol() + "://" + urlprefixCollection.getMatchingPhrase(protocolStrippedURL, '/'); result = mediaRepositoryByURL.get(key); if (result == null) { String domain = purl.domain(); if (domain != null) { ArrayList<RepositoryPatternEntry> entries = mediaRepositoryByPattern.get(domain); if (entries != null) { for (RepositoryPatternEntry entry : entries) { Matcher matcher = entry.getPattern().matcher(purl.toString()); if (matcher.find()) { result = entry.getMetaMetadata(); } } } } } } } return (result != null) ? result : getByTagName(tagName); }
/** * Get MetaMetadata. First, try matching by url_base. If this fails, including if the attribute is * null, then try by url_prefix. If this fails, including if the attribute is null, then try by * url_pattern (regular expression). * * <p>If that lookup fails, then lookup by tag name, to acquire the default. * * @param purl * @param tagName * @return */ public MetaMetadata getDocumentMM(ParsedURL purl, String tagName) { MetaMetadata result = null; if (purl != null) { if (!purl.isFile()) { result = documentRepositoryByURL.get(purl.noAnchorNoQueryPageString()); if (result == null) { String protocolStrippedURL = purl.toString().split("://")[1]; String matchingPhrase = urlprefixCollection.getMatchingPhrase(protocolStrippedURL, '/'); // FIXME -- andruid needs abhinav to explain this code better and make more clear!!! if (matchingPhrase != null) { String key = purl.url().getProtocol() + "://" + matchingPhrase; result = documentRepositoryByURL.get(key); } } if (result == null) { String domain = purl.domain(); if (domain != null) { ArrayList<RepositoryPatternEntry> entries = documentRepositoryByPattern.get(domain); if (entries != null) { for (RepositoryPatternEntry entry : entries) { Matcher matcher = entry.getPattern().matcher(purl.toString()); if (matcher.find()) { result = entry.getMetaMetadata(); } } } } } } // Lastly, check for MMD by suffix if (result == null) { String suffix = purl.suffix(); if (suffix != null) result = getMMBySuffix(suffix); } } return (result != null) ? result : getByTagName(tagName); }