private void readGuestNotice()

in termsOfService-server/src/main/java/jetbrains/buildServer/termsOfService/TermsOfServiceManagerImpl.java [200:241]


    private void readGuestNotice(@NotNull Element config) {
        myGuestNotice = null;
        Element guestNoticeEl = config.getChild("guest-notice");
        if (guestNoticeEl != null) {

            if (isEnabled(guestNoticeEl)) {
                TermsOfServiceLogger.LOGGER.info("Guest Notice is disabled, to enable change 'enabled' attribute value to 'true'");
                return;
            }

            Element paramsElement = guestNoticeEl.getChild("parameters");
            Map<String, String> params = paramsElement == null ? emptyMap() : XmlUtil.readParameters(paramsElement);
            String title = params.get("title");
            String note = params.get("note");
            String contentFile = params.get("content-file");

            if (StringUtil.isEmptyOrSpaces(title)) {
                TermsOfServiceLogger.LOGGER.warn("Broken configuration: missing guest notice title, the guest notice is ignored.");
                return;
            }

            if (StringUtil.isEmptyOrSpaces(contentFile)) {
                TermsOfServiceLogger.LOGGER.warn("Broken configuration: missing 'content-file' parameter for a guest notice, the guest notice is ignored.");
                return;
            }

            File guestNoticeFile = myConfig.getConfigFile(params.get("content-file"));

            if (guestNoticeFile.exists() && guestNoticeFile.isFile()) {
                try {
                    String guestNoticeContent = FileUtil.readText(guestNoticeFile, "UTF-8");
                    String cookieName = params.getOrDefault("accepted-cookie-name", "guest-notice-accepted");
                    int cookieDurationMinutes = StringUtil.parseInt(params.getOrDefault("accepted-cookie-max-age-days", "30"), 30);
                    myGuestNotice = new GuestNoticeSettings(title, note, guestNoticeContent, cookieName, cookieDurationMinutes);
                } catch (IOException e) {
                    TermsOfServiceLogger.LOGGER.warnAndDebugDetails("Error while reading guest notice content from " + guestNoticeFile, e);
                }
            } else {
                TermsOfServiceLogger.LOGGER.warn("Broken configuration: guest notice content file '" + guestNoticeFile + "' doesn't exist");
            }
        }
    }