Author: andre
Date: 2009-06-05 12:41:11 +0200 (Fri, 05 Jun 2009)
New Revision: 35762
Modified:
mmbase/trunk/core/src/main/java/org/mmbase/framework/basic/BlockUrlConverter.java
mmbase/trunk/core/src/main/java/org/mmbase/framework/basic/ChainedUrlConverter.java
Log:
javadoc
Modified:
mmbase/trunk/core/src/main/java/org/mmbase/framework/basic/BlockUrlConverter.java
===================================================================
---
mmbase/trunk/core/src/main/java/org/mmbase/framework/basic/BlockUrlConverter.java
2009-06-05 10:40:10 UTC (rev 35761)
+++
mmbase/trunk/core/src/main/java/org/mmbase/framework/basic/BlockUrlConverter.java
2009-06-05 10:41:11 UTC (rev 35762)
@@ -28,7 +28,9 @@
protected final BasicFramework framework;
protected Set<Component> components = null;
+ protected final Map<Component, Set<Block>> blocks = new HashMap<Component,
Set<Block>>();
+
public BlockUrlConverter(BasicFramework fw) {
framework = fw;
}
@@ -40,21 +42,52 @@
return new Parameter[] {Parameter.REQUEST, Framework.COMPONENT,
Framework.BLOCK};
}
+ /**
+ * Explicitly add a block to make sure this BlockUrlConverter is only
about that block.
+ *
+ */
protected void addComponent(Component comp) {
if (components == null) components = new HashSet<Component>();
components.add(comp);
}
-
+
/**
- * The components for which this URLconverter can produce nice url. Or
<code>null</code> if it
+ * Explicitly add a block to make sure this BlockUrlConverter is only
about that block.
+ *
+ */
+ protected void addBlock(Block b) {
+ Component comp = b.getComponent();
+ addComponent(comp);
+ Set<Block> bs = blocks.get(comp);
+ if (bs == null) {
+ bs = new HashSet<Block>();
+ blocks.put(comp, bs);
+ }
+ bs.add(b);
+ }
+
+ /**
+ * The components for which this UrlConverter can produce a 'nice' url. Or
<code>null</code> if it
* can do that for any component.
*/
- protected Set<Component> getComponents() {
+ protected Collection<Component> getComponents() {
+ if (components == null) return
ComponentRepository.getInstance().getComponents();
return components;
}
+
+ /**
+ * The blocks for which this UrlConverter can produce a 'nice' url.
+ *
+ */
+ protected Collection<Block> getBlocks(Component c) {
+ Set<Block> bs = blocks.get(c);
+ if (bs != null) {
+ return bs;
+ } else {
+ return c.getBlocks();
+ }
+ }
-
-
/**
* This proposal implemention simply uses {...@link Framework#COMPONENT}
and {...@link
* Framework#BLOCK} framework parameters to determin the explicit block
for {...@link #getUrl},
@@ -102,8 +135,9 @@
// First explore
Block block = getExplicitBlock(path, frameworkParameters);
if (block != null) {
- if (components != null && !
components.contains(block.getComponent())) {
- log.debug("Explicit block, but not mine one");
+ Component component = block.getComponent();
+ if (!getComponents().contains(component) ||
!getBlocks(component).contains(block)) {
+ log.debug("Explicit block, but not from this component or not
the right block");
return null;
}
return block;
@@ -158,6 +192,7 @@
Map<String, ?> parameters,
Parameters frameworkParameters, boolean
escapeAmps, boolean action) throws FrameworkException {
Block block = getBlock(path, frameworkParameters);
+ log.debug("path: " + path);
if (block != null) {
Map<String, Object> map = new HashMap<String, Object>();
Url niceUrl;
Modified:
mmbase/trunk/core/src/main/java/org/mmbase/framework/basic/ChainedUrlConverter.java
===================================================================
---
mmbase/trunk/core/src/main/java/org/mmbase/framework/basic/ChainedUrlConverter.java
2009-06-05 10:40:10 UTC (rev 35761)
+++
mmbase/trunk/core/src/main/java/org/mmbase/framework/basic/ChainedUrlConverter.java
2009-06-05 10:41:11 UTC (rev 35762)
@@ -27,6 +27,7 @@
* question remains whether we want UrlConverters to be realy chained so that
the
* outcome of a converter can be added to the outcome of its preceder.
*
+ * @author Michiel Meeuwissen
* @author André van Toly
* @version $Id$
* @since MMBase-1.9
@@ -52,6 +53,7 @@
});
public static String URLCONVERTER = "org.mmbase.urlconverter";
+
/**
* List containing the UrlConverters found in the framework configuration.
*/
@@ -72,6 +74,7 @@
}
}
}
+
public boolean contains(UrlConverter u) {
return uclist.contains(u);
}
@@ -104,6 +107,11 @@
// return Link.NULL;
// }
+
+ /**
+ * The default weight of the UrlConverters. An Url proposal by an
UrlConverter receives a weight
+ * upon which is decided which one should resolve the request.
+ */
public int getDefaultWeight() {
return 0;
}
@@ -115,10 +123,14 @@
return false;
}
+ /**
+ * Upon examining the user request an 'nice' URL is proposed by an
UrlConverter to resolve the request.
+ * The proposed url receives a weight.
+ */
protected Url getProposal(Url u, Parameters frameworkParameters) {
HttpServletRequest request =
BasicUrlConverter.getUserRequest(frameworkParameters.get(Parameter.REQUEST));
UrlConverter current = (UrlConverter)
request.getAttribute(URLCONVERTER);
- Class<?> preferred = frameworkParameters.get(URLCONVERTER_PARAM);
+ Class<?> preferred = frameworkParameters.get(URLCONVERTER_PARAM);
Url b = u;
if (preferred != null && ! preferred.isInstance(u.getUrlConverter())) {
int q = b.getWeight();
@@ -132,7 +144,8 @@
}
/**
- * The URL to be printed in a page
+ * The URL to be printed in a page, the 'nice' url. This method requests
an url proposal from
+ * {...@link #getProposal} and decides upon their weight which one
prevails.
*/
public Url getUrl(String path,
Map<String, ?> params,
@@ -152,7 +165,11 @@
}
return result;
}
-
+
+
+ /**
+ * Basically the same as {...@link #getUrl} but for a Processor url.
+ */
public Url getProcessUrl(String path,
Map<String, ?> params,
Parameters frameworkParameters, boolean
escapeAmps) throws FrameworkException {
@@ -171,7 +188,9 @@
/**
- * The 'technical' url
+ * The 'technical' url. The 'nice' urls received by FrameworkFilter
resolve to these. This method
+ * decides upon their weight which of the proposed technical url's by the
UrlConverters matches
+ * the 'nice' url.
*/
public Url getInternalUrl(String path,
Map<String, ?> params,
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs