Gets http servlet request user agent from request context.

@param context the context
@return the http servlet request user agent from request context
770536
public static String getHttpServletRequestUserAgentFromRequestContext(final RequestContext context) {
        val request = getHttpServletRequestFromExternalWebflowContext(context);
        return getHttpServletRequestUserAgentFromRequestContext(request);
    }
111614
protected EvaluationContext getEvaluationContext(PortletRequest request) {
        Map<String, String> userInfo =
                (Map<String, String>) request.getAttribute(PortletRequest.USER_INFO);
        final SpELEnvironmentRoot root =
                new SpELEnvironmentRoot(new PortletWebRequest(request), userInfo);
        final StandardEvaluationContext context = new StandardEvaluationContext(root);
        // Allows for @myBeanName replacements
        context.setBeanResolver(this.beanResolver);
        return context;
    }
817716
protected EvaluationContext getEvaluationContext(WebRequest request) {
        final HttpServletRequest httpRequest =
                this.portalRequestUtils.getOriginalPortalRequest(request);
        final IUserInstance userInstance = this.userInstanceManager.getUserInstance(httpRequest);
        final IPerson person = userInstance.getPerson();

        final SpELEnvironmentRoot root = new SpELEnvironmentRoot(request, person);
        final StandardEvaluationContext context = new StandardEvaluationContext(root);
        context.setBeanResolver(this.beanResolver);
        return context;
    }
1365043
@Nullable
  public static String getHttpUserAgentStringFromRequest (@Nonnull final HttpServletRequest aHttpRequest)
  {
    // Use non-standard headers first
    String sUserAgent = aHttpRequest.getHeader (CHttpHeader.UA);
    if (sUserAgent == null)
    {
      sUserAgent = aHttpRequest.getHeader (CHttpHeader.X_DEVICE_USER_AGENT);
      if (sUserAgent == null)
        sUserAgent = aHttpRequest.getHeader (CHttpHeader.USER_AGENT);
    }
    return sUserAgent;
  }
861968
public static String getServletPath(HttpServletRequest request) {
    String servletPath = request.getServletPath();
    if (Strings.isNotEmpty(servletPath)) {
      return servletPath;
    } else {
      String uri = request.getRequestURI();
      if (uri.length() == 1) return "";
      // process context
      String context = request.getContextPath();
      int length = context.length();
      if (length > 2) {
        if ('/' == context.charAt(length - 1)) context = context.substring(0, length - 1);
        return servletPath = uri.substring(context.length());
      } else {
        return uri;
      }
    }
  }
1016513
public static String getUserAgent() {
        if (USER_AGENT == null) {
            USER_AGENT = String.format(Locale.ENGLISH, "%s/%s (%s/%s)",
                    PRODUCT_NAME,
                    Version.SYNC_PROTOCOL_VERSION,
                    Version.getVersionName(),
                    Version.getCommitHash());
        }
        return USER_AGENT;
    }
428888
public static HttpServletRequest getHttpServletRequestFromRequestAttributes() {
        try {
            return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
        } catch (final Exception e) {
            LOGGER.trace(e.getMessage(), e);
        }
        return null;
    }
626179
public static String getRequestParameter(FacesContext context, String name) {
		return context.getExternalContext().getRequestParameterMap().get(name);
	}
1248334
protected String createUserAgent(String name) {
        final String defaultUserAgent = environmentName == null ? name : String.format("%s (%s)", environmentName, name);
        return configuration.getUserAgent().orElse(defaultUserAgent);
    }
683508
public static ApiUser getUserAgent(User sfsUser) {
        Object userAgent = sfsUser.getProperty(APIKey.USER);
        if(userAgent == null) 
            throw new RuntimeException("Can not get user agent");
        return (ApiUser)userAgent;
    }
734030
private TeaServletContextSource createContextSource(boolean http)
        throws Exception {

        return new TeaServletContextSource(getClass().getClassLoader(), 
                                           this, 
                                           mEngine.getServletContext(), 
                                           mEngine.getLog(), 
                                           http,
                                           mEngine.getProperties().getBoolean("management.httpcontext", false),
                                           mEngine.getProperties().getInt("management.httpcontext.readUrlCacheSize", 500),
                                           mEngine.getProperties().getBoolean("profiling.enabled", true));
    }
