private void fetchRemoteConnectionFromUrl(HttpServletRequest req){

		String connection = req.getParameter("remoteConnection");

		if(connection != null) try {
			connection = URLDecoder.decode(connection, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			return;
		}
		else
			return;

		String[] remoteHostAndPort;

		if( (remoteHostAndPort = connection.split(":")).length == 2 ){

			String remoteHost = remoteHostAndPort[0];
			int remotePort;

			try {
				remotePort = Integer.valueOf(remoteHostAndPort[1]);
			}catch (NumberFormatException e){
				return;
			}

			try {
				if (!APILookupUtility.isLocal() &&
						APILookupUtility.getCurrentRemoteInstance().equalsByKey(remoteHost + '-' + remotePort))
					return; // Current remote connection already points to url from params
			}catch (IllegalStateException ignored){
				// Means moskito has no remote connection while GET query specifies one.
			}

			RemoteInstance newRemoteInstance = new RemoteInstance();
			newRemoteInstance.setHost(remoteHost);
			newRemoteInstance.setPort(remotePort);
			WebUIConfig.getInstance().addRemote(newRemoteInstance);
			APILookupUtility.setCurrentConnectivityMode(ConnectivityMode.REMOTE);
			APILookupUtility.setCurrentRemoteInstance(newRemoteInstance);

		}

	}
private void fetchRemoteConnectionFromUrl ( HttpServletRequest req ) { String connection = req . getParameter ( "remoteConnection" ) ; if ( connection != null ) try { connection = URLDecoder . decode ( connection , "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { return ; } else return ; String [ ] remoteHostAndPort ; if ( ( remoteHostAndPort = connection . split ( ":" ) ) . length == 2 ) { String remoteHost = remoteHostAndPort [ 0 ] ; int remotePort ; try { remotePort = Integer . valueOf ( remoteHostAndPort [ 1 ] ) ; } catch ( NumberFormatException e ) { return ; } try { if ( ! APILookupUtility . isLocal ( ) && APILookupUtility . getCurrentRemoteInstance ( ) . equalsByKey ( remoteHost + '-' + remotePort ) ) return ; } catch ( IllegalStateException ignored ) { } RemoteInstance newRemoteInstance = new RemoteInstance ( ) ; newRemoteInstance . setHost ( remoteHost ) ; newRemoteInstance . setPort ( remotePort ) ; WebUIConfig . getInstance ( ) . addRemote ( newRemoteInstance ) ; APILookupUtility . setCurrentConnectivityMode ( ConnectivityMode . REMOTE ) ; APILookupUtility . setCurrentRemoteInstance ( newRemoteInstance ) ; } }
Acquire remote connection url from request parameter.
If current user is not connected to application
from url - moskito will be connected to this application.
This made up for possibility to share links on moskito-inspect pages.

This method expects, that request will contain `remoteConnection` parameter
with value contains host and port separated by column. Example : `localhost:9401`.
If request have no such parameter - current connection will not be changed.

@param req current request object