コード例 #1
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);
   }
 }
コード例 #2
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;
 }