Skip to contentMethod: getLibraryPath()
1: /*
2: * #%L
3: * *********************************************************************************************************************
4: *
5: * NorthernWind - lightweight CMS
6: * http://northernwind.tidalwave.it - git clone https://bitbucket.org/tidalwave/northernwind-src.git
7: * %%
8: * Copyright (C) 2011 - 2023 Tidalwave s.a.s. (http://tidalwave.it)
9: * %%
10: * *********************************************************************************************************************
11: *
12: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
13: * the License. You may obtain a copy of the License at
14: *
15: * http://www.apache.org/licenses/LICENSE-2.0
16: *
17: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
18: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
19: * specific language governing permissions and limitations under the License.
20: *
21: * *********************************************************************************************************************
22: *
23: *
24: * *********************************************************************************************************************
25: * #L%
26: */
27: package it.tidalwave.northernwind.core.model;
28:
29: import javax.annotation.Nonnull;
30: import java.util.List;
31: import java.util.Locale;
32: import java.util.Optional;
33: import java.nio.file.spi.FileSystemProvider;
34: import it.tidalwave.util.Finder;
35: import lombok.AccessLevel;
36: import lombok.AllArgsConstructor;
37: import lombok.Getter;
38: import lombok.RequiredArgsConstructor;
39: import lombok.ToString;
40: import lombok.With;
41:
42: /***********************************************************************************************************************
43: *
44: * The model for the container of the whole site, it contains a collection of {@link Content}s, {@link Media} items and
45: * {@link SiteNode}s.
46: *
47: * @author Fabrizio Giudici
48: *
49: **********************************************************************************************************************/
50: public interface Site
51: {
52: /*******************************************************************************************************************
53: *
54: * A builder of a {@link Site}.
55: *
56: ******************************************************************************************************************/
57: @AllArgsConstructor(access = AccessLevel.PRIVATE) @RequiredArgsConstructor
58: @Getter @ToString(exclude = "callBack")
59: public final class Builder
60: {
61: // Workaround for a Lombok limitation with Wither and subclasses
62: @FunctionalInterface
63: public static interface CallBack
64: {
65: @Nonnull
66: public Site build (@Nonnull Builder builder);
67: }
68:
69: @Nonnull
70: private final ModelFactory modelFactory;
71:
72: @Nonnull
73: private final CallBack callBack;
74:
75: @With
76: private String contextPath;
77:
78: @With
79: private String documentPath;
80:
81: @With
82: private String mediaPath;
83:
84: @With
85: private String libraryPath;
86:
87: @With
88: private String nodePath;
89:
90: @With
91: private boolean logConfigurationEnabled;
92:
93: @With
94: private List<Locale> configuredLocales;
95:
96: @With
97: private List<String> ignoredFolders;
98:
99: @Nonnull
100: public Site build()
101: {
102: return callBack.build(this);
103: }
104: }
105:
106: /*******************************************************************************************************************
107: *
108: * Returns the context path for this web site.
109: *
110: ******************************************************************************************************************/
111: @Nonnull
112: public String getContextPath();
113:
114: /*******************************************************************************************************************
115: *
116: * Creates an HTML link to the node mapped to the given URI.
117: *
118: * @param relativeUri the target URI
119: * @return the link
120: *
121: ******************************************************************************************************************/
122: @Nonnull
123: public String createLink (@Nonnull ResourcePath relativeUri);
124:
125: /*******************************************************************************************************************
126: *
127: * Finds something.
128: *
129: * @param <TYPE> the static type of the thing to find
130: * @param type the dynamic type of thing to find
131: * @return the {@link Finder} for that thing.
132: *
133: ******************************************************************************************************************/
134: @Nonnull
135: public <TYPE> SiteFinder<TYPE> find (@Nonnull Class<TYPE> type);
136:
137: /*******************************************************************************************************************
138: *
139: * Returns the {@link FileSystemProvider} used by this {@code Site}.
140: *
141: * @return the {@code FileSystemProvider}
142: *
143: ******************************************************************************************************************/
144: @Nonnull
145: public ResourceFileSystemProvider getFileSystemProvider();
146:
147: /*******************************************************************************************************************
148: *
149: * Returns the {@link Locale}s configured for this site.
150: *
151: * @return the {@code Locale}s.
152: *
153: ******************************************************************************************************************/
154: @Nonnull
155: public List<Locale> getConfiguredLocales();
156:
157: /*******************************************************************************************************************
158: *
159: * Gets a template from a {@link Content}, whose relative path is provided; the template is retrieved through the
160: * property {@code P_TEMPLATE} of the {@code Content}. If nothing is found, a default template with the given name
161: * is loaded from the embedded resources.
162: *
163: * @param clazz the class used as starting point for resolving the embedded resource path
164: * @param templatePath the path of the {@code Content}
165: * @param embeddedResourceName the name of the default embedded resource
166: * @return the template contents
167: *
168: ******************************************************************************************************************/
169: @Nonnull
170: public Template getTemplate (@Nonnull Class<?> clazz,
171: @Nonnull Optional<? extends ResourcePath> templatePath,
172: @Nonnull String embeddedResourceName);
173:
174: /*******************************************************************************************************************
175: *
176: * Gets a template from a {@link Content}, whose relative path is provided. The template is retrieved through the
177: * property {@code P_TEMPLATE} of the {@code Content}.
178: *
179: * @param clazz the class used as starting point for resolving the embedded resource path
180: * @param templatePath the path of the {@code Content}
181: * @return the template contents
182: *
183: ******************************************************************************************************************/
184: @Deprecated
185: @Nonnull
186: public Optional<String> getTemplate (@Nonnull Class<?> clazz, @Nonnull ResourcePath templatePath);
187: }