Invoke REST Service using GET method.

@param urlStr
the REST service URL String.
@return the HttpResponse.
@throws IOException
@throws ServiceException
553704
public static HttpResponse getJson(String urlStr) throws IOException, ServiceException {
        URL url = new URL(urlStr);
        HttpURLConnection urlConnection = (HttpURLConnection) url
                .openConnection();
        if (urlConnection instanceof HttpsURLConnection) {
            setTLSConnection((HttpsURLConnection)urlConnection);
        }
        urlConnection.addRequestProperty("Accept", "application/json");

        return getHttpResponse(urlConnection);
    }
962958
public RestResponse get(final String uri, final Map<String, Object> params) throws Exception {
        final String path = getPath(uri);
        final RestResponse response = request(path, HttpGet.METHOD_NAME, params);
        if (response.isError()) {
            throw new IOException(response.getResponseText());
        }
        return response;
    }
764637
public Response get(String path) throws IOException, RESTException {
        return get(path, null, null);
    }
1043944
private static String fetchHttpResponse(URL url) throws IOException {
      HttpURLConnection conn = null;
      try {
         logger.info("fetching from url = " + url);
         conn = (HttpURLConnection) url.openConnection();
         int response = conn.getResponseCode();
         if (response != HttpURLConnection.HTTP_ACCEPTED) {
            String responseContent = IOUtils.toString(conn.getInputStream());
            logger.info("responseContent = " + responseContent);
            
            return responseContent;
         }
         throw new IOException("response from service not valid");
      } catch (IOException e) {
         logger.severe("unable to do proper http request url = " + url.toString());
         throw e;
      } finally {
         conn.disconnect();
      }

   }
11736
public void service(HttpServletRequest req, HttpServletResponse res) 
        throws ServletException, IOException
    {
        String regex = this.getProperty(REGEX);
        String server = req.getServerName();
        if (regex != null)
        	if (server != null)
        {
        	String match = null;
        	if (regex.indexOf('/') != -1)
        	{
        	    match = regex.substring(regex.indexOf('/'));
        	    regex = regex.substring(0, regex.indexOf('/'));
        	}
        	if (server.matches(regex))
	        {
        		String target = this.getProperty(REGEX_TARGET);
        		if (target != null)
        		{
        	        if (logger != null)
        	        	logger.info("Redirect " + server + " to " + target);
                    String requestPath = req.getServletPath();
        	        if ((match == null) || (requestPath.matches(match)))
        	        	res.sendRedirect(target);
        	        else
        	        {
        	            boolean fileFound = sendResourceFile(req, res);
        	            if (!fileFound)
        	                res.sendError(HttpServletResponse.SC_NOT_FOUND, "File not found");
        	        }
                    return;
        		}
	        }
        }
    	super.service(req, res);
    }
