com.redfin.sitemapgenerator.WebSitemapUrl Java Examples
The following examples show how to use
com.redfin.sitemapgenerator.WebSitemapUrl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnnotationUrlProvider.java From play-sitemap-module.edulify.com with Apache License 2.0 | 6 votes |
@Override public void addUrlsTo(WebSitemapGenerator generator) { String baseUrl = configuration.getString("sitemap.baseUrl"); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Reflections reflections = new Reflections("controllers", new MethodAnnotationsScanner()); Set<Method> actions = reflections.getMethodsAnnotatedWith(SitemapItem.class); for(Method method : actions) { String actionUrl = actionUrl(classLoader, method); SitemapItem annotation = method.getAnnotation(SitemapItem.class); if(annotation != null) { WebSitemapUrl url = webSitemapUrl(baseUrl, actionUrl, annotation); generator.addUrl(url); } } }
Example #2
Source File: SitemapGenerator.java From scipio-erp with Apache License 2.0 | 5 votes |
protected void buildSitemapCategoryLink(GenericValue productCategory, Map<Locale, List<String>> trailNames, List<GenericValue> trailEntities) throws GeneralException { String productCategoryId = productCategory.getString("productCategoryId"); try { // TODO: missing multi-locale link support - unclear if library supports Locale locale = getDefaultLocale(); String url; if (getSitemapConfig().isPreProcessTrail()) { List<String> trail = trailNames.get(locale); CatalogAltUrlSanitizer.SanitizeContext sanitizeCtx = getUrlWorker().getCatalogAltUrlSanitizer().makeSanitizeContext().setTargetCategory(productCategory) .setLast(true).setNameIndex(trail.size() - 1).setTotalNames(trail.size()); url = getUrlWorker().makeCategoryUrlPath(getDelegator(), getDispatcher(), locale, productCategory, trail, getContextPath(), sanitizeCtx, isUseCache()).toString(); } else { url = getUrlWorker().makeCategoryUrlCore(getDelegator(), getDispatcher(), locale, productCategory, null, null, trailEntities, getWebappInfo(), isUseCache()).toString(); } url = postprocessElementLink(url); if (Debug.verboseOn()) Debug.logVerbose(getLogMsgPrefix()+"Processing category url: " + url, module); WebSitemapUrl libUrl = buildSitemapLibUrl(url, null); getCategoryElemHandler().addUrl(libUrl); } catch(Exception e) { getStats().categoryError++; Debug.logError(getLogErrorPrefix() + "Cannot build URL for category '" + productCategoryId + "': " + e.getMessage(), module); } }
Example #3
Source File: SitemapGenerator.java From scipio-erp with Apache License 2.0 | 5 votes |
protected void buildSitemapProductLink(GenericValue product, Map<Locale, List<String>> trailNames, List<GenericValue> trailEntities) throws GeneralException { String productId = product.getString("productId"); try { // TODO: missing multi-locale link support - unclear if library supports Locale locale = getDefaultLocale(); String url; if (getSitemapConfig().isPreProcessTrail()) { List<String> trail = trailNames.get(locale); CatalogAltUrlSanitizer.SanitizeContext sanitizeCtx = getUrlWorker().getCatalogAltUrlSanitizer().makeSanitizeContext().setTargetProduct(product) .setLast(true).setNameIndex(trail.size()).setTotalNames(trail.size() + 1); url = getUrlWorker().makeProductUrlPath(getDelegator(), getDispatcher(), locale, product, trail, getContextPath(), sanitizeCtx, isUseCache()).toString(); } else { url = getUrlWorker().makeProductUrlCore(getDelegator(), getDispatcher(), locale, product, null, null, trailEntities, getWebappInfo(), isUseCache()).toString(); } url = postprocessElementLink(url); if (Debug.verboseOn()) Debug.logVerbose(getLogMsgPrefix()+"Processing product url: " + url, module); WebSitemapUrl libUrl = buildSitemapLibUrl(url, sitemapConfig.isUseProductLastModDate() ? product.getTimestamp("lastModifiedDate") : null); getProductElemHandler().addUrl(libUrl); // TODO?: is there need to do variants (not explicitly associated to category)? // usually don't want to advertise the variants unless attached to category for some reason?... //if (config.doChildProduct) { //} } catch(Exception e) { getStats().productError++; Debug.logError(getLogErrorPrefix() + "Cannot build URL for product '" + productId + "': " + e.getMessage(), module); } }
Example #4
Source File: SitemapGenerator.java From scipio-erp with Apache License 2.0 | 5 votes |
protected void buildSitemapCmsPageLink(String uri, Locale locale) { try { uri = PathUtil.concatPaths(getContextPath(), uri); String url = postprocessElementLink(uri); if (Debug.verboseOn()) { Debug.logVerbose(getLogMsgPrefix()+"Processing CMS page url: " + url, module); } WebSitemapUrl libUrl = buildSitemapLibUrl(url, null); getContentElemHandler().addUrl(libUrl); } catch(Exception e) { getStats().contentError++; Debug.logError(getLogErrorPrefix()+"Error processing cms page URI: " + uri + ": " + e.getMessage(), module); } }
Example #5
Source File: SitemapGenerator.java From scipio-erp with Apache License 2.0 | 5 votes |
public void addUrl(WebSitemapUrl url) throws IOException, URISyntaxException { if (sitemapConfig.getSizemapSize() != null && urlCount >= sitemapConfig.getSizemapSize()) { commitSitemapFile(); } if (wsg == null) { beginSitemapFile(); } String urlStr = url.getUrl().toString(); if (!seenUrls.contains(urlStr)) { wsg.addUrl(url); seenUrls.add(urlStr); urlCount++; updateStatsCount(); } }
Example #6
Source File: SitemapGenerator.java From scipio-erp with Apache License 2.0 | 5 votes |
protected WebSitemapUrl buildSitemapLibUrl(String url, Timestamp lastModDate) throws MalformedURLException { WebSitemapUrl.Options opts = new WebSitemapUrl.Options(url); if (lastModDate != null) { opts.lastMod(new Date(lastModDate.getTime())); } return opts.build(); }
Example #7
Source File: SitemapTest.java From jakduk-api with MIT License | 5 votes |
@Test public void generateSitemap() { try { WebSitemapGenerator wsg = new WebSitemapGenerator("https://jakduk.com"); WebSitemapUrl url = new WebSitemapUrl.Options("https://jakduk.com/board/free/1") .lastMod(new Date()).priority(1.0).changeFreq(ChangeFreq.DAILY).build(); wsg.addUrl(url); Assert.assertTrue(! ObjectUtils.isEmpty(wsg.writeAsStrings())); } catch (MalformedURLException e) { e.printStackTrace(); } }
Example #8
Source File: AnnotationUrlProvider.java From play-sitemap-module.edulify.com with Apache License 2.0 | 5 votes |
private WebSitemapUrl webSitemapUrl(String baseUrl, String actionUrl, SitemapItem annotation) { try { return new WebSitemapUrl.Options(String.format("%s%s", baseUrl, actionUrl)) .changeFreq(annotation.changefreq()) .priority(annotation.priority()) .build(); } catch(MalformedURLException ex) { play.Logger.error("MalformedURLException: ", ex); } return null; }