Skip to content

Commit

Permalink
feat: Refactorings
Browse files Browse the repository at this point in the history
Refs: #DEV-11775
  • Loading branch information
nirikash committed Jun 10, 2024
1 parent d806bcf commit d1afe87
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class WeasyPrintServiceConnector implements WeasyPrintConverter {
private static final Logger logger = Logger.getLogger(WeasyPrintServiceConnector.class);
private static final String WEASYPRINT_VERSION_HEADER = "Weasyprint-Version";
private static final String PYTHON_VERSION_HEADER = "Python-Version";
private static final AtomicReference<String> weasyprintVersion = new AtomicReference<>();
private static final AtomicReference<String> weasyPrintVersion = new AtomicReference<>();
private static final AtomicReference<String> pythonVersion = new AtomicReference<>();

@Override
Expand All @@ -45,7 +45,7 @@ public byte[] convertToPdf(String htmlPage, WeasyPrintOptions weasyPrintOptions)
if (response.getStatus() == Response.Status.OK.getStatusCode()) {
InputStream inputStream = response.readEntity(InputStream.class);
try {
logWeasyprintVersionFromHeader(response);
logWeasyPrintVersionFromHeader(response);
return inputStream.readAllBytes();
} catch (IOException e) {
throw new IllegalStateException("Could not read response stream", e);
Expand Down Expand Up @@ -93,15 +93,15 @@ private String getWeasyPrintServiceBaseUrl() {
return PdfExporterExtensionConfiguration.getInstance().getWeasyprintService();
}

private void logWeasyprintVersionFromHeader(Response response) {
private void logWeasyPrintVersionFromHeader(Response response) {
String actualWeasyprintVersion = response.getHeaderString(WEASYPRINT_VERSION_HEADER);
String actualPythonVersion = response.getHeaderString(PYTHON_VERSION_HEADER);

logWeasyprintVersion(actualWeasyprintVersion, weasyprintVersion, "Weasyprint");
logWeasyprintVersion(actualPythonVersion, pythonVersion, "Python");
logWeasyPrintVersion(actualWeasyprintVersion, weasyPrintVersion, "Weasyprint");
logWeasyPrintVersion(actualPythonVersion, pythonVersion, "Python");
}

private void logWeasyprintVersion(String actualVersion, AtomicReference<String> version, String nameInMessage) {
public void logWeasyPrintVersion(String actualVersion, AtomicReference<String> version, String nameInMessage) {
if (!isEmpty(actualVersion)
&& !actualVersion.equals(version.getAndSet(actualVersion))) {
logger.info(String.format("Using Weasyprint Service with %s version: %s", nameInMessage, actualVersion));
Expand Down

0 comments on commit d1afe87

Please sign in to comment.