コード例 #1
0
ファイル: MdsExtractor.java プロジェクト: stetro/MDS-Viewer
 public void createFolder(PackageName packageName) {
   try {
     MDSSession mdsSession = getMdsSession();
     PTransaction transaction = getpTransaction(mdsSession);
     transaction.createPackage(packageName);
     mdsSession.flushChanges();
   } catch (Exception e) {
     throw new IllegalArgumentException("Could not create Folder ! " + e.getMessage());
   }
 }
コード例 #2
0
ファイル: MdsExtractor.java プロジェクト: stetro/MDS-Viewer
 public void createFile(String path, String content) {
   try {
     MDSSession session = getMdsSession();
     PTransaction transaction = getpTransaction(session);
     DocumentName mdsDocumentName = DocumentName.create(path);
     InputSource is = new InputSource(new StringReader(content));
     transaction.createDocument(mdsDocumentName, is);
     session.flushChanges();
   } catch (Exception e) {
     throw new IllegalArgumentException("Could not add new file ", e);
   }
 }
コード例 #3
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);
   }
 }
コード例 #4
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);
   }
 }
コード例 #5
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);
   }
 }
コード例 #6
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;
 }
コード例 #7
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);
 }
コード例 #8
0
ファイル: MdsExtractor.java プロジェクト: stetro/MDS-Viewer
 private PTransaction getpTransaction(MDSSession session) {
   return session.getPTransaction();
 }