183956
private <T> T sendPostRequest(Object request, String urlStr, Class<T> clazz) throws IOException, URISyntaxException {
        ObjectWriter writer = mapper.writer().without(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
        boolean notPlainText = false;
        if (request instanceof DocumentRequest) {
            Object rawContent = ((DocumentRequest) request).getRawContent();
            if (rawContent instanceof String) {
                writer = writer.withView(DocumentRequestMixin.Views.Content.class);
            } else if (rawContent != null) {
                notPlainText = true;
            }
        } else if (request instanceof AdmRequest) {
            notPlainText = true;
        }

        URIBuilder uriBuilder = new URIBuilder(urlStr);

        if (AnnotatedText.class.isAssignableFrom(clazz) || AdmResponse.class.equals(clazz)) {
            //TODO: change output=rosette to Accept: model/vnd.rosette.annotated-data-model header
            uriBuilder.addParameter("output", "rosette");
        }

        final ObjectWriter finalWriter = writer;

        HttpPost post = new HttpPost(uriBuilder.build());
        for (Header header : additionalHeaders) {
            post.addHeader(header);
        }

        //TODO: add compression!
        if (notPlainText) {
            setupMultipartRequest((Request) request, finalWriter, post);
        } else {
            setupPlainRequest(request, finalWriter, post);
        }

        HttpRosetteAPIException lastException = null;
        int numRetries = this.failureRetries;
        while (numRetries-- > 0) {
            try (CloseableHttpResponse response = httpClient.execute(post)) {
                T resp = getResponse(response, clazz);
                Header ridHeader = response.getFirstHeader("X-RosetteAPI-DocumentRequest-Id");
                if (ridHeader != null && ridHeader.getValue() != null) {
                    LOG.debug("DocumentRequest ID " + ridHeader.getValue());
                }
                if (resp instanceof Response) {
                    responseHeadersToExtendedInformation((Response)resp, response);
                }
                return resp;
            } catch (HttpRosetteAPIException e) {
                // only 5xx errors are worthy retrying, others throw right away
                if (e.getHttpStatusCode() < 500) {
                    throw e;
                } else {
                    lastException = e;
                }
            }
        }
        throw lastException;
    }
157240
private HttpResponse getResponse(StringBuilder q, String _id) throws URISyntaxException, IOException,
            ClientProtocolException
    {
        URI uri = new URI(CouchDBConstants.PROTOCOL, null, httpHost.getHostName(), httpHost.getPort(), _id,
                q.toString(), null);
        HttpGet get = new HttpGet(uri);
        get.addHeader("Accept", "application/json");
        return httpClient.execute(httpHost, get, CouchDBUtils.getContext(httpHost));
    }
982633
public static String get(String url, String params) throws IOException {
        return HttpUtil.get(url, null, params);
    }
1202980
public void service(ServletRequest req, ServletResponse res, WebAppServletInvocationEvent evt) throws IOException, ServletException {
        // 569469
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
            logger.entering(CLASS_NAME, "service " + this.toString());
        }
        // 569469

        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) res;
        
        HttpServletRequest httpRequest = null;
        IExtendedRequest wasreq = null;
        
        if(useOriginalRequestState){
                
                WebContainerRequestState reqStateSaveFilteredRequest = WebContainerRequestState.getInstance(false);
                if(reqStateSaveFilteredRequest != null){                        
                        httpRequest = (HttpServletRequest)reqStateSaveFilteredRequest.getAttribute("unFilteredRequestObject");
                        //remove attribute
                        reqStateSaveFilteredRequest.removeAttribute("unFilteredRequestObject");
                        if(httpRequest != null) {
                                wasreq = (IExtendedRequest) ServletUtil.unwrapRequest(httpRequest);                     
                        }
                }               
        }
        //if httpRequest is null then get it from unwrapped
        if(httpRequest == null)
        {
                wasreq = (IExtendedRequest) ServletUtil.unwrapRequest(request);
        }
       // IExtendedRequest wasreq = (IExtendedRequest) ServletUtil.unwrapRequest(req);
        WebAppDispatcherContext dispatchContext = (WebAppDispatcherContext) wasreq.getWebAppDispatcherContext();

        boolean writeResponseBody = true;
        // PK55965 Start
        boolean notify = notifyInvocationListeners && (evt != null);
        long curLastAccessTime = 0;
        long endTime = 0;

        if (notify) {
            evtSource.onServletStartService(evt);
            curLastAccessTime = System.currentTimeMillis();
        }
        // PK55965 End

        try {
            synchronized (this) {
                nServicing++;
            }
            boolean isInclude = dispatchContext.isInclude();
            if (!isInclude) {
                writeResponseBody = setResponseHeaders(request, response);
            }
            if (writeResponseBody) {

                // begin pq65763
                // <!-- move response writing into separate method -->
                writeResponseToClient(request, response, wasreq);
                // end pq65763
            }

            // PK55965 Start
            if (notify) {
                endTime = System.currentTimeMillis();
                evt.setResponseTime(endTime - curLastAccessTime);
                evtSource.onServletFinishService(evt);
            }
        } catch (Throwable e) {

            if (notify) {
                if (endTime == 0) {
                    endTime = System.currentTimeMillis();
                    evt.setResponseTime(endTime - curLastAccessTime);
                    if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
                        logger.logp(Level.FINE, CLASS_NAME, "service", "Notify onServletFinishService : response time "
                                    + (endTime - curLastAccessTime) + " milliseconds");
                    }
                    evtSource.onServletFinishService(evt);
                }
                ServletErrorEvent errorEvent = new ServletErrorEvent(this, getServletContext(), getServletName(), "FileServletWrapper", e);
                if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
                    logger.logp(Level.FINE, CLASS_NAME, "service", "Notify onServletServiceError : " + errorEvent.toString());
                }
                evtSource.onServletServiceError(errorEvent);
            }
            throw new ServletException(e);

        } finally {
            synchronized (this) {
                nServicing--;
            }
            // 569469
            if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
                logger.exiting(CLASS_NAME, "service");
            }
            // 569469
        }
    }
366237
public CloseableHttpResponse get(String url, Map<String, String> reqHeaders) throws IOException {
        CloseableHttpClient req = getClient();
        CloseableHttpResponse resp = null;
        HttpGet get = new HttpGet(url);
        addHeaders(get, reqHeaders);
        resp = req.execute(get);
        return resp;
    }
1099594
@Override
  public final void service (@Nonnull final ServletRequest req,
                             @Nonnull final ServletResponse res) throws ServletException, IOException
  {
    super.service (req, res);
  }
