public void sendUpdateNotification(final String hub, final String topic) throws NotificationException {
        try {
            final StringBuilder sb = new StringBuilder("hub.mode=publish&hub.url=").append(URLEncoder.encode(topic, "UTF-8"));
            final URL hubUrl = new URL(hub);
            final HttpURLConnection connection = (HttpURLConnection) hubUrl.openConnection();
            // connection.setRequestProperty("Host", hubUrl.getHost());
            connection.setRequestProperty("User-Agent", "ROME-Certiorem");
            connection.setRequestProperty("ContentType", "application/x-www-form-urlencoded");
            connection.setDoOutput(true);
            connection.connect();

            final OutputStream os = connection.getOutputStream();
            os.write(sb.toString().getBytes("UTF-8"));
            os.close();

            final int rc = connection.getResponseCode();
            connection.disconnect();

            if (rc != 204) {
                throw new NotificationException("Server returned an unexcepted response code: " + rc + " " + connection.getResponseMessage());
            }

        } catch (final UnsupportedEncodingException ex) {
            LOG.error("Could not encode URL", ex);
            throw new NotificationException("Could not encode URL", ex);
        } catch (final IOException ex) {
            LOG.error("Communication error", ex);
            throw new NotificationException("Unable to communicate with " + hub, ex);
        }
    }
public void sendUpdateNotification ( final String hub , final String topic ) throws NotificationException { try { final StringBuilder sb = new StringBuilder ( "hub.mode=publish&hub.url=" ) . append ( URLEncoder . encode ( topic , "UTF-8" ) ) ; final URL hubUrl = new URL ( hub ) ; final HttpURLConnection connection = ( HttpURLConnection ) hubUrl . openConnection ( ) ; connection . setRequestProperty ( "User-Agent" , "ROME-Certiorem" ) ; connection . setRequestProperty ( "ContentType" , "application/x-www-form-urlencoded" ) ; connection . setDoOutput ( true ) ; connection . connect ( ) ; final OutputStream os = connection . getOutputStream ( ) ; os . write ( sb . toString ( ) . getBytes ( "UTF-8" ) ) ; os . close ( ) ; final int rc = connection . getResponseCode ( ) ; connection . disconnect ( ) ; if ( rc != 204 ) { throw new NotificationException ( "Server returned an unexcepted response code: " + rc + " " + connection . getResponseMessage ( ) ) ; } } catch ( final UnsupportedEncodingException ex ) { LOG . error ( "Could not encode URL" , ex ) ; throw new NotificationException ( "Could not encode URL" , ex ) ; } catch ( final IOException ex ) { LOG . error ( "Communication error" , ex ) ; throw new NotificationException ( "Unable to communicate with " + hub , ex ) ; } }
Sends the HUB url a notification of a change in topic

@param hub URL of the hub to notify.
@param topic The Topic that has changed
@throws NotificationException Any failure