List of usage examples for org.apache.commons.transaction.file ResourceManagerException getStatus
public int getStatus()
From source file:org.apache.slide.store.txfile.AbstractTxFileStoreService.java
protected XAException createXAException(ResourceManagerException e) { if (e.getStatus() == ResourceManagerException.ERR_DUP_TX) { return new XAException(XAException.XAER_DUPID); } else if (e.getStatus() == ResourceManagerException.ERR_TXID_INVALID) { return new XAException(XAException.XAER_NOTA); } else {/*from w w w.j a v a 2 s. co m*/ return new XAException(e.toString()); } }
From source file:org.apache.slide.store.txfile.TxFileContentStore.java
public NodeRevisionContent retrieveRevisionContent(Uri uri, NodeRevisionDescriptor revisionDescriptor) throws ServiceAccessException, RevisionNotFoundException { String revisionUri = uri.toString() + "_" + revisionDescriptor.getRevisionNumber(); try {/* www . ja v a 2 s . c o m*/ Object txId = getActiveTxId(); InputStream is; if (txId != null) { is = rm.readResource(txId, revisionUri); } else { is = rm.readResource(revisionUri); } NodeRevisionContent result = new NodeRevisionContent(); result.setContent(is); return result; } catch (ResourceManagerException e) { if (e.getStatus() == ResourceManagerException.ERR_NO_SUCH_RESOURCE) { throw new RevisionNotFoundException(uri.toString(), revisionDescriptor.getRevisionNumber()); } else { throwInternalError(e, uri.toString()); return null; // XXX fake (is never called) } } }
From source file:org.apache.slide.store.txfile.XMLResourceDescriptor.java
/** * Stores this descriptor to the resource manager. * * @throws ServiceAccessException if anything goes wrong at system level * @throws ObjectNotFoundException if the descriptor has not been created before *//* w ww. j av a2 s . co m*/ public void save() throws ServiceAccessException, ObjectNotFoundException { if (txId == null) { store.throwInternalError("Not inside tx"); } logger.logFine("Tx " + txId + " saves data for " + loadPath); OutputStream os = null; try { os = rm.writeResource(txId, loadPath); save(os); registeredForSaving = false; } catch (ResourceManagerException e) { if (e.getStatus() == ResourceManagerException.ERR_NO_SUCH_RESOURCE) { throw new ObjectNotFoundException(uri); } else { store.throwInternalError(e, uri); } } catch (IOException e) { store.throwInternalError(e); } finally { try { if (os != null) { os.close(); } } catch (IOException e) { } } }
From source file:org.apache.slide.store.txfile.XMLResourceDescriptor.java
/** * Creates this descriptor in the resource manager. * * @throws ServiceAccessException if anything goes wrong at system level * @throws ObjectAlreadyExistsException if the descriptor already exists *///from w ww. j a v a 2s. co m public void create() throws ServiceAccessException, ObjectAlreadyExistsException { logger.logFiner("Tx " + txId + " creates " + loadPath); if (txId == null) { store.throwInternalError("Not inside tx"); } try { rm.createResource(txId, loadPath, false); init(); } catch (ResourceManagerException e) { if (e.getStatus() == ResourceManagerException.ERR_RESOURCE_EXISTS) { throw new ObjectAlreadyExistsException(uri.toString()); } else { store.throwInternalError(e, uri); } } }
From source file:org.apache.slide.store.txfile.XMLResourceDescriptor.java
/** * Deletes this descriptor from the resource manager. * * @throws ServiceAccessException if anything goes wrong at system level * @throws ObjectNotFoundException if the descriptor does not exist *///w w w . ja v a2 s . c om public void delete() throws ServiceAccessException, ObjectNotFoundException { logger.logFiner("Tx " + txId + " deletes " + loadPath); if (txId == null) { store.throwInternalError("Not inside tx"); } try { rm.deleteResource(txId, loadPath, false); object = null; registeredForSaving = false; // do not save what is no longer there } catch (ResourceManagerException e) { if (e.getStatus() == ResourceManagerException.ERR_NO_SUCH_RESOURCE) { throw new ObjectNotFoundException(uri.toString()); } else { store.throwInternalError(e, uri); } } }
From source file:org.apache.slide.store.txfile.XMLResourceDescriptor.java
/** * Loads this descriptor from the resource manager. * * @throws ServiceAccessException if anything goes wrong at system level * @throws ObjectNotFoundException if the descriptor does not exist *//*from w w w . j a v a 2s .co m*/ public void load() throws ServiceAccessException, ObjectNotFoundException { logger.logFiner("Tx " + txId + " loads data for " + loadPath); InputStream is = null; try { if (txId != null) { if (rm.resourceExists(txId, loadPath)) { is = rm.readResource(txId, loadPath); load(is); } else { init(); } } else { logger.logFinest("Faking read access from outside tx for " + loadPath); if (rm.resourceExists(loadPath)) { is = rm.readResource(loadPath); load(is); } else { init(); } } } catch (JDOMException je) { store.throwInternalError(je, uri); } catch (IOException ioe) { store.throwInternalError(ioe, uri); } catch (ResourceManagerException e) { if (e.getStatus() == ResourceManagerException.ERR_NO_SUCH_RESOURCE) { throw new ObjectNotFoundException(uri); } else { store.throwInternalError(e, uri); } } finally { try { if (is != null) { is.close(); } } catch (IOException e) { } } }