class HMSLocalServerRestService {

    @RequestMapping( value = "/{hostId}/portname", method = RequestMethod.GET )
    public @ResponseBody String getPortName( @PathVariable String hostId )
        throws HmsException
    {
        try
        {
            if ( !InventoryLoader.getInstance().getNodeMap().containsKey( hostId ) )
                throw new HMSRestException( Status.NOT_FOUND.getStatusCode(), "Invalid Request",
                                            "Can't find host with id " + hostId );
            else
            {
                ServerNode node = InventoryLoader.getInstance().getNodeMap().get( hostId );
                String portName =
                    ESXIInfoHelper.getHostConnectedSwitchPort( (ServiceServerNode) node.getServiceObject() );
                return portName;
            }
        }
        catch ( HmsException e )
        {
            if ( e instanceof HMSRestException )
            {
                logger.error( "Error while getting portName to which Node: {}, is connected.", hostId, e );
                throw (HMSRestException) e;
            }
            else
            {
                logger.error( "Error while getting portName to which Node: {}, is connected.", hostId, e );
                throw new HMSRestException( Status.INTERNAL_SERVER_ERROR.getStatusCode(), "Server Error", e );
            }
        }
        catch ( Exception e )
        {
            logger.error( "Error while getting portName to which Node: {}, is connected.", hostId, e );
            throw new HMSRestException( Status.INTERNAL_SERVER_ERROR.getStatusCode(), "Server Error", e );
        }
    }

}