本文整理了Java中org.restlet.Request.getConditions
方法的一些代码示例,展示了Request.getConditions
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getConditions
方法的具体详情如下:
包路径:org.restlet.Request
类名称:Request
方法名:getConditions
[英]Returns the modifiable conditions applying to this request. Creates a new instance if no one has been set.
[中]返回应用于此请求的可修改条件。如果未设置任何实例,则创建新实例。
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Returns the conditions applying to this call.
*
* @return The conditions applying to this call.
*/
@Override
public Conditions getConditions() {
return getWrappedRequest().getConditions();
}
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Returns the modifiable conditions applying to this request. Creates a new
* instance if no one has been set.
*
* @return The conditions applying to this call.
* @see Request#getConditions()
*/
public Conditions getConditions() {
return getRequest() == null ? null : getRequest().getConditions();
}
代码示例来源:origin: apache/attic-polygene-java
public void updateCommandConditions( Request request )
{
String identity = pathToIdentity.get( getIdentityPath( request.getResourceRef() ) );
if( identity != null )
{
CacheInfo cacheInfo = identityToTimestamp.get( identity );
if( cacheInfo != null )
{
// LoggerFactory.getLogger( ClientCache.class ).info( "Send: "+cacheInfo.getEntity()+" ("+request.getMethod().getName()+":"+request.getResourceRef()+") -> "+cacheInfo.getLastModified() );
request.getConditions().setUnmodifiedSince( from( cacheInfo.getLastModified() ) );
}
}
}
代码示例来源:origin: apache/attic-polygene-java
public void updateQueryConditions( Request request )
{
String identity = pathToIdentity.get( getIdentityPath( request.getResourceRef() ) );
if( identity != null )
{
CacheInfo cacheInfo = identityToTimestamp.get( identity );
if( cacheInfo != null )
{
// LoggerFactory.getLogger( ClientCache.class ).info( "Send: "+cacheInfo.getEntity()+" ("+request.getMethod().getName()+":"+request.getResourceRef()+") -> "+cacheInfo.getLastModified() );
request.getConditions().setModifiedSince( from( cacheInfo.getLastModified() ) );
}
}
}
代码示例来源:origin: org.apache.polygene.libraries/org.apache.polygene.library.rest-server
void checkRequest()
throws ResourceException
{
// Check command rules
Instant unmodifiedSince = request.getConditions().getUnmodifiedSince().toInstant();
EntityState state = spi.entityStateOf( entity );
Instant lastModifiedSeconds = state.lastModified().with(ChronoField.NANO_OF_SECOND, 0 );
if( unmodifiedSince != null )
{
if( lastModifiedSeconds.isAfter( unmodifiedSince ) )
{
throw new ResourceException( Status.CLIENT_ERROR_CONFLICT );
}
}
// Check query rules
Instant modifiedSince = request.getConditions().getModifiedSince().toInstant();
if( modifiedSince != null )
{
if( !lastModifiedSeconds.isAfter( modifiedSince ) )
{
throw new ResourceException( Status.REDIRECTION_NOT_MODIFIED );
}
}
}
}
代码示例来源:origin: apache/attic-polygene-java
void checkRequest()
throws ResourceException
{
// Check command rules
Instant unmodifiedSince = request.getConditions().getUnmodifiedSince().toInstant();
EntityState state = spi.entityStateOf( entity );
Instant lastModifiedSeconds = state.lastModified().with(ChronoField.NANO_OF_SECOND, 0 );
if( unmodifiedSince != null )
{
if( lastModifiedSeconds.isAfter( unmodifiedSince ) )
{
throw new ResourceException( Status.CLIENT_ERROR_CONFLICT );
}
}
// Check query rules
Instant modifiedSince = request.getConditions().getModifiedSince().toInstant();
if( modifiedSince != null )
{
if( !lastModifiedSeconds.isAfter( modifiedSince ) )
{
throw new ResourceException( Status.REDIRECTION_NOT_MODIFIED );
}
}
}
}
代码示例来源:origin: org.qi4j.library/org.qi4j.library.rest-server
public void checkRequest()
throws ResourceException
{
// Check command rules
Date modificationDate = request.getConditions().getUnmodifiedSince();
if( modificationDate != null )
{
EntityState state = spi.entityStateOf( entity );
Date lastModified = new Date( ( state.lastModified() / 1000 ) * 1000 ); // Cut off milliseconds
if( lastModified.after( modificationDate ) )
{
throw new ResourceException( Status.CLIENT_ERROR_CONFLICT );
}
}
// Check query rules
modificationDate = request.getConditions().getModifiedSince();
if( modificationDate != null )
{
EntityState state = spi.entityStateOf( entity );
Date lastModified = new Date( ( state.lastModified() / 1000 ) * 1000 ); // Cut off milliseconds
if( !lastModified.after( modificationDate ) )
{
throw new ResourceException( Status.REDIRECTION_NOT_MODIFIED );
}
}
}
}
代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs
/**
* Evaluates the preconditions of the current request against the given last
* modified date and / or the given entity tag. This method does not check,
* if the arguments are not null.
*
* @param lastModified
* @param entityTag
* @return
* @see Request#evaluateConditions(Tag, Date)
*/
private ResponseBuilder evaluatePreconditionsInternal(
final Date lastModified, final EntityTag entityTag) {
Status status = this.request.getConditions().getStatus(
this.request.getMethod(), true,
Converter.toRestletTag(entityTag), lastModified);
if (status == null)
return null;
if (status.equals(Status.REDIRECTION_NOT_MODIFIED)) {
final ResponseBuilder rb = Response.notModified();
rb.lastModified(lastModified);
rb.tag(entityTag);
return rb;
}
return Response.status(STATUS_PREC_FAILED);
}
代码示例来源:origin: org.restlet.osgi/org.restlet
for (Tag o : request.getConditions().getMatch()) {
conditions.getMatch().add(o);
conditions.setModifiedSince(request.getConditions().getModifiedSince());
for (Tag o : request.getConditions().getNoneMatch()) {
conditions.getNoneMatch().add(o);
conditions.setRangeDate(request.getConditions().getRangeDate());
conditions.setRangeTag(request.getConditions().getRangeTag());
conditions.setUnmodifiedSince(request.getConditions()
.getUnmodifiedSince());
代码示例来源:origin: apache/attic-polygene-java
java.util.Date lastModified = getRequest().getConditions().getModifiedSince();
if( lastModified != null )
代码示例来源:origin: org.restlet.osgi/org.restlet
final Conditions result = super.getConditions();
代码示例来源:origin: org.restlet.osgi/org.restlet
&& (!request.getConditions().hasSomeRange()
|| request.getConditions().getRangeStatus(response.getEntity()).isSuccess())) {
Range requestedRange = request.getRanges().get(0);
代码示例来源:origin: org.restlet.osgi/org.restlet
Conditions conditions = request.getConditions();
addHeader(HEADER_IF_MATCH, TagWriter.write(conditions.getMatch()), headers);
addHeader(HEADER_IF_NONE_MATCH, TagWriter.write(conditions.getNoneMatch()), headers);
内容来源于网络,如有侵权,请联系作者删除!