-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContentSource.java
More file actions
53 lines (49 loc) · 2.44 KB
/
Copy pathContentSource.java
File metadata and controls
53 lines (49 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.openelements.content;
import java.util.List;
/**
* One declaratively-configured content source (a website or, later, a Git repository).
*
* <p>Sources are configured under {@code open-elements.content.sources} in {@code application.yaml};
* adding a new source requires no code changes. This record is immutable and normalizes its optional
* list fields to non-null defaults so that consumers never have to null-check them:
*
* <ul>
* <li>{@code sitemaps}, {@code urlExclude}, {@code contentExclude} default to an empty list.
* <li>{@code urlInclude} defaults to {@code ["/**"]} (match everything) when absent — see
* {@link UrlMatcher}.
* </ul>
*
* @param id stable identifier of the source (e.g. {@code open-elements})
* @param type discovery/extraction strategy selector; see {@link SourceType}
* @param baseUrl base URL of the source (e.g. {@code https://open-elements.com})
* @param sitemaps sitemap paths relative to {@code baseUrl} (e.g. {@code /en/sitemap.xml})
* @param urlInclude Ant-glob patterns; a URL path must match at least one to be crawled
* @param urlExclude Ant-glob patterns; a URL path matching any is skipped (exclude wins)
* @param contentSelector CSS selector for the main content element (applied in spec 006)
* @param contentExclude CSS selectors removed before text extraction (applied in spec 006)
* @param enabled whether the source is active; consumers in later specs skip disabled sources
* @param git Git configuration; present only for {@link SourceType#GIT} sources (spec 016)
*/
public record ContentSource(
String id,
SourceType type,
String baseUrl,
List<String> sitemaps,
List<String> urlInclude,
List<String> urlExclude,
String contentSelector,
List<String> contentExclude,
boolean enabled,
GitConfig git
) {
/** The include pattern applied when a source declares no {@code urlInclude}: match everything. */
public static final List<String> DEFAULT_URL_INCLUDE = List.of("/**");
public ContentSource {
sitemaps = sitemaps == null ? List.of() : List.copyOf(sitemaps);
urlInclude = (urlInclude == null || urlInclude.isEmpty())
? DEFAULT_URL_INCLUDE
: List.copyOf(urlInclude);
urlExclude = urlExclude == null ? List.of() : List.copyOf(urlExclude);
contentExclude = contentExclude == null ? List.of() : List.copyOf(contentExclude);
}
}