mcardle 2006/01/04 18:37:53 CET
Modified files:
core/src/java/org/jahia/services/esi JesiObject.java
Log:
* correctly parses various types of Jahia Urls
Revision Changes Path
1.9 +95 -83
jahia/core/src/java/org/jahia/services/esi/JesiObject.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/esi/JesiObject.java.diff?r1=1.8&r2=1.9&f=h
Index: JesiObject.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/services/esi/JesiObject.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- JesiObject.java 15 Nov 2005 12:47:39 -0000 1.8
+++ JesiObject.java 4 Jan 2006 17:37:53 -0000 1.9
@@ -90,67 +90,79 @@
query = Url.getQuery();
if (path != null) {
- //extract user part of url string
- int pos = path.indexOf("/user/");
- if (pos != -1) {
- user = path.substring(pos,
- path.indexOf("/",
- pos + "/user/".length()));
- }
+ String parsing = null;
+ try {
- //extract group part of url string
- pos = path.indexOf("/group/");
- if (pos != -1) {
- group = path.substring(pos,
- path.indexOf("/",
- pos + "/group/".length()));
- }
+ //extract user part of url string
+ parsing = "/user";
+ int pos = path.indexOf("/user/");
+ if (pos != -1) {
+ user = path.substring(pos,
+ path.indexOf("/",
+ pos + "/user/".length()));
+ }
- //extract site part of url string
- pos = path.indexOf("/site/");
- if (pos != -1) {
- site = path.substring(pos,
- path.indexOf("/",
- pos + "/site/".length()));
- }
+ //extract group part of url string
+ parsing = "/group";
+ pos = path.indexOf("/group/");
+ if (pos != -1) {
+ group = path.substring(pos,
+ path.indexOf("/",
+ pos + "/group/".length()));
+ }
- //extract mode part of url string
- pos = path.indexOf("/op/");
- if (pos != -1) {
- mode = path.substring(pos,
- path.indexOf("/",
- pos + "/op/".length()));
- }
+ //extract site part of url string
+ parsing = "/site";
- /* //extract site part of url string
- pos = path.indexOf("/site/");
- if (pos != -1) {
- site = path.substring(pos,
- path.indexOf("/",
- pos + "/site/".length()));
- }*/
-
- //extract prefix part of url string i.e. /jahia/Jahia or
/defaultContextPath/defaultServletPath
- pos = path.indexOf("/", 1);//gets the second slash from the
start of the URL
- if (pos != -1) {
- int endIndex = path.indexOf("/", pos + 1);//gets the third
slash from the start of the URL
- if (endIndex == -1) { //in case URL is of the following form
: http://192.168.2.178:7780/jahia/Jahia
- endIndex = path.length();
+ pos = path.indexOf("/site/");
+ if (pos != -1) {
+ site = path.substring(pos,
+ path.indexOf("/",
+ pos + "/site/".length()));
}
- prefix = path.substring(0, endIndex);
- //if ("".equals(prefix) || prefix==null)
- // prefix = path.substring(0, path.length() );
//corresponds to http://192.168.2.178:7779/jahia/Jahia
- }
+ //extract mode part of url string
+ parsing = "/op";
+ pos = path.indexOf("/op/");
+ if (pos != -1) {
+ int posOp = path.indexOf("/", pos + "/op/".length());
+ mode = path.substring(pos, (posOp == -1) ? path.length()
: posOp );
+ }
- //extract pid part of url string
- pos = path.indexOf("/pid/");
- if (pos != -1) {
- int posPid = path.indexOf("/", pos + "/pid/".length());
- pid = path.substring(pos,
- (posPid == -1) ? path.length() : posPid); //since
pid/5 might be the last part of URL i.e. no trailing /
+ /* //extract site part of url string
+ pos = path.indexOf("/site/");
+ if (pos != -1) {
+ site = path.substring(pos,
+ path.indexOf("/",
+ pos + "/site/".length()));
+ }*/
+
+ //extract prefix part of url string i.e. /jahia/Jahia or
/defaultContextPath/defaultServletPath
+ parsing = "/prefix";
+ pos = path.indexOf("/", 1);//gets the second slash from the
start of the URL
+ if (pos != -1) {
+ int endIndex = path.indexOf("/", pos + 1);//gets the
third slash from the start of the URL
+ if (endIndex == -1) { //in case URL is of the following
form : http://192.168.2.178:7780/jahia/Jahia
+ endIndex = path.length();
+ }
+ prefix = path.substring(0, endIndex);
+ //if ("".equals(prefix) || prefix==null)
+ // prefix = path.substring(0, path.length() );
//corresponds to http://192.168.2.178:7779/jahia/Jahia
+ }
+
+ //extract pid part of url string
+ parsing = "/pid";
+ pos = path.indexOf("/pid/");
+ if (pos != -1) {
+ int posPid = path.indexOf("/", pos + "/pid/".length());
+ pid = path.substring(pos,
+ (posPid == -1) ? path.length() : posPid);
//since pid/5 might be the last part of URL i.e. no trailing /
+ }
}
- } else logger.warn("[esi]: path string of JesiObject is null.
Shouldn't be.");
+ catch (Exception e) {
+ logger.warn("Could not parse "+parsing+ "/ parameter in URL
:"+Url+" . Exception is :"+e);
+ }
+ } else logger.warn("[esi]: path string of JesiObject is null.
Shouldn't be. In Url:"+Url);
}
/**
@@ -175,15 +187,15 @@
new Integer(fieldID)}); //TODO: convert to List since
not using other hashmap value
if (logger.isDebugEnabled())
logger.debug(objType + ".addField(): fieldID:" + fieldID +
- " on page " + pageID +
- " ===>> ADDED ");
+ " on page " + pageID +
+ " ===>> ADDED ");
return true;
} else {
if (logger.isDebugEnabled())
logger.debug(objType + ".addField(): fieldID:" + fieldID +
- " on page " + pageID +
- " ===>> Already added ");
+ " on page " + pageID +
+ " ===>> Already added ");
return false;
}
}
@@ -205,13 +217,13 @@
pages.put(key, new Integer(pageID));
if (logger.isDebugEnabled())
logger.debug(objType + ".addPage(): pageID:" + pageID +
- " ===>> ADDED ");
+ " ===>> ADDED ");
return true;
} else {
if (logger.isDebugEnabled())
logger.debug("[esi]: Fragment.addPage(): pageID:" + pageID +
- " ===>> Already added ");
+ " ===>> Already added ");
return false;
}
}
@@ -238,15 +250,15 @@
ctnListID0.put(defName, defName);
if (logger.isDebugEnabled())
logger.debug(objType + ".addContainerListID0(): defName:" +
defName +
- " on page " + pageID +
- " ===>> ADDED ");
+ " on page " + pageID +
+ " ===>> ADDED ");
return true;
} else {
if (logger.isDebugEnabled())
logger.debug(objType + ".addContainerListID0(): defName:" +
defName +
- " on page " + pageID +
- " ===>> Already added ");
+ " on page " + pageID +
+ " ===>> Already added ");
return false;
}
}
@@ -273,15 +285,15 @@
new Integer(ctnID)});
if (logger.isDebugEnabled())
logger.debug(objType + ".addContainer(): ctnID:" + ctnID +
- " on page " + pageID +
- " ===>> ADDED ");
+ " on page " + pageID +
+ " ===>> ADDED ");
return true;
} else {
if (logger.isDebugEnabled())
logger.debug(objType + ".addContainer(): ctnID:" + ctnID +
- " on page " + pageID +
- " ===>> Already added ");
+ " on page " + pageID +
+ " ===>> Already added ");
return false;
}
}
@@ -315,15 +327,15 @@
new Integer(ctnlistID)});
if (logger.isDebugEnabled())
logger.debug(objType + ".addContainerList(): ctnlistID:" +
- ctnlistID + " on page " + pageID +
- " ===>> ADDED ");
+ ctnlistID + " on page " + pageID +
+ " ===>> ADDED ");
return true;
} else {
if (logger.isDebugEnabled())
logger.debug(objType + ".addContainerList(): ctnlistID:" +
- ctnlistID + " on page " + pageID +
- " ===>> Already added ");
+ ctnlistID + " on page " + pageID +
+ " ===>> Already added ");
return false;
}
}
@@ -375,13 +387,13 @@
* within this JesiObject
*/
public boolean containsAclUserName(String username) {
- if (aclUserNames.contains(username)) {
- if (logger.isDebugEnabled())
- logger.debug("[esi]: The requesting user ["+username+"]
has specific permissions over content contained in this "+getObjDetails());
- return true;
- }
- else
- return false;
+ if (aclUserNames.contains(username)) {
+ if (logger.isDebugEnabled())
+ logger.debug("[esi]: The requesting user ["+username+"] has
specific permissions over content contained in this "+getObjDetails());
+ return true;
+ }
+ else
+ return false;
}
/**
@@ -406,11 +418,11 @@
public void emptyContent() {
if (logger.isDebugEnabled())
logger.debug(objType + " : Clearing [" + fields.size() + "]+
fields, " +
- " [" + ctns.size() + "] Containers, " +
- " [" + ctnlists.size() + "] ContainerLists, " +
- " [" + pages.size() + "] Pages, "+
- " [" + aclUserNames.size() + "] aclUserNames, "+
- " [" + this.ctnListID0.size() + "] ctnListID0 " );
+ " [" + ctns.size() + "] Containers, " +
+ " [" + ctnlists.size() + "] ContainerLists, " +
+ " [" + pages.size() + "] Pages, "+
+ " [" + aclUserNames.size() + "] aclUserNames, "+
+ " [" + this.ctnListID0.size() + "] ctnListID0 " );
fields.clear();
ctnlists.clear();
ctns.clear();