You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by so...@apache.org on 2008/02/01 01:23:03 UTC
svn commit: r617315 [2/2] - in /lenya/branches/revolution/1.3.x/src:
java/org/apache/lenya/cms/cocoon/components/modules/input/
java/org/apache/lenya/cms/cocoon/generation/
java/org/apache/lenya/cms/content/ java/org/apache/lenya/cms/modules/
java/org/...
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleInputModule.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleInputModule.java?rev=617315&r1=617314&r2=617315&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleInputModule.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleInputModule.java Thu Jan 31 16:23:00 2008
@@ -5,10 +5,10 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.lenya.cms.cocoon.components.modules.input.AbstractPageEnvelopeModule;
+import org.apache.cocoon.components.modules.input.AbstractInputModule;
import org.apache.lenya.cms.publication.PageEnvelope;
+import org.apache.lenya.cms.publication.PageEnvelopeException;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.PublicationModules;
import org.apache.lenya.util.Globals;
/**
* Retrieves Module Variables from publication.xconf and module.xml.
@@ -18,25 +18,28 @@
* @author solprovider
* @since 1.3
*/
-public class ModuleInputModule extends AbstractPageEnvelopeModule implements ThreadSafe {
- // public class ModuleInputModule extends AbstractPageEnvelopeModule implements Serviceable, ThreadSafe {
- // private ServiceManager manager;
+public class ModuleInputModule extends AbstractInputModule implements ThreadSafe {
/**
* @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String, org.apache.avalon.framework.configuration.Configuration, java.util.Map)
*/
private String moduleId = "";
public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
+ System.out.println(Globals.getObjectModel());
if(getLogger().isDebugEnabled()){
getLogger().debug("Resolving [" + name + "]");
}
- // init();
moduleId = Globals.getModule();
// Standard Variables
if(name.equalsIgnoreCase("module")){
return moduleId;
}
// Module Variables
- PageEnvelope pe = getEnvelope(objectModel);
+ PageEnvelope pe;
+ try{
+ pe = PageEnvelope.getCurrent();
+ }catch(PageEnvelopeException e){
+ throw new ConfigurationException("Resolving page envelope failed: ", e);
+ }
Publication pub = pe.getPublication();
PublicationModules modules = pub.getModules();
return modules.getVariable(moduleId, name);
@@ -54,42 +57,10 @@
Object[] objects = {getAttribute(name, modeConf, objectModel)};
return objects;
}
- // /**
- // * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
- // */
- // public void service(ServiceManager manager) throws ServiceException {
- // this.manager = manager;
- // }
/**
* @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
*/
public void configure(Configuration conf) throws ConfigurationException {
super.configure(conf);
- }
- private void init() {
- // ## Set ModuleId
- // OBSOLETE: Following code replaced by Globals.getModule()
- // String uri = "";
- // try{
- // SourceResolver resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
- // Source source = resolver.resolveURI("");
- // uri = source.getURI();
- // if(resolver != null)
- // manager.release(resolver);
- // }catch(org.apache.avalon.framework.service.ServiceException se){
- // // Report Error?
- // }catch(java.net.MalformedURLException mue){
- // // Report Error?
- // }catch(java.io.IOException ioe){
- // // Report Error?
- // }
- // // XTODO: Release resolver
- // StringTokenizer tokens = new StringTokenizer(uri, "/");
- // while(tokens.hasMoreTokens() && !(tokens.nextToken().equals("modules")));
- // if(tokens.hasMoreTokens()){
- // moduleId = tokens.nextToken();
- // }
- // END OBSOLETE
- moduleId = Globals.getModule();
}
}
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleSet.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleSet.java?rev=617315&r1=617314&r2=617315&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleSet.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleSet.java Thu Jan 31 16:23:00 2008
@@ -1,4 +1,6 @@
package org.apache.lenya.cms.modules;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.lenya.cms.content.Content;
/**
*
@@ -6,38 +8,31 @@
* @since 1.3
*/
public class ModuleSet {
- Module flat = null;
- Module hierarchical = null;
- public ModuleSet() {
+ // TODO: Rewrite to use Map(type) = Module. Needs to handle >2 Types.
+ Map modules = new HashMap();
+ String defaultType;
+ // Module flat = null;
+ // Module hierarchical = null;
+ public ModuleSet(Module module) {
+ String type = module.getContentType();
+ modules.put(type, module);
+ defaultType = type;
}
- public Module getFlat() {
- return flat;
- }
- public Module getHierarchical() {
- return hierarchical;
+ public Module getModule(String type) {
+ if(modules.containsKey(type)){
+ return (Module) modules.get(type);
+ }
+ return (Module) modules.get(defaultType);
}
public void add(Module module) {
- if(Content.TYPE_FLAT.equalsIgnoreCase(module.getType())){
- if(null == flat){
- flat = module;
- }else if(Content.TYPE_FLAT.equalsIgnoreCase(flat.getType())){
- flat = compareModules(flat, module);
- }else{
- flat = module;
- }
- }else if(Content.TYPE_HIERARCHICAL.equalsIgnoreCase(module.getType())){
- if(null == hierarchical){
- hierarchical = module;
- }else if(Content.TYPE_HIERARCHICAL.equalsIgnoreCase(hierarchical.getType())){
- hierarchical = compareModules(hierarchical, module);
- }else{
- hierarchical = module;
- }
+ String type = module.getContentType();
+ if(modules.containsKey(type)){
+ modules.put(type, compareModules((Module) modules.get(type), module));
}else{
- if(null == flat)
- flat = module;
- if(null == hierarchical)
- hierarchical = module;
+ modules.put(type, module);
+ if(Content.TYPE_DEFAULT.equalsIgnoreCase(type)){
+ defaultType = Content.TYPE_DEFAULT;
+ }
}
}
private Module compareModules(Module m1, Module m2) {
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleSourceFactory.java?rev=617315&r1=617314&r2=617315&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleSourceFactory.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModuleSourceFactory.java Thu Jan 31 16:23:00 2008
@@ -7,7 +7,6 @@
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.components.CocoonComponentManager;
-import org.apache.cocoon.components.ContextHelper;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceFactory;
import org.apache.excalibur.source.SourceNotFoundException;
@@ -16,7 +15,6 @@
import org.apache.excalibur.source.URIAbsolutizer;
import org.apache.excalibur.source.impl.FileSource;
import org.apache.lenya.cms.publication.PageEnvelope;
-import org.apache.lenya.cms.publication.PageEnvelopeFactory;
import org.apache.lenya.cms.publication.Publication;
/**
* 2000125: Integrated with org.apache.lenya.cms.modules
@@ -46,7 +44,7 @@
String publication;
Publication pub;
try{
- PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(ContextHelper.getObjectModel(context));
+ PageEnvelope envelope = PageEnvelope.getCurrent();
pub = envelope.getPublication();
publication = pub.getId();
}catch(org.apache.lenya.cms.publication.PageEnvelopeException pee){
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/Modules.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/Modules.java?rev=617315&r1=617314&r2=617315&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/Modules.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/Modules.java Thu Jan 31 16:23:00 2008
@@ -3,7 +3,6 @@
import java.util.HashMap;
import java.util.Map;
import org.apache.cocoon.util.IOUtils;
-import org.apache.lenya.cms.content.Content;
/**
* Singleton class containing all Modules.
*
@@ -38,8 +37,7 @@
Object o = modules.get(id);
if(Module.class.isAssignableFrom(o.getClass())){
Module oldModule = (Module) o;
- ModuleSet moduleSet = new ModuleSet();
- moduleSet.add(oldModule);
+ ModuleSet moduleSet = new ModuleSet(oldModule);
moduleSet.add(newModule);
modules.put(id, moduleSet);
}else if(ModuleSet.class.isAssignableFrom(o.getClass())){
@@ -77,8 +75,7 @@
Object o = modules.get(id);
if(Module.class.isAssignableFrom(o.getClass())){
Module oldModule = (Module) o;
- ModuleSet moduleSet = new ModuleSet();
- moduleSet.add(oldModule);
+ ModuleSet moduleSet = new ModuleSet(oldModule);
moduleSet.add(newModule);
modules.put(id, moduleSet);
}else if(ModuleSet.class.isAssignableFrom(o.getClass())){
@@ -130,18 +127,11 @@
}
static private Module getModuleByType(Object o, String type) {
if(Module.class.isAssignableFrom(o.getClass())){
- // System.out.println("GetModuleByType Module");
return (Module) o;
}else if(ModuleSet.class.isAssignableFrom(o.getClass())){
- if(Content.TYPE_HIERARCHICAL.equals(type)){
- // System.out.println("GetModuleByType Hierarchical");
- return (Module) ((ModuleSet) o).getHierarchical();
- }else{
- // System.out.println("GetModuleByType Flat");
- return (Module) ((ModuleSet) o).getFlat();
- }
+ return (Module) ((ModuleSet) o).getModule(type);
}
- // System.out.println("GetModuleByType Null");
+ System.out.println("Modules.GetModuleByType found Class " + o.getClass().getName());
return null;
}
}
Added: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModulesGenerator.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModulesGenerator.java?rev=617315&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModulesGenerator.java (added)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/ModulesGenerator.java Thu Jan 31 16:23:00 2008
@@ -0,0 +1,117 @@
+package org.apache.lenya.cms.modules;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.Map;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.caching.CacheableProcessingComponent;
+import org.apache.cocoon.generation.ServiceableGenerator;
+import org.apache.excalibur.source.SourceValidity;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+public class ModulesGenerator extends ServiceableGenerator implements CacheableProcessingComponent {
+ private static final String PREFIX = "modules";
+ private static final String URI = "http://apache.org/lenya/1.3/" + PREFIX;
+ private static final String ATTR_MODULE_NAME = "name";
+ private static final String ELEMENT_TOP = "modules";
+ private static final String ELEMENT_MODULE = "module";
+ private static final String ATTR_MODULE_ID = "id";
+ private static final String ATTR_MODULE_TYPE = "type";
+ private static final String ATTR_MODULE_PUBLICATION = "publication";
+ private static final String ELEMENT_DESCRIPTION = "description";
+ public Serializable getKey() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ public SourceValidity getValidity() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ public void generate() throws IOException, SAXException, ProcessingException {
+ ContentHandler handler = this.contentHandler;
+ handler.startDocument();
+ handler.startPrefixMapping(PREFIX, URI);
+ AttributesImpl attributes = new AttributesImpl();
+ attributes.addAttribute("", "xmlns", "xmlns", "CDATA", URI);
+ // attributes.addAttribute("xmlns", PREFIX, "xmlns:" + PREFIX, "CDATA", URI);
+ handler.startElement(URI, ELEMENT_TOP, ELEMENT_TOP, attributes);
+ handleModules(handler, Modules.modules);
+ handler.endElement(URI, ELEMENT_TOP, ELEMENT_TOP);
+ handler.endDocument();
+ }
+ private void handleModules(ContentHandler handler, Map modules) throws SAXException {
+ Iterator moduleI = modules.entrySet().iterator();
+ while(moduleI.hasNext()){
+ Map.Entry entry = (Map.Entry) moduleI.next();
+ String moduleKey = (String) entry.getKey();
+ Object o = entry.getValue();
+ String[] moduleKeyParts = moduleKey.split(".", 2);
+ String publicationId = moduleKeyParts[0];
+ String moduleId = "";
+ AttributesImpl attributes = new AttributesImpl();
+ if(moduleKeyParts.length > 1){
+ moduleId = moduleKeyParts[1];
+ }
+ if(publicationId.length() < 1){
+ attributes.addAttribute(URI, ATTR_MODULE_TYPE, ATTR_MODULE_TYPE, "CDATA", "global");
+ }else{
+ attributes.addAttribute(URI, ATTR_MODULE_TYPE, ATTR_MODULE_TYPE, "CDATA", "publication");
+ attributes.addAttribute(URI, ATTR_MODULE_PUBLICATION, ATTR_MODULE_PUBLICATION, "CDATA", publicationId);
+ }
+ attributes.addAttribute(URI, ATTR_MODULE_ID, ATTR_MODULE_ID, "CDATA", moduleId);
+ handler.startElement(URI, ELEMENT_MODULE, ELEMENT_MODULE, attributes);
+ handleObject(handler, o);
+ handler.endElement(URI, ELEMENT_MODULE, ELEMENT_MODULE);
+ }
+ }
+ private void handleObject(ContentHandler handler, Object o) throws SAXException {
+ if(Module.class.isAssignableFrom(o.getClass())){
+ Module module = (Module) o;
+ handleModule(handler, module);
+ }else if(ModuleSet.class.isAssignableFrom(o.getClass())){
+ ModuleSet moduleSet = (ModuleSet) o;
+ // Care about default?
+ Iterator moduleI = moduleSet.modules.values().iterator();
+ while(moduleI.hasNext()){
+ Module module = (Module) moduleI.next();
+ handleModule(handler, module);
+ }
+ }else{
+ System.out.println("ModuleGenerator: Found class " + o.getClass().toString());
+ }
+ }
+ private void handleModule(ContentHandler handler, Module module) throws SAXException {
+ AttributesImpl attributes = new AttributesImpl();
+ attributes.addAttribute(URI, ATTR_MODULE_TYPE, ATTR_MODULE_TYPE, "CDATA", module.getContentType());
+ attributes.addAttribute(URI, ATTR_MODULE_NAME, ATTR_MODULE_NAME, "CDATA", module.name);
+ if(module.resource.length() > 0){
+ attributes.addAttribute(URI, ATTR_MODULE_TYPE, ATTR_MODULE_TYPE, "CDATA", module.resource);
+ }
+ handler.startElement(URI, ELEMENT_MODULE, ELEMENT_MODULE, attributes);
+ String description = module.description;
+ int length = description.length();
+ if(length > 0){
+ handler.startElement(URI, ELEMENT_DESCRIPTION, ELEMENT_DESCRIPTION, null);
+ handler.characters(description.toCharArray(), 0, length);
+ handler.endElement(URI, ELEMENT_DESCRIPTION, ELEMENT_DESCRIPTION);
+ }
+ handleList(handler, module.inheritList, "inherit");
+ handleList(handler, module.requiredList, "required");
+ handleList(handler, module.recommendedList, "recommended");
+ handleList(handler, module.optionalList, "optional");
+ handler.endElement(URI, ELEMENT_MODULE, ELEMENT_MODULE);
+ }
+ private void handleList(ContentHandler handler, Map map, String element) throws SAXException {
+ Iterator iterator = map.entrySet().iterator();
+ while(iterator.hasNext()){
+ Map.Entry entry = (Map.Entry) iterator.next();
+ String description = (String) entry.getValue();
+ AttributesImpl attributes = new AttributesImpl();
+ attributes.addAttribute(URI, ATTR_MODULE_ID, ATTR_MODULE_ID, "CDATA", (String) entry.getKey());
+ handler.startElement(URI, element, element, attributes);
+ handler.characters(description.toCharArray(), 0, description.length());
+ handler.endElement(URI, element, element);
+ }
+ }
+}
Copied: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/PublicationModules.java (from r617035, lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PublicationModules.java)
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/PublicationModules.java?p2=lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/PublicationModules.java&p1=lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PublicationModules.java&r1=617035&r2=617315&rev=617315&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PublicationModules.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/modules/PublicationModules.java Thu Jan 31 16:23:00 2008
@@ -1,4 +1,4 @@
-package org.apache.lenya.cms.publication;
+package org.apache.lenya.cms.modules;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -7,14 +7,13 @@
import java.util.Map;
import java.util.Set;
import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.lenya.cms.modules.Module;
-import org.apache.lenya.cms.modules.Modules;
/**
*
* @author solprovider
* @since 1.3
*/
public class PublicationModules {
+ // Moved from publication package to modules for access to Modules.modules
// TODO: Rearchitect class so can reset all without restarting Lenya?
private List templates = new ArrayList(); // Default list of Publications for inherit.
// TODO: external and exclude should have defaults in module.xml.
@@ -29,11 +28,7 @@
boolean allAllowed = true;
boolean allExternal = true;
static Map variables = new HashMap(); // publication.module.variablename = value from publication.xconf
- // static Map defaultvariables = new HashMap(); // publication.module.variablename = value from module.xml
- // static Map globalvariables = new HashMap(); // module.variable = value from global module.xml
- // static boolean isGlobalvariablesSet = false;
private String publicationId;
- // private String servletContextPath;
private String contentType;
// Dev testing
Configuration config;
@@ -265,11 +260,4 @@
} // for
return map;
}
- // private Publication getPublication() {
- // try{
- // return PublicationFactory.getPublication(publicationId, servletContextPath);
- // }catch(org.apache.lenya.cms.publication.PublicationException pe){
- // return (Publication) null;
- // }
- // }
}
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/AbstractPublication.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/AbstractPublication.java?rev=617315&r1=617314&r2=617315&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/AbstractPublication.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/AbstractPublication.java Thu Jan 31 16:23:00 2008
@@ -27,6 +27,7 @@
import org.apache.lenya.cms.content.Content;
import org.apache.lenya.cms.content.flat.FlatContent;
import org.apache.lenya.cms.content.hierarchical.HierarchicalContent;
+import org.apache.lenya.cms.modules.PublicationModules;
import org.apache.lenya.cms.publishing.PublishingEnvironment;
import org.apache.log4j.Logger;
// Lenya1.3 - END
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PageEnvelope.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PageEnvelope.java?rev=617315&r1=617314&r2=617315&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PageEnvelope.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PageEnvelope.java Thu Jan 31 16:23:00 2008
@@ -16,273 +16,267 @@
*/
/* $Id$ */
package org.apache.lenya.cms.publication;
-
import java.util.Map;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.lenya.cms.rc.RCEnvironment;
+import org.apache.lenya.util.Globals;
import org.apache.lenya.util.ServletHelper;
-
/**
- * A page envelope carries a set of information that are needed during the
- * presentation of a document.
+ * A page envelope carries a set of information that are needed during the presentation of a document.
*/
public class PageEnvelope {
- public static final String PUBLICATION_ID = "publication-id";
- public static final String PUBLICATION = "publication";
- public static final String PUBLICATION_LANGUAGES_CSV = "publication-languages-csv";
- public static final String CONTEXT = "context-prefix";
- public static final String AREA = "area";
- public static final String DEFAULT_LANGUAGE = "default-language";
- public static final String DOCUMENT = "document";
- public static final String DOCUMENT_ID = "document-id";
- public static final String DOCUMENT_NAME = "document-name";
- public static final String DOCUMENT_TYPE = "document-type";
- public static final String DOCUMENT_NODE_ID = "document-node-id";
- public static final String DOCUMENT_LABEL = "document-label";
- public static final String DOCUMENT_URL = "document-url";
- public static final String DOCUMENT_URL_WITHOUT_LANGUAGE = "document-url-without-language";
- public static final String DOCUMENT_FILE = "document-file";
- public static final String DOCUMENT_PATH = "document-path";
- public static final String DOCUMENT_EXTENSION = "document-extension";
- public static final String DOCUMENT_LANGUAGE = "document-language";
- public static final String DOCUMENT_LANGUAGES = "document-languages";
- public static final String DOCUMENT_LANGUAGES_CSV = "document-languages-csv";
- /**
- * @deprecated Use
- * {@link org.apache.lenya.cms.publication.Document#getDublinCore()}
- * instead
- */
- public static final String DOCUMENT_DC_TITLE = "document-dc-title";
- /**
- * @deprecated Use
- * {@link org.apache.lenya.cms.publication.Document#getDublinCore()}
- * instead
- */
- public static final String DOCUMENT_DC_CREATOR = "document-dc-creator";
- /**
- * @deprecated Use
- * {@link org.apache.lenya.cms.publication.Document#getDublinCore()}
- * instead
- */
- public static final String DOCUMENT_DC_SUBJECT = "document-dc-subject";
- /**
- * @deprecated Use
- * {@link org.apache.lenya.cms.publication.Document#getDublinCore()}
- * instead
- */
- public static final String DOCUMENT_DC_PUBLISHER = "document-dc-publisher";
- /**
- * @deprecated Use
- * {@link org.apache.lenya.cms.publication.Document#getDublinCore()}
- * instead
- */
- public static final String DOCUMENT_DC_DATE_CREATED = "document-dc-date-created";
- /**
- * @deprecated Use
- * {@link org.apache.lenya.cms.publication.Document#getDublinCore()}
- * instead
- */
- public static final String DOCUMENT_DC_DESCRIPTION = "document-dc-description";
- /**
- * @deprecated Use
- * {@link org.apache.lenya.cms.publication.Document#getDublinCore()}
- * instead
- */
- public static final String DOCUMENT_DC_RIGHTS = "document-dc-rights";
- public static final String DOCUMENT_LASTMODIFIED = "document-lastmodified";
- public static final String BREADCRUMB_PREFIX = "breadcrumb-prefix";
- public static final String SSL_PREFIX = "ssl-prefix";
- public static final String NAMESPACE = "http://apache.org/cocoon/lenya/page-envelope/1.0";
- public static final String DEFAULT_PREFIX = "lenya";
- private String context;
- /**
- * Constructor.
- */
- protected PageEnvelope() {
- }
- /**
- * Creates a new instance of PageEnvelope from a sitemap inside a
- * publication.
- *
- * @param publication
- * The publication the page belongs to.
- * @param request
- * The request that calls the page.
- * @exception PageEnvelopeException
- * if an error occurs
- * @deprecated Performance problems. Use
- * {@link PageEnvelopeFactory#getPageEnvelope(Map)} instead.
- */
- public PageEnvelope(Publication publication, Request request) throws PageEnvelopeException {
- init(publication, request);
- }
- /**
- * Creates a page envelope from an object model.
- *
- * @param objectModel
- * The object model.
- * @throws PageEnvelopeException
- * when something went wrong.
- * @deprecated Performance problems. Use
- * {@link PageEnvelopeFactory#getPageEnvelope(Map)} instead.
- */
- public PageEnvelope(Map objectModel) throws PageEnvelopeException {
- try {
- init(PublicationFactory.getPublication(objectModel), ObjectModelHelper.getRequest(objectModel));
- } catch (PublicationException e) {
- throw new PageEnvelopeException(e);
- }
- }
- /**
- * Creates a new instance of PageEnvelope from a sitemap inside a
- * publication.
- *
- * @param publication
- * The publication the page belongs to.
- * @param request
- * The request that calls the page.
- * @param createdByFactory
- * A dummy parameter to allow creating an additional protected
- * constructor that is not deprecated.
- * @exception PageEnvelopeException
- * if an error occurs
- */
- public PageEnvelope(Publication publication, Request request, boolean createdByFactory) throws PageEnvelopeException {
- this(publication, request);
- }
- /**
- * Creates a page envelope from an object model.
- *
- * @param objectModel
- * The object model.
- * @param createdByFactory
- * A dummy parameter to allow creating an additional protected
- * constructor that is not deprecated.
- * @throws PageEnvelopeException
- * when something went wrong.
- */
- protected PageEnvelope(Map objectModel, boolean createdByFactory) throws PageEnvelopeException {
- this(objectModel);
- }
- /**
- * Setup an instance of Publication.
- *
- * Shared by multiple constructors.
- *
- * @param publication
- * The publication the page belongs to.
- * @param request
- * The request that calls the page.
- *
- * @throws PageEnvelopeException
- * if an error occurs.
- */
- protected void init(Publication publication, Request request)
- // FIXME: this method is mainly needed because the deprecated
- // constructor PageEnvelope(Map objectModel) needs to handle an
- // exception in
- // one of the arguments to another constructor. That's why the
- // constructor
- // functionality is factored out into this method.
- // If the deprecated constructor PageEnvelope(Map objectModel) is
- // removed
- // this method might not be needed anymore and the functionality
- // could
- // be moved back to the constructor PageEnvelope(Publication
- // publication, Request request).
- throws PageEnvelopeException {
- // assert publication != null;
- // assert request != null;
- String webappURI;
- try {
- context = request.getContextPath();
- if (context == null) {
- context = "";
- }
- webappURI = ServletHelper.getWebappURI(request);
- Document document = publication.getDocumentBuilder().buildDocument(publication, webappURI);
- setDocument(document);
- } catch (Exception e) {
- throw new PageEnvelopeException(e);
- }
- // plausibility check
- /*
- * if (!webappURI .startsWith( "/" + getPublication().getId() + "/" +
- * document.getArea() + document.getId())) { throw new
- * PageEnvelopeException(createExceptionMessage(request)); }
- */
- }
- /**
- * Creates the message to report when creating the envelope failed.
- *
- * @param request
- * The request.
- * @return A string.
- */
- protected String createExceptionMessage(Request request) {
- return "Resolving page envelope failed:" + "\n URI: " + request.getRequestURI() + "\n Context: " + getContext() + "\n Publication ID: " + getPublication().getId() + "\n Area: " + document.getArea() + "\n Document ID: " + document.getId();
- }
- /**
- * Returns the publication of this PageEnvelope.
- *
- * @return a <code>Publication</code> value
- */
- public Publication getPublication() {
- return getDocument().getPublication();
- }
- /**
- * Returns the rcEnvironment.
- *
- * @return a <code>RCEnvironment</code> value
- * @deprecated We should detach the RC environment from the page envelope.
- */
- public RCEnvironment getRCEnvironment() {
- return RCEnvironment.getInstance(getPublication().getServletContext().getAbsolutePath());
- }
- /**
- * Returns the context, e.g. "/lenya".
- *
- * @return a <code>String</code> value
- */
- public String getContext() {
- return context;
- }
- /**
- * Returns the document-path.
- *
- * @return a <code>File<code> value
- */
- public String getDocumentPath() {
- return getPublication().getPathMapper().getPath(getDocument().getId(), getDocument().getLanguage());
- }
- /**
- * The names of the page envelope parameters.
- */
- public static final String[] PARAMETER_NAMES = { PageEnvelope.AREA, PageEnvelope.CONTEXT, PageEnvelope.PUBLICATION_ID, PageEnvelope.PUBLICATION, PageEnvelope.PUBLICATION_LANGUAGES_CSV, PageEnvelope.DOCUMENT, PageEnvelope.DOCUMENT_ID, PageEnvelope.DOCUMENT_NAME, PageEnvelope.DOCUMENT_NODE_ID, PageEnvelope.DOCUMENT_LABEL, PageEnvelope.DOCUMENT_URL, PageEnvelope.DOCUMENT_URL_WITHOUT_LANGUAGE, PageEnvelope.DOCUMENT_PATH, PageEnvelope.DOCUMENT_EXTENSION, PageEnvelope.DEFAULT_LANGUAGE, PageEnvelope.DOCUMENT_LANGUAGE, PageEnvelope.DOCUMENT_LANGUAGES, PageEnvelope.DOCUMENT_LANGUAGES_CSV, PageEnvelope.DOCUMENT_DC_TITLE, PageEnvelope.DOCUMENT_DC_CREATOR, PageEnvelope.DOCUMENT_DC_PUBLISHER, PageEnvelope.DOCUMENT_DC_SUBJECT, PageEnvelope.DOCUMENT_DC_DATE_CREATED, PageEnvelope.DOCUMENT_DC_DESCRIPTION, PageEnvelope.DOCUMENT_DC_RIGHTS, PageEnvelope.DOCUMENT_LASTMODIFIED, PageEnvelope.BREADCRUMB_PREFIX, PageEnvelope.SSL_PREFIX };
- /**
- * @param string
- * The context.
- */
- protected void setContext(String string) {
- context = string;
- }
- private Document document;
- /**
- * Returns the document.
- *
- * @return A document
- */
- public Document getDocument() {
- return document;
- }
- /**
- * Sets the document.
- *
- * @param document
- * A document.
- */
- public void setDocument(Document document) {
- this.document = document;
- }
+ public static final String PUBLICATION_ID = "publication-id";
+ public static final String PUBLICATION = "publication";
+ public static final String PUBLICATION_LANGUAGES_CSV = "publication-languages-csv";
+ public static final String CONTEXT = "context-prefix";
+ public static final String AREA = "area";
+ public static final String DEFAULT_LANGUAGE = "default-language";
+ public static final String DOCUMENT = "document";
+ public static final String DOCUMENT_ID = "document-id";
+ public static final String DOCUMENT_NAME = "document-name";
+ public static final String DOCUMENT_TYPE = "document-type";
+ public static final String DOCUMENT_NODE_ID = "document-node-id";
+ public static final String DOCUMENT_LABEL = "document-label";
+ public static final String DOCUMENT_URL = "document-url";
+ public static final String DOCUMENT_URL_WITHOUT_LANGUAGE = "document-url-without-language";
+ public static final String DOCUMENT_FILE = "document-file";
+ public static final String DOCUMENT_PATH = "document-path";
+ public static final String DOCUMENT_EXTENSION = "document-extension";
+ public static final String DOCUMENT_LANGUAGE = "document-language";
+ public static final String DOCUMENT_LANGUAGES = "document-languages";
+ public static final String DOCUMENT_LANGUAGES_CSV = "document-languages-csv";
+ /**
+ * @deprecated Use {@link org.apache.lenya.cms.publication.Document#getDublinCore()} instead
+ */
+ public static final String DOCUMENT_DC_TITLE = "document-dc-title";
+ /**
+ * @deprecated Use {@link org.apache.lenya.cms.publication.Document#getDublinCore()} instead
+ */
+ public static final String DOCUMENT_DC_CREATOR = "document-dc-creator";
+ /**
+ * @deprecated Use {@link org.apache.lenya.cms.publication.Document#getDublinCore()} instead
+ */
+ public static final String DOCUMENT_DC_SUBJECT = "document-dc-subject";
+ /**
+ * @deprecated Use {@link org.apache.lenya.cms.publication.Document#getDublinCore()} instead
+ */
+ public static final String DOCUMENT_DC_PUBLISHER = "document-dc-publisher";
+ /**
+ * @deprecated Use {@link org.apache.lenya.cms.publication.Document#getDublinCore()} instead
+ */
+ public static final String DOCUMENT_DC_DATE_CREATED = "document-dc-date-created";
+ /**
+ * @deprecated Use {@link org.apache.lenya.cms.publication.Document#getDublinCore()} instead
+ */
+ public static final String DOCUMENT_DC_DESCRIPTION = "document-dc-description";
+ /**
+ * @deprecated Use {@link org.apache.lenya.cms.publication.Document#getDublinCore()} instead
+ */
+ public static final String DOCUMENT_DC_RIGHTS = "document-dc-rights";
+ public static final String DOCUMENT_LASTMODIFIED = "document-lastmodified";
+ public static final String BREADCRUMB_PREFIX = "breadcrumb-prefix";
+ public static final String SSL_PREFIX = "ssl-prefix";
+ public static final String NAMESPACE = "http://apache.org/cocoon/lenya/page-envelope/1.0";
+ public static final String DEFAULT_PREFIX = "lenya";
+ private String context;
+ /**
+ * Constructor.
+ */
+ protected PageEnvelope() {
+ }
+ /**
+ * Creates a new instance of PageEnvelope from a sitemap inside a publication.
+ *
+ * @param publication
+ * The publication the page belongs to.
+ * @param request
+ * The request that calls the page.
+ * @exception PageEnvelopeException
+ * if an error occurs
+ * @deprecated Performance problems. Use {@link PageEnvelopeFactory#getPageEnvelope(Map)} instead.
+ */
+ public PageEnvelope(Publication publication, Request request) throws PageEnvelopeException {
+ init(publication, request);
+ }
+ /**
+ * Creates a page envelope from an object model.
+ *
+ * @param objectModel
+ * The object model.
+ * @throws PageEnvelopeException
+ * when something went wrong.
+ * @deprecated Performance problems. Use {@link PageEnvelopeFactory#getPageEnvelope(Map)} instead.
+ */
+ public PageEnvelope(Map objectModel) throws PageEnvelopeException {
+ try{
+ init(PublicationFactory.getPublication(objectModel), ObjectModelHelper.getRequest(objectModel));
+ }catch(PublicationException e){
+ throw new PageEnvelopeException(e);
+ }
+ }
+ /**
+ * Creates a new instance of PageEnvelope from a sitemap inside a publication.
+ *
+ * @param publication
+ * The publication the page belongs to.
+ * @param request
+ * The request that calls the page.
+ * @param createdByFactory
+ * A dummy parameter to allow creating an additional protected constructor that is not deprecated.
+ * @exception PageEnvelopeException
+ * if an error occurs
+ */
+ public PageEnvelope(Publication publication, Request request, boolean createdByFactory) throws PageEnvelopeException {
+ this(publication, request);
+ }
+ /**
+ * Creates a page envelope from an object model.
+ *
+ * @param objectModel
+ * The object model.
+ * @param createdByFactory
+ * A dummy parameter to allow creating an additional protected constructor that is not deprecated.
+ * @throws PageEnvelopeException
+ * when something went wrong.
+ */
+ protected PageEnvelope(Map objectModel, boolean createdByFactory) throws PageEnvelopeException {
+ this(objectModel);
+ }
+ /**
+ * Setup an instance of Publication.
+ *
+ * Shared by multiple constructors.
+ *
+ * @param publication
+ * The publication the page belongs to.
+ * @param request
+ * The request that calls the page.
+ *
+ * @throws PageEnvelopeException
+ * if an error occurs.
+ */
+ protected void init(Publication publication, Request request)
+ // FIXME: this method is mainly needed because the deprecated
+ // constructor PageEnvelope(Map objectModel) needs to handle an
+ // exception in
+ // one of the arguments to another constructor. That's why the
+ // constructor
+ // functionality is factored out into this method.
+ // If the deprecated constructor PageEnvelope(Map objectModel) is
+ // removed
+ // this method might not be needed anymore and the functionality
+ // could
+ // be moved back to the constructor PageEnvelope(Publication
+ // publication, Request request).
+ throws PageEnvelopeException {
+ // assert publication != null;
+ // assert request != null;
+ String webappURI;
+ try{
+ context = request.getContextPath();
+ if(context == null){
+ context = "";
+ }
+ webappURI = ServletHelper.getWebappURI(request);
+ Document document = publication.getDocumentBuilder().buildDocument(publication, webappURI);
+ setDocument(document);
+ }catch(Exception e){
+ throw new PageEnvelopeException(e);
+ }
+ // plausibility check
+ /*
+ * if (!webappURI .startsWith( "/" + getPublication().getId() + "/" + document.getArea() + document.getId())) { throw new PageEnvelopeException(createExceptionMessage(request)); }
+ */
+ }
+ /**
+ * Returns current PageEnvelope. Checks cached version in Request. Replaces PageEnvelopeFactory.
+ *
+ * @since 1.3
+ * @return PageEnvelope
+ * @throws PageEnvelopeException
+ */
+ static public PageEnvelope getCurrent() throws PageEnvelopeException {
+ Request request = Globals.getRequest();
+ Object o = request.getAttribute(PageEnvelope.class.getName());
+ if(null != o){
+ return (PageEnvelope) o;
+ }
+ PageEnvelope envelope = (PageEnvelope) request.getAttribute(PageEnvelope.class.getName());
+ envelope = new PageEnvelope(Globals.getObjectModel(), true);
+ request.setAttribute(PageEnvelope.class.getName(), envelope);
+ return envelope;
+ }
+ /**
+ * Creates the message to report when creating the envelope failed.
+ *
+ * @param request
+ * The request.
+ * @return A string.
+ */
+ protected String createExceptionMessage(Request request) {
+ return "Resolving page envelope failed:" + "\n URI: " + request.getRequestURI() + "\n Context: " + getContext() + "\n Publication ID: " + getPublication().getId() + "\n Area: " + document.getArea() + "\n Document ID: " + document.getId();
+ }
+ /**
+ * Returns the publication of this PageEnvelope.
+ *
+ * @return a <code>Publication</code> value
+ */
+ public Publication getPublication() {
+ return getDocument().getPublication();
+ }
+ /**
+ * Returns the rcEnvironment.
+ *
+ * @return a <code>RCEnvironment</code> value
+ * @deprecated We should detach the RC environment from the page envelope.
+ */
+ public RCEnvironment getRCEnvironment() {
+ return RCEnvironment.getInstance(getPublication().getServletContext().getAbsolutePath());
+ }
+ /**
+ * Returns the context, e.g. "/lenya".
+ *
+ * @return a <code>String</code> value
+ */
+ public String getContext() {
+ return context;
+ }
+ /**
+ * Returns the document-path.
+ *
+ * @return a <code>File<code> value
+ */
+ public String getDocumentPath() {
+ return getPublication().getPathMapper().getPath(getDocument().getId(), getDocument().getLanguage());
+ }
+ /**
+ * The names of the page envelope parameters.
+ */
+ public static final String[] PARAMETER_NAMES = {PageEnvelope.AREA, PageEnvelope.CONTEXT, PageEnvelope.PUBLICATION_ID, PageEnvelope.PUBLICATION, PageEnvelope.PUBLICATION_LANGUAGES_CSV, PageEnvelope.DOCUMENT, PageEnvelope.DOCUMENT_ID, PageEnvelope.DOCUMENT_NAME, PageEnvelope.DOCUMENT_NODE_ID, PageEnvelope.DOCUMENT_LABEL, PageEnvelope.DOCUMENT_URL, PageEnvelope.DOCUMENT_URL_WITHOUT_LANGUAGE, PageEnvelope.DOCUMENT_PATH, PageEnvelope.DOCUMENT_EXTENSION, PageEnvelope.DEFAULT_LANGUAGE, PageEnvelope.DOCUMENT_LANGUAGE, PageEnvelope.DOCUMENT_LANGUAGES, PageEnvelope.DOCUMENT_LANGUAGES_CSV, PageEnvelope.DOCUMENT_DC_TITLE, PageEnvelope.DOCUMENT_DC_CREATOR, PageEnvelope.DOCUMENT_DC_PUBLISHER, PageEnvelope.DOCUMENT_DC_SUBJECT, PageEnvelope.DOCUMENT_DC_DATE_CREATED, PageEnvelope.DOCUMENT_DC_DESCRIPTION, PageEnvelope.DOCUMENT_DC_RIGHTS, PageEnvelope.DOCUMENT_LASTMODIFIED, PageEnvelope.BREADCRUMB_PREFIX, PageEnvelope.SSL_PREFIX};
+ /**
+ * @param string
+ * The context.
+ */
+ protected void setContext(String string) {
+ context = string;
+ }
+ private Document document;
+ /**
+ * Returns the document.
+ *
+ * @return A document
+ */
+ public Document getDocument() {
+ return document;
+ }
+ /**
+ * Sets the document.
+ *
+ * @param document
+ * A document.
+ */
+ public void setDocument(Document document) {
+ this.document = document;
+ }
}
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PageEnvelopeFactory.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PageEnvelopeFactory.java?rev=617315&r1=617314&r2=617315&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PageEnvelopeFactory.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/PageEnvelopeFactory.java Thu Jan 31 16:23:00 2008
@@ -14,55 +14,48 @@
* limitations under the License.
*
*/
-
/* $Id$ */
-
package org.apache.lenya.cms.publication;
-
import java.util.Map;
-
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
-
-
/**
* Common entry point for creating page envelopes.
+ *
+ * @deprecated Use PageEnvelope.getCurrent()
*/
public class PageEnvelopeFactory {
- /**
- * Creates a new PageEnvelopeFactory.
- */
- protected PageEnvelopeFactory() {
- }
-
- private static PageEnvelopeFactory instance;
-
- /**
- * Returns the singleton PageEnvelopeFactory.
- * @return The factory.
- */
- public static PageEnvelopeFactory getInstance() {
- if (instance == null) {
- instance = new PageEnvelopeFactory();
- }
- return instance;
- }
-
- /**
- * Returns the page envelope for the object model of a Cocoon component.
- * @param objectModel The object model.
- * @return A page envelope.
- * @throws PageEnvelopeException if something went wrong.
- */
- public PageEnvelope getPageEnvelope(Map objectModel)
- throws PageEnvelopeException {
- Request request = ObjectModelHelper.getRequest(objectModel);
- PageEnvelope envelope = (PageEnvelope) request.getAttribute(PageEnvelope.class.getName());
-
- envelope = new PageEnvelope(objectModel, true);
- request.setAttribute(PageEnvelope.class.getName(), envelope);
-
- return envelope;
- }
-
+ /**
+ * Creates a new PageEnvelopeFactory.
+ */
+ protected PageEnvelopeFactory() {
+ }
+ private static PageEnvelopeFactory instance;
+ /**
+ * Returns the singleton PageEnvelopeFactory.
+ *
+ * @return The factory.
+ */
+ public static PageEnvelopeFactory getInstance() {
+ if(instance == null){
+ instance = new PageEnvelopeFactory();
+ }
+ return instance;
+ }
+ /**
+ * Returns the page envelope for the object model of a Cocoon component.
+ *
+ * @param objectModel
+ * The object model.
+ * @return A page envelope.
+ * @throws PageEnvelopeException
+ * if something went wrong.
+ */
+ public PageEnvelope getPageEnvelope(Map objectModel) throws PageEnvelopeException {
+ Request request = ObjectModelHelper.getRequest(objectModel);
+ PageEnvelope envelope = (PageEnvelope) request.getAttribute(PageEnvelope.class.getName());
+ envelope = new PageEnvelope(objectModel, true);
+ request.setAttribute(PageEnvelope.class.getName(), envelope);
+ return envelope;
+ }
}
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/Publication.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/Publication.java?rev=617315&r1=617314&r2=617315&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/Publication.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/Publication.java Thu Jan 31 16:23:00 2008
@@ -21,6 +21,7 @@
import java.io.File;
+import org.apache.lenya.cms.modules.PublicationModules;
import org.apache.lenya.cms.publishing.PublishingEnvironment;
// LENYA1.3 - BEGIN
import org.apache.lenya.cms.content.Content;
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/util/Globals.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/util/Globals.java?rev=617315&r1=617314&r2=617315&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/util/Globals.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/util/Globals.java Thu Jan 31 16:23:00 2008
@@ -2,10 +2,18 @@
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Map;
+import org.apache.cocoon.environment.Context;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.Response;
import org.apache.cocoon.environment.http.HttpContext;
import org.apache.cocoon.environment.http.HttpEnvironment;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
+import org.apache.lenya.cms.publication.PageEnvelope;
+import org.apache.lenya.cms.publication.PageEnvelopeException;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.PublicationFactory;
import org.apache.log.ContextMap;
/**
* Static functions for accessing global and thread-based constants.
@@ -15,32 +23,34 @@
*
*/
public final class Globals {
+ /**
+ * Prevent instantiation.
+ */
private Globals() {
}
- // null
static public String getAction() {
- ContextMap contextMap = ContextMap.getCurrentContext();
- Map map = (Map) contextMap.get("objectModel");
- HttpEnvironment he = (HttpEnvironment) map.get("source-resolver");
+ HttpEnvironment he = (HttpEnvironment) getObjectModel().get("source-resolver");
return he.getAction();
}
// null
static public String getContentType() {
- ContextMap contextMap = ContextMap.getCurrentContext();
- Map map = (Map) contextMap.get("objectModel");
- HttpEnvironment he = (HttpEnvironment) map.get("source-resolver");
+ HttpEnvironment he = (HttpEnvironment) getObjectModel().get("source-resolver");
return he.getContentType();
}
+ public static final Context getContext() {
+ return (Context) getObjectModel().get(ObjectModelHelper.CONTEXT_OBJECT);
+ }
// file:///F:/eclipseWS/Lenya13x/build/lenya/webapp/lenya/modules/authoring/
// file:///F:/eclipseWS/Lenya13x/build/lenya/webapp/lenya/modules/cache/module.xmap
// file:///F:/eclipseWS/Lenya13x/build/lenya/webapp/lenya/modules/edit/
// ?? Last use of map:mount
- static public String getContext() {
- ContextMap contextMap = ContextMap.getCurrentContext();
- Map map = (Map) contextMap.get("objectModel");
- HttpEnvironment he = (HttpEnvironment) map.get("source-resolver");
+ static public String getEnvironmentContext() {
+ HttpEnvironment he = (HttpEnvironment) getObjectModel().get("source-resolver");
return he.getContext();
- }
+ }
+ public static final Long getExpires() {
+ return (Long) getObjectModel().get(ObjectModelHelper.EXPIRES_OBJECT);
+ }
static public String getModule() {
Source source = getSource();
if(null == source)
@@ -55,27 +65,47 @@
}
return ret;
}
+ // null
+ static public Map getObjectModel() {
+ ContextMap contextMap = ContextMap.getCurrentContext();
+ return (Map) contextMap.get("objectModel");
+ }
+ static public Publication getPublication() {
+ try{
+ return PageEnvelope.getCurrent().getPublication();
+ }catch(PageEnvelopeException e){
+ System.out.println("Globals.getPublication failed: " + e.getLocalizedMessage());
+ }
+ return null;
+ }
+ static public Publication getPublication(String publicationId) {
+ try{
+ return PublicationFactory.getPublication(publicationId, getServletContextPath());
+ }catch(org.apache.lenya.cms.publication.PublicationException pe){
+ return (Publication) null;
+ }
+ }
+ public static final Request getRequest() {
+ return (Request) getObjectModel().get(ObjectModelHelper.REQUEST_OBJECT);
+ }
+ public static final Response getResponse() {
+ return (Response) getObjectModel().get(ObjectModelHelper.RESPONSE_OBJECT);
+ }
// file:///F:/eclipseWS/Lenya13x/build/lenya/webapp/
// ??? servletContextPath with protocol
static public String getRootContext() {
- ContextMap contextMap = ContextMap.getCurrentContext();
- Map map = (Map) contextMap.get("objectModel");
- HttpEnvironment he = (HttpEnvironment) map.get("source-resolver");
+ HttpEnvironment he = (HttpEnvironment) getObjectModel().get("source-resolver");
return he.getRootContext();
}
// Jetty/4.2
static public String getServerName() {
- ContextMap contextMap = ContextMap.getCurrentContext();
- Map map = (Map) contextMap.get("objectModel");
- HttpContext hc = (HttpContext) map.get("context");
+ HttpContext hc = (HttpContext) getObjectModel().get("context");
return hc.getServerInfo();
}
// F:\eclipseWS\Lenya13x\build\lenya\webapp
// servletContextPath in OS' native format
static public String getServletContextPath() {
- ContextMap contextMap = ContextMap.getCurrentContext();
- Map map = (Map) contextMap.get("objectModel");
- HttpContext hc = (HttpContext) map.get("context");
+ HttpContext hc = (HttpContext) getObjectModel().get("context");
return hc.getRealPath("");
}
// Source.getURI() =
@@ -91,9 +121,7 @@
* FileSource
*/
static public Source getSource() {
- ContextMap contextMap = ContextMap.getCurrentContext();
- Map map = (Map) contextMap.get("objectModel");
- HttpEnvironment he = (HttpEnvironment) map.get("source-resolver");
+ HttpEnvironment he = (HttpEnvironment) getObjectModel().get("source-resolver");
try{
return he.resolveURI("");
}catch(MalformedURLException e){
@@ -107,34 +135,29 @@
}
// C:\DOCUME~1\solprovider\LOCALS~1\Temp\Jetty__8888__
static public String getTempDir() {
- ContextMap contextMap = ContextMap.getCurrentContext();
- Map map = (Map) contextMap.get("objectModel");
- HttpContext hc = (HttpContext) map.get("context");
+ HttpContext hc = (HttpContext) getObjectModel().get("context");
return (String) hc.getAttribute("javax.servlet.context.tempdir");
}
+ public static final Throwable getThrowable() {
+ return (Throwable) getObjectModel().get(ObjectModelHelper.THROWABLE_OBJECT);
+ }
// authoring/index.html
// edit
// live/features_en.html
// live/index.html
// ??? The current match string for the XMAP.
static public String getURI() {
- ContextMap contextMap = ContextMap.getCurrentContext();
- Map map = (Map) contextMap.get("objectModel");
- HttpEnvironment he = (HttpEnvironment) map.get("source-resolver");
+ HttpEnvironment he = (HttpEnvironment) getObjectModel().get("source-resolver");
return he.getURI();
}
// default13/
static public String getURIPrefix() {
- ContextMap contextMap = ContextMap.getCurrentContext();
- Map map = (Map) contextMap.get("objectModel");
- HttpEnvironment he = (HttpEnvironment) map.get("source-resolver");
+ HttpEnvironment he = (HttpEnvironment) getObjectModel().get("source-resolver");
return he.getURIPrefix();
}
// null
static public String getView() {
- ContextMap contextMap = ContextMap.getCurrentContext();
- Map map = (Map) contextMap.get("objectModel");
- HttpEnvironment he = (HttpEnvironment) map.get("source-resolver");
+ HttpEnvironment he = (HttpEnvironment) getObjectModel().get("source-resolver");
return he.getView();
}
}
Modified: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/module.xml
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/module.xml?rev=617315&r1=617314&r2=617315&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/module.xml (original)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/module.xml Thu Jan 31 16:23:00 2008
@@ -1,13 +1,4 @@
-<module id="edit" name="Edit">
- <version>
- <minimum>1.3</minimum>
- <created>1.3</created>
- <content>flat</content>
- </version>
- <dependencies>
- <recommended id="authoring">Failover for hierarchical content publications.</recommended>
- </dependencies>
-<description>PageModule for editing Resources.</description>
- <usage>
- </usage>
+<module id="edit" name="Edit" minimum="1.3" created="1.3" content="flat">
+ <recommended id="authoring">Failover for hierarchical content publications.</recommended>
+ <description>PageModule for editing Resources.</description>
</module>
Modified: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/home/module.xml
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/home/module.xml?rev=617315&r1=617314&r2=617315&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/home/module.xml (original)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/home/module.xml Thu Jan 31 16:23:00 2008
@@ -1,14 +1,7 @@
-<module id="homepage" name="Homepage" inherit="xhtml">
+<module id="homepage" name="Homepage" inherit="xhtml" minimum="1.3" created="1.3" resourcePath="/xml/xhtml">
<!-- Homepage Concept was originally xml/homepage Resource type. This should be child of /xml/xhtml and inherit xmap from live/xml/xhtml.
Allows removal of special case in live/module.xmap once 1.2 backwards-compatibility is not needed.
Change migration (flat) module. -->
- <version>
- <minimum>1.3</minimum>
- <created>1.3</created>
- </version>
- <dependencies>
- <resourcePath>/xml/xhtml</resourcePath>
- </dependencies>
<description>Alternate XSL for home resource type.</description>
<usage>
</usage>
Modified: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/module.xml
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/module.xml?rev=617315&r1=617314&r2=617315&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/module.xml (original)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/module.xml Thu Jan 31 16:23:00 2008
@@ -1,14 +1,6 @@
-<module id="link" name="Link">
- <version>
- <minimum>1.3</minimum>
- <created>1.3</created>
- <content>flat</content>
- </version>
- <dependencies>
- <resourcePath>/</resourcePath>
- <required id="form">?Because.</required>
- <recommended id="edit">For editing</recommended>
- </dependencies>
+<module id="link" name="Link" minimum="1.3" created="1.3" content="flat" resourcePath="/">
+ <required id="form">?Because.</required>
+ <recommended id="edit">For editing</recommended>
<description>Link Resource Type</description>
<usage>
</usage>
Modified: lenya/branches/revolution/1.3.x/src/webapp/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/sitemap.xmap?rev=617315&r1=617314&r2=617315&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/sitemap.xmap (original)
+++ lenya/branches/revolution/1.3.x/src/webapp/sitemap.xmap Thu Jan 31 16:23:00 2008
@@ -48,6 +48,7 @@
-->
<!-- LENYA1.3 BEGIN -->
<map:generator name="sitetree" label="content,data" logger="sitemap.generator.sitetree" src="org.apache.lenya.cms.content.flat.SitetreeGenerator"/>
+ <map:generator name="modules" label="content,data" logger="sitemap.generator.modules" src="org.apache.lenya.cms.modules.ModulesGenerator"/>
<!-- From Lenya-1.2.x -->
<map:generator name="sitetree2" logger="sitemap.generator.sitetree" pool-grow="2" pool-max="16" pool-min="2" src="org.apache.lenya.cms.cocoon.generation.SiteTreeGenerator"/>
<!-- LENYA1.3 END -->
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org