777508
private ContextModel getOrCreateContext(final HttpContext httpContext) {
		// org.osgi.service.http.HttpContext -> org.ops4j.pax.web.service.WebContainerContext
		final WebContainerContext context;
		if (httpContext == null) {
			context = createDefaultHttpContext();
		} else if (!(httpContext instanceof WebContainerContext)) {
			context = new WebContainerContextWrapper(serviceBundle, httpContext);
		} else {
			context = (WebContainerContext) httpContext;
		}

		// sanity check - non shared context should be associated to single bundle
		serverModel.associateHttpContext(context, serviceBundle, httpContext instanceof SharedWebContainerContext);

		ContextModel contextModel = serviceModel.getContextModel(context);
		if (contextModel == null) {
			contextModel = new ContextModel(context, serviceBundle,
					bundleClassLoader);
			contextModel.setVirtualHosts(serverController.getConfiguration()
					.getVirtualHosts());
		}
		return contextModel;
	}
1076891
public static UrlMappingsHolder lookupUrlMappings(ServletContext servletContext) {
        WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
        return (UrlMappingsHolder)wac.getBean(UrlMappingsHolder.BEAN_ID);
    }
460630
@SuppressWarnings("unchecked")
    protected String[] getUserRoles(SOAPMessageContext context) {
        HttpServletRequest request =
                (HttpServletRequest) context
                        .get(SOAPMessageContext.SERVLET_REQUEST);

        Map<String, Set<String>> reqAttr = null;
        reqAttr =
                (Map<String, Set<String>>) request
                        .getAttribute("FEDORA_AUX_SUBJECT_ATTRIBUTES");

        if (reqAttr == null) {
            return null;
        }

        Set<String> fedoraRoles = reqAttr.get("fedoraRole");
        if (fedoraRoles == null || fedoraRoles.size() == 0) {
            return null;
        }

        String[] fedoraRole =
                fedoraRoles.toArray(new String[fedoraRoles.size()]);

        return fedoraRole;
    }
56518
public static WebApplicationService getService(final RequestContext context) {
        return context != null ? (WebApplicationService) context.getFlowScope().get(PARAMETER_SERVICE) : null;
    }
723617
private String generateUserAgent(String userAgent) {
        String title = null;
        String thisVersion = null;

        if(userAgent == null) {
            StackTraceElement[] callers = Thread.currentThread().getStackTrace();
            String module = null;
            String callerClass = null;
            int stackIdx;
            for(stackIdx = callers.length - 1; stackIdx >= 0; stackIdx--) {
                callerClass = callers[stackIdx].getClassName();
                try {
                    Class<?> clazz = Class.forName(callerClass);
                    ClassLoader classLoader = clazz.getClassLoader();
                    // skip JRE classes
                    if (classLoader == null) {
                        continue;
                    }
                    String classFilePath = callerClass.replace(".", "/") + ".class";
                    URL classUrl = classLoader.getResource(classFilePath);
                    if (classUrl != null) {
                        String classUrlPath = classUrl.getPath();
                        int jarSeparator = classUrlPath.indexOf('!');
                        if (jarSeparator > 0) {
                            module = classUrlPath.substring(0, jarSeparator);
                            // extract the last path element (the jar name only)
                            module = module.substring(module.lastIndexOf('/') + 1);
                            break;
                        }
                    }
                } catch (Exception ex) { }
            }
            userAgent = module + "!" + callerClass;
        }
        try {
            final Properties properties = new Properties();
            properties.load(this.getClass().getClassLoader().getResourceAsStream("sdk.properties"));
            thisVersion = properties.getProperty("sdk.version");
            title = properties.getProperty("sdk.name");
        } catch (IOException e) { }
        return title + "/" + thisVersion + "/" + userAgent + "/" + System.getProperty("os.name") + " "
                + System.getProperty("java.vm.name") + " " + System.getProperty("java.vendor") + " "
                + System.getProperty("java.version");
    }
625015
public ServletContext getContext(String uripath) {
        ServletContext theContext = null;
        if (SecurityUtil.isPackageProtectionEnabled()) {
            theContext = (ServletContext)
                doPrivileged("getContext", new Object[]{uripath});
        } else {
            theContext = context.getContext(uripath);
        }
        if ((theContext != null) &&
            (theContext instanceof ConvergedApplicationContext)){
            theContext = ((ConvergedApplicationContext)theContext).getFacade();
        }
        return (theContext);
    }