private Map getRequestHeaders()

in src/main/java/com/microsoft/store/partnercenter/network/PartnerServiceClient.java [498:567]


	private Map<String, String> getRequestHeaders(IPartner rootPartnerOperations, String acceptType)
	{
		Map<String, String> headers = new HashMap<>();
		IRequestContext requestContext; 

		if (rootPartnerOperations.getRequestContext().getRequestId().equals(new UUID(0, 0)))
		{
			requestContext = RequestContextFactory.getInstance().create(
				rootPartnerOperations.getRequestContext().getCorrelationId(),
				UUID.randomUUID(),
				rootPartnerOperations.getRequestContext().getLocale());
		}
		else
		{
			requestContext = rootPartnerOperations.getRequestContext();
		}

		if(rootPartnerOperations.getCredentials().isExpired())
		{
			if (PartnerService.getInstance().getRefreshCredentialsHandler() != null) 
			{
				try 
				{
					PartnerService.getInstance().getRefreshCredentialsHandler()
						.onCredentialsRefreshNeeded(rootPartnerOperations.getCredentials(), rootPartnerOperations.getRequestContext());
				} 
				catch (Exception refreshProblem) 
				{
					throw new PartnerException("Refreshing the credentials has failed.", rootPartnerOperations.getRequestContext(),
						PartnerErrorCategory.UNAUTHORIZED, refreshProblem);
				}

				if (rootPartnerOperations.getCredentials().isExpired()) 
				{
					throw new PartnerException("The credential refresh mechanism provided expired credentials.",
						rootPartnerOperations.getRequestContext(), PartnerErrorCategory.UNAUTHORIZED);
				}
			}
			else
            {            
                throw new PartnerException(
                    "The partner credentials have expired. Please provide updated credentials.",
                    rootPartnerOperations.getRequestContext(), 
                    PartnerErrorCategory.UNAUTHORIZED);
            }
		} 

		headers.put(AUTHORIZATION_HEADER, AUTHORIZATION_SCHEME + " " +  rootPartnerOperations.getCredentials().getPartnerServiceToken());
		headers.put(CONTRACT_VERSION_HEADER, PartnerService.getInstance().getPartnerServiceApiVersion());
		headers.put(CORRELATION_ID_HEADER, requestContext.getCorrelationId().toString());
		headers.put(LOCALE_HEADER, requestContext.getLocale());
		headers.put(REQUEST_ID_HEADER, requestContext.getRequestId().toString());
		headers.put(SDK_VERSION_HEADER, PartnerService.getInstance().getSdkVersion());

		if (PartnerService.getInstance().getApplicationName() != null
			&& PartnerService.getInstance().getApplicationName().trim().isEmpty() != true) 
		{
			headers.put(
				PARTNER_CENTER_APP_HEADER, 
				PartnerService.getInstance().getApplicationName());
		}

		headers.put(
			CLIENT_HEADER,
			PartnerService.getInstance().getConfiguration().getPartnerCenterClient());

		headers.put(ACCEPT_HEADER, acceptType);

		return headers;
	}