Retrieves the application identity given the environment details
@return The application identity
@throws IOException
@throws HttpException
546698
private AppIdentity identifyApp(ApiConfiguration apiConfig) throws IOException, HttpException {
		// convert to json bytes
		byte[] jsonBytes = objectMapper.writer().writeValueAsBytes(apiConfig.getEnvDetail());

		if (LOGGER.isDebugEnabled())
		{
			LOGGER.debug("IdentifyApp Request: {}", new String(jsonBytes, "UTF-8"));
		}
		
		// post to stackify
		final HttpClient httpClient = new HttpClient(apiConfig);
		final String responseString = httpClient.post("/Metrics/IdentifyApp", jsonBytes);

		LOGGER.debug("IdentifyApp Response: {}", responseString);
		
		// deserialize the response and return the app identity
		ObjectReader jsonReader = objectMapper.reader(new TypeReference<AppIdentity>(){});
		AppIdentity identity = jsonReader.readValue(responseString);
		
		// make sure it has a valid DeviceAppID before accepting it
		
		if (deviceAppIdRequired)
		{
			if (identity.getDeviceAppId() == null)
			{
				throw new NullPointerException("DeviceAppId is null");
			}
		}
		
		// done
		
		return identity;
	}
388911
public static String getVersion() {
        String version = Default.VERSION_UNKNOW.toString();
        try (InputStream inputStream = Resources.getResource(Default.VERSION_PROPERTIES.toString()).openStream()) {
            final Properties properties = new Properties();
            properties.load(inputStream);
            version = String.valueOf(properties.get("version"));
        } catch (final IOException e) {
            LOG.error("Failed to get application version", e);
        }

        return version;
    }
471417
def get_details(app_url=defaults.APP_URL):
    
    url = '%s/environment' % app_url
    response = requests.get(url)

    if response.status_code == 200:
        return response.json()
    else:
        raise JutException('Unable to retrieve environment details from %s, got %s: %s' %
                           (url, response.status_code, response.text))
959792
protected function _getEnvironment()
    {
        $environment = self::$forceEnvironment;

        // Check if the environment has been manually set (forced).
        if ($environment !== null) {
            if (!isset($this->_environments[$environment])) {
                throw new Exception('Environment configuration for "' . $environment . '" could not be found.');
            }
        }
        // If no manual setting is available, use "host:port" to decide which config to use.
        if ($environment === null && !empty($_SERVER['HTTP_HOST'])) {
            $host = (string)$_SERVER['HTTP_HOST'];
            foreach ($this->_environments as $env => $envConfig) {
                if (isset($envConfig['domain']) && in_array($host, $envConfig['domain'])) {
                    $environment = $env;
                    break;
                }
            }
        }
        // If there is no host:port match, try "host" only.
        if ($environment === null && !empty($_SERVER['SERVER_NAME'])) {
            $host = (string)$_SERVER['SERVER_NAME'];
            foreach ($this->_environments as $env => $envConfig) {
                if (isset($envConfig['domain']) && in_array($host, $envConfig['domain'])) {
                    $environment = $env;
                    break;
                }
            }
        }
        // If no host matched then try to use the APP path.
        if ($environment === null && ($serverPath = $this->_getRealAppPath())) {
            foreach ($this->_environments as $env => $envConfig) {
                if (isset($envConfig['path']) && in_array($serverPath, $envConfig['path'])) {
                    $environment = $env;
                    break;
                }
            }
        }
        // No environment could be identified -> we are on a dev machine.
        if (!$environment) {
            $environment = 'local';
        }

        return $environment;
    }
853999
@JsonIgnore
	public String getUsername() {
		if (App.isRoot(user.getAppid())) {
			return user.getIdentifier();
		} else {
			return user.getAppid() + "/" + user.getIdentifier();
		}
	}
1180270
public ApplicationState getApplication(final String applicationId) throws IOException {
    final String url = this.getApplicationURL(applicationId);
    final HttpGet get = prepareGet(url);
    try (final CloseableHttpResponse response = this.httpClient.execute(get, this.httpClientContext)) {
      final String message = IOUtils.toString(response.getEntity().getContent());
      final ApplicationResponse result = this.objectMapper.readValue(message, ApplicationResponse.class);
      return result.getApplicationState();
    }
  }
1055159
public String getApplicationName()
    {
        return ivApplicationDisplayName != null ? ivApplicationDisplayName :
                        ivJ2eeName != null ? ivJ2eeName.getApplication() : null;
    }
282618
public JsonNode getApplicationsTree() throws IOException {
        Invocation invocation = getJerseyClient().target(getEndpoint() + "/v1/applications/fetch").request().buildGet();
        return invocation.invoke().readEntity(JsonNode.class);
    }
11146
public Identity identity() throws IOException {
        final Iterator<String> headers =
            new RqHeaders.Base(this).header(this.header).iterator();
        final Identity user;
        if (headers.hasNext()) {
            user = new CcPlain().decode(
                new Utf8String(headers.next()).asBytes()
            );
        } else {
            user = Identity.ANONYMOUS;
        }
        return user;
    }
450780
public String getAppNameAndID() {
        StringBuffer sb = new StringBuffer(" AppName=");
        sb.append(_appName);
        sb.append("; Id=").append(_sessionId);
        return sb.toString();
    }
55807
private ApplicationType getApplicationType() {
		ApplicationType applicationType = ApplicationType.Factory.newInstance();
		applicationType.setTypeOfApplication(getTypeOfApplication());
		return applicationType;
	}
312099
public ApiResponse<UserEnvelope> getSelfWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = getSelfValidateBeforeCall(null, null);
        Type localVarReturnType = new TypeToken<UserEnvelope>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }
414900
protected Environment startEnvironment(ApplicationContext applicationContext) {
        if (!applicationContext.isRunning()) {
            if (this instanceof PropertySource) {
                applicationContext.getEnvironment().addPropertySource((PropertySource) this);
            }

            return applicationContext
                    .start()
                    .getEnvironment();
        } else {
            return applicationContext.getEnvironment();
        }
    }
178192
public static GrailsApplication lookupApplication(ServletContext servletContext) {
        WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
        return (GrailsApplication)wac.getBean(GrailsApplication.APPLICATION_ID);
    }
282859
@Override
	public String getApplicationPath() {
		return request.getScheme() + "://" + request.getServerName()
			+ (request.getServerPort() != 80? ":" + request.getServerPort() : "")
			+ request.getContextPath();
	}
117497
protected File getHomeDir() {
        // check JNDI for the home directory first
        String varName = getApplicationName().toUpperCase() + "_HOME";
        try {
            InitialContext iniCtxt = new InitialContext();
            Context env = (Context) iniCtxt.lookup("java:comp/env");
            String value = (String) env.lookup(varName);
            if(value!=null && value.trim().length()>0)
                return new File(value.trim());
            // look at one more place. See HUDSON-1314
            value = (String) iniCtxt.lookup(varName);
            if(value!=null && value.trim().length()>0)
                return new File(value.trim());
        } catch (NamingException e) {
            // ignore
        }

        // finally check the system property
        String sysProp = System.getProperty(varName);
        if(sysProp!=null)
            return new File(sysProp.trim());

        // look at the env var next
        String env = System.getenv(varName);
        if(env!=null)
            return new File(env.trim()).getAbsoluteFile();

        return getDefaultHomeDir();
    }
723797
public Response getResource() throws IOException {
		buildQueryString();
		buildHeaders();

		connection.setDoOutput(true);
		connection.setRequestMethod("GET");

		return readResponse();
	}