@Override public Long[] getResourceAttributes(String name, Context context) { Long[] result = new Long[2]; try { ResourceAttributes resource = (ResourceAttributes) context.getResources().getAttributes(name); result[0] = resource.getContentLength(); result[1] = resource.getLastModified(); } catch (NamingException ex) { logger.trace("", ex); } return result; }
/** * Revalidate entry. */ protected boolean revalidate(CacheEntry entry) { // Get the attributes at the given path, and check the last // modification date if (!entry.exists) return false; if (entry.attributes == null) return false; long lastModified = entry.attributes.getLastModified(); long contentLength = entry.attributes.getContentLength(); if (lastModified <= 0) return false; try { Attributes tempAttributes = dirContext.getAttributes(entry.name); ResourceAttributes attributes = null; if (!(tempAttributes instanceof ResourceAttributes)) { attributes = new ResourceAttributes(tempAttributes); } else { attributes = (ResourceAttributes) tempAttributes; } long lastModified2 = attributes.getLastModified(); long contentLength2 = attributes.getContentLength(); return (lastModified == lastModified2) && (contentLength == contentLength2); } catch (NamingException e) { return false; } }
/** * Revalidate entry. */ protected boolean revalidate(CacheEntry entry) { // Get the attributes at the given path, and check the last // modification date if (!entry.exists) return false; if (entry.attributes == null) return false; long lastModified = entry.attributes.getLastModified(); long contentLength = entry.attributes.getContentLength(); if (lastModified <= 0) return false; try { Attributes tempAttributes = dirContext.getAttributes(entry.name); ResourceAttributes attributes = null; if (!(tempAttributes instanceof ResourceAttributes)) { attributes = new ResourceAttributes(tempAttributes); } else { attributes = (ResourceAttributes) tempAttributes; } long lastModified2 = attributes.getLastModified(); long contentLength2 = attributes.getContentLength(); return (lastModified == lastModified2) && (contentLength == contentLength2); } catch (NamingException e) { return false; } }
public int compare(NameClassPair p1, NameClassPair p2) { CacheEntry ce1 = resources.lookupCache( dirName + p1.getName()); long size1 = ce1.attributes.getContentLength(); CacheEntry ce2 = resources.lookupCache( dirName + p2.getName()); long size2 = ce2.attributes.getContentLength(); if (size1 < size2) { return -1; } else if (size1 > size2) { return 1; } else { return 0; } } }
/** * Revalidate entry. */ protected boolean revalidate(CacheEntry entry) { // Get the attributes at the given path, and check the last // modification date if (!entry.exists) return false; if (entry.attributes == null) return false; long lastModified = entry.attributes.getLastModified(); long contentLength = entry.attributes.getContentLength(); if (lastModified <= 0) return false; try { Attributes tempAttributes = dirContext.getAttributes(entry.name); ResourceAttributes attributes = null; if (!(tempAttributes instanceof ResourceAttributes)) { attributes = new ResourceAttributes(tempAttributes); } else { attributes = (ResourceAttributes) tempAttributes; } long lastModified2 = attributes.getLastModified(); long contentLength2 = attributes.getContentLength(); return (lastModified == lastModified2) && (contentLength == contentLength2); } catch (NamingException e) { return false; } }
/** * Revalidate entry. */ protected boolean revalidate(CacheEntry entry) { // Get the attributes at the given path, and check the last // modification date if (!entry.exists) return false; if (entry.attributes == null) return false; long lastModified = entry.attributes.getLastModified(); long contentLength = entry.attributes.getContentLength(); if (lastModified <= 0) return false; try { Attributes tempAttributes = dirContext.getAttributes(entry.name); ResourceAttributes attributes = null; if (!(tempAttributes instanceof ResourceAttributes)) { attributes = new ResourceAttributes(tempAttributes); } else { attributes = (ResourceAttributes) tempAttributes; } long lastModified2 = attributes.getLastModified(); long contentLength2 = attributes.getContentLength(); return (lastModified == lastModified2) && (contentLength == contentLength2); } catch (NamingException e) { return false; } }
/** * Revalidate entry. */ protected boolean revalidate(CacheEntry entry) { // Get the attributes at the given path, and check the last // modification date if (!entry.exists) return false; if (entry.attributes == null) return false; long lastModified = entry.attributes.getLastModified(); long contentLength = entry.attributes.getContentLength(); if (lastModified <= 0) return false; try { Attributes tempAttributes = dirContext.getAttributes(entry.name); ResourceAttributes attributes = null; if (!(tempAttributes instanceof ResourceAttributes)) { attributes = new ResourceAttributes(tempAttributes); } else { attributes = (ResourceAttributes) tempAttributes; } long lastModified2 = attributes.getLastModified(); long contentLength2 = attributes.getContentLength(); return (lastModified == lastModified2) && (contentLength == contentLength2); } catch (NamingException e) { return false; } }
/** * Revalidate entry. */ protected boolean revalidate(CacheEntry entry) { // Get the attributes at the given path, and check the last // modification date if (!entry.exists) return false; if (entry.attributes == null) return false; long lastModified = entry.attributes.getLastModified(); long contentLength = entry.attributes.getContentLength(); if (lastModified <= 0) return false; try { Attributes tempAttributes = dirContext.getAttributes(entry.name); ResourceAttributes attributes = null; if (!(tempAttributes instanceof ResourceAttributes)) { attributes = new ResourceAttributes(tempAttributes); } else { attributes = (ResourceAttributes) tempAttributes; } long lastModified2 = attributes.getLastModified(); long contentLength2 = attributes.getContentLength(); return (lastModified == lastModified2) && (contentLength == contentLength2); } catch (NamingException e) { return false; } }
/** * Revalidate entry. */ protected boolean revalidate(CacheEntry entry) { // Get the attributes at the given path, and check the last // modification date if (!entry.exists) return false; if (entry.attributes == null) return false; long lastModified = entry.attributes.getLastModified(); long contentLength = entry.attributes.getContentLength(); if (lastModified <= 0) return false; try { Attributes tempAttributes = dirContext.getAttributes(entry.name); ResourceAttributes attributes = null; if (!(tempAttributes instanceof ResourceAttributes)) { attributes = new ResourceAttributes(tempAttributes); } else { attributes = (ResourceAttributes) tempAttributes; } long lastModified2 = attributes.getLastModified(); long contentLength2 = attributes.getContentLength(); return (lastModified == lastModified2) && (contentLength == contentLength2); } catch (NamingException e) { return false; } }
/** * Get the ETag associated with a file. * * @param resourceAttributes The resource information */ protected String getETag(ResourceAttributes resourceAttributes) { String result = null; if ((result = resourceAttributes.getETag(true)) != null) { return result; } else if ((result = resourceAttributes.getETag()) != null) { return result; } else { return "W/\"" + resourceAttributes.getContentLength() + "-" + resourceAttributes.getLastModified() + "\""; } }
public boolean resolveResource(int type, String name) { ProxyDirContext resources = (ProxyDirContext) request.getContext().getResources(); CacheEntry cacheEntry = resources.lookupCache(name); if (!cacheEntry.exists) { return false; } else { switch (type) { case 0: return (cacheEntry.resource == null); case 1: return (cacheEntry.resource != null); case 2: return (cacheEntry.resource != null && cacheEntry.attributes.getContentLength() > 0); default: return false; } } }
public boolean resolveResource(int type, String name) { ProxyDirContext resources = (ProxyDirContext) request.getContext().getResources(); CacheEntry cacheEntry = resources.lookupCache(name); if (!cacheEntry.exists) { return false; } else { switch (type) { case 0: return (cacheEntry.resource == null); case 1: return (cacheEntry.resource != null); case 2: return (cacheEntry.resource != null && cacheEntry.attributes.getContentLength() > 0); default: return false; } } }
boolean resolveResource(final int type, final String name) { ProxyDirContext resources = (ProxyDirContext) context.getRequest().getContext().getResources(); CacheEntry cacheEntry = resources.lookupCache(name); if (!cacheEntry.exists) { return false; } else { switch (type) { case 0: return (cacheEntry.resource == null); case 1: return (cacheEntry.resource != null); case 2: return (cacheEntry.resource != null && cacheEntry.attributes.getContentLength() > 0); default: return false; } } }
/** * Retrieves the number of attributes in the attribute set. */ public int size() { if (attributes == null) { int size = 0; if (getCreationDate() != null) size += 2; if (getLastModifiedDate() != null) size += 2; if (getName() != null) size++; if (getResourceType() != null) size += 2; if (getContentLength() >= 0) size += 2; if (getETag() != null) size += 2; return size; } else { return attributes.size(); } }
/** * Retrieves the number of attributes in the attribute set. */ public int size() { if (attributes == null) { int size = 0; if (getCreationDate() != null) size += 2; if (getLastModifiedDate() != null) size += 2; if (getName() != null) size++; if (getResourceType() != null) size += 2; if (getContentLength() >= 0) size += 2; if (getETag() != null) size += 2; return size; } else { return attributes.size(); } }
/** * Retrieves the number of attributes in the attribute set. */ @Override public int size() { if (attributes == null) { int size = 0; if (getCreationDate() != null) size += 2; if (getLastModifiedDate() != null) size += 2; if (getName() != null) size++; if (getResourceType() != null) size += 2; if (getContentLength() >= 0) size += 2; if (getETag() != null) size += 2; return size; } else { return attributes.size(); } }
/** * Retrieves the number of attributes in the attribute set. */ @Override public int size() { if (attributes == null) { int size = 0; if (getCreationDate() != null) size += 2; if (getLastModifiedDate() != null) size += 2; if (getName() != null) size++; if (getResourceType() != null) size += 2; if (getContentLength() >= 0) size += 2; if (getETag() != null) size += 2; return size; } else { return attributes.size(); } }
/** * Retrieves the number of attributes in the attribute set. */ @Override public int size() { if (attributes == null) { int size = 0; if (getCreationDate() != null) size += 2; if (getLastModifiedDate() != null) size += 2; if (getName() != null) size++; if (getResourceType() != null) size += 2; if (getContentLength() >= 0) size += 2; if (getETag() != null) size += 2; return size; } else { return attributes.size(); } }
/** * Retrieves the number of attributes in the attribute set. */ @Override public int size() { if (attributes == null) { int size = 0; if (getCreationDate() != null) size += 2; if (getLastModifiedDate() != null) size += 2; if (getName() != null) size++; if (getResourceType() != null) size += 2; if (getContentLength() >= 0) size += 2; if (getETag() != null) size += 2; return size; } else { return attributes.size(); } }
/** * Retrieves the number of attributes in the attribute set. */ @Override public int size() { if (attributes == null) { int size = 0; if (getCreationDate() != null) size += 2; if (getLastModifiedDate() != null) size += 2; if (getName() != null) size++; if (getResourceType() != null) size += 2; if (getContentLength() >= 0) size += 2; if (getETag() != null) size += 2; return size; } else { return attributes.size(); } }