我有一个实现containerRequestFilter的类授权。
@Provider
@Authorization
public class AuthorizationFilter implements ContainerRequestFilter {
@Override
public void filter(ContainerRequestContext requestContext) throws
IOException {
// TODO Auto-generated method stub
InputStream entityIn = requestContext.getEntityStream();
}
}
应在此方法之前调用此过滤器:
@Path("/delete/volume")
@Authorization
public Response deleteVolumeForTechAccount(VolumeRequestJSON volumeForDeletion) {
log.debug("Delete volume was called ");
VolumeOperation operator = getVolumeOperator();
try {
log.debug("Deleting volume with id: " + volumeForDeletion.getVolumeId());
operator.deleteVolume(volumeForDeletion.getVolumeId());
log.debug("Volume with id: " + volumeForDeletion.getVolumeId() + "was deleted");
return Response.ok().build();
} catch (OperationException ex) {
log.error("OperationException occured durring deletion of volume: " + volumeForDeletion.getVolumeId(), ex);
return buildResponseWithHeader(HttpURLConnection.HTTP_INTERNAL_ERROR, ex.getMessage());
}
}
我正在使用以下JSON数据来调用其余的:
{" volumeid":" test"}
该方法已成功执行,但是当我致电时:
requestContext.getentityStream((在过滤器中返回始终为null。
我想读取过滤器中的JSON数据。
请说明我是否做错了什么。
谢谢
原因是因为我正在使用旧版本的Apache CXF捆绑包。当我将版本更改为:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle</artifactId>
<version>2.7.18</version>
</dependency>
问题已解决。
此外,该问题已正式提交给Apache CXF。链接在这里:https://issues.apache.org/jira/browse/cxf-5243