[Yanel-commits] rev 36528 -
public/yanel/trunk/src/contributions/resources/data-repo-sitetree/src/java/org/wyona/yanel/impl/resources/navigation
simon at wyona.com
simon at wyona.com
Tue May 13 15:42:06 CEST 2008
Author: simon
Date: 2008-05-13 15:42:05 +0200 (Tue, 13 May 2008)
New Revision: 36528
Modified:
public/yanel/trunk/src/contributions/resources/data-repo-sitetree/src/java/org/wyona/yanel/impl/resources/navigation/DataRepoSitetreeResource.java
Log:
improved. made configurable path-paramter-name and show-all-subnodes
Modified: public/yanel/trunk/src/contributions/resources/data-repo-sitetree/src/java/org/wyona/yanel/impl/resources/navigation/DataRepoSitetreeResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/data-repo-sitetree/src/java/org/wyona/yanel/impl/resources/navigation/DataRepoSitetreeResource.java 2008-05-13 13:26:47 UTC (rev 36527)
+++ public/yanel/trunk/src/contributions/resources/data-repo-sitetree/src/java/org/wyona/yanel/impl/resources/navigation/DataRepoSitetreeResource.java 2008-05-13 13:42:05 UTC (rev 36528)
@@ -56,9 +56,15 @@
* Get sitetree as XML
*/
private String getSitetreeAsXML() {
+ String name4pathParameter;
+ try {
+ name4pathParameter = getResourceConfigProperty("name4path-parameter");
+ } catch (Exception e) {
+ name4pathParameter = "path";
+ }
StringBuffer sb = new StringBuffer("<sitetree>");
- if (getRequest().getParameter("path") != null) {
- sb.append(getNodeAsXML(request.getParameter("path")));
+ if (getEnvironment().getRequest().getParameter(name4pathParameter) != null) {
+ sb.append(getNodeAsXML(request.getParameter(name4pathParameter)));
} else {
sb.append(getNodeAsXML("/"));
}
@@ -77,6 +83,14 @@
* Get node as XML
*/
private String getNodeAsXML(String path) {
+ boolean showAllSubnodes = true;
+ try {
+ if (getResourceConfigProperty("show-all-subnodes") != null) {
+ showAllSubnodes = Boolean.valueOf(getResourceConfigProperty("show-all-subnodes")).booleanValue();
+ }
+ } catch (Exception e) {
+ log.info("could not get property show-all-subnodes. falling back to show-all-subnodes=true.");
+ }
//private String getNodeAsXML(com.hp.hpl.jena.rdf.model.Resource resource) {
//log.error("DEBUG: Path: " + path);
Sitetree sitetree = getRealm().getRepoNavigation();
@@ -98,10 +112,12 @@
if (node != null) {
if (node.isCollection()) {
- sb.append("<collection path=\"" + path + "\" name=\"" + node.getName() + "\">");
- // TODO: ...
- sb.append("<label><![CDATA[" + node.getName() + "]]></label>");
- //sb.append("<label><![CDATA[" + node.getLabel() + "]]></label>");
+ if (showAllSubnodes) {
+ sb.append("<collection path=\"" + path + "\" name=\"" + node.getName() + "\">");
+ // TODO: ...
+ sb.append("<label><![CDATA[" + node.getName() + "]]></label>");
+ //sb.append("<label><![CDATA[" + node.getLabel() + "]]></label>");
+ }
Node[] children = node.getChildren();
for (int i = 0; i < children.length; i++) {
String childPath = path + "/" + children[i].getName();
@@ -111,7 +127,15 @@
//log.debug("Child path: " + childPath);
if (children[i].isCollection()) {
- sb.append(getNodeAsXML(childPath));
+ if (!showAllSubnodes) {
+ sb.append("<collection path=\"" + childPath + "\" name=\"" + children[i].getName() + "\">");
+ // TODO: ...
+ sb.append("<label><![CDATA[" +children[i].getName() + "]]></label>");
+ //sb.append("<label><![CDATA[" + children[i].getLabel() + "]]></label>");
+ sb.append("</collection>");
+ } else {
+ sb.append(getNodeAsXML(childPath));
+ }
//sb.append(getNodeAsXML(children[i].getPath()));
} else if (children[i].isResource()) {
sb.append("<resource path=\"" + childPath + "\" name=\"" + children[i].getName() + "\">");
@@ -125,7 +149,9 @@
//sb.append("<neither-resource-nor-collection path=\"" + children[i].getPath() + "\" name=\"" + children[i].getName() + "\"/>");
}
}
- sb.append("</collection>");
+ if (showAllSubnodes) {
+ sb.append("</collection>");
+ }
} else {
sb.append("<resource path=\"" + path + "\" name=\"" + node.getName() + "\">");
// TODO ...
More information about the Yanel-commits
mailing list