<commit_before>package com.ilscipio.scipio.product.seo.sitemap;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.ofbiz.base.component.ComponentConfig.WebappInfo;
import org.ofbiz.base.location.FlexibleLocation;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.GeneralException;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.condition.EntityOperator;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.webapp.WebAppUtil;
import org.xml.sax.SAXException;

import com.ilscipio.scipio.ce.webapp.filter.UrlRewriteConf;
import com.ilscipio.scipio.product.category.CatalogUrlType;
import com.ilscipio.scipio.product.category.CategoryTraverser;
import com.ilscipio.scipio.product.seo.SeoCatalogUrlWorker;
import com.ilscipio.scipio.product.seo.UrlGenStats;
import com.redfin.sitemapgenerator.SitemapIndexGenerator;
import com.redfin.sitemapgenerator.WebSitemapGenerator;
import com.redfin.sitemapgenerator.WebSitemapUrl;

/**
 * Builds sitemap and records stats.
 * <p>
 * NOT thread-safe.
 * <p>
 * TODO: missing multi-locale link support - unclear if library supports
 * TODO: does not delete old files (minor)
 * FIXME: Content wrappers do not respect the useCache flag
 */
public class SitemapGenerator extends CategoryTraverser {

    public static final String module = SitemapGenerator.class.getName();
    
    protected final List<Locale> locales;
    protected final String webSiteId;
    protected final String baseUrl;
    protected final String sitemapContextPath;
    protected final String contextPath;
    protected final SitemapConfig config;
    protected final SeoCatalogUrlWorker urlWorker;
    
    static final String logPrefix = "Seo: Sitemap: ";
    
    protected UrlRewriteConf urlRewriteConf;
    protected final WebappInfo webappInfo;
    
    protected final GenericValue webSite;
    protected final GenericValue productStore;
    <commit_msg>NoRef product: sitemap: SitemapGenerator: update the FIXMEs<commit_after>package com.ilscipio.scipio.product.seo.sitemap;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.ofbiz.base.component.ComponentConfig.WebappInfo;
import org.ofbiz.base.location.FlexibleLocation;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.GeneralException;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.condition.EntityOperator;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.webapp.WebAppUtil;
import org.xml.sax.SAXException;

import com.ilscipio.scipio.ce.webapp.filter.UrlRewriteConf;
import com.ilscipio.scipio.product.category.CatalogUrlType;
import com.ilscipio.scipio.product.category.CategoryTraverser;
import com.ilscipio.scipio.product.seo.SeoCatalogUrlWorker;
import com.ilscipio.scipio.product.seo.UrlGenStats;
import com.redfin.sitemapgenerator.SitemapIndexGenerator;
import com.redfin.sitemapgenerator.WebSitemapGenerator;
import com.redfin.sitemapgenerator.WebSitemapUrl;

/**
 * Builds sitemap and records stats.
 * <p>
 * NOT thread-safe.
 * <p>
 * TODO: missing multi-locale link support - unclear if library supports - may need to do one-locale-per-index
 * TODO: does not delete old files (minor issue - spiders will simply ignore them in theory)
 */
public class SitemapGenerator extends CategoryTraverser {

    public static final String module = SitemapGenerator.class.getName();
    
    protected final List<Locale> locales;
    protected final String webSiteId;
    protected final String baseUrl;
    protected final String sitemapContextPath;
    protected final String contextPath;
    protected final SitemapConfig config;
    protected final SeoCatalogUrlWorker urlWorker;
    
    static final String logPrefix = "Seo: Sitemap: ";
    
    protected UrlRewriteConf urlRewriteConf;
    protected final WebappInfo webappInfo;
    
    protected final GenericValue webSite;
    protected final GenericValue productStore;
    
{'fraction_non_alphanumeric': 0.0860655737704918, 'fraction_numerical': 0.0, 'mean_word_length': 5.07089552238806, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4234388', 'n_tokens_mistral': 1551, 'n_tokens_neox': 1515, 'n_words': 342}