}
private static ObjectAdapter getObjectAdapter(
final RendererContext rendererContext,
final String oidStrUnencoded) {
RootOidDefault rootOid = RootOidDefault.deString(oidStrUnencoded, getOidMarshaller());
final ObjectSpecId specId = rootOid.getObjectSpecId();
final ObjectSpecification spec = IsisContext.getSpecificationLoader().lookupBySpecId(specId);
if(spec == null) {
// eg "NONEXISTENT:123"
return null;
}
// TODO: the logic to figure out which PersistenceSession API to call should be pushed down into PersistenceSession itself.
final PersistenceSession persistenceSession = rendererContext.getPersistenceSession();
if(spec.containsFacet(ViewModelFacet.class)) {
// this is a hack; the RO viewer when rendering the URL for the view model loses the "view model" indicator
// ("*") from the specId, meaning that the marshalling logic above in RootOidDefault.deString() creates an
// oid in the wrong state. The code below checks for this and recreates the oid with the current state of 'view model'
if(!rootOid.isViewModel()) {
rootOid = new RootOidDefault(rootOid.getObjectSpecId(), rootOid.getIdentifier(), Oid.State.VIEWMODEL);
}
try {
return persistenceSession.getAdapterManager().adapterFor(rootOid);
} catch(final ObjectNotFoundException ex) {