public Resource create( final ResourceManager manager,
ResourceData data,
final ResourceKey context )
throws ResourceCreationException, ResourceLoadingException {
if ( data instanceof CachingResourceBundleData ) {
final CachingResourceBundleData cachingResourceBundleData = (CachingResourceBundleData) data;
data = cachingResourceBundleData.getBackend();
}
if ( data instanceof RepositoryResourceBundleData == false ) {
data = manager.loadResourceBundle( data.getKey() );
if ( data instanceof CachingResourceBundleData ) {
final CachingResourceBundleData cachingResourceBundleData = (CachingResourceBundleData) data;
data = cachingResourceBundleData.getBackend();
}
}
if ( data instanceof RepositoryResourceBundleData == false ) {
throw new ContentNotRecognizedException( "No valid handler for the given content." );
}
final RepositoryResourceBundleData bdata = (RepositoryResourceBundleData) data;
final Repository repository = bdata.getRepository();
try {
final StaticDocumentBundle bundle = new StaticDocumentBundle( repository, manager, bdata.getBundleKey() );
return new SimpleResource( data.getKey(), bundle, getFactoryType(), data.getVersion( manager ) );
} catch ( ResourceException e ) {
throw new ResourceCreationException( "Unable to interpret document-bundle", e );
}
}