*
* @param resources resource keys to be expanded
* @return collection with all resource libraries expanded to particular resource keys (keeps ordering)
*/
public Collection<ResourceKey> expandResourceLibraries(Collection<ResourceKey> resources) {
ResourceLibraryFactory factory = ServiceTracker.getService(ResourceLibraryFactory.class);
Collection<ResourceKey> expandedResources = Sets.newLinkedHashSet();
for (ResourceKey resourceKey : resources) {
if (resourceKey.getResourceName().endsWith(ResourceLibraryRenderer.RESOURCE_LIBRARY_EXTENSION)) {
String libraryName = resourceKey.getLibraryName();
String resourceName = resourceKey.getResourceName().substring(0,
resourceKey.getResourceName().length() - ResourceLibraryRenderer.RESOURCE_LIBRARY_EXTENSION.length());
ResourceLibrary resourceLibrary = factory.getResourceLibrary(resourceName, libraryName);
if (resourceLibrary == null) {
throw new IllegalArgumentException("Resource library is null: " + libraryName + ":" + resourceName);
}