Skip to content

Commit

Permalink
EA-4019 remove inconsistency
Browse files Browse the repository at this point in the history
  • Loading branch information
SrishtiSingh-eu committed Dec 19, 2024
1 parent d1dc297 commit bd7a8ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,6 @@ public static String generateETag(ZonedDateTime modified, String version, boolea
return eTag;
}

/**
* Generates an eTag surrounded with double quotes - alternate version for the resource
*
* @param data concatenated: datasetID + localID + resID + language (2-letter code) of the text resource
* plus version of this API as defined in the pom.xml
* @param weakETag if True, then the eTag will start with W/
* @return eTag generated eTag (String)
*/
public static String generateSimpleETag(String data, boolean weakETag) {
String eTag = "\"" + getSHA256Hash(data) + "\"";
if (weakETag) {
return "W/" + eTag;
}
return eTag;
}

/**
* Formats the given date according to the RFC 1123 pattern (e.g. Thu, 4 Oct 2018 10:34:20 GMT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ private ResponseEntity<String> getAnnoPageInfo(String datasetId, String localId,
if (cachingHeadersPresent(request)) {
ResponseEntity<String> cached = checkCached(request, modified, eTag);
if (cached != null) {
LOG.info("Returning cached object for {}, {}", datasetId, localId);
if (LOG.isDebugEnabled()) {
LOG.debug("Returning cached object for {}, {}", datasetId, localId);
}
return cached;
}
}
Expand Down Expand Up @@ -433,12 +435,7 @@ private ResponseEntity<String> resource(

resource = fts.fetchFTResource(datasetId, localId, pageId, lang);
ZonedDateTime modified = januarificator();
String eTag = generateSimpleETag(datasetId
+ localId
+ pageId
+ resource.getLanguage()
+ resource.getValue()
+ fts.getSettings().getAppVersion(), true);
String eTag = generateETag(modified, fts.getSettings().getAppVersion(), true);

if (cachingHeadersPresent(request)) {
ResponseEntity<String> cached = checkCached(request, modified, eTag);
Expand Down

0 comments on commit bd7a8ea

Please sign in to comment.