private String _getContentType(Resource resource, ExternalContext externalContext) { String contentType = resource.getContentType(); // the resource does not provide a content-type --> determine it via mime-type if (contentType == null || contentType.length() == 0) { String resourceName = getWrappedResourceName(resource); if (resourceName != null) { contentType = externalContext.getMimeType(resourceName); } } return contentType; }
private String _getContentType(Resource resource, ExternalContext externalContext) { String contentType = resource.getContentType(); // the resource does not provide a content-type --> determine it via mime-type if (contentType == null || contentType.length() == 0) { String resourceName = getWrappedResourceName(resource); if (resourceName != null) { contentType = externalContext.getMimeType(resourceName); } } return contentType; }
private String _getContentType(Resource resource, ExternalContext externalContext) { String contentType = resource.getContentType(); // the resource does not provide a content-type --> determine it via mime-type if (contentType == null || contentType.length() == 0) { String resourceName = getWrappedResourceName(resource); if (resourceName != null) { contentType = externalContext.getMimeType(resourceName); } } return contentType; }
/** * Recursively unwarp the resource until we find the real resourceName * This is needed because the JSF2 specced ResourceWrapper doesn't override * the getResourceName() method :( * @param resource * @return the first non-null resourceName or <code>null</code> if none set */ private String getWrappedResourceName(Resource resource) { String resourceName = resource.getResourceName(); if (resourceName != null) { return resourceName; } if (resource instanceof ResourceWrapper) { return getWrappedResourceName(((ResourceWrapper) resource).getWrapped()); } return null; }
/** * Recursively unwarp the resource until we find the real resourceName * This is needed because the JSF2 specced ResourceWrapper doesn't override * the getResourceName() method :( * @param resource * @return the first non-null resourceName or <code>null</code> if none set */ private String getWrappedResourceName(Resource resource) { String resourceName = resource.getResourceName(); if (resourceName != null) { return resourceName; } if (resource instanceof ResourceWrapper) { return getWrappedResourceName(((ResourceWrapper) resource).getWrapped()); } return null; } }
/** * Recursively unwarp the resource until we find the real resourceName * This is needed because the JSF2 specced ResourceWrapper doesn't override * the getResourceName() method :( * @param resource * @return the first non-null resourceName or <code>null</code> if none set */ private String getWrappedResourceName(Resource resource) { String resourceName = resource.getResourceName(); if (resourceName != null) { return resourceName; } if (resource instanceof ResourceWrapper) { return getWrappedResourceName(((ResourceWrapper) resource).getWrapped()); } return null; } }