stephan 2003/03/06 01:40:25
Modified: src/blocks/slide/java/org/apache/cocoon/components/source/impl SlideSource.java Log: Use atomic transactions for all other methods. Revision Changes Path 1.6 +51 -11 xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/impl/SlideSource.java Index: SlideSource.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/impl/SlideSource.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- SlideSource.java 5 Mar 2003 18:47:59 -0000 1.5 +++ SlideSource.java 6 Mar 2003 09:40:24 -0000 1.6 @@ -608,11 +608,18 @@ public void move(Source source) throws SourceException { if (source instanceof SlideSource) { try { + nat.begin(); this.macro.move(slideToken, this.config.getFilesPath()+this.path, this.config.getFilesPath()+ ((SlideSource) source).path); - } catch (SlideException se) { + nat.commit(); + } catch (Exception se) { + try { + nat.rollback(); + } catch (Exception rbe) { + getLogger().error("Rollback failed for moving source", rbe); + } throw new SourceException("Could not move source.", se); } } else { @@ -631,11 +638,18 @@ public void copy(Source source) throws SourceException { if (source instanceof SlideSource) { try { + nat.begin(); this.macro.copy(slideToken, this.config.getFilesPath()+this.path, this.config.getFilesPath()+ ((SlideSource) source).path); - } catch (SlideException se) { + nat.commit(); + } catch (Exception se) { + try { + nat.rollback(); + } catch (Exception rbe) { + getLogger().error("Rollback failed for moving source", rbe); + } throw new SourceException("Could not move source.", se); } } else { @@ -650,10 +664,18 @@ */ public boolean delete() { try { + nat.begin(); this.macro.delete(slideToken, this.config.getFilesPath()+this.path); + nat.commit(); return true; - } catch (SlideException se) { + } catch (Exception se) { + getLogger().error("Could not delete source.",se); + try { + nat.rollback(); + } catch (Exception rbe) { + getLogger().error("Rollback failed for moving source", rbe); + } return false; } } @@ -820,16 +842,22 @@ revisionDescriptor.setOwner(slideToken.getCredentialsToken().getPublicCredentials()); try { + nat.begin(); structure.create(slideToken, collection, this.config.getFilesPath()+this.path+"/"+ collectionname); content.create(slideToken, this.config.getFilesPath()+this.path+"/"+ collectionname, revisionDescriptor, null); - } catch (SlideException se) { + nat.commit(); + } catch (Exception se) { + try { + nat.rollback(); + } catch (Exception rbe) { + getLogger().error("Rollback failed for creating collection", rbe); + } throw new SourceException("Could not create collection.", se); } - } /** @@ -1050,6 +1078,7 @@ this.path, subject, action, inheritable, negative); + nat.begin(); this.security.grantPermission(this.slideToken, permission); // Last modification date @@ -1057,8 +1086,13 @@ content.store(slideToken, this.config.getFilesPath()+this.path, revisionDescriptor, null); - - } catch (SlideException se) { + nat.commit(); + } catch (Exception se) { + try { + nat.rollback(); + } catch (Exception rbe) { + getLogger().error("Rollback failed for granting permission", rbe); + } throw new SourceException("Couldn't grant permission", se); } } @@ -1255,6 +1289,7 @@ this.path, subject, action, inheritable, negative); + nat.begin(); this.security.revokePermission(this.slideToken, permission); // Last modification date @@ -1262,9 +1297,14 @@ content.store(slideToken, this.config.getFilesPath()+this.path, revisionDescriptor, null); - - } catch (SlideException se) { - throw new SourceException("Couldn't grant permission", se); + nat.commit(); + } catch (Exception se) { + try { + nat.rollback(); + } catch (Exception rbe) { + getLogger().error("Rollback failed for removing permission", rbe); + } + throw new SourceException("Couldn't remove permission", se); } }