本文整理汇总了Java中org.apache.naming.resources.ResourceAttributes.getLastModified方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceAttributes.getLastModified方法的具体用法?Java ResourceAttributes.getLastModified怎么用?Java ResourceAttributes.getLastModified使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.naming.resources.ResourceAttributes
的用法示例。
在下文中一共展示了ResourceAttributes.getLastModified方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例6: 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;
}
示例7: 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;
}
示例8: getResourceAttributes
import org.apache.naming.resources.ResourceAttributes; //导入方法依赖的package包/类
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 e) {
//Don't care
}
return result;
}
示例9: getResourceAttributes
import org.apache.naming.resources.ResourceAttributes; //导入方法依赖的package包/类
public Long[] getResourceAttributes(String name, Context context) {
Long result[] = new Long[2];
ResourceAttributes resource = (ResourceAttributes) context.getResources().getAttributes(name);
result[0] = resource.getContentLength();
result[1] = resource.getLastModified();
return result;
}