public class RYRequestFactory extends Object implements com.atlassian.applinks.api.ApplicationLinkRequestFactory
Modifier and Type | Class and Description |
---|---|
static class |
RYRequestFactory.RYApplinkRequest
This class intercepts the original Applink requests for 2 reasons:
- To add convenience methods,
- To intercept the fields and log them, if logging is wanted
|
Modifier and Type | Field and Description |
---|---|
private com.atlassian.applinks.api.ApplicationLink |
applink |
private Supplier<String[]> |
currentUserKeyAndNameSupplier |
private com.atlassian.applinks.api.ApplicationLinkRequestFactory |
delegate |
private Supplier<String> |
hostUrl |
private org.apache.log4j.Logger |
log |
private Supplier<javax.servlet.http.HttpServletRequest> |
requestSupplier |
Constructor and Description |
---|
RYRequestFactory(org.apache.log4j.Logger log,
com.atlassian.applinks.api.ApplicationLinkRequestFactory delegate,
Supplier<javax.servlet.http.HttpServletRequest> requestSupplier,
Supplier<String> hostUrl,
com.atlassian.applinks.api.ApplicationLink applink,
Supplier<String[]> currentUserKeyAndNameSupplier) |
Modifier and Type | Method and Description |
---|---|
private String |
attemptToDecodeBodyString(com.atlassian.sal.api.net.Response response,
int maxLength)
Like RY.extractMessageFromXHR(), attempts to parse the response body as a JSON string, and return the
first line of the stacktrace.
|
RYRequestFactory.RYApplinkRequest |
createRequest(com.atlassian.sal.api.net.Request.MethodType methodType,
String url) |
RYRequestFactory.RYApplinkRequest |
createRequest2(com.atlassian.sal.api.net.Request.MethodType methodType,
String url) |
URI |
getAuthorisationURI() |
URI |
getAuthorisationURI(URI callback) |
ApplinkException |
getException(com.atlassian.sal.api.net.Request.MethodType method,
String url,
Supplier<String> webpageUrl,
com.atlassian.sal.api.net.Response response,
String body,
String message)
Utility method to create the correct exception (CredentialsException if HTTP 401, ApplinkException for other errors)
|
private final org.apache.log4j.Logger log
private final com.atlassian.applinks.api.ApplicationLinkRequestFactory delegate
private final Supplier<javax.servlet.http.HttpServletRequest> requestSupplier
private final com.atlassian.applinks.api.ApplicationLink applink
public RYRequestFactory(org.apache.log4j.Logger log, com.atlassian.applinks.api.ApplicationLinkRequestFactory delegate, Supplier<javax.servlet.http.HttpServletRequest> requestSupplier, Supplier<String> hostUrl, com.atlassian.applinks.api.ApplicationLink applink, Supplier<String[]> currentUserKeyAndNameSupplier)
public RYRequestFactory.RYApplinkRequest createRequest(com.atlassian.sal.api.net.Request.MethodType methodType, String url) throws com.atlassian.applinks.api.CredentialsRequiredException
createRequest
in interface com.atlassian.applinks.api.ApplicationLinkRequestFactory
com.atlassian.applinks.api.CredentialsRequiredException
public RYRequestFactory.RYApplinkRequest createRequest2(com.atlassian.sal.api.net.Request.MethodType methodType, String url) throws CredentialsException
CredentialsException
public URI getAuthorisationURI(URI callback)
getAuthorisationURI
in interface com.atlassian.applinks.api.AuthorisationURIGenerator
public URI getAuthorisationURI()
getAuthorisationURI
in interface com.atlassian.applinks.api.AuthorisationURIGenerator
public ApplinkException getException(com.atlassian.sal.api.net.Request.MethodType method, String url, Supplier<String> webpageUrl, com.atlassian.sal.api.net.Response response, String body, String message)
url
- the URL of the REST resource we tried to access, just to write it in the logs.webpageUrl
- the URL of the webpage to visit after the OAuth dance, if it is neededprivate String attemptToDecodeBodyString(com.atlassian.sal.api.net.Response response, int maxLength)
Copyright © 2022 Requirement Yogi. All rights reserved.