Skip to content

Commit

Permalink
fix Hibiscus connection setup and add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mathisdt committed Sep 12, 2023
1 parent 86e7ad9 commit 6967fa2
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
import org.zephyrsoft.optigemspoonfeeder.mt940.Mt940File;
import org.zephyrsoft.optigemspoonfeeder.mt940.Mt940Record;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service
public class HibiscusImportService {

Expand All @@ -44,22 +47,26 @@ public class HibiscusImportService {

public HibiscusImportService(OptigemSpoonfeederProperties properties) {
this.properties = properties;
if (isConfiguredAndReachable()) {
if (isConfigured()) {
client = createXmlRpcClient();
}
}

public boolean isConfigured() {
return Objects.nonNull(properties.getHibiscusServerUrl())
boolean result = Objects.nonNull(properties.getHibiscusServerUrl())
&& StringUtils.isNotBlank(properties.getHibiscusServerUsername())
&& StringUtils.isNotBlank(properties.getHibiscusServerPassword());
log.info("Hibiscus is configured: {}", result);
return result;
}

public boolean isReachable() {
try {
client.execute("hibiscus.xmlrpc.konto.find", Collections.emptyList());
log.info("Hibiscus is reachable: true");
return true;
} catch (Exception e) {
log.info("Hibiscus is reachable: false ({})", e.getMessage());
return false;
}
}
Expand Down

0 comments on commit 6967fa2

Please sign in to comment.