// If the id was not specified, look for an id generator
if (id == null && idFactories != null)
{
MongoIdFactory mongoIdFactory = idFactories.get(uri.trimSegments(uri.segmentCount() - 2).toString());
if (mongoIdFactory != null)
{
id = mongoIdFactory.getNextId();
uri = uri.appendSegment(id.toString());
resource.setURI(resource.getURI().trimSegments(1).appendSegment(id.toString()));
}
}