Пример #1
0
 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
 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
 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
 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);
   }
 }