boolean resolved = false;
if (contractPreferred != null)
{
for (ContractResourceLoader loader : getResourceHandlerSupport().getContractResourceLoaders())
{
ResourceMeta resourceMeta = deriveResourceMeta(
facesContext, loader, resourceId, contractPreferred);
if (resourceMeta != null)
{
String contentType = facesContext.getExternalContext().getMimeType(
resourceMeta.getResourceName());
resource = new ResourceImpl(resourceMeta, loader,
getResourceHandlerSupport(), contentType);
// cache it
getResourceLoaderCache().putResource(resourceId, resourceMeta, loader,
new ResourceCachedInfo(resource.getURL(), resource.getRequestPath()));
resolved = true;
break;
}
}
}
if (!resolved && !contracts.isEmpty())
{
for (ContractResourceLoader loader :
getResourceHandlerSupport().getContractResourceLoaders())
{
for (String contract : contracts)
{
ResourceMeta resourceMeta = deriveResourceMeta(
facesContext, loader, resourceId, contract);
if (resourceMeta != null)
{
String contentType = facesContext.getExternalContext().getMimeType(
resourceMeta.getResourceName());
resource = new ResourceImpl(resourceMeta, loader,
getResourceHandlerSupport(), contentType);
// cache it
getResourceLoaderCache().putResource(resourceId, resourceMeta, loader,
new ResourceCachedInfo(resource.getURL(), resource.getRequestPath()));
resolved = true;
break;
}
}
}
}
if (!resolved)
{
for (ResourceLoader loader : getResourceHandlerSupport().getResourceLoaders())
{
ResourceMeta resourceMeta = deriveResourceMeta(facesContext, loader, resourceId);
if (resourceMeta != null)
{
String contentType = facesContext.getExternalContext().getMimeType(
resourceMeta.getResourceName());
resource = new ResourceImpl(resourceMeta, loader, getResourceHandlerSupport(), contentType);
// cache it
getResourceLoaderCache().putResource(resourceId, resourceMeta, loader,