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


Java MethodNotAllowedException类代码示例

本文整理汇总了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);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:39,代码来源:LoadBalancerNorthbound.java


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