当前位置: 首页>>代码示例>>Java>>正文


Java ResourceAttributes类代码示例

本文整理汇总了Java中org.apache.naming.resources.ResourceAttributes的典型用法代码示例。如果您正苦于以下问题:Java ResourceAttributes类的具体用法?Java ResourceAttributes怎么用?Java ResourceAttributes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ResourceAttributes类属于org.apache.naming.resources包,在下文中一共展示了ResourceAttributes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkIfModifiedSince

import org.apache.naming.resources.ResourceAttributes; //导入依赖的package包/类
/**
 * Check if the if-modified-since condition is satisfied.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @param resourceAttributes File object
 * @return boolean true if the resource meets the specified condition,
 * and false if the condition is not satisfied, in which case request
 * processing is stopped
 */
protected boolean checkIfModifiedSince(HttpServletRequest request,
        HttpServletResponse response,
        ResourceAttributes resourceAttributes) {
    try {
        long headerValue = request.getDateHeader("If-Modified-Since");
        long lastModified = resourceAttributes.getLastModified();
        if (headerValue != -1) {

            // If an If-None-Match header has been specified, if modified since
            // is ignored.
            if ((request.getHeader("If-None-Match") == null)
                && (lastModified < headerValue + 1000)) {
                // The entity has not been modified since the date
                // specified by the client. This is not an error case.
                response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                response.setHeader("ETag", resourceAttributes.getETag());

                return false;
            }
        }
    } catch (IllegalArgumentException illegalArgument) {
        return true;
    }
    return true;

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:37,代码来源:DefaultServlet.java

示例2: checkIfUnmodifiedSince

import org.apache.naming.resources.ResourceAttributes; //导入依赖的package包/类
/**
 * Check if the if-unmodified-since condition is satisfied.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @param resourceAttributes File object
 * @return boolean true if the resource meets the specified condition,
 * and false if the condition is not satisfied, in which case request
 * processing is stopped
 */
protected boolean checkIfUnmodifiedSince(HttpServletRequest request,
                                       HttpServletResponse response,
                                       ResourceAttributes resourceAttributes)
    throws IOException {
    try {
        long lastModified = resourceAttributes.getLastModified();
        long headerValue = request.getDateHeader("If-Unmodified-Since");
        if (headerValue != -1) {
            if ( lastModified >= (headerValue + 1000)) {
                // The entity has not been modified since the date
                // specified by the client. This is not an error case.
                response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
                return false;
            }
        }
    } catch(IllegalArgumentException illegalArgument) {
        return true;
    }
    return true;

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:32,代码来源:DefaultServlet.java

示例3: checkIfUnmodifiedSince

import org.apache.naming.resources.ResourceAttributes; //导入依赖的package包/类
/**
 * Check if the if-unmodified-since condition is satisfied.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @param resourceInfo File object
 * @return boolean true if the resource meets the specified condition,
 * and false if the condition is not satisfied, in which case request
 * processing is stopped
 */
protected boolean checkIfUnmodifiedSince(HttpServletRequest request,
                                       HttpServletResponse response,
                                       ResourceAttributes resourceAttributes)
    throws IOException {
    try {
        long lastModified = resourceAttributes.getLastModified();
        long headerValue = request.getDateHeader("If-Unmodified-Since");
        if (headerValue != -1) {
            if ( lastModified >= (headerValue + 1000)) {
                // The entity has not been modified since the date
                // specified by the client. This is not an error case.
                response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
                return false;
            }
        }
    } catch(IllegalArgumentException illegalArgument) {
        return true;
    }
    return true;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:DefaultServlet.java

示例4: checkIfModifiedSince

import org.apache.naming.resources.ResourceAttributes; //导入依赖的package包/类
/**
 * Check if the if-modified-since condition is satisfied.
 *
 * @param request
 *            The servlet request we are processing
 * @param response
 *            The servlet response we are creating
 * @param resourceAttributes
 *            File object
 * @return boolean true if the resource meets the specified condition, and
 *         false if the condition is not satisfied, in which case request
 *         processing is stopped
 */
protected boolean checkIfModifiedSince(HttpServletRequest request, HttpServletResponse response,
		ResourceAttributes resourceAttributes) {
	try {
		long headerValue = request.getDateHeader("If-Modified-Since");
		long lastModified = resourceAttributes.getLastModified();
		if (headerValue != -1) {

			// If an If-None-Match header has been specified, if modified
			// since
			// is ignored.
			if ((request.getHeader("If-None-Match") == null) && (lastModified < headerValue + 1000)) {
				// The entity has not been modified since the date
				// specified by the client. This is not an error case.
				response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
				response.setHeader("ETag", resourceAttributes.getETag());

				return false;
			}
		}
	} catch (IllegalArgumentException illegalArgument) {
		return true;
	}
	return true;

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:39,代码来源:DefaultServlet.java

示例5: checkIfUnmodifiedSince

import org.apache.naming.resources.ResourceAttributes; //导入依赖的package包/类
/**
 * Check if the if-unmodified-since condition is satisfied.
 *
 * @param request
 *            The servlet request we are processing
 * @param response
 *            The servlet response we are creating
 * @param resourceAttributes
 *            File object
 * @return boolean true if the resource meets the specified condition, and
 *         false if the condition is not satisfied, in which case request
 *         processing is stopped
 */
protected boolean checkIfUnmodifiedSince(HttpServletRequest request, HttpServletResponse response,
		ResourceAttributes resourceAttributes) throws IOException {
	try {
		long lastModified = resourceAttributes.getLastModified();
		long headerValue = request.getDateHeader("If-Unmodified-Since");
		if (headerValue != -1) {
			if (lastModified >= (headerValue + 1000)) {
				// The entity has not been modified since the date
				// specified by the client. This is not an error case.
				response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
				return false;
			}
		}
	} catch (IllegalArgumentException illegalArgument) {
		return true;
	}
	return true;

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:33,代码来源:DefaultServlet.java

示例6: checkIfHeaders

import org.apache.naming.resources.ResourceAttributes; //导入依赖的package包/类
/**
 * Check if the conditions specified in the optional If headers are
 * satisfied.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @param resourceAttributes The resource information
 * @return boolean true if the resource meets all the specified conditions,
 * and false if any of the conditions is not satisfied, in which case
 * request processing is stopped
 */
@Override
protected boolean checkIfHeaders(HttpServletRequest request,
                                 HttpServletResponse response,
                                 ResourceAttributes resourceAttributes)
    throws IOException {

    if (!super.checkIfHeaders(request, response, resourceAttributes))
        return false;

    // TODO : Checking the WebDAV If header
    return true;

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:25,代码来源:WebdavServlet.java

示例7: checkIfHeaders

import org.apache.naming.resources.ResourceAttributes; //导入依赖的package包/类
/**
 * Check if the conditions specified in the optional If headers are
 * satisfied.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @param resourceAttributes The resource information
 * @return boolean true if the resource meets all the specified conditions,
 * and false if any of the conditions is not satisfied, in which case
 * request processing is stopped
 */
protected boolean checkIfHeaders(HttpServletRequest request,
                                 HttpServletResponse response,
                                 ResourceAttributes resourceAttributes)
    throws IOException {

    return checkIfMatch(request, response, resourceAttributes)
        && checkIfModifiedSince(request, response, resourceAttributes)
        && checkIfNoneMatch(request, response, resourceAttributes)
        && checkIfUnmodifiedSince(request, response, resourceAttributes);

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:23,代码来源:DefaultServlet.java

示例8: checkIfMatch

import org.apache.naming.resources.ResourceAttributes; //导入依赖的package包/类
/**
 * Check if the if-match condition is satisfied.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @param resourceAttributes File object
 * @return boolean true if the resource meets the specified condition,
 * and false if the condition is not satisfied, in which case request
 * processing is stopped
 */
protected boolean checkIfMatch(HttpServletRequest request,
                             HttpServletResponse response,
                             ResourceAttributes resourceAttributes)
    throws IOException {

    String eTag = resourceAttributes.getETag();
    String headerValue = request.getHeader("If-Match");
    if (headerValue != null) {
        if (headerValue.indexOf('*') == -1) {

            StringTokenizer commaTokenizer = new StringTokenizer
                (headerValue, ",");
            boolean conditionSatisfied = false;

            while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) {
                String currentToken = commaTokenizer.nextToken();
                if (currentToken.trim().equals(eTag))
                    conditionSatisfied = true;
            }

            // If none of the given ETags match, 412 Precodition failed is
            // sent back
            if (!conditionSatisfied) {
                response.sendError
                    (HttpServletResponse.SC_PRECONDITION_FAILED);
                return false;
            }

        }
    }
    return true;

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:44,代码来源:DefaultServlet.java

示例9: checkIfHeaders

import org.apache.naming.resources.ResourceAttributes; //导入依赖的package包/类
/**
 * Check if the conditions specified in the optional If headers are
 * satisfied.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @param resourceAttributes The resource information
 * @return boolean true if the resource meets all the specified conditions,
 * and false if any of the conditions is not satisfied, in which case
 * request processing is stopped
 */
protected boolean checkIfHeaders(HttpServletRequest request,
                                 HttpServletResponse response,
                                 ResourceAttributes resourceAttributes)
    throws IOException {

    if (!super.checkIfHeaders(request, response, resourceAttributes))
        return false;

    // TODO : Checking the WebDAV If header
    return true;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:WebdavServlet.java

示例10: checkIfMatch

import org.apache.naming.resources.ResourceAttributes; //导入依赖的package包/类
/**
 * Check if the if-match condition is satisfied.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @param resourceInfo File object
 * @return boolean true if the resource meets the specified condition,
 * and false if the condition is not satisfied, in which case request
 * processing is stopped
 */
protected boolean checkIfMatch(HttpServletRequest request,
                             HttpServletResponse response,
                             ResourceAttributes resourceAttributes)
    throws IOException {

    String eTag = resourceAttributes.getETag();
    String headerValue = request.getHeader("If-Match");
    if (headerValue != null) {
        if (headerValue.indexOf('*') == -1) {

            StringTokenizer commaTokenizer = new StringTokenizer
                (headerValue, ",");
            boolean conditionSatisfied = false;

            while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) {
                String currentToken = commaTokenizer.nextToken();
                if (currentToken.trim().equals(eTag))
                    conditionSatisfied = true;
            }

            // If none of the given ETags match, 412 Precodition failed is
            // sent back
            if (!conditionSatisfied) {
                response.sendError
                    (HttpServletResponse.SC_PRECONDITION_FAILED);
                return false;
            }

        }
    }
    return true;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:44,代码来源:DefaultServlet.java

示例11: checkIfModifiedSince

import org.apache.naming.resources.ResourceAttributes; //导入依赖的package包/类
/**
 * Check if the if-modified-since condition is satisfied.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @param resourceInfo File object
 * @return boolean true if the resource meets the specified condition,
 * and false if the condition is not satisfied, in which case request
 * processing is stopped
 */
protected boolean checkIfModifiedSince(HttpServletRequest request,
                                     HttpServletResponse response,
                                     ResourceAttributes resourceAttributes)
    throws IOException {
    try {
        long headerValue = request.getDateHeader("If-Modified-Since");
        long lastModified = resourceAttributes.getLastModified();
        if (headerValue != -1) {

            // If an If-None-Match header has been specified, if modified since
            // is ignored.
            if ((request.getHeader("If-None-Match") == null)
                && (lastModified < headerValue + 1000)) {
                // The entity has not been modified since the date
                // specified by the client. This is not an error case.
                response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                response.setHeader("ETag", resourceAttributes.getETag());

                return false;
            }
        }
    } catch (IllegalArgumentException illegalArgument) {
        return true;
    }
    return true;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:38,代码来源:DefaultServlet.java

示例12: checkIfNoneMatch

import org.apache.naming.resources.ResourceAttributes; //导入依赖的package包/类
/**
 * Check if the if-none-match condition is satisfied.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @param resourceAttributes File object
 * @return boolean true if the resource meets the specified condition,
 * and false if the condition is not satisfied, in which case request
 * processing is stopped
 */
protected boolean checkIfNoneMatch(HttpServletRequest request,
                                 HttpServletResponse response,
                                 ResourceAttributes resourceAttributes)
    throws IOException {

    String eTag = resourceAttributes.getETag();
    String headerValue = request.getHeader("If-None-Match");
    if (headerValue != null) {

        boolean conditionSatisfied = false;

        if (!headerValue.equals("*")) {

            StringTokenizer commaTokenizer =
                new StringTokenizer(headerValue, ",");

            while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) {
                String currentToken = commaTokenizer.nextToken();
                if (currentToken.trim().equals(eTag))
                    conditionSatisfied = true;
            }

        } else {
            conditionSatisfied = true;
        }

        if (conditionSatisfied) {

            // For GET and HEAD, we should respond with
            // 304 Not Modified.
            // For every other method, 412 Precondition Failed is sent
            // back.
            if ( ("GET".equals(request.getMethod()))
                 || ("HEAD".equals(request.getMethod())) ) {
                response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                response.setHeader("ETag", eTag);

                return false;
            }
            response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
            return false;
        }
    }
    return true;

}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:57,代码来源:DefaultServlet.java

示例13: checkIfMatch

import org.apache.naming.resources.ResourceAttributes; //导入依赖的package包/类
/**
 * Check if the if-match condition is satisfied.
 *
 * @param request
 *            The servlet request we are processing
 * @param response
 *            The servlet response we are creating
 * @param resourceAttributes
 *            File object
 * @return boolean true if the resource meets the specified condition, and
 *         false if the condition is not satisfied, in which case request
 *         processing is stopped
 */
protected boolean checkIfMatch(HttpServletRequest request, HttpServletResponse response,
		ResourceAttributes resourceAttributes) throws IOException {

	String eTag = resourceAttributes.getETag();
	String headerValue = request.getHeader("If-Match");
	if (headerValue != null) {
		if (headerValue.indexOf('*') == -1) {

			StringTokenizer commaTokenizer = new StringTokenizer(headerValue, ",");
			boolean conditionSatisfied = false;

			while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) {
				String currentToken = commaTokenizer.nextToken();
				if (currentToken.trim().equals(eTag))
					conditionSatisfied = true;
			}

			// If none of the given ETags match, 412 Precondition failed is
			// sent back
			if (!conditionSatisfied) {
				response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
				return false;
			}

		}
	}
	return true;

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:43,代码来源:DefaultServlet.java

示例14: getResourceAttributes

import org.apache.naming.resources.ResourceAttributes; //导入依赖的package包/类
@Override
public Long[] getResourceAttributes(String name, Context context) {
  Long[] result = new Long[2];
  try {
    ResourceAttributes resource = (ResourceAttributes) context.getResources().getAttributes(name);
    result[0] = resource.getContentLength();
    result[1] = resource.getLastModified();
  } catch (NamingException ex) {
    logger.trace("", ex);
  }
  return result;
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:13,代码来源:Tomcat70ContainerAdapter.java

示例15: resourceAttributes

import org.apache.naming.resources.ResourceAttributes; //导入依赖的package包/类
/**
 * Resource attributes.
 *
 * @throws NamingException Signals that a Naming exception has occurred.
 */
@Test
public void resourceAttributes() throws NamingException {
  Assert.assertNotNull(new Expectations() {
    {
      resource.getAttributes(this.anyString);
      this.result = new ResourceAttributes();
    }
  });

  final Tomcat70ContainerAdapter adapter = new Tomcat70ContainerAdapter();
  adapter.getResourceAttributes("name", context);
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:18,代码来源:Tomcat70ContainerAdapterTest.java


注:本文中的org.apache.naming.resources.ResourceAttributes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。