final long version = data.getVersion(manager);
final ResourceKey key = data.getKey();
final Object o = key.getFactoryParameters().get(DOMAIN_ID);
if (o == null)
{
throw new ResourceLoadingException("Your resource-key must have a domain-id factory key defined.");
}
try
{
final InMemoryMetadataDomainRepository repo = new InMemoryMetadataDomainRepository();
final XmiParser parser = new XmiParser();
final Domain domain = parser.parseXmi(stream);
domain.setId(String.valueOf(o));
repo.storeDomain(domain, true);
return new SimpleResource(key, repo, IMetadataDomainRepository.class, version);
}
catch (ResourceCreationException e)
{
throw e;
}
catch (ResourceLoadingException e)
{
throw e;
}
catch (IOException ioe)
{
throw new ResourceLoadingException("IOError", ioe);
}
catch (Exception e)
{
throw new ResourceCreationException("Generic Error", e);
}