676224
protected void service(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException
    {
        // Get the requested path and info
        boolean included=false;
        String servlet_path=(String)request.getAttribute(Dispatcher.__INCLUDE_SERVLET_PATH);
        if (servlet_path==null)
            servlet_path=request.getServletPath();
        else
            included=true;
        String path_info = (String)request.getAttribute(Dispatcher.__INCLUDE_PATH_INFO);
        if (path_info==null)
            path_info=request.getPathInfo();
        
        // Get the servlet class
        String servlet = path_info;
        if (servlet==null || servlet.length()<=1 )
        {
            response.sendError(404);
            return;
        }
        
        int i0=servlet.charAt(0)=='/'?1:0;
        int i1=servlet.indexOf('/',i0);
        servlet=i1<0?servlet.substring(i0):servlet.substring(i0,i1);

        // look for a named holder
        ServletHolder holder=_servletHandler.getServletHolder(servlet);
        if (holder!=null)
        {
            // Add named servlet mapping
            _servletHandler.addServletHolder(holder);
            _servletHandler.mapPathToServlet(URI.addPaths(servlet_path,servlet)+"/*", holder.getName());
        }
        else
        {
            // look for a class mapping
            if (servlet.endsWith(".class"))
                servlet=servlet.substring(0,servlet.length()-6);
            if (servlet==null || servlet.length()==0)
            {
                response.sendError(404);
                return;
            }   
        
            synchronized(_servletHandler)
            {
                // find the entry for the invoker
                if (_invokerEntry==null)
                    _invokerEntry=_servletHandler.getHolderEntry(servlet_path);
            
                // Check for existing mapping (avoid threaded race).
                String path=URI.addPaths(servlet_path,servlet);
                Map.Entry entry = _servletHandler.getHolderEntry(path);

                if (entry!=null && entry!=_invokerEntry)
                {
                    // Use the holder
                    holder=(ServletHolder)entry.getValue();       
                }
                else
                {
                    // Make a holder
                    holder=new ServletHolder(_servletHandler,servlet,servlet);
                    
                    if (_parameters!=null)
                        holder.putAll(_parameters);
                    
                    try {holder.start();}
                    catch (Exception e)
                    {
                        log.debug(LogSupport.EXCEPTION,e);
                        throw new UnavailableException(e.toString());
                    }
                    
                    // Check it is from an allowable classloader
                    if (!_nonContextServlets)
                    {
                        Object s=holder.getServlet();
                        
                        if (_servletHandler.getClassLoader()!=
                            s.getClass().getClassLoader())
                        {
                            holder.stop();
                            log.warn("Dynamic servlet "+s+
                                         " not loaded from context "+
                                         request.getContextPath());
                            throw new UnavailableException("Not in context");
                        }
                    }

                    // Add the holder for all the possible paths
                    if (_verbose)
                        log("Dynamic load '"+servlet+"' at "+path);
                    _servletHandler.addServletHolder(holder);
                    _servletHandler.mapPathToServlet(path+"/*",holder.getName());
                    _servletHandler.mapPathToServlet(path+".class/*",holder.getName());
                }
            }
            
        }
        
        if (holder!=null)
            holder.handle(new Request(request,included,servlet,servlet_path,path_info),
                          response);
        else
            response.sendError(404);
        
    }
1173298
public void service(HttpServletRequest req, HttpServletResponse res) 
        throws ServletException, IOException
    {
        String browser = this.getBrowser(req);
        String queryString = req.getQueryString();
        String path = req.getPathInfo();
        if (path == null)
        	path = "";
        String target = this.getProperty(browser);
        if (target == null)
            target = this.getProperty(TARGET);
        if (target == null)
            target = req.getParameter(TARGET);
        if (queryString != null)
        {
            char delimiter = '?';
            if (target.indexOf('?') != -1)
                delimiter = '&';
            target = target + delimiter + queryString;
        }

        if (logger != null)
        	logger.info("Redirect to " + target);
        String match = this.getProperty(MATCH);
        if ((target != null) && ((match == null) || path.matches(match)))
        	res.sendRedirect(target);
        else
        	super.service(req, res);
    }
957209
@Override
	public void service(final ServletRequest req, final ServletResponse res)
			throws ServletException, IOException {
		if (jspFile != null) {
			req.setAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH, jspFile);
		}
		String includeRequestUri = (String) req
				.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI);

		if (includeRequestUri != null) {
			req.removeAttribute(RequestDispatcher.INCLUDE_REQUEST_URI);
		}

		try {
			ContextClassLoaderUtils.doWithClassLoader(jasperClassLoader,
					new Callable<Void>() {

						@Override
						public Void call() throws Exception {
							jasperServlet.service(req, res);
							return null;
						}

					});
		} catch (ServletException | IOException e) {
			// re-thrown
			throw e;
		} catch (Exception ignore) {
			// ignored as it should never happen
			LOG.error("Ignored exception", ignore);
		}
		//CHECKSTYLE:ON
	}
117902
@Override
    public Object get(HttpServletRequest req, HttpServletResponse res)
            throws IOException {
        res.sendRedirect(path);
        return null;
    }
773475
@Override
    protected void service( HttpServletRequest req,
                            HttpServletResponse resp ) throws ServletException, IOException {
        ModeShapeWebdavStore.setRequest(req);
        try {
            super.service(req, resp);
        } finally {
            ModeShapeWebdavStore.setRequest(null);
        }
    }
386388
@Restricted(DoNotUse.class) // WebOnly
    public HttpResponse doRestartStatus() throws IOException {
        JSONObject response = new JSONObject();
        Jenkins jenkins = Jenkins.get();
        response.put("restartRequired", jenkins.getUpdateCenter().isRestartRequiredForCompletion());
        response.put("restartSupported", jenkins.getLifecycle().canRestart());
        return HttpResponses.okJSON(response);
    }