Package com.dbxml.db.core.transaction

Examples of com.dbxml.db.core.transaction.Transaction


   }

   public static final String[] PARAMS_insertValue = {"value"};

   public String insertValue(byte[] value) throws DBException {
      Transaction tx = new Transaction();
      try {
         return col.insertRecord(tx, new Value(value)).toString();
      }
      catch ( DBException e ) {
         tx.cancel();
         throw e;
      }
      finally {
         if ( tx.getStatus() == Transaction.ACTIVE )
            tx.commit();
      }
   }
View Full Code Here


   }

   public static final String[] PARAMS_setValue = {"key", "value"};

   public void setValue(String key, byte[] value) throws DBException {
      Transaction tx = new Transaction();
      try {
         col.setRecord(tx, key, new Value(value));
      }
      catch ( DBException e ) {
         tx.cancel();
         throw e;
      }
      finally {
         if ( tx.getStatus() == Transaction.ACTIVE )
            tx.commit();
      }
   }
View Full Code Here

   }

   public static final String[] PARAMS_getValue = {"key"};

   public byte[] getValue(String key) throws DBException {
      Transaction tx = new Transaction();
      try {
         Record rec = col.getRecord(tx, key);
         if ( rec == null )
            throw new DBException(FaultCodes.COL_CANNOT_RETRIEVE, "Record '"+key+"' not found");

         return rec.getValue().getData();
      }
      catch ( DBException e ) {
         tx.cancel();
         throw e;
      }
      finally {
         if ( tx.getStatus() == Transaction.ACTIVE )
            tx.commit();
      }
   }
View Full Code Here

   public static final String[] PARAMS_queryCollection = {"style", "query", "nsMap"};
   public static final String REST_CONTENT_TYPE_queryCollection = Headers.TYPE_TEXT_XML;

   public String queryCollection(String style, String query, Map nsMap) throws DBException {
      Transaction tx = new Transaction();
      try {
         return ResultSetWrapper.toText(col.queryCollection(tx, style, query, new NamespaceMap(nsMap)));
      }
      catch ( DBException e ) {
         tx.cancel();
         throw e;
      }
      finally {
         if ( tx.getStatus() == Transaction.ACTIVE )
            tx.commit();
      }
   }
View Full Code Here

   public static final String[] PARAMS_queryDocument = {"style", "query", "nsMap", "key"};
   public static final String REST_CONTENT_TYPE_queryDocument = Headers.TYPE_TEXT_XML;

   public String queryDocument(String style, String query, Map nsMap, String key) throws DBException {
      Transaction tx = new Transaction();
      try {
         return ResultSetWrapper.toText(col.queryDocument(tx, style, query, new NamespaceMap(nsMap), key));
      }
      catch ( DBException e ) {
         tx.cancel();
         throw e;
      }
      finally {
         if ( tx.getStatus() == Transaction.ACTIVE )
            tx.commit();
      }
   }
View Full Code Here

         fileHeader.write();

         createTransactionLog();
         openTransactionLog();

         Transaction tx = new Transaction();
         checkTransaction(tx);

         try {
            tx.commit();
         }
         catch ( DBException e ) {
            /** @todo This is VERY bad */
            tx.cancel();
            throw e;
         }

         closeTransactionLog();

View Full Code Here

   }

   public synchronized boolean close() throws DBException {
      try {
         if ( opened ) {
            Transaction tx = new Transaction();
            checkTransaction(tx);
            try {
               tx.commit();
            }
            catch ( DBException e ) {
               /** @todo This is VERY bad */
               tx.cancel();
               throw e;
            }

            closeTransactionLog();

View Full Code Here

   private XMLSerializableAdapter groupsCol;
   private XMLSerializableAdapter contentCol;

   public String getMachineID() {
      if ( machineID == null ) {
         Transaction tx = new Transaction();

         try {
            Collection sysCol = collection.getSystemCollection();
            Collection cfgCol = sysCol.getCollection(SystemCollection.CONFIGS);
        DOMAdapter domAdapter = new DOMAdapter(cfgCol);
        Document doc = domAdapter.getDocument(tx, SYNCID_XML);
            if ( doc != null ) {
               Element elem = doc.getDocumentElement();
               machineID = elem.getAttribute(ID);
            }
            else {
               machineID = cfgCol.createNewOID().toString();
               doc = DOMHelper.newDocument();
               Element elem = doc.createElement(SYNC);
               doc.appendChild(elem);
               elem.setAttribute(ID, machineID);
          domAdapter.setDocument(tx, SYNCID_XML, doc);
            }
         }
         catch ( Exception e ) {
            try {
               tx.cancel();
            }
            catch ( DBException ex ) {
               ex.printStackTrace(System.err);
            }

            // If this doesn't work, something is VERY wrong
            e.printStackTrace(System.err);
            machineID = collection.createNewOID().toString();
         }
      finally {
        if ( tx.getStatus() == Transaction.ACTIVE ) {
          try {
             tx.commit();
          }
          catch ( DBException e ) {
            e.printStackTrace(System.err);
          }
        }
View Full Code Here

   }

   public static final String[] PARAMS_removeGroup = {"group"};

   public void removeGroup(String group) throws DBException {
      Transaction tx = new Transaction();
      try {
         XMLSerializableAdapter col = getGroupsCollection();
         col.remove(tx, group);
      }
      catch ( DBException e ) {
         tx.cancel();
         throw e;
      }
    finally {
       if ( tx.getStatus() == Transaction.ACTIVE )
           tx.commit();
    }
   }
View Full Code Here

           tx.commit();
    }
   }

   public String[] listGroups() throws DBException {
      Transaction tx = new Transaction();
      try {
         XMLSerializableAdapter col = getGroupsCollection();
      Key[] keys = col.listKeys(tx);
      String[] result = new String[keys.length];
      for ( int i = 0; i < keys.length; i++ )
        result[i] = keys[i].toString();
         return result;
      }
      catch ( DBException e ) {
         tx.cancel();
         throw e;
      }
    finally {
       if ( tx.getStatus() == Transaction.ACTIVE )
           tx.commit();
    }
   }
View Full Code Here

TOP

Related Classes of com.dbxml.db.core.transaction.Transaction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.