@ POST @ Produces ( { MediaType . TEXT_PLAIN } ) public Response createChannel ( @ QueryParam ( "ccid" ) String ccid , @ HeaderParam ( ChannelServiceConstants . X_ATMOSPHERE_TRACKING_ID ) String atmosphereTrackingId ) { try { log . info ( "CREATE channel for channel ID: {}" , ccid ) ; if ( ccid == null || ccid . isEmpty ( ) ) throw new JoynrHttpException ( Status . BAD_REQUEST , JOYNRMESSAGINGERROR_CHANNELNOTSET ) ; Channel channel = channelService . getChannel ( ccid ) ; if ( channel != null ) { String encodedChannelLocation = response . encodeURL ( channel . getLocation ( ) . toString ( ) ) ; return Response . ok ( ) . entity ( encodedChannelLocation ) . header ( "Location" , encodedChannelLocation ) . header ( "bp" , channel . getBounceProxy ( ) . getId ( ) ) . build ( ) ; } // look for an existing bounce proxy handling the channel channel = channelService . createChannel ( ccid , atmosphereTrackingId ) ; String encodedChannelLocation = response . encodeURL ( channel . getLocation ( ) . toString ( ) ) ; log . debug ( "encoded channel URL " + channel . getLocation ( ) + " to " + encodedChannelLocation ) ; return Response . created ( URI . create ( encodedChannelLocation ) ) . entity ( encodedChannelLocation ) . header ( "bp" , channel . getBounceProxy ( ) . getId ( ) ) . build ( ) ; } catch ( WebApplicationException ex ) { throw ex ; } catch ( Exception e ) { throw new WebApplicationException ( e ) ; } }
HTTP POST to create a channel returns location to new resource which can then be long polled . Since the channel id may later change to be a UUID not using a PUT but rather POST with used id being returned