當前位置: 首頁>>代碼示例>>Java>>正文


Java RestMessages類代碼示例

本文整理匯總了Java中org.opendaylight.controller.northbound.commons.RestMessages的典型用法代碼示例。如果您正苦於以下問題:Java RestMessages類的具體用法?Java RestMessages怎麽用?Java RestMessages使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RestMessages類屬於org.opendaylight.controller.northbound.commons包,在下文中一共展示了RestMessages類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleNodeAvailability

import org.opendaylight.controller.northbound.commons.RestMessages; //導入依賴的package包/類
private Node handleNodeAvailability(String containerName, String nodeType,
        String nodeId) {

    Node node = Node.fromString(nodeType, nodeId);
    if (node == null) {
        throw new ResourceNotFoundException(nodeId + " : "
                + RestMessages.NONODE.toString());
    }

    ISwitchManager sm = (ISwitchManager) ServiceHelper.getInstance(
            ISwitchManager.class, containerName, this);

    if (sm == null) {
        throw new ServiceUnavailableException("Switch Manager "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    if (!sm.getNodes().contains(node)) {
        throw new ResourceNotFoundException(node.toString() + " : "
                + RestMessages.NONODE.toString());
    }
    return node;
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:24,代碼來源:SwitchNorthbound.java

示例2: handleNodeConnectorAvailability

import org.opendaylight.controller.northbound.commons.RestMessages; //導入依賴的package包/類
private void handleNodeConnectorAvailability(String containerName,
        Node node, String nodeConnectorType, String nodeConnectorId) {

    NodeConnector nc = NodeConnector.fromStringNoNode(nodeConnectorType,
            nodeConnectorId, node);
    if (nc == null) {
        throw new ResourceNotFoundException(nc + " : "
                + RestMessages.NORESOURCE.toString());
    }

    ISwitchManager sm = (ISwitchManager) ServiceHelper.getInstance(
            ISwitchManager.class, containerName, this);

    if (sm == null) {
        throw new ServiceUnavailableException("Switch Manager "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    if (!sm.getNodeConnectors(node).contains(nc)) {
        throw new ResourceNotFoundException(nc.toString() + " : "
                + RestMessages.NORESOURCE.toString());
    }
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:24,代碼來源:SwitchNorthbound.java

示例3: getStaticRoutesInternal

import org.opendaylight.controller.northbound.commons.RestMessages; //導入依賴的package包/類
private List<StaticRoute> getStaticRoutesInternal(String containerName) {

        IForwardingStaticRouting staticRouting = (IForwardingStaticRouting) ServiceHelper
                .getInstance(IForwardingStaticRouting.class, containerName,
                        this);

        if (staticRouting == null) {
            throw new ResourceNotFoundException(RestMessages.NOCONTAINER
                    .toString());
        }

        List<StaticRoute> routes = new ArrayList<StaticRoute>();

        for (StaticRouteConfig conf : staticRouting.getStaticRouteConfigs()
                .values()) {
            StaticRoute route = new StaticRoute(conf.getName(), conf
                    .getStaticRoute(), conf.getNextHop());
            routes.add(route);
        }
        return routes;
    }
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:22,代碼來源:StaticRoutingNorthbound.java

示例4: getActiveHosts

import org.opendaylight.controller.northbound.commons.RestMessages; //導入依賴的package包/類
/**
 * Returns a list of all Hosts : both configured via PUT API and dynamically
 * learnt on the network.
 *
 * @param containerName
 *            Name of the Container. The Container name for the base
 *            controller is "default".
 * @return List of Active Hosts.
 */
@Path("/{containerName}")
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@TypeHint(Hosts.class)
@StatusCodes({
        @ResponseCode(code = 200, condition = "Operation successful"),
        @ResponseCode(code = 404, condition = "The containerName is not found"),
        @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
public Hosts getActiveHosts(@PathParam("containerName") String containerName) {

    if (!NorthboundUtils.isAuthorized(
            getUserName(), containerName, Privilege.READ, this)) {
        throw new UnauthorizedException(
                "User is not authorized to perform this operation on container "
                        + containerName);
    }
    IfIptoHost hostTracker = getIfIpToHostService(containerName);
    if (hostTracker == null) {
        throw new ServiceUnavailableException("Host Tracker "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    return new Hosts(hostTracker.getAllHosts());
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:34,代碼來源:HostTrackerNorthbound.java

示例5: getInactiveHosts

import org.opendaylight.controller.northbound.commons.RestMessages; //導入依賴的package包/類
/**
 * Returns a list of Hosts that are statically configured and are connected
 * to a NodeConnector that is down.
 *
 * @param containerName
 *            Name of the Container. The Container name for the base
 *            controller is "default".
 * @return List of inactive Hosts.
 */
@Path("/{containerName}/inactive")
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@TypeHint(Hosts.class)
@StatusCodes({
        @ResponseCode(code = 200, condition = "Operation successful"),
        @ResponseCode(code = 404, condition = "The containerName is not found"),
        @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
public Hosts getInactiveHosts(
        @PathParam("containerName") String containerName) {
    if (!NorthboundUtils.isAuthorized(
            getUserName(), containerName, Privilege.READ, this)) {
        throw new UnauthorizedException(
                "User is not authorized to perform this operation on container "
                        + containerName);
    }
    IfIptoHost hostTracker = getIfIpToHostService(containerName);
    if (hostTracker == null) {
        throw new ServiceUnavailableException("Host Tracker "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    return new Hosts(hostTracker.getInactiveStaticHosts());
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:34,代碼來源:HostTrackerNorthbound.java

示例6: getAllPools

import org.opendaylight.controller.northbound.commons.RestMessages; //導入依賴的package包/類
@Path("/{containerName}")
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@TypeHint(Pools.class)
@StatusCodes( {
    @ResponseCode(code = 200, condition = "Operation successful"),
    @ResponseCode(code = 404, condition = "The containerName is not found"),
    @ResponseCode(code = 503, condition = "Load balancer service is unavailable") })
public Pools getAllPools(
        @PathParam("containerName") String containerName) {

    IConfigManager configManager = getConfigManagerService(containerName);
    if (configManager == null) {
        throw new ServiceUnavailableException("Load Balancer "
                                                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    return new Pools(configManager.getAllPools());
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:20,代碼來源:LoadBalancerNorthbound.java

示例7: getAllVIPs

import org.opendaylight.controller.northbound.commons.RestMessages; //導入依賴的package包/類
@Path("/{containerName}/vips")
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@TypeHint(VIPs.class)
@StatusCodes( {
    @ResponseCode(code = 200, condition = "Operation successful"),
    @ResponseCode(code = 404, condition = "The containerName is not found"),
    @ResponseCode(code = 503, condition = "Load balancer service is unavailable") })
public VIPs getAllVIPs(
        @PathParam("containerName") String containerName) {

    IConfigManager configManager = getConfigManagerService(containerName);
    if (configManager == null) {
        throw new ServiceUnavailableException("Load Balancer "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    return new VIPs(configManager.getAllVIPs());
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:20,代碼來源:LoadBalancerNorthbound.java

示例8: getIfSwitchManagerService

import org.opendaylight.controller.northbound.commons.RestMessages; //導入依賴的package包/類
private ISwitchManager getIfSwitchManagerService(String containerName) {
    IContainerManager containerManager = (IContainerManager) ServiceHelper
            .getGlobalInstance(IContainerManager.class, this);
    if (containerManager == null) {
        throw new ServiceUnavailableException("Container "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    boolean found = false;
    List<String> containerNames = containerManager.getContainerNames();
    for (String cName : containerNames) {
        if (cName.trim().equalsIgnoreCase(containerName.trim())) {
            found = true;
            break;
        }
    }

    if (found == false) {
        throw new ResourceNotFoundException(containerName + " "
                + RestMessages.NOCONTAINER.toString());
    }

    ISwitchManager switchManager = (ISwitchManager) ServiceHelper
            .getInstance(ISwitchManager.class, containerName, this);

    if (switchManager == null) {
        throw new ServiceUnavailableException("Switch Manager "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    return switchManager;
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:33,代碼來源:SwitchNorthbound.java

示例9: deleteNodeProperty

import org.opendaylight.controller.northbound.commons.RestMessages; //導入依賴的package包/類
/**
 * Delete a property of a node
 *
 * @param containerName
 *            Name of the Container
 * @param nodeType
 *            Type of the node being programmed
 * @param nodeId
 *            Node Identifier as specified by
 *            {@link org.opendaylight.controller.sal.core.Node}
 * @param propertyName
 *            Name of the Property specified by
 *            {@link org.opendaylight.controller.sal.core.Property} and its
 *            extended classes
 * @return Response as dictated by the HTTP Response Status code
 */

@Path("/{containerName}/node/{nodeType}/{nodeId}/property/{propertyName}")
@DELETE
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes({
        @ResponseCode(code = 200, condition = "Operation successful"),
        @ResponseCode(code = 404, condition = "The Container Name or nodeId or configuration name is not found"),
        @ResponseCode(code = 503, condition = "One or more of Controller services are unavailable") })
public Response deleteNodeProperty(
        @PathParam("containerName") String containerName,
        @PathParam("nodeType") String nodeType,
        @PathParam("nodeId") String nodeId,
        @PathParam("propertyName") String propertyName) {

    if (!NorthboundUtils.isAuthorized(
            getUserName(), containerName, Privilege.WRITE, this)) {
        throw new UnauthorizedException(
                "User is not authorized to perform this operation on container "
                        + containerName);
    }
    handleDefaultDisabled(containerName);

    ISwitchManager switchManager = getIfSwitchManagerService(containerName);
    if (switchManager == null) {
        throw new ServiceUnavailableException("Switch Manager "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    handleNodeAvailability(containerName, nodeType, nodeId);
    Node node = Node.fromString(nodeType, nodeId);
    Status ret = switchManager.removeNodeProp(node, propertyName);
    if (ret.isSuccess()) {
        return Response.ok().build();
    }
    throw new ResourceNotFoundException(ret.getDescription());
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:53,代碼來源:SwitchNorthbound.java

示例10: saveSwitchConfig

import org.opendaylight.controller.northbound.commons.RestMessages; //導入依賴的package包/類
/**
 * Save the current switch configurations
 *
 * @param containerName
 *            Name of the Container
 * @return Response as dictated by the HTTP Response Status code
 */
@Path("/{containerName}/switch-config")
@POST
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes({
        @ResponseCode(code = 200, condition = "Operation successful"),
        @ResponseCode(code = 404, condition = "The containerName is not found"),
        @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
public Response saveSwitchConfig(
        @PathParam("containerName") String containerName) {

    if (!NorthboundUtils.isAuthorized(
            getUserName(), containerName, Privilege.WRITE, this)) {
        throw new UnauthorizedException(
                "User is not authorized to perform this operation on container "
                        + containerName);
    }
    ISwitchManager switchManager = getIfSwitchManagerService(containerName);
    if (switchManager == null) {
        throw new ServiceUnavailableException("Switch Manager "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    Status ret = switchManager.saveSwitchConfig();
    if (ret.isSuccess()) {
        return Response.ok().build();
    }
    throw new InternalServerErrorException(ret.getDescription());
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:36,代碼來源:SwitchNorthbound.java

示例11: handleDefaultDisabled

import org.opendaylight.controller.northbound.commons.RestMessages; //導入依賴的package包/類
private void handleDefaultDisabled(String containerName) {
    IContainerManager containerManager = (IContainerManager) ServiceHelper
            .getGlobalInstance(IContainerManager.class, this);
    if (containerManager == null) {
        throw new InternalServerErrorException(
                RestMessages.INTERNALERROR.toString());
    }
    if (containerName.equals(GlobalConstants.DEFAULT.toString())
            && containerManager.hasNonDefaultContainer()) {
        throw new ResourceConflictException(
                RestMessages.DEFAULTDISABLED.toString());
    }
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:14,代碼來源:SwitchNorthbound.java

示例12: getStaticRoute

import org.opendaylight.controller.northbound.commons.RestMessages; //導入依賴的package包/類
/**
 * Returns the static route for the provided configuration name on a given container
 *
 * @param containerName Name of the Container. The Container name for the base controller is "default".
 * @param name Name of the Static Route configuration
 * @return Static route configured with the supplied Name.
 */
@Path("/{containerName}/{name}")
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@TypeHint(StaticRoute.class)
@StatusCodes( {
        @ResponseCode(code = 200, condition = "Operation successful"),
        @ResponseCode(code = 404, condition = "The Container Name or Static Route Configuration name passed was not found") })
public StaticRoute getStaticRoute(
        @PathParam("containerName") String containerName,
        @PathParam("name") String name) {

    if(!NorthboundUtils.isAuthorized(getUserName(), containerName,
            Privilege.WRITE, this)){
        throw new
            UnauthorizedException("User is not authorized to perform this operation on container "
                        + containerName);
    }
    List<StaticRoute> routes = this.getStaticRoutesInternal(containerName);
    for (StaticRoute route : routes) {
        if (route.getName().equalsIgnoreCase(name)) {
            return route;
        }
    }

    throw new ResourceNotFoundException(RestMessages.NOSTATICROUTE
            .toString());
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:35,代碼來源:StaticRoutingNorthbound.java

示例13: removeStaticRoute

import org.opendaylight.controller.northbound.commons.RestMessages; //導入依賴的package包/類
/**
 *
 * Delete a Static Route
 *
 * @param containerName Name of the Container. The Container name for the base controller is "default".
 * @param name Name of the Static Route configuration to be removed
 *
 * @return Response as dictated by the HTTP Response code
 */

@Path("/{containerName}/{name}")
@DELETE
@StatusCodes( {
        @ResponseCode(code = 200, condition = "Operation successful"),
        @ResponseCode(code = 404, condition = "Container Name or Configuration Name not found"),
        @ResponseCode(code = 406, condition = "Cannot operate on Default Container when other Containers are active") })
public Response removeStaticRoute(
        @PathParam(value = "containerName") String containerName,
        @PathParam(value = "name") String name) {

    if(!NorthboundUtils.isAuthorized(getUserName(), containerName,
            Privilege.WRITE, this)){
        throw new
            UnauthorizedException("User is not authorized to perform this operation on container "
                        + containerName);
    }
    handleDefaultDisabled(containerName);

    IForwardingStaticRouting staticRouting = (IForwardingStaticRouting) ServiceHelper
            .getInstance(IForwardingStaticRouting.class, containerName,
                    this);

    if (staticRouting == null) {
        throw new ResourceNotFoundException(RestMessages.NOCONTAINER
                .toString());
    }

    Status status = staticRouting.removeStaticRoute(name);
    if (status.isSuccess()) {
        return Response.ok().build();
    }
    throw new ResourceNotFoundException(status.getDescription());
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:44,代碼來源:StaticRoutingNorthbound.java

示例14: handleDefaultDisabled

import org.opendaylight.controller.northbound.commons.RestMessages; //導入依賴的package包/類
private void handleDefaultDisabled(String containerName) {
    IContainerManager containerManager = (IContainerManager) ServiceHelper
            .getGlobalInstance(IContainerManager.class, this);
    if (containerManager == null) {
        throw new InternalServerErrorException(RestMessages.INTERNALERROR
                .toString());
    }
    if (containerName.equals(GlobalConstants.DEFAULT.toString())
            && containerManager.hasNonDefaultContainer()) {
        throw new NotAcceptableException(RestMessages.DEFAULTDISABLED
                .toString());
    }
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:14,代碼來源:StaticRoutingNorthbound.java

示例15: getForwardingRulesManagerService

import org.opendaylight.controller.northbound.commons.RestMessages; //導入依賴的package包/類
private IForwardingRulesManager getForwardingRulesManagerService(
        String containerName) {
    IContainerManager containerManager = (IContainerManager) ServiceHelper
            .getGlobalInstance(IContainerManager.class, this);
    if (containerManager == null) {
        throw new ServiceUnavailableException("Container "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    boolean found = false;
    List<String> containerNames = containerManager.getContainerNames();
    for (String cName : containerNames) {
        if (cName.trim().equalsIgnoreCase(containerName.trim())) {
            found = true;
        }
    }

    if (found == false) {
        throw new ResourceNotFoundException(containerName + " "
                + RestMessages.NOCONTAINER.toString());
    }

    IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper
            .getInstance(IForwardingRulesManager.class, containerName, this);

    if (frm == null) {
        throw new ServiceUnavailableException("Flow Programmer "
                + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    return frm;
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:33,代碼來源:FlowProgrammerNorthbound.java


注:本文中的org.opendaylight.controller.northbound.commons.RestMessages類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。