if (service == null) {
return null;
}
// check that the service is part of catalog... If not add
ICatalog local = CatalogPlugin.getDefault().getLocalCatalog();
if (local.getById(IService.class, service.getID(), new NullProgressMonitor()) == null) {
local.add(resource.service(null));
}
LayerImpl layer = (LayerImpl) ProjectFactory.eINSTANCE.createLayer();
if (layer == null) {
throw new IOException(
"Unable to create layer from resource '" + resource.getIdentifier() + "'"); //$NON-NLS-1$ //$NON-NLS-2$
}
ID resourceID = resource.getID();
layer.setResourceID(resourceID);
// process the style content extension point to initially populate
// the style blackboard with style info
// TODO: the style objects need access to preference system
final Layer theLayer = layer;
ICatalog localCatalog = local;
ID layerResourceID = layer.getResourceID();
IProgressMonitor monitor = ProgressManager.instance().get();
List<IResolve> resolves = localCatalog.find(layerResourceID, monitor);
if (resolves.isEmpty()) {
// Identifier lookup is being inconsistent; this often happens when code trips up over
// converting URLs to and from Files
throw new IOException("Could not find " + layerResourceID + " in local catalog");
}