コード例 #1
0
ファイル: MdsExtractor.java プロジェクト: stetro/MDS-Viewer
 public void updateFile(DocumentName documentName, String content) {
   try {
     MDSSession session = getMdsSession();
     PTransaction transaction = getpTransaction(session);
     PManager pManager = storeInitializer.getMDSInstance().getPersistenceManager();
     PContext pContext = session.getPContext();
     PDocument pdocument = pManager.getDocument(pContext, documentName);
     InputSource is = new InputSource(new StringReader(content));
     transaction.saveDocument(pdocument, true, is);
     session.flushChanges();
   } catch (Exception e) {
     throw new IllegalArgumentException("Could not edit file ", e);
   }
 }
コード例 #2
0
ファイル: MdsExtractor.java プロジェクト: stetro/MDS-Viewer
 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);
   }
 }
コード例 #3
0
ファイル: MdsExtractor.java プロジェクト: stetro/MDS-Viewer
 public void deleteFile(ResourceName path) {
   try {
     MDSSession session = getMdsSession();
     PTransaction transaction = getpTransaction(session);
     PManager pManager = storeInitializer.getMDSInstance().getPersistenceManager();
     PContext pContext = session.getPContext();
     if (path instanceof PackageName) {
       PPackage ppackage = pManager.getPackage(pContext, (PackageName) path);
       transaction.deletePackage(ppackage, true);
     } else {
       PDocument pdocument = pManager.getDocument(pContext, (DocumentName) path);
       transaction.deleteDocument(pdocument, true);
     }
     session.flushChanges();
   } catch (Exception e) {
     throw new IllegalArgumentException("Could not remove file ", e);
   }
 }
コード例 #4
0
ファイル: MdsExtractor.java プロジェクト: stetro/MDS-Viewer
 public boolean isAvailable(ResourceName documentName) {
   try {
     MDSSession session = getMdsSession();
     PManager pManager = storeInitializer.getMDSInstance().getPersistenceManager();
     PContext pContext = session.getPContext();
     if (documentName instanceof PackageName) {
       PPackage ppackage = pManager.getPackage(pContext, (PackageName) documentName);
       if (ppackage == null) return false;
     } else {
       PDocument pdocument = pManager.getDocument(pContext, (DocumentName) documentName);
       if (pdocument == null) return false;
     }
   } catch (InvalidNamespaceException e) {
     return false;
   } catch (MDSAccessException e) {
     return false;
   }
   return true;
 }
コード例 #5
0
ファイル: MdsExtractor.java プロジェクト: stetro/MDS-Viewer
 private PDocument getpDocument(DocumentName documentName) throws MDSAccessException {
   MDSSession session = getMdsSession();
   PManager pManager = storeInitializer.getMDSInstance().getPersistenceManager();
   PContext pContext = session.getPContext();
   return pManager.getDocument(pContext, documentName);
 }