22
33import com .fasterxml .jackson .core .JsonProcessingException ;
44import com .fasterxml .jackson .databind .ObjectMapper ;
5+ import java .io .IOException ;
6+ import java .io .InputStream ;
7+ import java .nio .charset .Charset ;
8+ import java .util .HashMap ;
9+ import java .util .Map ;
10+ import java .util .Properties ;
511import lombok .extern .slf4j .Slf4j ;
612import org .apache .commons .lang3 .StringUtils ;
7- import org .apache .commons .lang3 . text .StrSubstitutor ;
13+ import org .apache .commons .text .StringSubstitutor ;
814import org .springframework .beans .factory .annotation .Autowired ;
915import org .springframework .core .env .Environment ;
1016import org .springframework .core .io .ClassPathResource ;
11- import org .springframework .http .MediaType ;
1217import org .springframework .security .web .csrf .CsrfToken ;
1318import org .springframework .util .StreamUtils ;
1419import org .springframework .web .bind .annotation .PathVariable ;
1520import org .springframework .web .bind .annotation .RequestParam ;
1621
17- import java .io .IOException ;
18- import java .io .InputStream ;
19- import java .nio .charset .Charset ;
20- import java .util .HashMap ;
21- import java .util .Map ;
22- import java .util .Properties ;
23-
2422/**
2523 * @author Andrew Potter
2624 */
@@ -63,7 +61,8 @@ private void loadHeaders() {
6361 headerProperties = propertyReader .load ();
6462 }
6563
66- public byte [] graphiql (String contextPath , @ PathVariable Map <String , String > params , Object csrf ) {
64+ public byte [] graphiql (String contextPath , @ PathVariable Map <String , String > params ,
65+ Object csrf ) {
6766 if (csrf != null ) {
6867 CsrfToken csrfToken = (CsrfToken ) csrf ;
6968 headerProperties .setProperty (csrfToken .getHeaderName (), csrfToken .getToken ());
@@ -75,7 +74,7 @@ public byte[] graphiql(String contextPath, @PathVariable Map<String, String> par
7574 contextPath + graphiQLProperties .getSTATIC ().getBasePath ()
7675 );
7776
78- String populatedTemplate = StrSubstitutor .replace (template , replacements );
77+ String populatedTemplate = StringSubstitutor .replace (template , replacements );
7978 return populatedTemplate .getBytes (Charset .defaultCharset ());
8079 }
8180
@@ -89,7 +88,8 @@ private Map<String, String> getReplacements(
8988 replacements .put ("subscriptionsEndpoint" , subscriptionsEndpoint );
9089 replacements .put ("staticBasePath" , staticBasePath );
9190 replacements .put ("pageTitle" , graphiQLProperties .getPageTitle ());
92- replacements .put ("pageFavicon" , getResourceUrl (staticBasePath , "favicon.ico" , FAVICON_GRAPHQL_ORG ));
91+ replacements
92+ .put ("pageFavicon" , getResourceUrl (staticBasePath , "favicon.ico" , FAVICON_GRAPHQL_ORG ));
9393 replacements .put ("es6PromiseJsUrl" , getResourceUrl (staticBasePath , "es6-promise.auto.min.js" ,
9494 joinCdnjsPath ("es6-promise" , "4.1.1" , "es6-promise.auto.min.js" )));
9595 replacements .put ("fetchJsUrl" , getResourceUrl (staticBasePath , "fetch.min.js" ,
@@ -115,9 +115,11 @@ private Map<String, String> getReplacements(
115115 log .error ("Cannot serialize headers" , e );
116116 }
117117 replacements
118- .put ("subscriptionClientTimeout" , String .valueOf (graphiQLProperties .getSubscriptions ().getTimeout () * 1000 ));
118+ .put ("subscriptionClientTimeout" ,
119+ String .valueOf (graphiQLProperties .getSubscriptions ().getTimeout () * 1000 ));
119120 replacements
120- .put ("subscriptionClientReconnect" , String .valueOf (graphiQLProperties .getSubscriptions ().isReconnect ()));
121+ .put ("subscriptionClientReconnect" ,
122+ String .valueOf (graphiQLProperties .getSubscriptions ().isReconnect ()));
121123 replacements .put ("editorThemeCss" , getEditorThemeCssURL ());
122124 return replacements ;
123125 }
@@ -153,7 +155,8 @@ private String joinJsDelivrPath(String library, String cdnVersion, String cdnFil
153155 return CDN_JSDELIVR_NET_NPM + library + "@" + cdnVersion + "/" + cdnFileName ;
154156 }
155157
156- private String constructGraphQlEndpoint (String contextPath , @ RequestParam Map <String , String > params ) {
158+ private String constructGraphQlEndpoint (String contextPath ,
159+ @ RequestParam Map <String , String > params ) {
157160 String endpoint = graphiQLProperties .getEndpoint ().getGraphql ();
158161 for (Map .Entry <String , String > param : params .entrySet ()) {
159162 endpoint = endpoint .replaceAll ("\\ {" + param .getKey () + "}" , param .getValue ());
0 commit comments