communication-xmpp/src/main/java/org/arrowhead/wp5/com/xmpp/api/HOXTWrapper.java
public HttpOverXmppResp sendRequest(HttpOverXmppReq request, String dest)
            throws HOXTException, NotConnectedException,
            XmppStringprepException {
        /** Reset the id value in case of overflow */
        if (reqId.get() < 0) {
            reqId.set(0);
        }
        String id = Integer.toString(reqId.incrementAndGet());
        try {
            /** TODO use the timed out version poll **/
            synchronized (reqMap) {
                reqMap.put(id, request);
            }

            request.setStanzaId(id);
            request.setTo(dest);
            request.setFrom(id);
            // request.setTo(JidCreate.from(dest));
            // request.setFrom(JidCreate.from(id));
            /* Need to set version otherwise NullPointerException */
            request.setVersion("1.1");
            logger.info(connection.getUser());
            connection.sendStanza(request);
            synchronized (request) {
                /** TODO set a time out */
                // request.wait(5000);
                request.wait();
            }
        } catch (InterruptedException e) {
            synchronized (reqMap) {
                reqMap.remove(id);
                throw new HOXTException("Request was not performed");
            }
        }

        AbstractHttpOverXmpp tmp = reqMap.get(id);
        if (!(tmp instanceof HttpOverXmppResp)) {
            throw new HOXTException("No response received or error");
        }
        HttpOverXmppResp response = (HttpOverXmppResp) reqMap.get(id);
        if (response == null) {
            throw new HOXTException("Destination " + dest + " not available");
        }

        if (response.getStatusCode() == 404) {
            throw new HOXTException("404 - Resource not foud on server.");
        }

        return response;
    }
/**
     * Send an HTTP request to the node specified by dest (e.g.
     * user@server/resource)
     * 
     * @param request
     * @param dest
     * @return
     * @throws HOXTException
     * @throws NotConnectedException
     * @throws XmppStringprepException
     */
Send an HTTP request to the node specified by dest


Send an HTTP request to the node specified by dest
public HttpOverXmppResp sendRequest(HttpOverXmppReq request, String dest)
            throws HOXTException, NotConnectedException,
            XmppStringprepException {
        /** Reset the id value in case of overflow */
        if (reqId.get() < 0) {
            reqId.set(0);
        }
        String id = Integer.toString(reqId.incrementAndGet());
        try {
            /** TODO use the timed out version poll **/
            synchronized (reqMap) {
                reqMap.put(id, request);
            }
            request.setStanzaId(id);
            request.setTo(dest);
            request.setFrom(id);
            /* Need to set version otherwise NullPointerException */
            request.setVersion("1.1");
            logger.info(connection.getUser());
            connection.sendStanza(request);
            synchronized (request) {
                /** TODO set a time out */
                request.wait();
            }
        } catch (InterruptedException e) {
            synchronized (reqMap) {
                reqMap.remove(id);
                throw new HOXTException("Request was not performed");
            }
        }
        AbstractHttpOverXmpp tmp = reqMap.get(id);
        if (!(tmp instanceof HttpOverXmppResp)) {
            throw new HOXTException("No response received or error");
        }
        HttpOverXmppResp response = (HttpOverXmppResp) reqMap.get(id);
        if (response == null) {
            throw new HOXTException("Destination " + dest + " not available");
        }
        if (response.getStatusCode() == 404) {
            throw new HOXTException("404 - Resource not foud on server.");
        }
        return response;
    }
public HttpOverXmppResp sendRequest ( HttpOverXmppReq request , String dest ) throws HOXTException , NotConnectedException , XmppStringprepException { /** Reset the id value in case of overflow */ if ( reqId . get ( ) < 0 ) { reqId . set ( 0 ) ; } String id = Integer . toString ( reqId . incrementAndGet ( ) ) ; try { /** TODO use the timed out version poll **/ synchronized ( reqMap ) { reqMap . put ( id , request ) ; } request . setStanzaId ( id ) ; request . setTo ( dest ) ; request . setFrom ( id ) ; /* Need to set version otherwise NullPointerException */ request . setVersion ( "1.1" ) ; logger . info ( connection . getUser ( ) ) ; connection . sendStanza ( request ) ; synchronized ( request ) { /** TODO set a time out */ request . wait ( ) ; } } catch ( InterruptedException e ) { synchronized ( reqMap ) { reqMap . remove ( id ) ; throw new HOXTException ( "Request was not performed" ) ; } } AbstractHttpOverXmpp tmp = reqMap . get ( id ) ; if ( ! ( tmp instanceof HttpOverXmppResp ) ) { throw new HOXTException ( "No response received or error" ) ; } HttpOverXmppResp response = ( HttpOverXmppResp ) reqMap . get ( id ) ; if ( response == null ) { throw new HOXTException ( "Destination " + dest + " not available" ) ; } if ( response . getStatusCode ( ) == 404 ) { throw new HOXTException ( "404 - Resource not foud on server." ) ; } return response ; }
Send an HTTP request to the node specified by dest (e.g.
Send an HTTP request to the node specified by dest ( e . g .
// request.setTo(JidCreate.from(dest)); // request.setFrom(JidCreate.from(id)); // request.wait(5000);