You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2005/04/26 18:07:05 UTC
svn commit: r164808 [1/3] - in /cocoon/branches/BRANCH_2_1_X/src:
blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/context/
blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/generation/
blocks/chaperon/java/org/apache/cocoon/transformation/
blocks/forms/java/org/apache/cocoon/forms/datatype/
blocks/mail/java/org/apache/cocoon/generation/
blocks/mail/java/org/apache/cocoon/mail/
blocks/ojb/java/org/apache/cocoon/ojb/components/
blocks/portal-fw/java/org/apache/cocoon/webapps/portal/components/
blocks/portal/java/org/apache/cocoon/portal/tools/generation/
blocks/profiler/java/org/apache/cocoon/generation/
blocks/proxy/java/org/apache/cocoon/generation/
blocks/qdox/java/org/apache/cocoon/components/source/impl/
blocks/repository/java/org/apache/cocoon/components/source/helpers/
blocks/repository/java/org/apache/cocoon/generation/
blocks/slop/java/org/apache/cocoon/slop/parsing/
blocks/web3/java/org/apache/cocoon/components/web3/impl/
blocks/webdav/java/org/apache/cocoon/components/source/impl/
blocks/webdav/java/org/apache/cocoon/transformation/
blocks/woody/java/org/apache/cocoon/woody/
blocks/xsp/java/org/apache/cocoon/components/language/markup/
blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/
deprecated/java/org/apache/cocoon/transformation/
java/org/apache/cocoon/components/notification/
java/org/apache/cocoon/generation/ java/org/apache/cocoon/serialization/
java/org/apache/cocoon/sitemap/ java/org/apache/cocoon/transformation/
java/org/apache/cocoon/xml/dom/
samples/org/apache/cocoon/samples/errorhandling/
samples/org/apache/cocoon/samples/parentcm/
Author: vgritsenko
Date: Tue Apr 26 09:07:03 2005
New Revision: 164808
URL: http://svn.apache.org/viewcvs?rev=164808&view=rev
Log:
Use EMPTY_PROPERTIES
Modified:
cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/context/AuthenticationContext.java
cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/generation/ConfigurationGenerator.java
cocoon/branches/BRANCH_2_1_X/src/blocks/chaperon/java/org/apache/cocoon/transformation/PatternTransformer.java
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/DynamicSelectionList.java
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/generation/IMAPGenerator.java
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/MailContentHandlerDelegate.java
cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/java/org/apache/cocoon/ojb/components/LoggerImpl.java
cocoon/branches/BRANCH_2_1_X/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/components/PortalManagerImpl.java
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/tools/generation/I18nCatalogueGenerator.java
cocoon/branches/BRANCH_2_1_X/src/blocks/profiler/java/org/apache/cocoon/generation/ProfilerGenerator.java
cocoon/branches/BRANCH_2_1_X/src/blocks/proxy/java/org/apache/cocoon/generation/GenericProxyGenerator.java
cocoon/branches/BRANCH_2_1_X/src/blocks/proxy/java/org/apache/cocoon/generation/HttpProxyGenerator.java
cocoon/branches/BRANCH_2_1_X/src/blocks/qdox/java/org/apache/cocoon/components/source/impl/QDoxSource.java
cocoon/branches/BRANCH_2_1_X/src/blocks/repository/java/org/apache/cocoon/components/source/helpers/SourceProperty.java
cocoon/branches/BRANCH_2_1_X/src/blocks/repository/java/org/apache/cocoon/generation/TraversableSourceDescriptionGenerator.java
cocoon/branches/BRANCH_2_1_X/src/blocks/slop/java/org/apache/cocoon/slop/parsing/SimpleSlopParser.java
cocoon/branches/BRANCH_2_1_X/src/blocks/web3/java/org/apache/cocoon/components/web3/impl/DefaultWeb3StreamerImpl.java
cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java
cocoon/branches/BRANCH_2_1_X/src/blocks/webdav/java/org/apache/cocoon/transformation/DASLTransformer.java
cocoon/branches/BRANCH_2_1_X/src/blocks/woody/java/org/apache/cocoon/woody/Constants.java
cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/CocoonMarkupLanguage.java
cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/XSPMarkupLanguage.java
cocoon/branches/BRANCH_2_1_X/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/xsp/XSPObjectHelper.java
cocoon/branches/BRANCH_2_1_X/src/deprecated/java/org/apache/cocoon/transformation/CachingCIncludeTransformer.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/notification/Notifier.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/LinkStatusGenerator.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/SessionAttributeGenerator.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/StatusGenerator.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/serialization/TextSerializer.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/sitemap/ContentAggregator.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/dom/DOMUtil.java
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/errorhandling/ExceptionGenerator.java
cocoon/branches/BRANCH_2_1_X/src/samples/org/apache/cocoon/samples/parentcm/Generator.java
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/context/AuthenticationContext.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/context/AuthenticationContext.java?rev=164808&r1=164807&r2=164808&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/context/AuthenticationContext.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/context/AuthenticationContext.java Tue Apr 26 09:07:03 2005
@@ -1,12 +1,12 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
* Licensed 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.
@@ -15,16 +15,10 @@
*/
package org.apache.cocoon.webapps.authentication.context;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
import org.apache.avalon.framework.CascadingRuntimeException;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.parameters.Parameters;
+
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.ContextHelper;
import org.apache.cocoon.components.source.SourceUtil;
@@ -36,7 +30,9 @@
import org.apache.cocoon.webapps.authentication.user.UserHandler;
import org.apache.cocoon.webapps.session.context.SessionContext;
import org.apache.cocoon.webapps.session.context.SimpleSessionContext;
+import org.apache.cocoon.xml.XMLUtils;
import org.apache.cocoon.xml.dom.DOMUtil;
+
import org.apache.excalibur.source.SourceParameters;
import org.apache.excalibur.source.SourceResolver;
import org.apache.excalibur.xml.xpath.XPathProcessor;
@@ -47,16 +43,21 @@
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.ext.LexicalHandler;
-import org.xml.sax.helpers.AttributesImpl;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
/**
* This is the implementation for the authentication context
- *
+ *
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
- * @version CVS $Id$
+ * @version $Id$
*/
-public class AuthenticationContext
-implements SessionContext {
+public class AuthenticationContext implements SessionContext {
protected String name;
protected UserHandler handler;
@@ -68,14 +69,14 @@
protected SourceResolver resolver;
/** A list of roles the user is in */
protected List roles;
-
+
/** Constructor */
public AuthenticationContext(Context context, XPathProcessor processor, SourceResolver resolver) {
this.context = context;
this.xpathProcessor = processor;
this.resolver = resolver;
}
-
+
/**
* Initialize the context. This method has to be called right after
* the constructor.
@@ -91,25 +92,25 @@
throw new CascadingRuntimeException("Unable to create simple context.", pe);
}
}
-
+
/**
* Return the current authentication state
*/
protected RequestState getState() {
return DefaultAuthenticationManager.getRequestState( this.context );
}
-
+
/**
* Initialize this context
*/
- public void init(Document doc)
+ public void init(Document doc)
throws ProcessingException {
if ( initialized ) {
throw new ProcessingException("The context can only be initialized once.");
}
this.authContext.setNode("/", doc.getFirstChild());
}
-
+
/* (non-Javadoc)
* @see org.apache.cocoon.webapps.session.context.SessionContext#setup(java.lang.String, java.lang.String, java.lang.String)
*/
@@ -135,7 +136,7 @@
if (!path.startsWith("/")) path = '/' + path;
final String applicationName = this.getState().getApplicationName();
-
+
DocumentFragment frag = null;
if ( path.equals("/") ) {
@@ -222,7 +223,7 @@
this.cleanParametersCache();
this.authContext.setXML(path, fragment);
- } else if (path.equals("/application")
+ } else if (path.equals("/application")
|| path.startsWith("/application/") ) {
if (applicationName == null) {
@@ -302,7 +303,7 @@
this.cleanParametersCache();
this.authContext.removeXML(path);
- } else if (path.equals("/application")
+ } else if (path.equals("/application")
|| path.startsWith("/application/") ) {
if (applicationName == null) {
throw new ProcessingException("removeXML: Application is required for path " + path);
@@ -398,12 +399,12 @@
if (path.equals("/") ) {
// get all: first authentication then application
- contentHandler.startElement("", "authentication", "authentication", new AttributesImpl());
+ contentHandler.startElement("", "authentication", "authentication", XMLUtils.EMPTY_ATTRIBUTES);
this.authContext.streamXML("/authentication", contentHandler, lexicalHandler);
contentHandler.endElement("", "authentication", "authentication");
if (applicationName != null) {
- contentHandler.startElement("", "application", "application", new AttributesImpl());
+ contentHandler.startElement("", "application", "application", XMLUtils.EMPTY_ATTRIBUTES);
this.authContext.streamXML("/applications/" + applicationName, contentHandler, lexicalHandler);
contentHandler.endElement("", "application", "application");
}
@@ -561,7 +562,7 @@
throws ProcessingException {
String authLoadResource = this.handler.getHandlerConfiguration().getLoadResource();
SourceParameters authLoadResourceParameters = this.handler.getHandlerConfiguration().getLoadResourceParameters();
-
+
if (authLoadResource == null) {
throw new ProcessingException("The context " + this.name + " does not support loading.");
}
@@ -576,14 +577,14 @@
}
parameters = this.createParameters(parameters,
path,
- false);
+ false);
DocumentFragment frag;
-
- frag = SourceUtil.readDOM(authLoadResource,
- null,
- parameters,
+
+ frag = SourceUtil.readDOM(authLoadResource,
+ null,
+ parameters,
resolver);
-
+
this.setXML(path, frag);
} // end synchronized
@@ -617,9 +618,9 @@
path,
true);
DocumentFragment fragment;
- fragment = SourceUtil.readDOM(loadResource,
- null,
- parameters,
+ fragment = SourceUtil.readDOM(loadResource,
+ null,
+ parameters,
resolver);
this.authContext.setXML("/applications/" + applicationName + '/', fragment);
@@ -745,7 +746,7 @@
}
}
- public Map getContextInfo()
+ public Map getContextInfo()
throws ProcessingException {
Map map = (Map)this.authContext.getAttribute( "cachedmap" );
if (map == null) {
@@ -765,8 +766,8 @@
}
return map;
}
-
- public SourceParameters getContextInfoAsParameters()
+
+ public SourceParameters getContextInfoAsParameters()
throws ProcessingException {
SourceParameters pars = (SourceParameters)this.authContext.getAttribute( "cachedpar" );
if (pars == null) {
@@ -779,14 +780,14 @@
/**
* Load XML of an application
*/
- public void loadApplicationXML(ApplicationConfiguration appConf,
+ public void loadApplicationXML(ApplicationConfiguration appConf,
SourceResolver resolver)
throws ProcessingException {
String loadResource = appConf.getLoadResource();
SourceParameters loadResourceParameters = appConf.getLoadResourceParameters();
if ( !this.handler.isApplicationLoaded(appConf) && loadResource != null ) {
synchronized (this.authContext) {
-
+
SourceParameters parameters;
if (loadResourceParameters != null) {
parameters = (SourceParameters)loadResourceParameters.clone();
@@ -797,12 +798,12 @@
null,
true);
DocumentFragment fragment;
- fragment = SourceUtil.readDOM(loadResource,
- null,
- parameters,
+ fragment = SourceUtil.readDOM(loadResource,
+ null,
+ parameters,
resolver);
this.authContext.setXML("/applications/" + appConf.getName() + '/', fragment);
-
+
} // end synchronized
}
this.handler.setApplicationIsLoaded(appConf);
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/generation/ConfigurationGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/generation/ConfigurationGenerator.java?rev=164808&r1=164807&r2=164808&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/generation/ConfigurationGenerator.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/generation/ConfigurationGenerator.java Tue Apr 26 09:07:03 2005
@@ -1,12 +1,12 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
* Licensed 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.
@@ -15,15 +15,11 @@
*/
package org.apache.cocoon.webapps.authentication.generation;
-
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.Map;
-
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
+
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.source.SourceUtil;
import org.apache.cocoon.environment.ObjectModelHelper;
@@ -39,6 +35,7 @@
import org.apache.cocoon.xml.XMLConsumer;
import org.apache.cocoon.xml.XMLUtils;
import org.apache.cocoon.xml.dom.DOMUtil;
+
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
import org.apache.excalibur.source.SourceParameters;
@@ -48,17 +45,19 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.DefaultHandler;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Map;
+
/**
* This is the authentication Configuration Generator.
*
* @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
- * @version CVS $Id: ConfigurationGenerator.java,v 1.9 2004/03/19 13:59:22 cziegeler Exp $
+ * @version $Id$
*/
-public final class ConfigurationGenerator
-extends ServiceableGenerator {
+public final class ConfigurationGenerator extends ServiceableGenerator {
/** Request parameter */
public static final String REQ_PARAMETER_STATE = "authstate";
@@ -70,7 +69,7 @@
/** The XPath Processor */
protected XPathProcessor xpathProcessor;
-
+
/* (non-Javadoc)
* @see org.apache.avalon.framework.activity.Disposable#dispose()
*/
@@ -101,15 +100,15 @@
try {
authManager = (AuthenticationManager)this.manager.lookup(AuthenticationManager.ROLE);
state = authManager.getState();
-
+
} catch (Exception ignore) {
}
-
+
this.xmlConsumer.startDocument();
if ( state != null ) {
try {
UserHandler userhandler = state.getHandler();
-
+
Configuration conf = state.getModuleConfiguration("single-role-user-management");
if (conf == null) {
throw new ProcessingException("Module configuration 'single-role-user-management' for authentication user management generator not found.");
@@ -117,7 +116,7 @@
UserManagementHandler handler = new UserManagementHandler(conf,
state.getApplicationName());
this.showConfiguration(this.xmlConsumer, this.source, handler, userhandler.getContext());
-
+
} catch (ConfigurationException ex) {
throw new ProcessingException("ConfigurationException: " + ex, ex);
}
@@ -147,32 +146,31 @@
Request request = ObjectModelHelper.getRequest(this.objectModel);
Response response = ObjectModelHelper.getResponse(this.objectModel);
Session session = request.getSession();
-
+
boolean isAdmin = (src == null || src.equals("admin"));
// now start producing xml:
- AttributesImpl attr = new AttributesImpl();
- consumer.startElement("", "configuration", "configuration", attr);
+ consumer.startElement("", "configuration", "configuration", XMLUtils.EMPTY_ATTRIBUTES);
// set the conf uri:
// This is a bug in the servlet 2.2 API!!!
// It does not contain the context: String uri = HttpUtils.getRequestURL(this.request).toString();
// So: ABSOLUTELY USELESS
String uri = response.encodeURL(request.getRequestURI());
- consumer.startElement("", "uri", "uri", attr);
+ consumer.startElement("", "uri", "uri", XMLUtils.EMPTY_ATTRIBUTES);
consumer.characters(uri.toCharArray(), 0, uri.length());
consumer.endElement("", "uri", "uri");
if (isAdmin == true) {
// build the menue
- consumer.startElement("", "menue", "menue", attr);
+ consumer.startElement("", "menue", "menue", XMLUtils.EMPTY_ATTRIBUTES);
if (handler.getNewRoleResource() != null) {
- consumer.startElement("", "addrole", "addrole", attr);
+ consumer.startElement("", "addrole", "addrole", XMLUtils.EMPTY_ATTRIBUTES);
consumer.endElement("", "addrole", "addrole");
}
if (handler.getDeleteRoleResource() != null) {
- consumer.startElement("", "delrole", "delrole", attr);
+ consumer.startElement("", "delrole", "delrole", XMLUtils.EMPTY_ATTRIBUTES);
consumer.endElement("", "delrole", "delrole");
}
@@ -180,7 +178,7 @@
}
- synchronized (session) {
+ synchronized (session) {
String state = request.getParameter(REQ_PARAMETER_STATE);
if (state == null) {
@@ -256,7 +254,7 @@
}
addingNewUserFailed = !this.addUser(role, id, pars, handler);
if (addingNewUserFailed == false) {
- consumer.startElement("", "addeduser", "addeduser", attr);
+ consumer.startElement("", "addeduser", "addeduser", XMLUtils.EMPTY_ATTRIBUTES);
consumer.characters(id.toCharArray(), 0, id.length());
consumer.endElement("", "addeduser", "addeduser");
}
@@ -308,7 +306,7 @@
} catch (javax.xml.transform.TransformerException local) {
throw new ProcessingException("TransformerException: " + local, local);
}
- consumer.startElement("", "uservalues", "uservalues", attr);
+ consumer.startElement("", "uservalues", "uservalues", XMLUtils.EMPTY_ATTRIBUTES);
if (users != null && users.hasChildNodes() == true) {
NodeList childs = users.getChildNodes();
for(int i = 0; i < childs.getLength(); i++) {
@@ -318,11 +316,11 @@
}
consumer.endElement("", "uservalues", "uservalues");
}
- consumer.startElement("", "user", "user", attr);
+ consumer.startElement("", "user", "user", XMLUtils.EMPTY_ATTRIBUTES);
consumer.characters("old".toCharArray(), 0, 3);
consumer.endElement("", "user", "user");
if (isAdmin == false) {
- consumer.startElement("", "role", "role", attr);
+ consumer.startElement("", "role", "role", XMLUtils.EMPTY_ATTRIBUTES);
consumer.characters(role.toCharArray(), 0, role.length());
consumer.endElement("", "role", "role");
}
@@ -351,7 +349,7 @@
} catch (javax.xml.transform.TransformerException local) {
throw new ProcessingException("TransformerException: " + local, local);
}
- consumer.startElement("", "uservalues", "uservalues", attr);
+ consumer.startElement("", "uservalues", "uservalues", XMLUtils.EMPTY_ATTRIBUTES);
if (users != null && users.hasChildNodes() == true) {
NodeList childs = users.getChildNodes();
for(int i = 0; i < childs.getLength(); i++) {
@@ -361,18 +359,18 @@
}
consumer.endElement("", "uservalues", "uservalues");
}
- consumer.startElement("", "user", "user", attr);
+ consumer.startElement("", "user", "user", XMLUtils.EMPTY_ATTRIBUTES);
consumer.characters("error".toCharArray(), 0, 5);
consumer.endElement("", "user", "user");
if (isAdmin == false) {
- consumer.startElement("", "role", "role", attr);
+ consumer.startElement("", "role", "role", XMLUtils.EMPTY_ATTRIBUTES);
consumer.characters(role.toCharArray(), 0, role.length());
consumer.endElement("", "role", "role");
}
}
if (state.equals("adduser") == true) {
- consumer.startElement("", "user", "user", attr);
+ consumer.startElement("", "user", "user", XMLUtils.EMPTY_ATTRIBUTES);
consumer.characters("new".toCharArray(), 0, 3);
consumer.endElement("", "user", "user");
}
@@ -405,7 +403,7 @@
// include selected role
String role = (String)session.getAttribute(SESSION_CONTEXT_ATTRIBUTE_ADMIN_ROLE);
if (role != null) {
- consumer.startElement("", "role", "role", attr);
+ consumer.startElement("", "role", "role", XMLUtils.EMPTY_ATTRIBUTES);
consumer.characters(role.toCharArray(), 0, role.length());
consumer.endElement("", "role", "role");
}
@@ -671,18 +669,18 @@
throws IOException, ProcessingException, SAXException {
Source source = null;
try {
- source = SourceUtil.getSource(resource,
- null,
- parameters,
+ source = SourceUtil.getSource(resource,
+ null,
+ parameters,
this.resolver);
- SourceUtil.parse(this.manager, source, new DefaultHandler());
+ SourceUtil.parse(this.manager, source, new DefaultHandler());
} catch (SourceException se) {
throw SourceUtil.handle(se);
} finally {
this.resolver.release(source);
}
}
-
+
/**
* Load XML resource
*/
@@ -691,9 +689,9 @@
throws IOException, ProcessingException, SAXException {
Source source = null;
try {
- source = SourceUtil.getSource(resource,
- null,
- parameters,
+ source = SourceUtil.getSource(resource,
+ null,
+ parameters,
this.resolver);
return SourceUtil.toDOM(source);
} catch (SourceException se) {
@@ -708,11 +706,11 @@
/** The name of the current application */
private String applicationName;
-
+
/** The load-users resource */
private String loadUsersResource;
private SourceParameters loadUsersResourceParameters;
-
+
/** The load-roles resource */
private String loadRolesResource;
private SourceParameters loadRolesResourceParameters;
@@ -744,9 +742,9 @@
String appName)
throws ConfigurationException {
Configuration child;
-
+
this.applicationName = appName;
-
+
// get load-users resource (optional)
child = conf.getChild("load-users", false);
if (child != null) {
@@ -801,7 +799,7 @@
* Get the name of the current application
*/
public String getApplicationName() { return this.applicationName; }
-
+
/**
* Get the load users resource
*/
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/chaperon/java/org/apache/cocoon/transformation/PatternTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/chaperon/java/org/apache/cocoon/transformation/PatternTransformer.java?rev=164808&r1=164807&r2=164808&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/chaperon/java/org/apache/cocoon/transformation/PatternTransformer.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/chaperon/java/org/apache/cocoon/transformation/PatternTransformer.java Tue Apr 26 09:07:03 2005
@@ -1,19 +1,18 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
* Licensed 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.transformation;
import net.sourceforge.chaperon.build.LexicalAutomatonBuilder;
@@ -35,6 +34,7 @@
import org.apache.avalon.framework.service.Serviceable;
import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.xml.XMLUtils;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.components.source.SourceUtil;
import org.apache.cocoon.environment.SourceResolver;
@@ -57,7 +57,7 @@
/**
* This transfomer transforms text pattern of a XML file into lexemes by using a lexicon file.
- *
+ *
* <p>
* Input:
* </p>
@@ -66,7 +66,7 @@
* Text 123 bla
* </section>
* </pre>
- *
+ *
* <p>
* can be transformed into the following output:
* </p>
@@ -79,13 +79,12 @@
* </pre>
*
* @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
- * @version CVS $Id$
+ * @version $Id$
*/
-public class PatternTransformer extends AbstractTransformer implements LogEnabled, Serviceable,
- Recyclable, Disposable,
- Parameterizable,
- CacheableProcessingComponent
-{
+public class PatternTransformer extends AbstractTransformer
+ implements LogEnabled, Serviceable, Recyclable,
+ Disposable, Parameterizable, CacheableProcessingComponent {
+
/** Namespace for the SAX events. */
public static final String NS = "http://chaperon.sourceforge.net/schema/lexemes/2.0";
private String lexicon = null;
@@ -425,15 +424,13 @@
atts.addAttribute("", "text", "text", "CDATA", lexemetext);
contentHandler.startElement(NS, "lexeme", "lexeme", atts);
- if (this.groups)
- {
- for (int group = 0; group<groups.length; group++)
- {
- contentHandler.startElement(NS, "group", "group", new AttributesImpl());
- contentHandler.characters(groups[group].toCharArray(), 0, groups[group].length());
- contentHandler.endElement(NS, "group", "group");
+ if (this.groups) {
+ for (int group = 0; group<groups.length; group++) {
+ contentHandler.startElement(NS, "group", "group", XMLUtils.EMPTY_ATTRIBUTES);
+ contentHandler.characters(groups[group].toCharArray(), 0, groups[group].length());
+ contentHandler.endElement(NS, "group", "group");
+ }
}
- }
contentHandler.endElement(NS, "lexeme", "lexeme");
contentHandler.endPrefixMapping("");
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/DynamicSelectionList.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/DynamicSelectionList.java?rev=164808&r1=164807&r2=164808&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/DynamicSelectionList.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/DynamicSelectionList.java Tue Apr 26 09:07:03 2005
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
import org.apache.cocoon.forms.datatype.convertor.ConversionResult;
import org.apache.cocoon.xml.AttributesImpl;
import org.apache.cocoon.xml.AbstractXMLPipe;
+import org.apache.cocoon.xml.XMLUtils;
import org.apache.cocoon.xml.dom.DOMBuilder;
import org.w3c.dom.Element;
@@ -189,7 +190,7 @@
if (localName.equals("item")) {
if (!hasLabel) {
// make the label now
- super.startElement(Constants.INSTANCE_NS, LABEL_EL, Constants.INSTANCE_PREFIX_COLON + LABEL_EL, new AttributesImpl());
+ super.startElement(Constants.INSTANCE_NS, LABEL_EL, Constants.INSTANCE_PREFIX_COLON + LABEL_EL, XMLUtils.EMPTY_ATTRIBUTES);
super.characters(currentValueAsString.toCharArray(), 0, currentValueAsString.length());
super.endElement(Constants.INSTANCE_NS, LABEL_EL, Constants.INSTANCE_PREFIX_COLON + LABEL_EL);
}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/generation/IMAPGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/generation/IMAPGenerator.java?rev=164808&r1=164807&r2=164808&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/generation/IMAPGenerator.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/generation/IMAPGenerator.java Tue Apr 26 09:07:03 2005
@@ -1,5 +1,5 @@
/*
-* Copyright 1999-2004 The Apache Software Foundation
+* Copyright 1999-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,21 +15,23 @@
*/
package org.apache.cocoon.generation;
-import java.io.IOException;
-import java.util.Map;
-import java.util.Properties;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.xml.XMLUtils;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
import javax.mail.AuthenticationFailedException;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Store;
-
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.environment.SourceResolver;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
+import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
/**
* Generates an XML listing of messages from an IMAP mail server.
@@ -44,52 +46,50 @@
* and password parameters to the generator.</p>
*
* Instructions: get the JavaMail API jar from http://java.sun.com/products/javamail/, and
- * the JAF activation.jar from http://java.sun.com/beans/glasgow/jaf.html. Put mail.jar
+ * the JAF activation.jar from http://java.sun.com/beans/glasgow/jaf.html. Put mail.jar
* and activation.jar in xml-cocoon2/lib/local/, and recompile. These jars could actually be
* moved to lib/optional and added to jars.xml in the future.
*
- * TODO Refactor all of this to use the MailCommandManager, etc...
+ * <br>TODO Refactor all of this to use the MailCommandManager, etc...
*
* @author <a href="mailto:tony@apache.org">Tony Collen</a>
- * @version CVS $Id: IMAPGenerator.java,v 1.6 2004/03/06 02:26:09 antonio Exp $
+ * @version $Id$
*/
public class IMAPGenerator extends AbstractGenerator {
-
+
static final String URI = "http://apache.org/cocoon/imap/1.0/";
static final String PREFIX = "imap";
private String host;
private String user;
private String pass;
-
+
private Properties props = new Properties();
- private Message message[] = null;
-
+ private Message message[];
+
public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
- throws ProcessingException, SAXException, IOException {
-
+ throws ProcessingException, SAXException, IOException {
+
// TODO: the default values should be something else...
this.host = par.getParameter("host", "none");
this.user = par.getParameter("user", "none");
this.pass = par.getParameter("pass", "none");
- if (this.host.equals("none") ||
- this.user.equals("none") ||
+ if (this.host.equals("none") ||
+ this.user.equals("none") ||
this.pass.equals("none")) {
throw new ProcessingException("You must configure this generator with host, user, and pass parameters.");
}
}
-
+
public void generate()
throws SAXException, ProcessingException {
-
+
try {
Session sess = Session.getDefaultInstance(this.props, null);
Store st = sess.getStore("imap");
- AttributesImpl attr = new AttributesImpl();
-
log("Connecting to IMAP server @ " + this.host);
st.connect(this.host, this.user, this.pass);
@@ -107,34 +107,32 @@
this.contentHandler.startDocument();
this.contentHandler.startPrefixMapping(PREFIX, URI);
- start("imap", attr);
-
- start("messages", attr);
+ start("imap", XMLUtils.EMPTY_ATTRIBUTES);
+ start("messages", XMLUtils.EMPTY_ATTRIBUTES);
for (i = 0; i < this.message.length; i++) {
+ // Loop through the messages and output XML.
+ // TODO: actually use the attributes...
- // loop through the messages and output XML.
- // TODO: actually use the attributes...
-
- start("msg", attr);
+ start("msg", XMLUtils.EMPTY_ATTRIBUTES);
- start("subject", attr);
- data( this.message[i].getSubject() );
- end("subject");
+ start("subject", XMLUtils.EMPTY_ATTRIBUTES);
+ data(this.message[i].getSubject());
+ end("subject");
- start("from", attr);
- data( this.message[i].getFrom()[0].toString() );
- end("from");
+ start("from", XMLUtils.EMPTY_ATTRIBUTES);
+ data(this.message[i].getFrom()[0].toString());
+ end("from");
- start("sentDate", attr);
- data( this.message[i].getSentDate().toString() );
- end("sentDate");
+ start("sentDate", XMLUtils.EMPTY_ATTRIBUTES);
+ data(this.message[i].getSentDate().toString());
+ end("sentDate");
- start("num", attr);
- data( Integer.toString( this.message[i].getMessageNumber() ) );
- end("num");
+ start("num", XMLUtils.EMPTY_ATTRIBUTES);
+ data(Integer.toString(this.message[i].getMessageNumber()));
+ end("num");
- end("msg");
+ end("msg");
}
end("messages");
@@ -148,9 +146,8 @@
} catch (AuthenticationFailedException afe) {
throw new ProcessingException("Failed to authenticate with the IMAP server.");
} catch (Exception e) {
-
// TODO: be more specific when catching this exception...
- throw new ProcessingException( e.toString() );
+ throw new ProcessingException(e.toString());
}
}
@@ -158,7 +155,6 @@
* Recycle the generator by removing references
*/
public void recycle() {
-
this.host = null;
this.user = null;
this.pass = null;
@@ -167,33 +163,24 @@
this.message = null;
super.recycle();
-
}
- private void start(String name, AttributesImpl attr)
- throws SAXException
- {
+ private void start(String name, Attributes attr)
+ throws SAXException {
super.contentHandler.startElement(URI, name, PREFIX + ":" + name, attr);
- attr.clear();
}
- private void end(String name)
- throws SAXException
- {
+ private void end(String name)
+ throws SAXException {
super.contentHandler.endElement(URI, name, PREFIX + ":" + name);
}
-
- private void data(String data)
- throws SAXException
- {
+
+ private void data(String data)
+ throws SAXException {
super.contentHandler.characters( data.toCharArray(), 0, data.length() );
}
-
- private void log(String msg)
- {
- if (this.getLogger().isDebugEnabled()) {
- this.getLogger().debug(msg);
- }
+
+ private void log(String msg) {
+ getLogger().debug(msg);
}
-
}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/MailContentHandlerDelegate.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/MailContentHandlerDelegate.java?rev=164808&r1=164807&r2=164808&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/MailContentHandlerDelegate.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/MailContentHandlerDelegate.java Tue Apr 26 09:07:03 2005
@@ -1,12 +1,12 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
* Licensed 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.
@@ -49,7 +49,7 @@
*
* @author Bernhard Huber
* @since 24. Oktober 2002
- * @version CVS $Id: MailContentHandlerDelegate.java,v 1.6 2004/03/05 13:02:00 bdelacretaz Exp $
+ * @version $Id$
*/
/*
@@ -303,7 +303,6 @@
this.contentHandler.startPrefixMapping(PREFIX, URI);
attributes = new AttributesImpl();
- attributes.clear();
attributes.addAttribute("", PREFIX, "xmlns:" + PREFIX, "CDATA", URI);
startElement("mail", attributes);
}
@@ -801,7 +800,7 @@
*
*@author Bernhard Huber
*@created 30. Dezember 2002
- *@version CVS Version: $Id: MailContentHandlerDelegate.java,v 1.6 2004/03/05 13:02:00 bdelacretaz Exp $
+ *@version CVS Version: $Id$
*/
static class FolderXMLizer extends AbstractLogEnabled
implements XMLizable {
@@ -852,7 +851,7 @@
*
*@author Bernhard Huber
*@created 30. Dezember 2002
- *@version CVS Version: $Id: MailContentHandlerDelegate.java,v 1.6 2004/03/05 13:02:00 bdelacretaz Exp $
+ *@version CVS Version: $Id$
*/
static class MessageEnvelopeXMLizer extends AbstractLogEnabled
implements XMLizable {
@@ -928,7 +927,7 @@
*
*@author Bernhard Huber
*@created 30. Dezember 2002
- *@version CVS Version: $Id: MailContentHandlerDelegate.java,v 1.6 2004/03/05 13:02:00 bdelacretaz Exp $
+ *@version CVS Version: $Id$
*/
static class MessageXMLizer extends AbstractLogEnabled
implements XMLizable {
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/java/org/apache/cocoon/ojb/components/LoggerImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/java/org/apache/cocoon/ojb/components/LoggerImpl.java?rev=164808&r1=164807&r2=164808&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/java/org/apache/cocoon/ojb/components/LoggerImpl.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/java/org/apache/cocoon/ojb/components/LoggerImpl.java Tue Apr 26 09:07:03 2005
@@ -23,6 +23,7 @@
import org.apache.ojb.broker.util.configuration.Configuration;
import org.apache.ojb.broker.util.configuration.ConfigurationException;
import org.apache.ojb.broker.util.logging.Logger;
+import org.apache.ojb.broker.util.logging.LoggingConfiguration;
/**
* OJB logger implementation delegating to the Avalon logger
@@ -51,10 +52,17 @@
}
/**
- * Constructor used by OJB to create a logger instance
+ * Constructor used by OJB 1.0 to create a logger instance
*/
public LoggerImpl(String name) {
this.name = name.startsWith("org.apache.ojb.")? name.substring(15): name;
+ }
+
+ /**
+ * Constructor used by OJB 1.1 to create a logger instance
+ */
+ public LoggerImpl(String name, LoggingConfiguration config) {
+ this(name);
}
/**
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/components/PortalManagerImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/components/PortalManagerImpl.java?rev=164808&r1=164807&r2=164808&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/components/PortalManagerImpl.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/components/PortalManagerImpl.java Tue Apr 26 09:07:03 2005
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* Licensed 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.
@@ -92,16 +92,16 @@
/** The media manager */
private MediaManager mediaManager;
-
+
/** The XPath Processor */
private XPathProcessor xpathProcessor;
/** The session manager */
private SessionManager sessionManager;
-
+
/** The Context manager */
private ContextManager contextManager;
-
+
/** The transaction manager */
private TransactionManager transactionManager;
@@ -113,10 +113,10 @@
/** The context */
protected Context componentContext;
-
+
/** Are we already setup for this request? */
protected boolean initialized = false;
-
+
/* (non-Javadoc)
* @see org.apache.avalon.excalibur.pool.Recyclable#recycle()
*/
@@ -145,7 +145,7 @@
AuthenticationManager authManager = null;
try {
authManager = (AuthenticationManager)this.manager.lookup(AuthenticationManager.ROLE);
- return authManager.getState();
+ return authManager.getState();
} catch (ComponentException ce) {
// ignore this here
return null;
@@ -157,7 +157,7 @@
/* (non-Javadoc)
* @see org.apache.avalon.framework.component.Composable#compose(org.apache.avalon.framework.component.ComponentManager)
*/
- public void compose(ComponentManager manager)
+ public void compose(ComponentManager manager)
throws ComponentException {
this.manager = manager;
this.resolver = (SourceResolver)manager.lookup(SourceResolver.ROLE);
@@ -241,16 +241,16 @@
protected void setup()
throws ProcessingException {
if ( !this.initialized ) {
-
+
final Request request = ContextHelper.getRequest(this.componentContext);
-
+
if ( request.getAttribute(PortalManager.ROLE) == null ) {
-
+
request.setAttribute(PortalManager.ROLE, Boolean.TRUE);
-
+
// Get and ignore the configuration
this.getConfiguration();
-
+
try {
this.changeProfile();
} catch (SAXException se) {
@@ -259,7 +259,7 @@
throw new ProcessingException(ioe);
}
}
-
+
this.initialized = true;
}
}
@@ -268,14 +268,14 @@
* @see org.apache.cocoon.webapps.portal.components.PortalManager#configurationTest()
*/
public void configurationTest()
- throws ProcessingException, IOException, SAXException {
+ throws ProcessingException, IOException, SAXException {
// no sync required
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("BEGIN configurationTest");
}
this.setup();
-
+
// Ignore result
this.getConfiguration();
@@ -308,7 +308,7 @@
if (context == null && create) {
// create new context
-
+
context = this.getAuthenticationManager().createApplicationContext(attrName, null, null);
}
@@ -333,7 +333,7 @@
// synchronized not req.
this.setup();
Response response = ContextHelper.getResponse(this.componentContext);
-
+
XMLUtils.startElement(consumer, PortalConstants.ELEMENT_CONFIGURATION);
// set the portal-page uri:
@@ -548,12 +548,12 @@
if (saveResource == null) {
throw new ProcessingException("portal: No save resource defined for type coplet-base.");
} else {
-
- SourceUtil.writeDOM(saveResource,
- null,
- pars,
- copletsFragment,
- this.resolver,
+
+ SourceUtil.writeDOM(saveResource,
+ null,
+ pars,
+ copletsFragment,
+ this.resolver,
"xml");
// now the hardest part, clean up the whole cache
@@ -576,11 +576,10 @@
}
// now start producing xml:
- AttributesImpl attr = new AttributesImpl();
- consumer.startElement("", PortalConstants.ELEMENT_ADMINCONF, PortalConstants.ELEMENT_ADMINCONF, attr);
+ consumer.startElement("", PortalConstants.ELEMENT_ADMINCONF, PortalConstants.ELEMENT_ADMINCONF, XMLUtils.EMPTY_ATTRIBUTES);
context.setAttribute(ATTRIBUTE_ADMIN_STATE, state);
- consumer.startElement("", PortalConstants.ELEMENT_STATE, PortalConstants.ELEMENT_STATE, attr);
+ consumer.startElement("", PortalConstants.ELEMENT_STATE, PortalConstants.ELEMENT_STATE, XMLUtils.EMPTY_ATTRIBUTES);
consumer.characters(state.toCharArray(), 0, state.length());
consumer.endElement("", PortalConstants.ELEMENT_STATE, PortalConstants.ELEMENT_STATE);
@@ -634,7 +633,7 @@
}
context.setAttribute(ATTRIBUTE_ADMIN_ROLE, role);
if (role != null) {
- consumer.startElement("", PortalConstants.ELEMENT_ROLE, PortalConstants.ELEMENT_ROLE, attr);
+ consumer.startElement("", PortalConstants.ELEMENT_ROLE, PortalConstants.ELEMENT_ROLE, XMLUtils.EMPTY_ATTRIBUTES);
consumer.characters(role.toCharArray(), 0, role.length());
consumer.endElement("", PortalConstants.ELEMENT_ROLE, PortalConstants.ELEMENT_ROLE);
profileID = this.getProfileID(PortalManagerImpl.BUILDTYPE_VALUE_ROLE, role, null, true);
@@ -658,10 +657,10 @@
context.setAttribute(ATTRIBUTE_ADMIN_ID, id);
context.setAttribute(ATTRIBUTE_ADMIN_ROLE, role);
if (role != null && id != null) {
- consumer.startElement("", PortalConstants.ELEMENT_ROLE, PortalConstants.ELEMENT_ROLE, attr);
+ consumer.startElement("", PortalConstants.ELEMENT_ROLE, PortalConstants.ELEMENT_ROLE, XMLUtils.EMPTY_ATTRIBUTES);
consumer.characters(role.toCharArray(), 0, role.length());
consumer.endElement("", PortalConstants.ELEMENT_ROLE, PortalConstants.ELEMENT_ROLE);
- consumer.startElement("", PortalConstants.ELEMENT_ID, PortalConstants.ELEMENT_ID, attr);
+ consumer.startElement("", PortalConstants.ELEMENT_ID, PortalConstants.ELEMENT_ID, XMLUtils.EMPTY_ATTRIBUTES);
consumer.characters(id.toCharArray(), 0, id.length());
consumer.endElement("", PortalConstants.ELEMENT_ID, PortalConstants.ELEMENT_ID);
@@ -686,7 +685,7 @@
}
}
if (state.equals(PortalConstants.STATE_COPLETS) ) {
- consumer.startElement("", PortalConstants.ELEMENT_COPLETS, PortalConstants.ELEMENT_COPLETS, attr);
+ consumer.startElement("", PortalConstants.ELEMENT_COPLETS, PortalConstants.ELEMENT_COPLETS, XMLUtils.EMPTY_ATTRIBUTES);
// load the base coplets profile
if (copletsFragment == null) {
@@ -697,9 +696,9 @@
if (res == null) {
throw new ProcessingException("No configuration for portal-coplet base profile found.");
}
- copletsFragment = SourceUtil.readDOM(res,
- null,
- pars,
+ copletsFragment = SourceUtil.readDOM(res,
+ null,
+ pars,
this.resolver);
context.setAttribute(ATTRIBUTE_ADMIN_COPLETS, copletsFragment);
}
@@ -770,7 +769,7 @@
configMode+", adminProfile="+adminProfile);
}
this.setup();
-
+
SessionContext context = this.getContext(true);
String profileID = null;
Map storedProfile = null;
@@ -1608,7 +1607,7 @@
public String getProfileID(String type,
String role,
String id,
- boolean adminProfile)
+ boolean adminProfile)
throws ProcessingException {
// No sync required
this.setup();
@@ -2632,9 +2631,9 @@
// each attribute of first must be in second with the same value
while (i < l && ok) {
value = attr1.item(i).getNodeName();
- if (!value.equals("formtype")
- && !value.equals("formpath")
- && !value.equals("formdescription")
+ if (!value.equals("formtype")
+ && !value.equals("formpath")
+ && !value.equals("formdescription")
&& !value.startsWith("xmlns:")) {
ok = false;
m = 0;
@@ -2855,7 +2854,7 @@
if (children != null && children.getLength() > 0) {
int l = children.getLength();
for(int i = 0; i < l; i++) {
- if (!children.item(i).getNodeName().equals("status")
+ if (!children.item(i).getNodeName().equals("status")
&& children.item(i).getNodeType() == Node.ELEMENT_NODE) {
IncludeXMLConsumer.includeNode(children.item(i), consumer, consumer);
}
@@ -2928,18 +2927,18 @@
/* (non-Javadoc)
* @see org.apache.cocoon.webapps.portal.components.PortalManager#getMediaType()
*/
- public String getMediaType()
+ public String getMediaType()
throws ProcessingException {
this.setup();
return this.getMediaManager().getMediaType();
}
-
+
/**
* Get the coplet with the id
*/
private Element getCopletConfiguration(String copletID,
Map defaultCoplets,
- Map mediaCoplets)
+ Map mediaCoplets)
throws ProcessingException {
// calling method is synced
String media = this.getMediaManager().getMediaType();
@@ -3244,7 +3243,7 @@
boolean result = false;
SessionContext context = this.getContext(false);
if (context != null
- && (String)context.getAttribute(PortalManagerImpl.ATTRIBUTE_PORTAL_ROLE) != null) {
+ && context.getAttribute(PortalManagerImpl.ATTRIBUTE_PORTAL_ROLE) != null) {
try {
this.getTransactionManager().startReadingTransaction(context);
@@ -3502,9 +3501,9 @@
if (this.getLogger().isInfoEnabled()) {
this.getLogger().info("Building portal profile: " + resource);
}
- SourceUtil.readDOM(resource,
- null,
- pars,
+ SourceUtil.readDOM(resource,
+ null,
+ pars,
this.resolver);
} else {
this.buildProfile(type, role, id, adminProfile);
@@ -3549,9 +3548,9 @@
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("Loading coplet base profile");
}
- copletsFragment = SourceUtil.readDOM(res,
- null,
- pars,
+ copletsFragment = SourceUtil.readDOM(res,
+ null,
+ pars,
this.resolver);
if (this.getLogger().isDebugEnabled()) {
@@ -3565,9 +3564,9 @@
this.getLogger().debug("loading layout base profile");
}
pars.setSingleParameterValue("profile", "layout-base");
- layoutFragment = SourceUtil.readDOM(res,
- null,
- pars,
+ layoutFragment = SourceUtil.readDOM(res,
+ null,
+ pars,
this.resolver);
if (this.getLogger().isDebugEnabled()) {
@@ -3595,9 +3594,9 @@
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("loading type base profile");
}
- typeFragment = SourceUtil.readDOM(res,
- null,
- pars,
+ typeFragment = SourceUtil.readDOM(res,
+ null,
+ pars,
this.resolver);
profileRoot.appendChild(profileDoc.importNode(DOMUtil.selectSingleNode(typeFragment,
"type-profile", this.xpathProcessor), true));
@@ -3638,9 +3637,9 @@
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("loading global profile");
}
- globalFragment = SourceUtil.readDOM(res,
- null,
- pars,
+ globalFragment = SourceUtil.readDOM(res,
+ null,
+ pars,
this.resolver);
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("global profile loaded");
@@ -3657,9 +3656,9 @@
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("loading global type profile");
}
- globalFragment = SourceUtil.readDOM(res,
- null,
- pars,
+ globalFragment = SourceUtil.readDOM(res,
+ null,
+ pars,
this.resolver);
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("global type profile loaded");
@@ -3695,9 +3694,9 @@
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("loading role profile");
}
- roleFragment = SourceUtil.readDOM(res,
- null,
- pars,
+ roleFragment = SourceUtil.readDOM(res,
+ null,
+ pars,
this.resolver);
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("role profile loaded");
@@ -3715,9 +3714,9 @@
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("loading role type profile");
}
- roleFragment = SourceUtil.readDOM(res,
- null,
- pars,
+ roleFragment = SourceUtil.readDOM(res,
+ null,
+ pars,
this.resolver);
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("role type profile loaded");
@@ -3751,9 +3750,9 @@
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("loading user profile");
}
- userFragment = SourceUtil.readDOM(res,
- null,
- pars,
+ userFragment = SourceUtil.readDOM(res,
+ null,
+ pars,
this.resolver);
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("user profile loaded");
@@ -3771,9 +3770,9 @@
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("loading user type profile");
}
- userFragment = SourceUtil.readDOM(res,
- null,
- pars,
+ userFragment = SourceUtil.readDOM(res,
+ null,
+ pars,
this.resolver);
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("user type profile loaded");
@@ -3812,9 +3811,9 @@
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("loading user status profile");
}
- userFragment = SourceUtil.readDOM(res,
- null,
- pars,
+ userFragment = SourceUtil.readDOM(res,
+ null,
+ pars,
this.resolver);
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("user status profile loaded");
@@ -3874,11 +3873,11 @@
pars.setSingleParameterValue("handler", reqstate.getHandlerName());
pars.setSingleParameterValue("profile", "user-status");
- SourceUtil.writeDOM(res,
- null,
+ SourceUtil.writeDOM(res,
+ null,
pars,
- userFragment,
- this.resolver,
+ userFragment,
+ this.resolver,
"xml");
} finally {
@@ -4061,11 +4060,11 @@
if (role != null) pars.setSingleParameterValue("role", role);
pars.setSingleParameterValue("application", reqstate.getApplicationName());
pars.setSingleParameterValue("handler", reqstate.getHandlerName());
- SourceUtil.writeDOM(saveResource,
- null,
+ SourceUtil.writeDOM(saveResource,
+ null,
pars,
- delta,
- this.resolver,
+ delta,
+ this.resolver,
"xml");
if (delta.getParentNode() != null) delta.getParentNode().removeChild(delta);
@@ -4203,7 +4202,7 @@
if (child != null) {
String loadUsersResource = child.getAttribute("uri", null);
SourceParameters loadUsersResourceParameters = SourceParameters.create(child);
-
+
if (loadUsersResource != null) {
SourceParameters parameters = (loadUsersResourceParameters == null) ? new SourceParameters()
@@ -4218,11 +4217,11 @@
}
if (role != null) parameters.setSingleParameterValue("role", role);
frag = this.loadResource(loadUsersResource, parameters);
-
+
}
}
}
-
+
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("END getUsers fragment="+(frag == null ? "null" : XMLUtils.serializeNode(frag, XMLUtils.createPropertiesForXML(false))));
}
@@ -4280,9 +4279,9 @@
throws IOException, ProcessingException, SAXException {
Source source = null;
try {
- source = SourceUtil.getSource(resource,
- null,
- parameters,
+ source = SourceUtil.getSource(resource,
+ null,
+ parameters,
this.resolver);
return SourceUtil.toDOM(source);
} catch (SourceException se) {
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/tools/generation/I18nCatalogueGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/tools/generation/I18nCatalogueGenerator.java?rev=164808&r1=164807&r2=164808&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/tools/generation/I18nCatalogueGenerator.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/tools/generation/I18nCatalogueGenerator.java Tue Apr 26 09:07:03 2005
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2005 The Apache Software Foundation.
- *
+ *
* Licensed 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.
@@ -15,46 +15,47 @@
*/
package org.apache.cocoon.portal.tools.generation;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
+
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.generation.ServiceableGenerator;
import org.apache.cocoon.portal.tools.PortalToolCatalogue;
import org.apache.cocoon.portal.tools.PortalToolManager;
import org.apache.cocoon.xml.IncludeXMLConsumer;
+import org.apache.cocoon.xml.XMLUtils;
+
import org.apache.excalibur.source.Source;
import org.apache.excalibur.xml.sax.SAXParser;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
/**
- *
- * @version CVS $Id$
+ *
+ * @version $Id$
*/
public class I18nCatalogueGenerator extends ServiceableGenerator {
-
+
private SAXParser parser;
private PortalToolManager ptm;
private final String CATALOGUE_TAG = "catalogue";
private String lang = ".xml";
- private StringBuffer i18n = new StringBuffer();
-
+
/* (non-Javadoc)
* @see org.apache.cocoon.generation.Generator#generate()
*/
- public void generate() throws IOException, SAXException,
- ProcessingException {
+ public void generate()
+ throws IOException, SAXException, ProcessingException {
this.xmlConsumer.startDocument();
- this.xmlConsumer.startElement("", CATALOGUE_TAG, CATALOGUE_TAG, new AttributesImpl());
+ this.xmlConsumer.startElement("", CATALOGUE_TAG, CATALOGUE_TAG, XMLUtils.EMPTY_ATTRIBUTES);
List cats = ptm.getI18n();
for(Iterator it = cats.iterator(); it.hasNext();) {
PortalToolCatalogue ptc = (PortalToolCatalogue) it.next();
@@ -73,11 +74,11 @@
this.xmlConsumer.endElement("", CATALOGUE_TAG, CATALOGUE_TAG);
this.xmlConsumer.endDocument();
}
-
+
/* (non-Javadoc)
* @see org.apache.cocoon.sitemap.SitemapModelComponent#setup(org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
*/
- public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
+ public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
throws ProcessingException, SAXException, IOException {
super.setup(resolver, objectModel, src, par);
if(src.indexOf("_") != -1) {
@@ -86,7 +87,7 @@
}
}
-
+
/* (non-Javadoc)
* @see org.apache.cocoon.generation.ServiceableGenerator#service(org.apache.avalon.framework.service.ServiceManager)
*/
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/profiler/java/org/apache/cocoon/generation/ProfilerGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/profiler/java/org/apache/cocoon/generation/ProfilerGenerator.java?rev=164808&r1=164807&r2=164808&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/profiler/java/org/apache/cocoon/generation/ProfilerGenerator.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/profiler/java/org/apache/cocoon/generation/ProfilerGenerator.java Tue Apr 26 09:07:03 2005
@@ -1,12 +1,12 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
* Licensed 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.
@@ -27,6 +27,8 @@
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.xml.IncludeXMLConsumer;
+import org.apache.cocoon.xml.XMLUtils;
+
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
@@ -44,7 +46,7 @@
* @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
* @author <a href="mailto:bruno@outerthought.org">Bruno Dumon</a>
* @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
- * @version CVS $Id: ProfilerGenerator.java,v 1.6 2004/03/05 13:02:20 bdelacretaz Exp $
+ * @version $Id$
*/
public class ProfilerGenerator extends ServiceableGenerator {
@@ -158,7 +160,7 @@
} else {
this.contentHandler.startDocument();
this.contentHandler.startPrefixMapping(PREFIX, PROFILER_NS);
- this.contentHandler.startElement(PROFILER_NS, "fragment-error", PREFIX_COLON + "fragment-error", new AttributesImpl());
+ this.contentHandler.startElement(PROFILER_NS, "fragment-error", PREFIX_COLON + "fragment-error", XMLUtils.EMPTY_ATTRIBUTES);
char[] message = "Fragment is not available.".toCharArray();
this.contentHandler.characters(message, 0, message.length);
this.contentHandler.endElement(PROFILER_NS, "fragment-error", PREFIX_COLON + "fragment-error");
@@ -188,7 +190,6 @@
String dateTime = DateFormat.getDateTimeInstance().format(new Date());
AttributesImpl atts = new AttributesImpl();
-
atts.addAttribute("", "date", "date", "CDATA", dateTime);
this.contentHandler.startElement(PROFILER_NS, PROFILERINFO_ELEMENT,
PREFIX_COLON + PROFILERINFO_ELEMENT, atts);
@@ -211,11 +212,12 @@
/**
*
*
- * @param key
- * @param result
+ * @param key
+ * @param result
*/
private void generateResults(Long key,
- ProfilerResult result) throws SAXException {
+ ProfilerResult result)
+ throws SAXException {
AttributesImpl atts = new AttributesImpl();
int count = result.getCount();
@@ -231,8 +233,9 @@
// Total time of all requests
long totalTimeSum = 0;
- for (int i = 0; i<count; i++)
+ for (int i = 0; i<count; i++) {
totalTimeSum += totalTime[i];
+ }
atts.addAttribute("", "uri", "uri", "CDATA", result.getURI());
atts.addAttribute("", "count", "count", "CDATA",
@@ -311,10 +314,10 @@
EnvironmentInfo environmentInfo,
long totalTime, long[] setupTimes,
long[] processingTimes,
- Object[] fragments) throws SAXException {
+ Object[] fragments)
+ throws SAXException {
AttributesImpl atts = new AttributesImpl();
-
atts.addAttribute("", "time", "time", "CDATA",
Long.toString(totalTime));
atts.addAttribute("", "index", "index", "CDATA",
@@ -338,10 +341,10 @@
private void generateComponent(int componentIndex, String role,
String source, long setupTime,
long processingTime,
- Object fragment) throws SAXException {
+ Object fragment)
+ throws SAXException {
AttributesImpl atts = new AttributesImpl();
-
atts.addAttribute("", "index", "index", "CDATA",
String.valueOf(componentIndex));
@@ -369,7 +372,7 @@
if (this.componentIndex==componentIndex) {
this.contentHandler.startElement(PROFILER_NS, FRAGMENT_ELEMENT,
PREFIX_COLON + FRAGMENT_ELEMENT,
- new AttributesImpl());
+ XMLUtils.EMPTY_ATTRIBUTES);
generateSAXFragment(fragment, true);
this.contentHandler.endElement(PROFILER_NS, FRAGMENT_ELEMENT,
PREFIX_COLON + FRAGMENT_ELEMENT);
@@ -383,14 +386,14 @@
throws SAXException {
this.contentHandler.startElement(PROFILER_NS, ENVIROMENTINFO_ELEMENT,
PREFIX_COLON + ENVIROMENTINFO_ELEMENT,
- new AttributesImpl());
+ XMLUtils.EMPTY_ATTRIBUTES);
if (environmentInfo!=null) {
// Generate SAX events for the request parameters
this.contentHandler.startElement(PROFILER_NS,
REQUESTPARAMETERS_ELEMENT,
PREFIX_COLON + REQUESTPARAMETERS_ELEMENT,
- new AttributesImpl());
+ XMLUtils.EMPTY_ATTRIBUTES);
Map requestParameters = environmentInfo.getRequestParameters();
Set requestParamEntries = requestParameters.entrySet();
@@ -420,7 +423,7 @@
this.contentHandler.startElement(PROFILER_NS,
SESSIONATTRIBUTES_ELEMENT,
PREFIX_COLON + SESSIONATTRIBUTES_ELEMENT,
- new AttributesImpl());
+ XMLUtils.EMPTY_ATTRIBUTES);
Map sessionAttributes = environmentInfo.getSessionAttributes();
Set sessionAttrEntries = sessionAttributes.entrySet();
@@ -448,7 +451,7 @@
// And the rest
this.contentHandler.startElement(PROFILER_NS, "uri", PREFIX_COLON + "uri",
- new AttributesImpl());
+ XMLUtils.EMPTY_ATTRIBUTES);
this.contentHandler.characters(environmentInfo.getURI().toCharArray(),
0, environmentInfo.getURI().length());
this.contentHandler.endElement(PROFILER_NS, "uri", PREFIX_COLON + "uri");
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/proxy/java/org/apache/cocoon/generation/GenericProxyGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/proxy/java/org/apache/cocoon/generation/GenericProxyGenerator.java?rev=164808&r1=164807&r2=164808&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/proxy/java/org/apache/cocoon/generation/GenericProxyGenerator.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/proxy/java/org/apache/cocoon/generation/GenericProxyGenerator.java Tue Apr 26 09:07:03 2005
@@ -1,12 +1,12 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
* Licensed 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.
@@ -26,6 +26,7 @@
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.xml.XMLUtils;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.environment.http.HttpEnvironment;
import org.apache.cocoon.util.RequestForwardingHttpMethod;
@@ -40,18 +41,18 @@
import org.xml.sax.helpers.AttributesImpl;
/**
- * This is a generic HTTP proxy, designed to handle any possible HTTP method,
+ * This is a generic HTTP proxy, designed to handle any possible HTTP method,
* but with a particular bias towards WebDAV. As of now it's pretty unstable, but
* still it might be a good proof of concept towards a pure HTTP(++) proxy.
- *
- * TODO: doesn't handle authentication properly
- * TODO: doesn't handle (and doubt it'll ever will) HTTP/1.1 keep-alive
- *
+ *
+ * <br>TODO: doesn't handle authentication properly
+ * <br>TODO: doesn't handle (and doubt it'll ever will) HTTP/1.1 keep-alive
+ *
* @author <a href="mailto:gianugo@apache.org">Gianugo Rabellino</a>
- * @version $Id: GenericProxyGenerator.java,v 1.5 2004/03/05 13:02:20 bdelacretaz Exp $
+ * @version $Id$
*/
public class GenericProxyGenerator extends ServiceableGenerator {
-
+
/** The real URL to forward requests to */
HttpURL destination;
/** The current request */
@@ -64,7 +65,7 @@
/**
* Compose and get a SAX parser for further use.
- *
+ *
* @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
*/
public void service(ServiceManager manager) throws ServiceException {
@@ -82,14 +83,14 @@
}
super.dispose();
}
-
+
/**
- * Setup this component by getting the (required) "url" parameter and the
+ * Setup this component by getting the (required) "url" parameter and the
* (optional) "path" parameter. If path is not specified, the request URI will
* be used and forwarded.
- *
+ *
* TODO: handle query string
- *
+ *
* @see org.apache.cocoon.sitemap.SitemapModelComponent#setup(org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
*/
public void setup(
@@ -109,69 +110,68 @@
if (path == null)
path = request.getRequestURI();
destination = new HttpURL(url);
-
+
}
-
-
+
+
/**
* Get the request data, pass them on to the forwarder and return the result.
- *
+ *
* TODO: much better header handling
- * TODO: handle non XML and bodyless responses (probably needs a smarter Serializer,
+ * TODO: handle non XML and bodyless responses (probably needs a smarter Serializer,
* since some XML has to go through the pipeline anyway.
- *
+ *
* @see org.apache.cocoon.generation.Generator#generate()
*/
public void generate()
throws IOException, SAXException, ProcessingException {
- RequestForwardingHttpMethod method =
+ RequestForwardingHttpMethod method =
new RequestForwardingHttpMethod(request, destination);
-
- // Build the forwarded connection
- HttpConnection conn = new HttpConnection(destination.getHost(), destination.getPort());
+
+ // Build the forwarded connection
+ HttpConnection conn = new HttpConnection(destination.getHost(), destination.getPort());
HttpState state = new HttpState();
- state.setCredentials(null, destination.getHost(),
+ state.setCredentials(null, destination.getHost(),
new UsernamePasswordCredentials(destination.getUser(), destination.getPassword()));
method.setPath(path);
-
+
// Execute the method
method.execute(state, conn);
-
+
// Send the output to the client: set the status code...
response.setStatus(method.getStatusCode());
-
- // ... retrieve the headers from the origin server and pass them on
+
+ // ... retrieve the headers from the origin server and pass them on
Header[] methodHeaders = method.getResponseHeaders();
for (int i = 0; i < methodHeaders.length; i++) {
// there is more than one DAV header
if (methodHeaders[i].getName().equals("DAV")) {
response.addHeader(methodHeaders[i].getName(), methodHeaders[i].getValue());
} else if (methodHeaders[i].getName().equals("Content-Length")) {
- // drop the original Content-Length header. Don't ask me why but there
+ // drop the original Content-Length header. Don't ask me why but there
// it's always one byte off
} else {
response.setHeader(methodHeaders[i].getName(), methodHeaders[i].getValue());
- }
+ }
}
-
+
// no HTTP keepalives here...
response.setHeader("Connection", "close");
// Parse the XML, if any
- if (method.getResponseHeader("Content-Type").getValue().startsWith("text/xml")) {
- InputStream stream = method.getResponseBodyAsStream();
+ if (method.getResponseHeader("Content-Type").getValue().startsWith("text/xml")) {
+ InputStream stream = method.getResponseBodyAsStream();
parser.parse(new InputSource(stream), this.contentHandler, this.lexicalHandler);
} else {
// Just send a dummy XML
this.contentHandler.startDocument();
- this.contentHandler.startElement("", "no-xml-content", "no-xml-content", new AttributesImpl());
+ this.contentHandler.startElement("", "no-xml-content", "no-xml-content", XMLUtils.EMPTY_ATTRIBUTES);
this.contentHandler.endElement("", "no-xml-content", "no-xml-content");
this.contentHandler.endDocument();
}
-
+
// again, no keepalive here.
conn.close();
-
}
}