Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 34139 invoked by uid 500); 5 Mar 2003 18:48:01 -0000 Mailing-List: contact cocoon-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: cocoon-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cocoon-cvs@xml.apache.org Received: (qmail 34110 invoked by uid 500); 5 Mar 2003 18:48:00 -0000 Delivered-To: apmail-xml-cocoon2-cvs@apache.org Received: (qmail 34096 invoked from network); 5 Mar 2003 18:48:00 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 5 Mar 2003 18:48:00 -0000 Received: (qmail 3949 invoked by uid 1509); 5 Mar 2003 18:48:00 -0000 Date: 5 Mar 2003 18:48:00 -0000 Message-ID: <20030305184800.3948.qmail@icarus.apache.org> From: stephan@apache.org To: xml-cocoon2-cvs@apache.org Subject: cvs commit: xml-cocoon2/src/blocks/slide/samples sitemap.xmap X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N stephan 2003/03/05 10:48:00 Modified: src/blocks/slide/conf slide-repository.xconf slide-repository.xroles src/blocks/slide/java/org/apache/cocoon/components/repository Repository.java src/blocks/slide/java/org/apache/cocoon/components/repository/impl SlidePrincipalProvider.java src/blocks/slide/java/org/apache/cocoon/components/source/impl SlideSource.java SlideSourceFactory.java src/blocks/slide/samples sitemap.xmap Log: Add transaction support for setProperty, see Bug 17496. Add some fixes to use XML fragments in SourceProperties. And reverting the usage of the ComponentSelector, since the repository role depend heavy on Slide. Revision Changes Path 1.2 +21 -28 xml-cocoon2/src/blocks/slide/conf/slide-repository.xconf Index: slide-repository.xconf =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/slide/conf/slide-repository.xconf,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- slide-repository.xconf 31 Jan 2003 18:08:42 -0000 1.1 +++ slide-repository.xconf 5 Mar 2003 18:47:59 -0000 1.2 @@ -1,33 +1,26 @@ - + - - + + - - - + + - - - - - - + + + 1.2 +4 -6 xml-cocoon2/src/blocks/slide/conf/slide-repository.xroles Index: slide-repository.xroles =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/slide/conf/slide-repository.xroles,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- slide-repository.xroles 31 Jan 2003 18:08:42 -0000 1.1 +++ slide-repository.xroles 5 Mar 2003 18:47:59 -0000 1.2 @@ -1,11 +1,9 @@ - + - - - + InputStream object to read from the source. * This is the data at the point of invocation of this method, * so if this is Modifiable, you might get different content @@ -537,7 +561,7 @@ } catch (Exception e) { if (e instanceof IOException) { - throw (IOException)e; + throw (IOException) e; } throw new CascadingIOException("Could not create source", e); } finally { @@ -576,7 +600,7 @@ /** * Move the current source to a specified destination. * - * @param source + * @param source * * @throws SourceException If an exception occurs during * the move. @@ -599,7 +623,7 @@ /** * Copy the current source to a specified destination. * - * @param source + * @param source * * @throws SourceException If an exception occurs during * the copy. @@ -1574,6 +1598,7 @@ */ public void setSourceProperty(SourceProperty sourceproperty) throws SourceException { + getLogger().debug("Set source property"); try { revisionDescriptor.setProperty(sourceproperty.getName(), sourceproperty.getNamespace(), @@ -1582,10 +1607,17 @@ // Last modification date revisionDescriptor.setLastModified(new Date()); + nat.begin(); content.store(slideToken, this.config.getFilesPath()+this.path, revisionDescriptor, null); - } catch (SlideException se) { - throw new SourceException("Could not set property", se); + nat.commit(); + } catch (Exception se) { + try { + nat.rollback(); + } catch (Exception rbe) { + getLogger().error("Rollback failed for setting a source property", rbe); + } + throw new SourceException("Could not set source property", se); } } @@ -1607,9 +1639,28 @@ return null; } - return new SourceProperty(namespace, name, - revisionDescriptor.getProperty(name, - namespace).getValue().toString()); + final String quote = "\""; + NodeProperty np = revisionDescriptor.getProperty(name, namespace); + String pre = "<"+name+" xmlns="+quote+namespace+quote+" >"; + String post = ""; + + StringReader reader = new StringReader(pre+np.getValue().toString()+ + post); + InputSource src = new InputSource(reader); + + DOMParser parser = null; + Document doc = null; + + try { + parser = (DOMParser) this.manager.lookup(DOMParser.ROLE); + doc = parser.parseDocument(src); + } catch (Exception e) { + throw new SourceException("Could not parse property", e); + } finally { + this.manager.release((Component) parser); + } + + return new SourceProperty(doc.getDocumentElement()); } /** @@ -1627,13 +1678,34 @@ Vector sourceproperties = new Vector(); - NodeProperty property; + DOMParser parser = null; + String xml = ""; + + try { + parser = (DOMParser) this.manager.lookup(DOMParser.ROLE); + final String quote = "\""; + + for (Enumeration e = revisionDescriptor.enumerateProperties(); + e.hasMoreElements(); ) { + NodeProperty property = (NodeProperty) e.nextElement(); + String name = property.getName(); + String namespace = property.getNamespace(); + String pre = "<"+name+" xmlns="+quote+namespace+quote+" >"; + String post = ""; + + xml = pre+property.getValue().toString()+post; + StringReader reader = new StringReader(xml); + + Document doc = parser.parseDocument(new InputSource(reader)); - for (Enumeration e = revisionDescriptor.enumerateProperties(); - e.hasMoreElements(); ) { - property = (NodeProperty) e.nextElement(); - sourceproperties.addElement(new SourceProperty(property.getNamespace(), - property.getName(), property.getValue().toString())); + SourceProperty srcProperty = new SourceProperty(doc.getDocumentElement()); + + sourceproperties.addElement(srcProperty); + } + } catch (Exception e) { + throw new SourceException("Could not parse property "+xml, e); + } finally { + this.manager.release((Component) parser); } SourceProperty[] sourcepropertiesArray = new SourceProperty[sourceproperties.size()]; 1.3 +5 -14 xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/impl/SlideSourceFactory.java Index: SlideSourceFactory.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/impl/SlideSourceFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- SlideSourceFactory.java 31 Jan 2003 22:49:32 -0000 1.2 +++ SlideSourceFactory.java 5 Mar 2003 18:47:59 -0000 1.3 @@ -166,14 +166,9 @@ path = "/"; } - ComponentSelector repositories = null; Repository repository = null; - try { - repositories = (ComponentSelector) this.manager.lookup(Repository.ROLE+ - "Selector"); - - repository = (Repository) repositories.select(repositoryname); + repository = (Repository) this.manager.lookup(Repository.ROLE); if ( !(repository instanceof SlideRepository)) { getLogger().error("Can't get Slide repository"); @@ -195,21 +190,17 @@ source.enableLogging(getLogger()); source.contextualize(this.context); + source.compose(this.manager); return source; } catch (ComponentException ce) { getLogger().error("Could not lookup for component.", ce); } finally { - if ((repository!=null) && (repository instanceof Component)) { - repositories.release((Component) repository); + if (repository!=null) { + this.manager.release(repository); } repository = null; - - if (repositories!=null) { - this.manager.release(repositories); - } - repositories = null; } return null; 1.6 +1 -1 xml-cocoon2/src/blocks/slide/samples/sitemap.xmap Index: sitemap.xmap =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/slide/samples/sitemap.xmap,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- sitemap.xmap 26 Feb 2003 15:28:32 -0000 1.5 +++ sitemap.xmap 5 Mar 2003 18:48:00 -0000 1.6 @@ -128,7 +128,7 @@ - +