本文整理汇总了Java中org.opendaylight.controller.northbound.commons.exception.MethodNotAllowedException类的典型用法代码示例。如果您正苦于以下问题:Java MethodNotAllowedException类的具体用法?Java MethodNotAllowedException怎么用?Java MethodNotAllowedException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MethodNotAllowedException类属于org.opendaylight.controller.northbound.commons.exception包,在下文中一共展示了MethodNotAllowedException类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateVIP
import org.opendaylight.controller.northbound.commons.exception.MethodNotAllowedException; //导入依赖的package包/类
@Path("/{containerName}/update/vip")
@PUT
@Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes( {
@ResponseCode(code = 201, condition = "VIP updated successfully"),
@ResponseCode(code = 404, condition = "The containerName not found"),
@ResponseCode(code = 503, condition = "VIP not found"),
@ResponseCode(code = 404, condition = "Pool not found"),
@ResponseCode(code = 405, condition = "Pool already attached to the VIP"),
@ResponseCode(code = 415, condition = "Invalid input name")})
public Response updateVIP(@PathParam("containerName") String containerName,
@TypeHint(VIP.class) JAXBElement<VIP> inVIP) {
VIP vipInput = inVIP.getValue();
String name = vipInput.getName();
String poolName = vipInput.getPoolName();
if(name.isEmpty() ||
poolName.isEmpty()){
throw new UnsupportedMediaTypeException(RestMessages.INVALIDDATA.toString());
}
IConfigManager configManager = getConfigManagerService(containerName);
if (configManager == null) {
throw new ServiceUnavailableException("Load Balancer "
+ RestMessages.SERVICEUNAVAILABLE.toString());
}
if(!configManager.poolExists(poolName))
throw new ResourceNotFoundException(NBConst.RES_POOL_NOT_FOUND);
if(configManager.getVIPAttachedPool(name)!=null)
throw new MethodNotAllowedException(NBConst.RES_VIP_POOL_EXIST);
if(configManager.updateVIP(name, poolName)!= null)
return Response.status(Response.Status.ACCEPTED).build();
throw new InternalServerErrorException(NBConst.RES_VIP_UPDATE_FAILED);
}