|
|
Choosing A Webhost: |
svn commit: r332057 - /lenya/branches/BRANCH_1_2_X/src/java/org/apache/leny: msg#00029cms.lenya.cvs
Author: michi Date: Wed Nov 9 06:59:19 2005 New Revision: 332057 URL: http://svn.apache.org/viewcvs?rev=332057&view=rev Log: input module to make content dir configurable started Added: lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PublicationContentDirModule.java Added: lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PublicationContentDirModule.java URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PublicationContentDirModule.java?rev=332057&view=auto ============================================================================== --- lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PublicationContentDirModule.java (added) +++ lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PublicationContentDirModule.java Wed Nov 9 06:59:19 2005 @@ -0,0 +1,104 @@ +/* + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.lenya.cms.cocoon.components.modules.input; + +import java.util.Collections; +import java.util.Iterator; +import java.util.Map; + +import org.apache.avalon.framework.activity.Disposable; +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.avalon.framework.service.Serviceable; +import org.apache.cocoon.components.modules.input.AbstractInputModule; +import org.apache.excalibur.source.Source; +import org.apache.excalibur.source.SourceNotFoundException; +import org.apache.excalibur.source.SourceResolver; + +/** + * Gets the content directory of a specific publication and specific area + */ +public class PublicationContentDirModule extends AbstractInputModule implements Serviceable, Disposable { + + /* (non-Javadoc) + * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String, org.apache.avalon.framework.configuration.Configuration, java.util.Map) + */ + public Object getAttribute(String name, Configuration modeConf, Map objectModel) + throws ConfigurationException { + + String resourceURI = name; + + Source source = null; + boolean exists = false; + try { + source = resolver.resolveURI(resourceURI); + exists = source.exists(); + } catch (SourceNotFoundException e) { + exists = false; + } catch (Exception e) { + getLogger().warn("Exception resolving resource [" + resourceURI + "]", e); + exists = false; + } finally { + if (source != null) { + resolver.release(source); + } + } + + return Boolean.toString(exists); + } + + /* (non-Javadoc) + * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration, java.util.Map) + */ + public Iterator getAttributeNames(Configuration modeConf, Map objectModel) + throws ConfigurationException { + return Collections.EMPTY_SET.iterator(); + } + + private ServiceManager manager; + private SourceResolver resolver; + + /* (non-Javadoc) + * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager) + */ + public void service(ServiceManager manager) throws ServiceException { + this.manager = manager; + this.resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE); + } + + /* (non-Javadoc) + * @see org.apache.avalon.framework.activity.Disposable#dispose() + */ + public void dispose() { + super.dispose(); + this.manager.release(this.resolver); + this.resolver = null; + this.manager = null; + } + + /* (non-Javadoc) + * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String, org.apache.avalon.framework.configuration.Configuration, java.util.Map) + */ + public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel) + throws ConfigurationException { + Object result = this.getAttribute(name, modeConf, objectModel); + return (result == null ? null : new Object[] {result}); + } + +}
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | svn commit: r332044 - in /lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs: blog/parameter-doctype.xmap default/parameter-doctype.xmap, michi |
|---|---|
| Next by Date: | svn commit: r332058 - /lenya/branches/BRANCH_1_2_X/src/webapp/lenya/usecase.xmap, michi |
| Previous by Thread: | svn commit: r332044 - in /lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs: blog/parameter-doctype.xmap default/parameter-doctype.xmap, michi |
| Next by Thread: | svn commit: r332058 - /lenya/branches/BRANCH_1_2_X/src/webapp/lenya/usecase.xmap, michi |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |