/**
* @see org.apache.lenya.transaction.Transactionable#saveTransactionable()
*/
public synchronized void saveTransactionable() throws TransactionException {
if (!isCheckedOut()) {
throw new TransactionException("Cannot save node [" + this.sourceURI
+ "]: not checked out!");
}
if (getLogger().isDebugEnabled()) {
getLogger().debug("Saving [" + this + "] to source [" + getRealSourceURI() + "]");
}
if (this.data != null) {
SourceResolver resolver = null;
ModifiableSource source = null;
InputStream in = null;
OutputStream out = null;
try {
resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
source = (ModifiableSource) resolver.resolveURI(getRealSourceURI());
out = source.getOutputStream();
byte[] buf = new byte[4096];
in = new ByteArrayInputStream(this.data);
int read = in.read(buf);
while (read > 0) {
out.write(buf, 0, read);
read = in.read(buf);
}
} catch (Exception e) {
throw new TransactionException(e);
} finally {
try {
if (in != null) {
in.close();