You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by re...@apache.org on 2001/07/25 02:51:35 UTC
cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/method GetMethod.java WebdavMethod.java
remm 01/07/24 17:51:34
Modified: src/webdav/server/org/apache/slide/webdav WebdavServlet.java
src/webdav/server/org/apache/slide/webdav/method
GetMethod.java WebdavMethod.java
Log:
- Move the generation of HTML collection index pages out of GetMethod
- HTTP GET/POST requests on collection resources are now handled by
the servlets doGet()/doPost() methods, respectively. This enables
easy extension of WebdavServlet to provide custom functionality on
such requests.
- The generation of HTML collection index pages can be disabled by
settings the servlet init-parameter 'directory-browsing' to 'false',
or anything else than 'true' (not case-sensitive).
- WebdavMethod: Some methods added, made public and/or static so they
could be used from outside WebdavMethod and subclasses; Removed
unused fields
Patch submitted by Christopher Lenz.
Revision Changes Path
1.18 +528 -14 jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java
Index: WebdavServlet.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- WebdavServlet.java 2001/07/12 12:13:43 1.17
+++ WebdavServlet.java 2001/07/25 00:51:34 1.18
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java,v 1.17 2001/07/12 12:13:43 juergen Exp $
- * $Revision: 1.17 $
- * $Date: 2001/07/12 12:13:43 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java,v 1.18 2001/07/25 00:51:34 remm Exp $
+ * $Revision: 1.18 $
+ * $Date: 2001/07/25 00:51:34 $
*
* ====================================================================
*
@@ -74,18 +74,36 @@
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
+
+import org.apache.util.URLUtil;
import org.apache.util.WebdavStatus;
-import org.apache.slide.webdav.method.*;
-import org.apache.slide.common.NamespaceAccessToken;
+
+import org.apache.slide.authenticate.SecurityToken;
import org.apache.slide.common.Domain;
-import org.apache.slide.structure.*;
+import org.apache.slide.common.Namespace;
+import org.apache.slide.common.NamespaceAccessToken;
+import org.apache.slide.common.SlideException;
+import org.apache.slide.common.SlideToken;
+import org.apache.slide.content.Content;
+import org.apache.slide.content.NodeRevisionDescriptor;
+import org.apache.slide.content.NodeRevisionDescriptors;
+import org.apache.slide.lock.Lock;
+import org.apache.slide.lock.NodeLock;
+import org.apache.slide.security.AccessDeniedException;
+import org.apache.slide.security.NodePermission;
+import org.apache.slide.security.Security;
+import org.apache.slide.structure.LinkedObjectNotFoundException;
+import org.apache.slide.structure.ObjectNode;
+import org.apache.slide.structure.ObjectNotFoundException;
+import org.apache.slide.structure.Structure;
import org.apache.slide.util.conf.*;
-import org.apache.slide.authenticate.SecurityToken;
+import org.apache.slide.util.Messages;
+import org.apache.slide.util.logger.Logger;
import org.apache.slide.webdav.logger.XHttpServletRequestFacade;
import org.apache.slide.webdav.logger.XHttpServletResponseFacade;
import org.apache.slide.webdav.logger.XMLTestCaseGenerator;
-import org.apache.slide.util.logger.Logger;
+import org.apache.slide.webdav.method.*;
/**
@@ -128,7 +146,13 @@
protected int depthLimit = 3;
- // -------------------------------------------------------- Private Methods
+ /**
+ * Directory browsing enabled.
+ */
+ protected boolean directoryBrowsing = true;
+
+
+ // ------------------------------------------------------ Protected Methods
/**
@@ -212,12 +236,19 @@
(new SecurityToken(this), namespaceName);
}
- WebdavMethod method = null;
-
try {
- //System.out.println(System.currentTimeMillis"Parsing request");
- method = createWebdavMethod(req, resp);
- method.run();
+ String methodName = req.getMethod();
+ if ((methodName.equalsIgnoreCase("GET") ||
+ methodName.equalsIgnoreCase("POST")) &&
+ WebdavMethod.isCollection(req, token)) {
+ // let the standard doGet() / doPost() methods handle
+ // GET/POST requests on collections (to display a directory
+ // index pag or something similar)
+ super.service(req, resp);
+ } else {
+ WebdavMethod method = createWebdavMethod(req, resp);
+ method.run();
+ }
} catch (WebdavException e) {
// There has been an error somewhere ...
// TODO : Show error page.
@@ -288,6 +319,14 @@
} catch (Throwable t) {
;
}
+ try {
+ value = getServletConfig().getInitParameter("directory-browsing");
+ if (value != null) {
+ directoryBrowsing = new Boolean(value).booleanValue();
+ }
+ } catch (Throwable t) {
+ ;
+ }
try {
@@ -313,6 +352,481 @@
Domain.closeNamespace(token);
}
+
+ /**
+ * Handle a GET request on a collection resource.
+ */
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+
+ if (directoryBrowsing) {
+ Writer writer = resp.getWriter();
+ resp.setContentType("text/html");
+ try {
+ displayDirectoryBrowsing(req, writer);
+ } catch (AccessDeniedException e) {
+ resp.sendError(WebdavStatus.SC_FORBIDDEN);
+ } catch (ObjectNotFoundException e) {
+ resp.sendError(WebdavStatus.SC_NOT_FOUND);
+ } catch (LinkedObjectNotFoundException e) {
+ resp.sendError(WebdavStatus.SC_NOT_FOUND);
+ } catch (SlideException e) {
+ resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ }
+ } else {
+ resp.sendError(WebdavStatus.SC_FORBIDDEN);
+ }
+ }
+
+
+ /**
+ * Display a directory browsing page.
+ */
+ protected void displayDirectoryBrowsing(HttpServletRequest req,
+ Writer servletWriter)
+ throws IOException, SlideException {
+
+ String contextPath = req.getContextPath();
+ if (contextPath == null)
+ contextPath = "";
+
+ // get the helpers
+ Content content = token.getContentHelper();
+ Lock lock = token.getLockHelper();
+ Security security = token.getSecurityHelper();
+ Structure structure = token.getStructureHelper();
+
+ SlideToken slideToken = WebdavMethod.createSlideToken(req);
+ String resourcePath = WebdavMethod.getRelativePath(req);
+ ObjectNode object = structure.retrieve(slideToken, resourcePath);
+ String name = object.getUri();
+
+ // Number of characters to trim from the beginnings of filenames
+ int trim = name.length();
+ if (!name.endsWith("/"))
+ trim += 1;
+ if (name.equals("/"))
+ trim = 1;
+
+ PrintWriter writer = new PrintWriter(servletWriter);
+
+ // Render the page header
+ writer.print("<html>\r\n");
+ writer.print("<head>\r\n");
+ writer.print("<title>");
+ writer.print
+ (Messages.format
+ ("org.apache.slide.webdav.GetMethod.directorylistingfor", name));
+ writer.print("</title>\r\n</head>\r\n");
+ writer.print("<body bgcolor=\"white\">\r\n");
+ writer.print("<table width=\"90%\" cellspacing=\"0\"" +
+ " cellpadding=\"5\" align=\"center\">\r\n");
+
+ // Render the in-page title
+ writer.print("<tr><td colspan=\"3\"><font size=\"+2\">\r\n<strong>");
+ writer.print
+ (Messages.format
+ ("org.apache.slide.webdav.GetMethod.directorylistingfor", name));
+ writer.print("</strong>\r\n</font></td></tr>\r\n");
+
+ // Render the link to our parent (if required)
+ String parentDirectory = name;
+ if (parentDirectory.endsWith("/")) {
+ parentDirectory =
+ parentDirectory.substring(0, parentDirectory.length() - 1);
+ }
+ int slash = parentDirectory.lastIndexOf("/");
+ if (slash >= 0) {
+ String parent = name.substring(0, slash);
+ writer.print("<tr><td colspan=\"5\" bgcolor=\"#ffffff\">\r\n");
+ writer.print("<a href=\"");
+ writer.print(URLUtil.URLEncode(contextPath, "UTF8"));
+ if (parent.equals(""))
+ parent = "/";
+ writer.print(parent);
+ writer.print("\">");
+ writer.print(Messages.format
+ ("org.apache.slide.webdav.GetMethod.parent", parent));
+ writer.print("</a>\r\n");
+ writer.print("</td></tr>\r\n");
+ }
+
+ Enumeration permissionsList = null;
+ Enumeration locksList = null;
+
+ try {
+
+ permissionsList =
+ security.enumeratePermissions(slideToken, object.getUri());
+ locksList = lock.enumerateLocks(slideToken, object.getUri());
+
+ } catch (SlideException e) {
+
+ // Any security based exception will be trapped here
+
+ // Any locking based exception will be trapped here
+
+ }
+
+ // Displaying ACL info
+ if( org.apache.slide.util.Configuration.useIntegratedSecurity() )
+ displayPermissions(permissionsList, writer, false);
+
+ // Displaying lock info
+ displayLocks(locksList, writer, false);
+
+ writer.print("<tr><td colspan=\"5\" bgcolor=\"#ffffff\">");
+ writer.print(" ");
+ writer.print("</td></tr>\r\n");
+
+ // Render the column headings
+ writer.print("<tr bgcolor=\"#cccccc\">\r\n");
+ writer.print("<td align=\"left\" colspan=\"3\">");
+ writer.print("<font size=\"+1\"><strong>");
+ writer.print(Messages.message
+ ("org.apache.slide.webdav.GetMethod.filename"));
+ writer.print("</strong></font></td>\r\n");
+ writer.print("<td align=\"center\"><font size=\"+1\"><strong>");
+ writer.print(Messages.message
+ ("org.apache.slide.webdav.GetMethod.size"));
+ writer.print("</strong></font></td>\r\n");
+ writer.print("<td align=\"right\"><font size=\"+1\"><strong>");
+ writer.print(Messages.message
+ ("org.apache.slide.webdav.GetMethod.lastModified"));
+ writer.print("</strong></font></td>\r\n");
+ writer.print("</tr>\r\n");
+
+ Enumeration resources = object.enumerateChildren();
+ boolean shade = false;
+
+ while (resources.hasMoreElements()) {
+
+ String currentResource = (String) resources.nextElement();
+
+ NodeRevisionDescriptor currentDescriptor = null;
+
+ permissionsList = null;
+ locksList = null;
+
+ try {
+
+ NodeRevisionDescriptors revisionDescriptors =
+ content.retrieve(slideToken, currentResource);
+ // Retrieve latest revision descriptor
+ currentDescriptor =
+ content.retrieve(slideToken, revisionDescriptors);
+
+ } catch (SlideException e) {
+
+ // Silent exception : Objects without any revision are
+ // considered collections, and do not have any attributes
+
+ // Any security based exception will be trapped here
+
+ // Any locking based exception will be trapped here
+
+ }
+
+ try {
+
+ permissionsList =
+ security.enumeratePermissions(slideToken, currentResource);
+ locksList = lock.enumerateLocks(slideToken, currentResource);
+
+ } catch (SlideException e) {
+
+ // Any security based exception will be trapped here
+
+ // Any locking based exception will be trapped here
+
+ }
+
+ String trimmed = currentResource.substring(trim);
+ if (trimmed.equalsIgnoreCase("WEB-INF") ||
+ trimmed.equalsIgnoreCase("META-INF"))
+ continue;
+
+ writer.print("<tr");
+ if (shade) {
+ writer.print(" bgcolor=\"dddddd\"");
+ } else {
+ writer.print(" bgcolor=\"eeeeee\"");
+ }
+ writer.print(">\r\n");
+ shade = !shade;
+
+ writer.print("<td align=\"left\" colspan=\"3\"> \r\n");
+ writer.print("<a href=\"");
+ writer.print(URLUtil.URLEncode(contextPath + currentResource,
+ "UTF8"));
+ writer.print("\"><tt>");
+ writer.print(trimmed);
+ if (WebdavMethod.isCollection(currentDescriptor)) {
+ writer.print("/");
+ }
+ writer.print("</tt></a></td>\r\n");
+
+ writer.print("<td align=\"right\"><tt>");
+ if (WebdavMethod.isCollection(currentDescriptor))
+ writer.print(" ");
+ else
+ writer.print(renderSize(currentDescriptor.getContentLength()));
+ writer.print("</tt></td>\r\n");
+
+ writer.print("<td align=\"right\"><tt>");
+ if (currentDescriptor != null) {
+ writer.print(currentDescriptor.getLastModified());
+ } else {
+ writer.print(" ");
+ }
+ writer.print("</tt></td>\r\n");
+
+ writer.print("</tr>\r\n");
+
+ // Displaying ACL info
+ if( org.apache.slide.util.Configuration.useIntegratedSecurity() )
+ displayPermissions(permissionsList, writer, shade);
+
+ // Displaying lock info
+ displayLocks(locksList, writer, shade);
+
+ }
+
+ // Render the page footer
+ writer.print("<tr><td colspan=\"5\"> </td></tr>\r\n");
+ writer.print("<tr><td colspan=\"3\" bgcolor=\"#cccccc\">");
+ writer.print("<font size=\"-1\">");
+ writer.print(Messages.message
+ ("org.apache.slide.webdav.GetMethod.version"));
+ writer.print("</font></td>\r\n");
+ writer.print("<td colspan=\"2\" align=\"right\" bgcolor=\"#cccccc\">");
+ writer.print("<font size=\"-1\">");
+ writer.print(formatter.format(new Date()));
+ writer.print("</font></td></tr>\r\n");
+ writer.print("</table>\r\n");
+ writer.print("</body>\r\n");
+ writer.print("</html>\r\n");
+
+ // Return an input stream to the underlying bytes
+ writer.flush();
+
+ }
+
+
+ /**
+ * Display an ACL list.
+ *
+ * @param permissionsList List of NodePermission objects
+ * @param boolean Shade
+ * @param writer The output will be appended to this writer
+ */
+ private void displayPermissions(Enumeration permissionsList,
+ PrintWriter writer,
+ boolean shade)
+ throws IOException {
+
+ if ((permissionsList != null) && (permissionsList.hasMoreElements())) {
+
+ writer.print("<tr");
+ if (!shade) {
+ writer.print(" bgcolor=\"dddddd\"");
+ } else {
+ writer.print(" bgcolor=\"eeeeee\"");
+ }
+ writer.print(">\r\n");
+ writer.print("<td align=\"left\" colspan=\"5\"><tt><b>");
+ writer.print(Messages.message
+ ("org.apache.slide.webdav.GetMethod.aclinfo"));
+ writer.print("</b></tt></td>\r\n");
+ writer.print("</tr>\r\n");
+
+ writer.print("<tr");
+ if (!shade) {
+ writer.print(" bgcolor=\"dddddd\"");
+ } else {
+ writer.print(" bgcolor=\"eeeeee\"");
+ }
+ writer.print(">\r\n");
+
+ writer.print("<td align=\"left\" colspan=\"2\"><tt><b>");
+ writer.print(Messages.message
+ ("org.apache.slide.webdav.GetMethod.subject"));
+ writer.print("</b></tt></td>\r\n");
+
+ writer.print("<td align=\"left\"><tt><b>");
+ writer.print(Messages.message
+ ("org.apache.slide.webdav.GetMethod.action"));
+ writer.print("</b></tt></td>\r\n");
+
+ writer.print("<td align=\"right\"><tt><b>");
+ writer.print(Messages.message
+ ("org.apache.slide.webdav.GetMethod.inheritable"));
+ writer.print("</b></tt></td>\r\n");
+
+ writer.print("<td align=\"right\"><tt><b>");
+ writer.print(Messages.message
+ ("org.apache.slide.webdav.GetMethod.deny"));
+ writer.print("</b></tt></td>\r\n");
+
+ writer.print("</tr>\r\n");
+
+ while (permissionsList.hasMoreElements()) {
+
+ writer.print("<tr");
+ if (!shade) {
+ writer.print(" bgcolor=\"dddddd\"");
+ } else {
+ writer.print(" bgcolor=\"eeeeee\"");
+ }
+ writer.print(">\r\n");
+
+ NodePermission currentPermission =
+ (NodePermission) permissionsList.nextElement();
+
+ writer.print("<td align=\"left\" colspan=\"2\"><tt>");
+ writer.print(currentPermission.getSubjectUri());
+ writer.print("</tt></td>\r\n");
+
+ writer.print("<td align=\"left\"><tt>");
+ writer.print(currentPermission.getActionUri());
+ writer.print("</tt></td>\r\n");
+
+ writer.print("<td align=\"right\"><tt>");
+ writer.print(currentPermission.isInheritable());
+ writer.print("</tt></td>\r\n");
+
+ writer.print("<td align=\"right\"><tt>");
+ writer.print(currentPermission.isNegative());
+ writer.print("</tt></td>\r\n");
+
+ writer.print("</tr>\r\n");
+ }
+
+ }
+
+ }
+
+
+ /**
+ * Display a lock list.
+ *
+ * @param locksList List of NodeLock objects
+ * @param boolean Shade
+ * @param writer The output will be appended to this writer
+ */
+ private void displayLocks(Enumeration locksList, PrintWriter writer,
+ boolean shade)
+ throws IOException {
+
+ if ((locksList != null) && (locksList.hasMoreElements())) {
+
+ writer.print("<tr");
+ if (!shade) {
+ writer.print(" bgcolor=\"dddddd\"");
+ } else {
+ writer.print(" bgcolor=\"eeeeee\"");
+ }
+ writer.print(">\r\n");
+ writer.print("<td align=\"left\" colspan=\"5\"><tt><b>");
+ writer.print(Messages.message
+ ("org.apache.slide.webdav.GetMethod.locksinfo"));
+ writer.print("</b></tt></td>\r\n");
+ writer.print("</tr>\r\n");
+
+ writer.print("<tr");
+ if (!shade) {
+ writer.print(" bgcolor=\"dddddd\"");
+ } else {
+ writer.print(" bgcolor=\"eeeeee\"");
+ }
+ writer.print(">\r\n");
+
+ writer.print("<td align=\"left\"><tt><b>");
+ writer.print(Messages.message
+ ("org.apache.slide.webdav.GetMethod.subject"));
+ writer.print("</b></tt></td>\r\n");
+
+ writer.print("<td align=\"left\"><tt><b>");
+ writer.print(Messages.message
+ ("org.apache.slide.webdav.GetMethod.type"));
+ writer.print("</b></tt></td>\r\n");
+
+ writer.print("<td align=\"right\"><tt><b>");
+ writer.print(Messages.message
+ ("org.apache.slide.webdav.GetMethod.expiration"));
+ writer.print("</b></tt></td>\r\n");
+
+ writer.print("<td align=\"right\"><tt><b>");
+ writer.print(Messages.message
+ ("org.apache.slide.webdav.GetMethod.inheritable"));
+ writer.print("</b></tt></td>\r\n");
+
+ writer.print("<td align=\"right\"><tt><b>");
+ writer.print(Messages.message
+ ("org.apache.slide.webdav.GetMethod.exclusive"));
+ writer.print("</b></tt></td>\r\n");
+
+ writer.print("</tr>\r\n");
+
+ while (locksList.hasMoreElements()) {
+
+ writer.print("<tr");
+ if (!shade) {
+ writer.print(" bgcolor=\"dddddd\"");
+ } else {
+ writer.print(" bgcolor=\"eeeeee\"");
+ }
+ writer.print(">\r\n");
+
+ NodeLock currentLock = (NodeLock) locksList.nextElement();
+
+ writer.print("<td align=\"left\"><tt>");
+ writer.print(currentLock.getSubjectUri());
+ writer.print("</tt></td>\r\n");
+
+ writer.print("<td align=\"left\"><tt>");
+ writer.print(currentLock.getTypeUri());
+ writer.print("</tt></td>\r\n");
+
+ writer.print("<td align=\"right\"><tt>");
+ writer.print
+ (formatter.format(currentLock.getExpirationDate()));
+ writer.print("</tt></td>\r\n");
+
+ writer.print("<td align=\"right\"><tt>");
+ writer.print(currentLock.isInheritable());
+ writer.print("</tt></td>\r\n");
+
+ writer.print("<td align=\"right\"><tt>");
+ writer.print(currentLock.isExclusive());
+ writer.print("</tt></td>\r\n");
+
+ }
+
+ }
+
+ }
+
+
+ // -------------------------------------------------------- Private Methods
+
+
+ /**
+ * Render the specified file size (in bytes).
+ *
+ * @param size File size (in bytes)
+ */
+ private String renderSize(long size) {
+
+ long leftSide = size / 1024;
+ long rightSide = (size % 1024) / 103; // Makes 1 digit
+ if ((leftSide == 0) && (rightSide == 0) && (size > 0))
+ rightSide = 1;
+
+ return ("" + leftSide + "." + rightSide + " kb");
+ }
+
+
}
1.13 +21 -495 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/GetMethod.java
Index: GetMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/GetMethod.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- GetMethod.java 2001/07/20 13:00:30 1.12
+++ GetMethod.java 2001/07/25 00:51:34 1.13
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/GetMethod.java,v 1.12 2001/07/20 13:00:30 juergen Exp $
- * $Revision: 1.12 $
- * $Date: 2001/07/20 13:00:30 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/GetMethod.java,v 1.13 2001/07/25 00:51:34 remm Exp $
+ * $Revision: 1.13 $
+ * $Date: 2001/07/25 00:51:34 $
*
* ====================================================================
*
@@ -70,16 +70,21 @@
import java.text.ParseException;
import javax.servlet.*;
import javax.servlet.http.*;
+
import org.apache.util.WebdavStatus;
-import org.apache.slide.common.*;
-import org.apache.slide.security.AccessDeniedException;
-import org.apache.slide.webdav.*;
-import org.apache.slide.util.Messages;
+import org.apache.slide.common.NamespaceAccessToken;
+import org.apache.slide.common.ServiceAccessException;
+import org.apache.slide.common.SlideException;
import org.apache.slide.content.*;
-import org.apache.slide.lock.*;
-import org.apache.slide.security.*;
-import org.apache.slide.structure.*;
+import org.apache.slide.lock.ObjectLockedException;
+import org.apache.slide.security.AccessDeniedException;
+import org.apache.slide.structure.LinkedObjectNotFoundException;
+import org.apache.slide.structure.ObjectNode;
+import org.apache.slide.structure.ObjectNotFoundException;
+import org.apache.slide.structure.Structure;
+import org.apache.slide.webdav.WebdavException;
+
/**
* GET method.
*
@@ -99,8 +104,8 @@
*/
protected static final SimpleDateFormat formats[] = {
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US),
- new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US),
- new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US)
+ new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US),
+ new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US)
};
@@ -190,15 +195,8 @@
NodeRevisionDescriptor revisionDescriptor =
content.retrieve(slideToken, revisionDescriptors);
- if (isCollection(revisionDescriptor)) {
-
- Writer writer = resp.getWriter();
- resp.setContentType("text/html");
- displayDirectoryBrowsing(object, writer);
- writer.close();
+ if (revisionDescriptor != null) {
- } else {
-
ResourceInfo resourceInfo =
new ResourceInfo(resourcePath, revisionDescriptor);
@@ -280,15 +278,12 @@
}
+ } else {
+ resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
} else {
-
- Writer writer = resp.getWriter();
- resp.setContentType("text/html");
- displayDirectoryBrowsing(object, writer);
- writer.close();
-
+ resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
} catch (RevisionNotFoundException e) {
@@ -336,476 +331,7 @@
}
- /**
- * Display a directory browsing page.
- */
- protected void displayDirectoryBrowsing(ObjectNode object,
- Writer servletWriter)
- throws IOException {
-
- String contextPath = req.getContextPath();
- if (contextPath == null)
- contextPath = "";
-
- String name = object.getUri();
-
- // Number of characters to trim from the beginnings of filenames
- int trim = name.length();
- if (!name.endsWith("/"))
- trim += 1;
- if (name.equals("/"))
- trim = 1;
-
- PrintWriter writer = new PrintWriter(servletWriter);
-
- // Render the page header
- writer.print("<html>\r\n");
- writer.print("<head>\r\n");
- writer.print("<title>");
- writer.print
- (Messages.format
- ("org.apache.slide.webdav.GetMethod.directorylistingfor", name));
- writer.print("</title>\r\n</head>\r\n");
- writer.print("<body bgcolor=\"white\">\r\n");
- writer.print("<table width=\"90%\" cellspacing=\"0\"" +
- " cellpadding=\"5\" align=\"center\">\r\n");
-
- // Render the in-page title
- writer.print("<tr><td colspan=\"3\"><font size=\"+2\">\r\n<strong>");
- writer.print
- (Messages.format
- ("org.apache.slide.webdav.GetMethod.directorylistingfor", name));
- writer.print("</strong>\r\n</font></td></tr>\r\n");
-
- // Render the link to our parent (if required)
- String parentDirectory = name;
- if (parentDirectory.endsWith("/")) {
- parentDirectory =
- parentDirectory.substring(0, parentDirectory.length() - 1);
- }
- int slash = parentDirectory.lastIndexOf("/");
- if (slash >= 0) {
- String parent = name.substring(0, slash);
- writer.print("<tr><td colspan=\"5\" bgcolor=\"#ffffff\">\r\n");
- writer.print("<a href=\"");
- writer.print(URLEncode(contextPath));
- if (parent.equals(""))
- parent = "/";
- writer.print(parent);
- writer.print("\">");
- writer.print(Messages.format
- ("org.apache.slide.webdav.GetMethod.parent", parent));
- writer.print("</a>\r\n");
- writer.print("</td></tr>\r\n");
- }
-
- Enumeration permissionsList = null;
- Enumeration locksList = null;
-
- try {
-
- permissionsList =
- security.enumeratePermissions(slideToken, object.getUri());
- locksList = lock.enumerateLocks(slideToken, object.getUri());
-
- } catch (SlideException e) {
-
- // Any security based exception will be trapped here
-
- // Any locking based exception will be trapped here
-
- }
-
- // Displaying ACL info
- if( org.apache.slide.util.Configuration.useIntegratedSecurity() )
- displayPermissions(permissionsList, writer, false);
-
- // Displaying lock info
- displayLocks(locksList, writer, false);
-
- writer.print("<tr><td colspan=\"5\" bgcolor=\"#ffffff\">");
- writer.print(" ");
- writer.print("</td></tr>\r\n");
-
- // Render the column headings
- writer.print("<tr bgcolor=\"#cccccc\">\r\n");
- writer.print("<td align=\"left\" colspan=\"3\">");
- writer.print("<font size=\"+1\"><strong>");
- writer.print(Messages.message
- ("org.apache.slide.webdav.GetMethod.filename"));
- writer.print("</strong></font></td>\r\n");
- writer.print("<td align=\"center\"><font size=\"+1\"><strong>");
- writer.print(Messages.message
- ("org.apache.slide.webdav.GetMethod.size"));
- writer.print("</strong></font></td>\r\n");
- writer.print("<td align=\"right\"><font size=\"+1\"><strong>");
- writer.print(Messages.message
- ("org.apache.slide.webdav.GetMethod.lastModified"));
- writer.print("</strong></font></td>\r\n");
- writer.print("</tr>\r\n");
-
- Enumeration resources = object.enumerateChildren();
- boolean shade = false;
-
- while (resources.hasMoreElements()) {
-
- String currentResource = (String) resources.nextElement();
-
- NodeRevisionDescriptor currentDescriptor = null;
-
- permissionsList = null;
- locksList = null;
-
- try {
-
- NodeRevisionDescriptors revisionDescriptors =
- content.retrieve(slideToken, currentResource);
- // Retrieve latest revision descriptor
- currentDescriptor =
- content.retrieve(slideToken, revisionDescriptors);
-
- } catch (SlideException e) {
-
- // Silent exception : Objects without any revision are
- // considered collections, and do not have any attributes
-
- // Any security based exception will be trapped here
-
- // Any locking based exception will be trapped here
-
- }
-
- try {
-
- permissionsList =
- security.enumeratePermissions(slideToken, currentResource);
- locksList = lock.enumerateLocks(slideToken, currentResource);
-
- } catch (SlideException e) {
-
- // Any security based exception will be trapped here
-
- // Any locking based exception will be trapped here
-
- }
-
- String trimmed = currentResource.substring(trim);
- if (trimmed.equalsIgnoreCase("WEB-INF") ||
- trimmed.equalsIgnoreCase("META-INF"))
- continue;
-
- writer.print("<tr");
- if (shade) {
- writer.print(" bgcolor=\"dddddd\"");
- } else {
- writer.print(" bgcolor=\"eeeeee\"");
- }
- writer.print(">\r\n");
- shade = !shade;
-
- writer.print("<td align=\"left\" colspan=\"3\"> \r\n");
- writer.print("<a href=\"");
- writer.print(URLEncode(contextPath + currentResource));
- writer.print("\"><tt>");
- writer.print(trimmed);
- if (isCollection(currentDescriptor)) {
- writer.print("/");
- }
- writer.print("</tt></a></td>\r\n");
-
- writer.print("<td align=\"right\"><tt>");
- if (isCollection(currentDescriptor))
- writer.print(" ");
- else
- writer.print(renderSize(currentDescriptor.getContentLength()));
- writer.print("</tt></td>\r\n");
-
- writer.print("<td align=\"right\"><tt>");
- if (currentDescriptor != null) {
- writer.print(currentDescriptor.getLastModified());
- } else {
- writer.print(" ");
- }
- writer.print("</tt></td>\r\n");
-
- writer.print("</tr>\r\n");
-
- // Displaying ACL info
- if( org.apache.slide.util.Configuration.useIntegratedSecurity() )
- displayPermissions(permissionsList, writer, shade);
-
- // Displaying lock info
- displayLocks(locksList, writer, shade);
-
- }
-
- // Render the page footer
- writer.print("<tr><td colspan=\"5\"> </td></tr>\r\n");
- writer.print("<tr><td colspan=\"3\" bgcolor=\"#cccccc\">");
- writer.print("<font size=\"-1\">");
- writer.print(Messages.message
- ("org.apache.slide.webdav.GetMethod.version"));
- writer.print("</font></td>\r\n");
- writer.print("<td colspan=\"2\" align=\"right\" bgcolor=\"#cccccc\">");
- writer.print("<font size=\"-1\">");
- writer.print(formats[0].format(new Date()));
- writer.print("</font></td></tr>\r\n");
- writer.print("</table>\r\n");
- writer.print("</body>\r\n");
- writer.print("</html>\r\n");
-
- // Return an input stream to the underlying bytes
- writer.flush();
-
- }
-
-
- /**
- * Display an ACL list.
- *
- * @param permissionsList List of NodePermission objects
- * @param boolean Shade
- * @param writer The output will be appended to this writer
- */
- private void displayPermissions(Enumeration permissionsList,
- PrintWriter writer,
- boolean shade)
- throws IOException {
-
- if ((permissionsList != null) && (permissionsList.hasMoreElements())) {
-
- writer.print("<tr");
- if (!shade) {
- writer.print(" bgcolor=\"dddddd\"");
- } else {
- writer.print(" bgcolor=\"eeeeee\"");
- }
- writer.print(">\r\n");
- writer.print("<td align=\"left\" colspan=\"5\"><tt><b>");
- writer.print(Messages.message
- ("org.apache.slide.webdav.GetMethod.aclinfo"));
- writer.print("</b></tt></td>\r\n");
- writer.print("</tr>\r\n");
-
- writer.print("<tr");
- if (!shade) {
- writer.print(" bgcolor=\"dddddd\"");
- } else {
- writer.print(" bgcolor=\"eeeeee\"");
- }
- writer.print(">\r\n");
-
- writer.print("<td align=\"left\" colspan=\"2\"><tt><b>");
- writer.print(Messages.message
- ("org.apache.slide.webdav.GetMethod.subject"));
- writer.print("</b></tt></td>\r\n");
-
- writer.print("<td align=\"left\"><tt><b>");
- writer.print(Messages.message
- ("org.apache.slide.webdav.GetMethod.action"));
- writer.print("</b></tt></td>\r\n");
-
- writer.print("<td align=\"right\"><tt><b>");
- writer.print(Messages.message
- ("org.apache.slide.webdav.GetMethod.inheritable"));
- writer.print("</b></tt></td>\r\n");
-
- writer.print("<td align=\"right\"><tt><b>");
- writer.print(Messages.message
- ("org.apache.slide.webdav.GetMethod.deny"));
- writer.print("</b></tt></td>\r\n");
-
- /*
- writer.print("<td align=\"right\"><tt><b>");
- writer.print("<a href=\"");
- if (req.getContextPath() != null) {
- writer.print(req.getContextPath());
- }
- writer.print(managerServletPath + token.getName()
- + "?command=addacl\">");
- writer.print(Messages.message
- ("org.apache.slide.webdav.GetMethod.add"));
- writer.print("</a>");
- writer.print("</b></tt></td>\r\n");
- */
-
- writer.print("</tr>\r\n");
-
- while (permissionsList.hasMoreElements()) {
-
- writer.print("<tr");
- if (!shade) {
- writer.print(" bgcolor=\"dddddd\"");
- } else {
- writer.print(" bgcolor=\"eeeeee\"");
- }
- writer.print(">\r\n");
-
- NodePermission currentPermission =
- (NodePermission) permissionsList.nextElement();
-
- writer.print("<td align=\"left\" colspan=\"2\"><tt>");
- writer.print(currentPermission.getSubjectUri());
- writer.print("</tt></td>\r\n");
-
- writer.print("<td align=\"left\"><tt>");
- writer.print(currentPermission.getActionUri());
- writer.print("</tt></td>\r\n");
-
- writer.print("<td align=\"right\"><tt>");
- writer.print(currentPermission.isInheritable());
- writer.print("</tt></td>\r\n");
-
- writer.print("<td align=\"right\"><tt>");
- writer.print(currentPermission.isNegative());
- writer.print("</tt></td>\r\n");
-
- /*
- writer.print("<td align=\"right\"><tt><b>");
- writer.print("<a href=\"");
- if (req.getContextPath() != null) {
- writer.print(req.getContextPath());
- }
- writer.print(managerServletPath + token.getName()
- + "?command=removeacl"
- + "&object=" + currentPermission.getObjectUri()
- + "&subject=" + currentPermission.getSubjectUri()
- + "&action=" + currentPermission.getActionUri()
- + "\">");
- writer.print(Messages.message
- ("org.apache.slide.webdav.GetMethod.remove"));
- writer.print("</a>");
- writer.print("</b></tt></td>\r\n");
- */
-
- writer.print("</tr>\r\n");
-
- }
-
- }
-
- }
-
-
- /**
- * Display a lock list.
- *
- * @param locksList List of NodeLock objects
- * @param boolean Shade
- * @param writer The output will be appended to this writer
- */
- private void displayLocks(Enumeration locksList, PrintWriter writer,
- boolean shade)
- throws IOException {
-
- if ((locksList != null) && (locksList.hasMoreElements())) {
-
- writer.print("<tr");
- if (!shade) {
- writer.print(" bgcolor=\"dddddd\"");
- } else {
- writer.print(" bgcolor=\"eeeeee\"");
- }
- writer.print(">\r\n");
- writer.print("<td align=\"left\" colspan=\"5\"><tt><b>");
- writer.print(Messages.message
- ("org.apache.slide.webdav.GetMethod.locksinfo"));
- writer.print("</b></tt></td>\r\n");
- writer.print("</tr>\r\n");
-
- writer.print("<tr");
- if (!shade) {
- writer.print(" bgcolor=\"dddddd\"");
- } else {
- writer.print(" bgcolor=\"eeeeee\"");
- }
- writer.print(">\r\n");
-
- writer.print("<td align=\"left\"><tt><b>");
- writer.print(Messages.message
- ("org.apache.slide.webdav.GetMethod.subject"));
- writer.print("</b></tt></td>\r\n");
-
- writer.print("<td align=\"left\"><tt><b>");
- writer.print(Messages.message
- ("org.apache.slide.webdav.GetMethod.type"));
- writer.print("</b></tt></td>\r\n");
-
- writer.print("<td align=\"right\"><tt><b>");
- writer.print(Messages.message
- ("org.apache.slide.webdav.GetMethod.expiration"));
- writer.print("</b></tt></td>\r\n");
-
- writer.print("<td align=\"right\"><tt><b>");
- writer.print(Messages.message
- ("org.apache.slide.webdav.GetMethod.inheritable"));
- writer.print("</b></tt></td>\r\n");
-
- writer.print("<td align=\"right\"><tt><b>");
- writer.print(Messages.message
- ("org.apache.slide.webdav.GetMethod.exclusive"));
- writer.print("</b></tt></td>\r\n");
-
- writer.print("</tr>\r\n");
-
- while (locksList.hasMoreElements()) {
-
- writer.print("<tr");
- if (!shade) {
- writer.print(" bgcolor=\"dddddd\"");
- } else {
- writer.print(" bgcolor=\"eeeeee\"");
- }
- writer.print(">\r\n");
-
- NodeLock currentLock = (NodeLock) locksList.nextElement();
-
- writer.print("<td align=\"left\"><tt>");
- writer.print(currentLock.getSubjectUri());
- writer.print("</tt></td>\r\n");
-
- writer.print("<td align=\"left\"><tt>");
- writer.print(currentLock.getTypeUri());
- writer.print("</tt></td>\r\n");
-
- writer.print("<td align=\"right\"><tt>");
- writer.print
- (formats[0].format(currentLock.getExpirationDate()));
- writer.print("</tt></td>\r\n");
-
- writer.print("<td align=\"right\"><tt>");
- writer.print(currentLock.isInheritable());
- writer.print("</tt></td>\r\n");
-
- writer.print("<td align=\"right\"><tt>");
- writer.print(currentLock.isExclusive());
- writer.print("</tt></td>\r\n");
-
- }
-
- }
-
- }
-
-
// -------------------------------------------------------- Private Methods
-
-
- /**
- * Render the specified file size (in bytes).
- *
- * @param size File size (in bytes)
- */
- private String renderSize(long size) {
-
- long leftSide = size / 1024;
- long rightSide = (size % 1024) / 103; // Makes 1 digit
- if ((leftSide == 0) && (rightSide == 0) && (size > 0))
- rightSide = 1;
-
- return ("" + leftSide + "." + rightSide + " kb");
-
- }
/**
1.29 +152 -124 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java
Index: WebdavMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- WebdavMethod.java 2001/07/22 16:43:49 1.28
+++ WebdavMethod.java 2001/07/25 00:51:34 1.29
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v 1.28 2001/07/22 16:43:49 remm Exp $
- * $Revision: 1.28 $
- * $Date: 2001/07/22 16:43:49 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v 1.29 2001/07/25 00:51:34 remm Exp $
+ * $Revision: 1.29 $
+ * $Date: 2001/07/25 00:51:34 $
*
* ====================================================================
*
@@ -90,6 +90,7 @@
* WebDAV method.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
+ * @author Christopher Lenz
*/
public abstract class WebdavMethod {
@@ -116,12 +117,6 @@
/**
- * Principal.
- */
- protected Principal principal;
-
-
- /**
* Servlet request.
*/
protected HttpServletRequest req;
@@ -157,12 +152,6 @@
/**
- * Files path.
- */
- protected String filesPath;
-
-
- /**
* Structure helper.
*/
protected Structure structure;
@@ -193,12 +182,6 @@
/**
- * Credentials token associated with the principal.
- */
- protected CredentialsToken credToken;
-
-
- /**
* Slide token.
*/
protected SlideToken slideToken;
@@ -257,7 +240,6 @@
}
}
- this.principal = req.getUserPrincipal();
this.req = req;
this.resp = resp;
this.servlet = servlet;
@@ -270,33 +252,138 @@
this.lock = token.getLockHelper();
this.macro = token.getMacroHelper();
+ this.slideToken = createSlideToken(req);
+ this.requestUri = getRelativePath(req);
+
+ parseHeaders();
+
+ }
+
+
+ // --------------------------------------------------------- Public Methods
+
+
+ /**
+ * Generate a SlideToken using the Authentication info from an HTTP request
+ *
+ * @param req The HTTP request.
+ * @return A new SlideToken instance
+ */
+ public static SlideToken createSlideToken(HttpServletRequest req) {
+
+ Principal principal = req.getUserPrincipal();
+ HttpSession session = req.getSession();
+
if (principal == null) {
- this.principal =
- (Principal) req.getSession(true).getAttribute(PRINCIPAL);
+ principal = (Principal) session.getAttribute(PRINCIPAL);
} else {
- req.getSession(true).setAttribute(PRINCIPAL, principal);
+ session.setAttribute(PRINCIPAL, principal);
}
+ CredentialsToken credentials;
if (principal == null) {
- this.credToken = new CredentialsToken("");
+ credentials = new CredentialsToken("");
} else {
- this.credToken = new CredentialsToken(principal);
+ credentials = new CredentialsToken(principal);
}
-
- this.slideToken = new SlideToken(this.credToken);
- this.slideToken.setEnforceLockTokens(true);
-
- this.requestUri = getRelativePath(req);
-
- parseHeaders();
+ SlideToken token = new SlideToken(credentials);
+ token.setEnforceLockTokens(true);
+
+ return token;
}
+
+
+ /**
+ * Return the relative path associated with this servlet.
+ *
+ * @param request The servlet request we are processing
+ */
+ public static String getRelativePath(HttpServletRequest request) {
+
+ String result = request.getPathInfo();
+ if (result == null) {
+ result = request.getServletPath();
+ }
+ if ((result == null) || (result.equals(""))) {
+ result = "/";
+ }
+ return URLDecode(result);
+
+ }
- // --------------------------------------------------------- Public Methods
+ /**
+ * Return an absolute URL (absolute in the HTTP sense) based on a Slide
+ * path.
+ */
+ public String getFullPath(String path) {
+ if (path.startsWith("/"))
+ return URLEncode(req.getContextPath() + path);
+ else
+ return URLEncode(req.getContextPath() + "/" + path);
+ }
+
+
+ /**
+ * Returns a Slide path based on an absolute URL
+ * (absolute in the HTTP sense)
+ */
+ public String getSlidePath(String fullpath) {
+ // strip off the protocol://host:port part
+ if (fullpath.indexOf("://") >= 0) {
+ fullpath=fullpath.substring(fullpath.indexOf("://")+3);
+ fullpath=fullpath.substring(fullpath.indexOf("/"));
+ }
+
+ // strip off the servlet context path
+ String contextPath=req.getContextPath();
+ if (fullpath.startsWith(contextPath)) {
+ fullpath=fullpath.substring(contextPath.length());
+ }
+ return fullpath;
+ }
+
+ /**
+ * Test whether a the requested URI maps to a collection resource.
+ *
+ * @param req The HTTP request
+ * @return true if the requested resource is a collection, false otherwise
+ */
+ public static boolean isCollection(HttpServletRequest req,
+ NamespaceAccessToken token) {
+
+ SlideToken slideToken = createSlideToken(req);
+ String path = getRelativePath(req);
+ return isCollection(token, slideToken, path);
+ }
+
/**
+ * Tests if a resource is a collection.
+ */
+ public static boolean isCollection
+ (NodeRevisionDescriptor revisionDescriptor) {
+
+ boolean result = false;
+
+ if (revisionDescriptor == null)
+ return true;
+
+ NodeProperty property = revisionDescriptor.getProperty("resourcetype");
+
+ if ((property != null)
+ && (property.getValue().equals("<collection/>"))) {
+ result = true;
+ }
+
+ return result;
+
+ }
+
+
+ /**
* Exceute method.
*
* @exception WebdavException
@@ -355,59 +442,6 @@
/**
- * Return the relative path associated with this servlet.
- *
- * @param request The servlet request we are processing
- */
- public static String getRelativePath(HttpServletRequest request) {
-
- String result = request.getPathInfo();
- if (result == null) {
- result = request.getServletPath();
- }
- if ((result == null) || (result.equals(""))) {
- result = "/";
- }
- return URLDecode(result);
-
- }
-
-
- /**
- * Return an absolute URL (absolute in the HTTP sense) based on a Slide
- * path.
- */
- public String getFullPath(String path) {
- if (path.startsWith("/"))
- return URLEncode(req.getContextPath() + path);
- else
- return URLEncode(req.getContextPath() + "/" + path);
- }
-
-
- /**
- * Returns a Slide path based on an absolute URL (absolute in the HTTP sense)
- */
- public String getSlidePath(String fullpath)
- {
- // strip off the protocol://host:port part
- if (fullpath.indexOf("://")>=0)
- {
- fullpath=fullpath.substring(fullpath.indexOf("://")+3);
- fullpath=fullpath.substring(fullpath.indexOf("/"));
- }
-
- // strip off the servlet context path
- String contextPath=req.getContextPath();
- if (fullpath.startsWith(contextPath))
- {
- fullpath=fullpath.substring(contextPath.length());
- }
- return fullpath;
- }
-
-
- /**
* Read request contents.
*
* @param req Request object handed out by the servlet container
@@ -501,46 +535,11 @@
* Test if a resource given by a path is a collection
*/
protected boolean isCollection(String path) {
- NodeRevisionDescriptors revisionDescriptors;
- try {
- revisionDescriptors = content.retrieve(slideToken, path);
-
- if (revisionDescriptors.hasRevisions()) {
- NodeRevisionDescriptor revisionDescriptor =
- content.retrieve(slideToken, revisionDescriptors);
- return(isCollection(revisionDescriptor));
- }
- else
- return true;
- } catch(ObjectNotFoundException e) {
- return false; // if the Object is not found return false for no 207 is generated
- } catch(SlideException e) { // this is the default
- return true;
- }
+ return isCollection(token, slideToken, path);
}
/**
- * Tests if a resource is a collection.
- */
- protected boolean isCollection(NodeRevisionDescriptor revisionDescriptor) {
-
- boolean result = false;
-
- if (revisionDescriptor == null)
- return true;
-
- NodeProperty property = revisionDescriptor.getProperty("resourcetype");
-
- if ((property != null)
- && (property.getValue().equals("<collection/>"))) {
- result = true;
- }
-
- return result;
-
- }
- /**
* Parse WebDAV XML query.
*
* @exception WebdavException
@@ -647,6 +646,35 @@
}
+ // -------------------------------------------------------- Private Methods
+
+
+ /**
+ *
+ */
+ private static boolean isCollection(NamespaceAccessToken token,
+ SlideToken slideToken,
+ String path) {
+ try {
+ Content content = token.getContentHelper();
+ NodeRevisionDescriptors revisionDescriptors =
+ content.retrieve(slideToken, path);
+ if (revisionDescriptors.hasRevisions()) {
+ NodeRevisionDescriptor revisionDescriptor =
+ content.retrieve(slideToken, revisionDescriptors);
+ return(isCollection(revisionDescriptor));
+ } else
+ return true;
+ } catch(ObjectNotFoundException e) {
+ // if the Object is not found return false for no 207 is generated
+ return false;
+ } catch(SlideException e) {
+ // this is the default
+ return true;
+ }
+ }
+
+
}