From 6d06fe6ecad3f7e866f08dff8cd3957892e3304a Mon Sep 17 00:00:00 2001 From: lresende Date: Sat, 1 Jan 2011 23:22:25 +0000 Subject: Adding java doc git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1054316 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tuscany/sca/common/http/HTTPUtil.java | 43 ++++++++++++---------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPUtil.java') diff --git a/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPUtil.java b/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPUtil.java index f810970869..a3dede88ec 100644 --- a/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPUtil.java +++ b/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPUtil.java @@ -6,15 +6,15 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations - * under the License. + * under the License. */ package org.apache.tuscany.sca.common.http; @@ -25,17 +25,17 @@ import java.security.MessageDigest; import javax.servlet.http.HttpServletRequest; /** - * + * * @tuscany.spi.extension.asclient * */ public class HTTPUtil { /** - * Calculate the relative request path taking in consideration if + * Calculate the relative request path taking in consideration if * the application is running in a embedded webContatiner or from * within a web application server host environment - * + * * @param request The http request * @return the relative path */ @@ -44,37 +44,42 @@ public class HTTPUtil { String contextPath = request.getContextPath(); String servletPath = request.getServletPath(); String requestURI = request.getRequestURI(); - + int contextPathLength = contextPath.length(); int servletPathLenght = servletPath.contains(contextPath) ? servletPath.length() - contextPath.length() : servletPath.length(); - + String requestPath = requestURI.substring(contextPathLength + servletPathLenght); - + return requestPath; } - + /** - * Calculate the context root for an application taking in consideration if + * Calculate the context root for an application taking in consideration if * the application is running in a embedded webContatiner or from - * within a web application server host environment. - * + * within a web application server host environment. + * * In the case of webContainer the contextRoot will always be a empty string. - * + * * @param request The http request * @return the contextRoot - */ + */ public static String getContextRoot(HttpServletRequest request) { // Get the request path String contextPath = request.getContextPath(); String requestURI = request.getRequestURI(); - + int contextPathLength = contextPath.length(); - + String contextRoot = requestURI.substring(0, contextPathLength); - + return contextRoot; } - + + /** + * Calculate the ETag using MD5 Hash Algorithm + * @param content the content to hash + * @return + */ public static String calculateHashETag(byte[] content) { String eTag = "invalid"; try { -- cgit v1.2.3