[Yanel-commits] rev 25732 - in public/yanel/trunk/src:
contributions/resources/nutch/src/test/junit/org/wyona/yanel/impl/resources
core/java/org/wyona/yanel/core
resources/directory/src/java/org/wyona/yanel/impl/resources
webapp/src/java/org/wyona/yanel/servlet
michi at wyona.com
michi at wyona.com
Tue Jul 3 15:24:54 CEST 2007
Author: michi
Date: 2007-07-03 15:24:54 +0200 (Tue, 03 Jul 2007)
New Revision: 25732
Modified:
public/yanel/trunk/src/contributions/resources/nutch/src/test/junit/org/wyona/yanel/impl/resources/NutchResourceTest.java
public/yanel/trunk/src/core/java/org/wyona/yanel/core/Environment.java
public/yanel/trunk/src/resources/directory/src/java/org/wyona/yanel/impl/resources/DirectoryResource.java
public/yanel/trunk/src/webapp/src/java/org/wyona/yanel/servlet/YanelServlet.java
Log:
area replaced by stateOfView and getPath replaced by getResourceContainerPath
Modified: public/yanel/trunk/src/contributions/resources/nutch/src/test/junit/org/wyona/yanel/impl/resources/NutchResourceTest.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/nutch/src/test/junit/org/wyona/yanel/impl/resources/NutchResourceTest.java 2007-07-03 12:14:42 UTC (rev 25731)
+++ public/yanel/trunk/src/contributions/resources/nutch/src/test/junit/org/wyona/yanel/impl/resources/NutchResourceTest.java 2007-07-03 13:24:54 UTC (rev 25732)
@@ -48,7 +48,7 @@
Map map = yanel.getMap();
Realm realm = yanel.getMap().getRealm(url);
String path = yanel.getMap().getPath(realm, url);
- Environment environment = new Environment(null, null, null, null);
+ Environment environment = new Environment(null, null, null, null, null);
this.resource = (NutchResource)yanel.getResourceManager().getResource(environment, realm, path);
confDir = this.resource.getRTD().getConfigFile().getParentFile().getAbsolutePath() +
File.separator + "conf" + File.separator;
Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/core/Environment.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/Environment.java 2007-07-03 12:14:42 UTC (rev 25731)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/Environment.java 2007-07-03 13:24:54 UTC (rev 25732)
@@ -24,7 +24,7 @@
/**
* The environment stores items which belong to the environment from which a resource
- * is called, i.e. the request, the response, the identity, and the area.
+ * is called, i.e. the request, the response, the identity, the state of view, and the resource container path.
*/
public class Environment {
@@ -33,13 +33,15 @@
private HttpServletRequest request;
private HttpServletResponse response;
private Identity identity;
- private String area;
+ private String sov;
+ private String rcp;
- public Environment(HttpServletRequest request, HttpServletResponse response, Identity identity, String area) {
+ public Environment(HttpServletRequest request, HttpServletResponse response, Identity identity, String stateOfView, String resourceContainerPath) {
this.request = request;
this.response = response;
this.identity = identity;
- this.area = area;
+ this.sov = stateOfView;
+ this.rcp = resourceContainerPath;
}
public Identity getIdentity() {
@@ -54,12 +56,20 @@
return response;
}
- public String getArea() {
- return area;
+ public String getStateOfView() {
+ return sov;
}
+
+ public String getResourceContainerPath() {
+ return rcp;
+ }
+
+ public void setResourceContainerPath(String path) {
+ this.rcp = path;
+ }
- public void setArea(String area) {
- this.area = area;
+ public void setStateOfView(String state) {
+ this.sov = state;
}
public void setIdentity(Identity identity) {
Modified: public/yanel/trunk/src/resources/directory/src/java/org/wyona/yanel/impl/resources/DirectoryResource.java
===================================================================
--- public/yanel/trunk/src/resources/directory/src/java/org/wyona/yanel/impl/resources/DirectoryResource.java 2007-07-03 12:14:42 UTC (rev 25731)
+++ public/yanel/trunk/src/resources/directory/src/java/org/wyona/yanel/impl/resources/DirectoryResource.java 2007-07-03 13:24:54 UTC (rev 25732)
@@ -16,6 +16,7 @@
package org.wyona.yanel.impl.resources;
+import org.wyona.yanel.core.Environment;
import org.wyona.yanel.core.Path;
import org.wyona.yanel.core.Resource;
import org.wyona.yanel.core.ResourceConfiguration;
@@ -58,6 +59,8 @@
public class DirectoryResource extends Resource implements ViewableV2, CreatableV2 {
private static Category log = Category.getInstance(DirectoryResource.class);
+
+ private Environment environment;
/**
*
@@ -76,6 +79,7 @@
*
*/
public View getView(String viewId) {
+ environment = getEnvironment();
View defaultView = new View();
StringBuffer sb = new StringBuffer("<?xml version=\"1.0\"?>");
@@ -249,10 +253,24 @@
String backToRoot = "";
int steps;
- if (getPath().endsWith("/") && !getPath().equals("/")) {
- steps = getPath().split("/").length - 1;
+ // TODO: Wouldn't it make more sense to use "tokens" and use a URL rewriter at the very end (also see the portlet specificatio http://jcp.org/aboutJava/communityprocess/review/jsr168/)
+ String resourceContainerPath = environment.getResourceContainerPath();
+ if (log.isDebugEnabled()) {
+ log.debug("Resource container path: " + resourceContainerPath);
+ log.debug("Resource path: " + getPath());
+ }
+ if (resourceContainerPath != null) {
+ if (resourceContainerPath.endsWith("/") && !resourceContainerPath.equals("/")) {
+ steps = resourceContainerPath.split("/").length - 1;
+ } else {
+ steps = resourceContainerPath.split("/").length - 2;
+ }
} else {
- steps = getPath().split("/").length - 2;
+ if (getPath().endsWith("/") && !getPath().equals("/")) {
+ steps = getPath().split("/").length - 1;
+ } else {
+ steps = getPath().split("/").length - 2;
+ }
}
for (int i = 0; i < steps; i++) {
Modified: public/yanel/trunk/src/webapp/src/java/org/wyona/yanel/servlet/YanelServlet.java
===================================================================
--- public/yanel/trunk/src/webapp/src/java/org/wyona/yanel/servlet/YanelServlet.java 2007-07-03 12:14:42 UTC (rev 25731)
+++ public/yanel/trunk/src/webapp/src/java/org/wyona/yanel/servlet/YanelServlet.java 2007-07-03 13:24:54 UTC (rev 25732)
@@ -426,7 +426,7 @@
String revisionName = request.getParameter("yanel.resource.revision");
if (ResourceAttributeHelper.hasAttributeImplemented(res, "Versionable", "2") && revisionName != null) {
view = ((VersionableV2) res).getView(viewId, revisionName);
- } else if (ResourceAttributeHelper.hasAttributeImplemented(res, "Workflowable", "1") && environment.getArea().equals(Area.LIVE)) {
+ } else if (ResourceAttributeHelper.hasAttributeImplemented(res, "Workflowable", "1") && environment.getStateOfView().equals(Area.LIVE)) {
WorkflowableV1 workflowable = (WorkflowableV1)res;
if (workflowable.isLive()) {
view = workflowable.getLiveView(viewId);
@@ -811,11 +811,12 @@
if (identity == null) {
identity = new Identity(); // world
}
- // TODO: implement detection of area
- String area = Area.AUTHORING;
- //String area = map.getArea(request.getServletPath());
- //System.out.println("url: " + request.getServletPath());
- //System.out.println("area: " + area);
+ Realm realm = map.getRealm(request.getServletPath());
+ // TODO: implement detection of state of view
+ String stateOfView = Area.AUTHORING;
+ //String area = map.getStateOfView(request.getServletPath());
+ //log.debug("url: " + request.getServletPath());
+ //log.debug("state of view: " + stateOfView);
/*String area = null;
Object toolbarAttr = request.getSession().getAttribute(TOOLBAR_KEY);
if (toolbarAttr != null && toolbarAttr.equals("on")) {
@@ -823,7 +824,7 @@
} else {
area = "live";
}*/
- Environment environment = new Environment(request, response, identity, area);
+ Environment environment = new Environment(request, response, identity, stateOfView, null);
return environment;
} catch (Exception e) {
throw new ServletException(e.getMessage(), e);
More information about the Yanel-commits
mailing list