You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2008/03/03 22:54:43 UTC
svn commit: r633288 - in /cocoon/trunk/blocks/cocoon-portal:
cocoon-portal-converter-castor/src/main/java/org/apache/cocoon/portal/converter/castor/
cocoon-portal-converter-castor/src/main/resources/org/apache/cocoon/portal/converter/castor/
cocoon-por...
Author: cziegeler
Date: Mon Mar 3 13:54:41 2008
New Revision: 633288
URL: http://svn.apache.org/viewvc?rev=633288&view=rev
Log:
Fix bugs and config after refactoring.
Added:
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/util/IncludeXMLConsumer.java (with props)
Modified:
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/java/org/apache/cocoon/portal/converter/castor/CastorSourceConverter.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/resources/org/apache/cocoon/portal/converter/castor/copletdefinition.xml
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/resources/org/apache/cocoon/portal/converter/castor/copletinstance.xml
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/resources/org/apache/cocoon/portal/converter/castor/layout.xml
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/DefaultCopletAspect.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/java/org/apache/cocoon/portal/converter/castor/CastorSourceConverter.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/java/org/apache/cocoon/portal/converter/castor/CastorSourceConverter.java?rev=633288&r1=633287&r2=633288&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/java/org/apache/cocoon/portal/converter/castor/CastorSourceConverter.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/java/org/apache/cocoon/portal/converter/castor/CastorSourceConverter.java Mon Mar 3 13:54:41 2008
@@ -81,6 +81,20 @@
/** By default we use the logger for this class. */
private Log logger = LogFactory.getLog(getClass());
+ /** The source resolver. */
+ protected SourceResolver resolver;
+
+ /** The configuration for loading/saving the profile. */
+ protected Properties configuration;
+
+ public void setSourceResolver(SourceResolver sr) {
+ this.resolver = sr;
+ }
+
+ public void setConfiguration(Properties configuration) {
+ this.configuration = configuration;
+ }
+
public Log getLogger() {
return this.logger;
}
@@ -102,8 +116,7 @@
}
protected Object getObject(InputStream stream,
- PersistenceType type,
- Map parameters)
+ PersistenceType type)
throws ProfileException {
try {
threadLocalMap.set(type);
@@ -122,8 +135,7 @@
protected void storeObject(OutputStream stream,
Object object,
- PersistenceType type,
- Map parameters)
+ PersistenceType type)
throws ProfileException {
Object references = object;
if ( object instanceof Collection && !(object instanceof CollectionWrapper) ) {
@@ -134,14 +146,7 @@
threadLocalMap.set(type);
Marshaller marshaller = new Marshaller( writer );
marshaller.setMapping((Mapping)((Object[])this.mappings.get(type.getType()))[0]);
- boolean suppressXSIType = this.defaultSuppressXSIType;
- if ( parameters != null ) {
- Boolean value = (Boolean)parameters.get("suppressXSIType");
- if (value != null) {
- suppressXSIType = value.booleanValue();
- }
- }
- marshaller.setSuppressXSIType(suppressXSIType);
+ marshaller.setSuppressXSIType(this.defaultSuppressXSIType);
marshaller.marshal(references);
writer.close();
} catch (MappingException e) {
@@ -223,20 +228,6 @@
}
}
- /** The source resolver. */
- protected SourceResolver resolver;
-
- /** The configuration for loading/saving the profile. */
- protected Properties configuration;
-
- public void setSourceResolver(SourceResolver sr) {
- this.resolver = sr;
- }
-
- public void setConfiguration(Properties configuration) {
- this.configuration = configuration;
- }
-
protected String getURI(ProfileKey key, String type, boolean load)
throws Exception {
// find uri in configuration
@@ -254,7 +245,7 @@
throw new ProfileException("Configuration for key '" + config.toString() + "' is missing.");
}
- return PropertyHelper.getProperty(uri, key, null);
+ return PropertyHelper.replace(uri, key, null);
}
/**
@@ -263,14 +254,12 @@
public Object loadProfile(ProfileKey key, PersistenceType type)
throws Exception {
final String uri = this.getURI( key, type.getType(), true );
-
Source source = null;
try {
source = this.resolver.resolveURI(uri);
return this.getObject(source.getInputStream(),
- type,
- null);
+ type);
} finally {
this.resolver.release(source);
}
@@ -290,8 +279,7 @@
if ( source instanceof ModifiableSource ) {
this.storeObject( ((ModifiableSource)source).getOutputStream(),
profile,
- type,
- null);
+ type);
return;
}
} finally {
@@ -302,9 +290,8 @@
final StringBuffer buffer = new StringBuffer(uri);
ByteArrayOutputStream writer = new ByteArrayOutputStream();
this.storeObject(writer,
- profile,
- type,
- null);
+ profile,
+ type);
buffer.append("&content=");
try {
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/resources/org/apache/cocoon/portal/converter/castor/copletdefinition.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/resources/org/apache/cocoon/portal/converter/castor/copletdefinition.xml?rev=633288&r1=633287&r2=633288&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/resources/org/apache/cocoon/portal/converter/castor/copletdefinition.xml (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/resources/org/apache/cocoon/portal/converter/castor/copletdefinition.xml Mon Mar 3 13:54:41 2008
@@ -19,7 +19,7 @@
<mapping>
<description>Coplet definition mapping file</description>
- <class name="org.apache.cocoon.portal.persistence.castor.CollectionWrapper">
+ <class name="org.apache.cocoon.portal.converter.castor.CollectionWrapper">
<map-to xml="coplets" />
<field name="objects"
@@ -47,13 +47,13 @@
<field name="attributes"
type="org.exolab.castor.mapping.MapItem"
collection="map"
- handler="org.apache.cocoon.portal.persistence.castor.AttributesFieldHandler">
+ handler="org.apache.cocoon.portal.converter.castor.AttributesFieldHandler">
<bind-xml name="attribute"/>
</field>
<field name="copletType"
type="java.lang.String"
- handler="org.apache.cocoon.portal.persistence.castor.ReferenceFieldHandler">
+ handler="org.apache.cocoon.portal.converter.castor.ReferenceFieldHandler">
<bind-xml name="coplet-type"/>
</field>
</class>
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/resources/org/apache/cocoon/portal/converter/castor/copletinstance.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/resources/org/apache/cocoon/portal/converter/castor/copletinstance.xml?rev=633288&r1=633287&r2=633288&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/resources/org/apache/cocoon/portal/converter/castor/copletinstance.xml (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/resources/org/apache/cocoon/portal/converter/castor/copletinstance.xml Mon Mar 3 13:54:41 2008
@@ -19,7 +19,7 @@
<mapping>
<description>Coplet instance mapping file</description>
- <class name="org.apache.cocoon.portal.persistence.castor.CollectionWrapper">
+ <class name="org.apache.cocoon.portal.converter.castor.CollectionWrapper">
<map-to xml="coplets" />
<field name="objects"
@@ -38,14 +38,14 @@
<field name="copletDefinition"
type="java.lang.String"
- handler="org.apache.cocoon.portal.persistence.castor.ReferenceFieldHandler">
+ handler="org.apache.cocoon.portal.converter.castor.ReferenceFieldHandler">
<bind-xml name="coplet-definition"/>
</field>
<field name="attributes"
type="org.exolab.castor.mapping.MapItem"
collection="map"
- handler="org.apache.cocoon.portal.persistence.castor.AttributesFieldHandler">
+ handler="org.apache.cocoon.portal.converter.castor.AttributesFieldHandler">
<bind-xml name="attribute"/>
</field>
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/resources/org/apache/cocoon/portal/converter/castor/layout.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/resources/org/apache/cocoon/portal/converter/castor/layout.xml?rev=633288&r1=633287&r2=633288&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/resources/org/apache/cocoon/portal/converter/castor/layout.xml (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-converter-castor/src/main/resources/org/apache/cocoon/portal/converter/castor/layout.xml Mon Mar 3 13:54:41 2008
@@ -23,7 +23,7 @@
<field name="parameters"
type="org.exolab.castor.mapping.MapItem"
collection="map"
- handler="org.apache.cocoon.portal.persistence.castor.ParametersFieldHandler">
+ handler="org.apache.cocoon.portal.converter.castor.ParametersFieldHandler">
<bind-xml name="parameter" node="element"/>
</field>
</class>
@@ -33,7 +33,7 @@
verify-constructable="false">
<field name="rendererName" type="java.lang.String"
- handler="org.apache.cocoon.portal.persistence.castor.ReferenceFieldHandler">
+ handler="org.apache.cocoon.portal.converter.castor.ReferenceFieldHandler">
<bind-xml name="renderer" node="attribute"/>
</field>
@@ -43,7 +43,7 @@
<field name="layoutType"
type="java.lang.String"
- handler="org.apache.cocoon.portal.persistence.castor.ReferenceFieldHandler">
+ handler="org.apache.cocoon.portal.converter.castor.ReferenceFieldHandler">
<bind-xml name="type" node="attribute"/>
</field>
</class>
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/DefaultCopletAspect.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/DefaultCopletAspect.java?rev=633288&r1=633287&r2=633288&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/DefaultCopletAspect.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/DefaultCopletAspect.java Mon Mar 3 13:54:41 2008
@@ -28,6 +28,7 @@
import org.apache.cocoon.portal.om.LayoutException;
import org.apache.cocoon.portal.om.LayoutFeatures;
import org.apache.cocoon.portal.services.PortalManager;
+import org.apache.cocoon.portal.util.IncludeXMLConsumer;
import org.apache.cocoon.portal.util.XMLUtils;
import org.apache.commons.lang.BooleanUtils;
import org.xml.sax.ContentHandler;
@@ -90,7 +91,7 @@
XMLUtils.endElement(handler, "script");
} else {
final CopletAdapter copletAdapter = cid.getCopletDefinition().getCopletType().getCopletAdapter();
- copletAdapter.toSAX(cid, handler);
+ copletAdapter.toSAX(cid, new IncludeXMLConsumer(handler));
}
if ( config.rootTag ) {
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java?rev=633288&r1=633287&r2=633288&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java Mon Mar 3 13:54:41 2008
@@ -31,6 +31,7 @@
import org.apache.cocoon.portal.om.Layout;
import org.apache.cocoon.portal.om.LayoutException;
import org.apache.cocoon.portal.services.VariableResolver;
+import org.apache.cocoon.portal.util.IncludeXMLConsumer;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceResolver;
import org.apache.excalibur.xml.xslt.XSLTProcessor;
@@ -130,6 +131,7 @@
theTransformer.setParameter((String)entry.getKey(), entry.getValue());
}
}
+ handler = new IncludeXMLConsumer(handler);
SAXResult result = new SAXResult(handler);
if (handler instanceof LexicalHandler) {
result.setLexicalHandler((LexicalHandler) handler);
Added: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/util/IncludeXMLConsumer.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/util/IncludeXMLConsumer.java?rev=633288&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/util/IncludeXMLConsumer.java (added)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/util/IncludeXMLConsumer.java Mon Mar 3 13:54:41 2008
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.util;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+
+/**
+ * A special purpose <code>XMLConsumer</code> which can:
+ * <ul>
+ * <li>Ignore startDocument, endDocument events.
+ * <li>Ignore startDTD, endDTD, and all comments within DTD.
+ * </ul>
+ *
+ * @version $Id$
+ */
+public class IncludeXMLConsumer implements ContentHandler, LexicalHandler {
+
+ private final ContentHandler contentHandler;
+ private final LexicalHandler lexicalHandler;
+
+ private boolean inDTD;
+
+ /**
+ * Constructor
+ */
+ public IncludeXMLConsumer (ContentHandler contentHandler) {
+ this(contentHandler, contentHandler instanceof LexicalHandler ? (LexicalHandler)contentHandler : null);
+ }
+
+ /**
+ * Constructor
+ */
+ public IncludeXMLConsumer (ContentHandler contentHandler, LexicalHandler lexicalHandler) {
+ this.contentHandler = contentHandler;
+ this.lexicalHandler = lexicalHandler;
+ }
+
+ //
+ // ContentHandler interface
+ //
+
+ public void setDocumentLocator(Locator loc) {
+ this.contentHandler.setDocumentLocator(loc);
+ }
+
+ public void startDocument() throws SAXException {
+ // Ignored
+ }
+
+ public void endDocument() throws SAXException {
+ // Ignored
+ }
+
+ public void startPrefixMapping(String prefix, String uri) throws SAXException {
+ this.contentHandler.startPrefixMapping(prefix, uri);
+ }
+
+ public void endPrefixMapping(String prefix) throws SAXException {
+ this.contentHandler.endPrefixMapping(prefix);
+ }
+
+ public void startElement(String uri, String local, String qName, Attributes attr) throws SAXException {
+ this.contentHandler.startElement(uri,local,qName,attr);
+ }
+
+ public void endElement(String uri, String local, String qName) throws SAXException {
+ this.contentHandler.endElement(uri, local, qName);
+ }
+
+ public void characters(char[] ch, int start, int end) throws SAXException {
+ this.contentHandler.characters(ch, start, end);
+ }
+
+ public void ignorableWhitespace(char[] ch, int start, int end) throws SAXException {
+ this.contentHandler.ignorableWhitespace(ch, start, end);
+ }
+
+ public void processingInstruction(String name, String value) throws SAXException {
+ this.contentHandler.processingInstruction(name, value);
+ }
+
+ public void skippedEntity(String ent) throws SAXException {
+ this.contentHandler.skippedEntity(ent);
+ }
+
+ //
+ // LexicalHandler interface
+ //
+
+ public void startDTD(String name, String public_id, String system_id)
+ throws SAXException {
+ // Ignored
+ this.inDTD = true;
+ }
+
+ public void endDTD() throws SAXException {
+ // Ignored
+ this.inDTD = false;
+ }
+
+ public void startEntity(String name) throws SAXException {
+ if (lexicalHandler != null) {
+ lexicalHandler.startEntity(name);
+ }
+ }
+
+ public void endEntity(String name) throws SAXException {
+ if (lexicalHandler != null) {
+ lexicalHandler.endEntity(name);
+ }
+ }
+
+ public void startCDATA() throws SAXException {
+ if (lexicalHandler != null) {
+ lexicalHandler.startCDATA();
+ }
+ }
+
+ public void endCDATA() throws SAXException {
+ if (lexicalHandler != null) {
+ lexicalHandler.endCDATA();
+ }
+ }
+
+ public void comment(char ary[], int start, int length) throws SAXException {
+ if (!inDTD && lexicalHandler != null) {
+ lexicalHandler.comment(ary,start,length);
+ }
+ }
+}
Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/util/IncludeXMLConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/util/IncludeXMLConsumer.java
------------------------------------------------------------------------------
svn:keywords = author date id revision url
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml?rev=633288&r1=633287&r2=633288&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml Mon Mar 3 13:54:41 2008
@@ -266,18 +266,6 @@
+-->
<!--+
- | Profile Store
- |
- +-->
- <bean name="org.apache.cocoon.portal.profile.ProfileStore/abstract"
- parent="org.apache.cocoon.portal.util.AbstractBean"
- abstract="true">
- <property name="converter" ref="org.apache.cocoon.portal.profile.Converter"/>
- <property name="sourceResolver" ref="org.apache.excalibur.source.SourceResolver"/>
- </bean>
-
-
- <!--+
| Profile Manager Aspects.
|
+-->
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml?rev=633288&r1=633287&r2=633288&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml Mon Mar 3 13:54:41 2008
@@ -115,11 +115,12 @@
<!--+
| This is the map based profile store.
+ | TODO : Create abstract def in castor module
+-->
<bean name="org.apache.cocoon.portal.profile.ProfileStore"
- class="org.apache.cocoon.portal.profile.impl.MapBasedProfileStore"
- parent="org.apache.cocoon.portal.profile.ProfileStore/abstract"
- scope="singleton">
+ class="org.apache.cocoon.portal.converter.castor.CastorSourceConverter"
+ scope="singleton" init-method="init">
+ <property name="sourceResolver" ref="org.apache.excalibur.source.SourceResolver"/>
<property name="configuration">
<value>
copletdefinition-global-load=profiles/copletdefinition/global.xml