private PDocument getPDocument(DocumentName documentName, Long key) { try { MDSInstance instance = storeInitializer.getMDSInstance(); MDSSession session = createSession(instance); PManager pManager = instance.getPersistenceManager(); PContext pContext = session.getPContext(); if (key > 0) { return pManager.getVersionSupport().getDocument(pContext, documentName, key); } else { return pManager.getDocument(pContext, documentName); } } catch (MDSAccessException e) { throw new IllegalArgumentException("Could not read ", e); } }