Class DefaultSiteTool
java.lang.Object
org.apache.maven.doxia.tools.DefaultSiteTool
- All Implemented Interfaces:
SiteTool
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.maven.artifact.handler.manager.ArtifactHandlerManagerThe component used for getting artifact handlers.protected SiteModelInheritanceAssemblerThe component for assembling inheritance.protected org.codehaus.plexus.i18n.I18NInternationalization.private static final org.slf4j.Loggerprotected org.eclipse.aether.RepositorySystemThe component that is used to resolve additional required artifacts.Fields inherited from interface SiteTool
DEFAULT_LOCALE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidappendMenuItem(org.apache.maven.project.MavenProject project, Menu menu, String name, String href, String defaultHref) private static StringbuildRelativePath(String toPath, String fromPath, char separatorChar) private LocalecodeToLocale(String localeCode) Converts a locale code like "en", "en_US" or "en_US_win" to ajava.util.Localeobject.private BannerconvertBanner(Banner oldBanner) private Imageprivate LinkItemconvertLinkItem(LinkItem oldLinkItem) convertMenuItems(List<MenuItem> oldMenuItems) private SiteModelconvertOldToNewSiteModel(DecorationModel oldModel) private MenuItemcreateCategoryMenu(String name, String href, List<org.apache.maven.reporting.MavenReport> categoryReports, Locale locale) private org.eclipse.aether.resolution.ArtifactRequestcreateSiteDescriptorArtifactRequest(org.apache.maven.project.MavenProject project, String localeStr, List<org.eclipse.aether.repository.RemoteRepository> remoteProjectRepositories) private voiddeletePseudoSiteDescriptorMarkerFile(org.eclipse.aether.RepositorySystemSession repoSession, org.eclipse.aether.resolution.ArtifactRequest request) private SiteModelprivate static StringgetDistMgmntSiteUrl(org.apache.maven.model.DistributionManagement distMgmnt) private static StringgetDistMgmntSiteUrl(org.apache.maven.project.MavenProject project) Return distributionManagement.site.url if defined, null otherwise.getInterpolatedSiteDescriptorContent(Map<String, String> props, org.apache.maven.project.MavenProject aProject, String siteDescriptorContent) Deprecated.private StringgetInterpolatedSiteDescriptorContent(org.apache.maven.execution.MavenExecutionRequest request, org.apache.maven.project.MavenProject aProject, String siteDescriptorContent, boolean isEarly) Interpolation similar to what AbstractStringBasedModelInterpolator.java is doing.private org.apache.maven.project.MavenProjectgetModuleFromReactor(org.apache.maven.project.MavenProject project, List<org.apache.maven.project.MavenProject> reactorProjects, String module) protected static StringgetNormalizedPath(String path) private static org.apache.maven.model.Pluginprivate static StringgetPluginParameter(org.apache.maven.project.MavenProject project, String pluginId, String param) private static StringgetRelativeFilePath(String oldPath, String newPath) getRelativePath(String to, String from) Deprecated.getSiteDescriptor(File siteDirectory, Locale locale) Get a site descriptor from the project's site directory.(package private) FilegetSiteDescriptorFromRepository(org.apache.maven.project.MavenProject project, org.eclipse.aether.RepositorySystemSession repoSession, List<org.eclipse.aether.repository.RemoteRepository> remoteProjectRepositories, Locale locale) Get a site descriptor from one of the repositories.getSiteLocales(String locales) Extracts from a comma-separated list the locales that are available insite-toolresource bundle.getSiteModel(int depth, File siteDirectory, Locale locale, org.apache.maven.execution.MavenExecutionRequest request, org.apache.maven.project.MavenProject project, org.eclipse.aether.RepositorySystemSession repoSession, List<org.eclipse.aether.repository.RemoteRepository> remoteProjectRepositories) getSiteModel(File siteDirectory, Locale locale, org.apache.maven.execution.MavenExecutionRequest request, org.apache.maven.project.MavenProject project, List<org.apache.maven.project.MavenProject> reactorProjects, org.eclipse.aether.RepositorySystemSession repoSession, List<org.eclipse.aether.repository.RemoteRepository> remoteProjectRepositories) Get a site model for a project.getSiteModel(File siteDirectory, Locale locale, org.apache.maven.project.MavenProject project, List<org.apache.maven.project.MavenProject> reactorProjects, org.eclipse.aether.RepositorySystemSession repoSession, List<org.eclipse.aether.repository.RemoteRepository> remoteProjectRepositories) Deprecated.org.apache.maven.artifact.ArtifactgetSkinArtifactFromRepository(org.eclipse.aether.RepositorySystemSession repoSession, List<org.eclipse.aether.repository.RemoteRepository> remoteProjectRepositories, Skin skin) Get a skin artifact from one of the repositories.private static booleanisEmptyList(List<?> list) Convenience method.private booleanisOldSiteModel(String siteDescriptorContent) private static PropertiesmergeProperties(org.apache.maven.execution.MavenExecutionRequest request, org.apache.maven.project.MavenProject aProject) Merge properties from different sources in the following order (with later sources overriding earlier ones): System properties from the Maven execution request Project properties from the Maven project User properties from the Maven execution requestprivate voidpopulateModulesMenu(SiteModel siteModel, Locale locale, org.apache.maven.project.MavenProject project, List<org.apache.maven.project.MavenProject> reactorProjects, boolean keepInheritedRefs) Populate the pre-definedmodulesmenu of the model, if used through<menu ref="modules"/>.private voidpopulateParentMenu(SiteModel siteModel, Locale locale, org.apache.maven.project.MavenProject project, org.apache.maven.project.MavenProject parentProject, boolean keepInheritedRefs) Populate the pre-definedparentmenu of the site model, if used through<menu ref="parent"/>.voidpopulateReportsMenu(SiteModel siteModel, Locale locale, Map<String, List<org.apache.maven.reporting.MavenReport>> categories) Populate the pre-definedreportsmenu of the site model, if used through<menu ref="reports"/>.private SiteModelreadSiteModel(String siteDescriptorContent, org.apache.maven.project.MavenProject project, Locale locale) private FileresolveSiteDescriptor(org.apache.maven.project.MavenProject project, org.eclipse.aether.RepositorySystemSession repoSession, List<org.eclipse.aether.repository.RemoteRepository> remoteProjectRepositories, Locale locale) private StringsiteModelToString(SiteModel siteModel) private static String
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
repositorySystem
@Inject protected org.eclipse.aether.RepositorySystem repositorySystemThe component that is used to resolve additional required artifacts. -
artifactHandlerManager
@Inject private org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManagerThe component used for getting artifact handlers. -
i18n
@Inject protected org.codehaus.plexus.i18n.I18N i18nInternationalization. -
assembler
The component for assembling inheritance.
-
-
Constructor Details
-
DefaultSiteTool
public DefaultSiteTool()
-
-
Method Details
-
getSkinArtifactFromRepository
public org.apache.maven.artifact.Artifact getSkinArtifactFromRepository(org.eclipse.aether.RepositorySystemSession repoSession, List<org.eclipse.aether.repository.RemoteRepository> remoteProjectRepositories, Skin skin) throws SiteToolException Get a skin artifact from one of the repositories.- Specified by:
getSkinArtifactFromRepositoryin interfaceSiteTool- Parameters:
repoSession- the repository system session, not null.remoteProjectRepositories- the Maven remote project repositories, not null.skin- the Skin model, not null.- Returns:
- the
Skinartifact defined in aSiteModelfrom a given project - Throws:
SiteToolException- if any
-
getRelativePath
Deprecated.This method is not implemented according to the URI specification and has many weird corner cases where it doesn't do the right thing. Please consider using a better implemented method from a different library such as org.apache.http.client.utils.URIUtils#resolve.- Specified by:
getRelativePathin interfaceSiteTool- Parameters:
to- thetourl of file as stringfrom- thefromurl of file as string- Returns:
- a relative path from
fromtoto.
-
getRelativeFilePath
-
getSiteDescriptor
Get a site descriptor from the project's site directory.- Specified by:
getSiteDescriptorin interfaceSiteTool- Parameters:
siteDirectory- the site directory, not nulllocale- the locale wanted for the site descriptor, not null. Most specific to least specific lookup fromsite_language_country_variant.xml,site_language_country.xml,site_language.xml}, tosite.xmlas last resort forLocale.ROOT, if provided locale defines a variant and/or a country and/or a language.- Returns:
- the most specific site descriptor file for the given locale
-
getSiteDescriptorFromRepository
File getSiteDescriptorFromRepository(org.apache.maven.project.MavenProject project, org.eclipse.aether.RepositorySystemSession repoSession, List<org.eclipse.aether.repository.RemoteRepository> remoteProjectRepositories, Locale locale) throws SiteToolException Get a site descriptor from one of the repositories.- Parameters:
project- the Maven project, not null.repoSession- the repository system session, not null.remoteProjectRepositories- the Maven remote project repositories, not null.locale- the locale wanted for the site descriptor, not null. SeegetSiteDescriptor(File, Locale)for details.- Returns:
- the site descriptor into the local repository after download of it from repositories or null if not found in repositories.
- Throws:
SiteToolException- if any
-
getSiteModel
@Deprecated public SiteModel getSiteModel(File siteDirectory, Locale locale, org.apache.maven.project.MavenProject project, List<org.apache.maven.project.MavenProject> reactorProjects, org.eclipse.aether.RepositorySystemSession repoSession, List<org.eclipse.aether.repository.RemoteRepository> remoteProjectRepositories) throws SiteToolException Deprecated.Description copied from interface:SiteToolGet a site model for a project.- Specified by:
getSiteModelin interfaceSiteTool- Parameters:
siteDirectory- the site directory, may be null if project from repositorylocale- the locale used for the i18n in SiteModel, not null. SeeSiteTool.getSiteDescriptor(File, Locale)for details.project- the Maven project, not null.reactorProjects- the Maven reactor projects, not null.repoSession- the repository system session, not null.remoteProjectRepositories- the Maven remote project repositories, not null.- Returns:
- the
SiteModelobject corresponding to thesite.xmlfile with some interpolations. - Throws:
SiteToolException- if any
-
getSiteModel
public SiteModel getSiteModel(File siteDirectory, Locale locale, org.apache.maven.execution.MavenExecutionRequest request, org.apache.maven.project.MavenProject project, List<org.apache.maven.project.MavenProject> reactorProjects, org.eclipse.aether.RepositorySystemSession repoSession, List<org.eclipse.aether.repository.RemoteRepository> remoteProjectRepositories) throws SiteToolException Description copied from interface:SiteToolGet a site model for a project.- Specified by:
getSiteModelin interfaceSiteTool- Parameters:
siteDirectory- the site directory, may be null if project from repositorylocale- the locale used for the i18n in SiteModel, not null. SeeSiteTool.getSiteDescriptor(File, Locale)for details.request- the Maven execution request, not null. This is needed to get the user properties and the system properties for interpolation.project- the Maven project, not null.reactorProjects- the Maven reactor projects, not null.repoSession- the repository system session, not null.remoteProjectRepositories- the Maven remote project repositories, not null.- Returns:
- the
SiteModelobject corresponding to thesite.xmlfile with some interpolations. - Throws:
SiteToolException- if any
-
getInterpolatedSiteDescriptorContent
@Deprecated public String getInterpolatedSiteDescriptorContent(Map<String, String> props, org.apache.maven.project.MavenProject aProject, String siteDescriptorContent) throws SiteToolExceptionDeprecated.Description copied from interface:SiteToolInterpolating several expressions in the site descriptor content. Actually, the expressions can be in the project, the environment variables and the specific properties likeencoding.For instance:
- ${project.name}
- The value from the POM of:
<project>
<name>myProjectName</name>
</project> - ${my.value}
- The value from the POM of:
<properties>
<my.value>hello</my.value>
</properties> - ${JAVA_HOME}
- The value of JAVA_HOME in the environment variables
- Specified by:
getInterpolatedSiteDescriptorContentin interfaceSiteTool- Parameters:
props- a map used for interpolation, not null.aProject- a Maven project, not null.siteDescriptorContent- the site descriptor file, not null.- Returns:
- the interpolated site descriptor content.
- Throws:
SiteToolException- if errors happened during the interpolation.
-
getInterpolatedSiteDescriptorContent
private String getInterpolatedSiteDescriptorContent(org.apache.maven.execution.MavenExecutionRequest request, org.apache.maven.project.MavenProject aProject, String siteDescriptorContent, boolean isEarly) throws SiteToolException Interpolation similar to what AbstractStringBasedModelInterpolator.java is doing.- Parameters:
request-aProject-siteDescriptorContent-isEarly-- Returns:
- the interpolated site descriptor content
- Throws:
SiteToolException
-
mergeProperties
private static Properties mergeProperties(org.apache.maven.execution.MavenExecutionRequest request, org.apache.maven.project.MavenProject aProject) Merge properties from different sources in the following order (with later sources overriding earlier ones):- System properties from the Maven execution request
- Project properties from the Maven project
- User properties from the Maven execution request
- Parameters:
request-aProject-- Returns:
-
populateParentMenu
private void populateParentMenu(SiteModel siteModel, Locale locale, org.apache.maven.project.MavenProject project, org.apache.maven.project.MavenProject parentProject, boolean keepInheritedRefs) Populate the pre-definedparentmenu of the site model, if used through<menu ref="parent"/>.- Parameters:
siteModel- the Doxia Sitetools SiteModel, not null.locale- the locale used for the i18n in SiteModel, not null.project- a Maven project, not null.parentProject- a Maven parent project, not null.keepInheritedRefs- used for inherited references.
-
populateModulesMenu
private void populateModulesMenu(SiteModel siteModel, Locale locale, org.apache.maven.project.MavenProject project, List<org.apache.maven.project.MavenProject> reactorProjects, boolean keepInheritedRefs) throws SiteToolException, IOException Populate the pre-definedmodulesmenu of the model, if used through<menu ref="modules"/>.- Parameters:
siteModel- the Doxia Sitetools SiteModel, not null.locale- the locale used for the i18n in SiteModel, not null.project- a Maven project, not null.reactorProjects- the Maven reactor projects, not null.keepInheritedRefs- used for inherited references.- Throws:
SiteToolException- if anyIOException
-
getModuleFromReactor
private org.apache.maven.project.MavenProject getModuleFromReactor(org.apache.maven.project.MavenProject project, List<org.apache.maven.project.MavenProject> reactorProjects, String module) throws IOException - Throws:
IOException
-
populateReportsMenu
public void populateReportsMenu(SiteModel siteModel, Locale locale, Map<String, List<org.apache.maven.reporting.MavenReport>> categories) Populate the pre-definedreportsmenu of the site model, if used through<menu ref="reports"/>. Notice this menu reference is translated into 2 separate menus: "Project Information" and "Project Reports".- Specified by:
populateReportsMenuin interfaceSiteTool- Parameters:
siteModel- the Doxia Sitetools SiteModel, not null.locale- the locale used for the i18n in SiteModel, not null. SeeSiteTool.getSiteDescriptor(File, Locale)for details.categories- reports per category to put in "Reports" or "Information" menus, not null.- See Also:
-
getSiteLocales
Extracts from a comma-separated list the locales that are available insite-toolresource bundle.- Specified by:
getSiteLocalesin interfaceSiteTool- Parameters:
locales- A comma separated list of locales- Returns:
- a list of
Locales.
-
codeToLocale
Converts a locale code like "en", "en_US" or "en_US_win" to ajava.util.Localeobject.If localeCode =
system, return the current value of the default locale for this instance of the Java Virtual Machine.If localeCode =
default, return the root locale.- Parameters:
localeCode- the locale code string.- Returns:
- a java.util.Locale object instanced or null if errors occurred
- See Also:
-
getNormalizedPath
-
createSiteDescriptorArtifactRequest
private org.eclipse.aether.resolution.ArtifactRequest createSiteDescriptorArtifactRequest(org.apache.maven.project.MavenProject project, String localeStr, List<org.eclipse.aether.repository.RemoteRepository> remoteProjectRepositories) - Parameters:
project- not nulllocaleStr- not nullremoteProjectRepositories- not null- Returns:
- the site descriptor artifact request
-
resolveSiteDescriptor
private File resolveSiteDescriptor(org.apache.maven.project.MavenProject project, org.eclipse.aether.RepositorySystemSession repoSession, List<org.eclipse.aether.repository.RemoteRepository> remoteProjectRepositories, Locale locale) throws org.eclipse.aether.resolution.ArtifactResolutionException - Parameters:
project- not nullrepoSession- the repository system session not nullremoteProjectRepositories- not nulllocale- not null- Returns:
- the resolved site descriptor or null if not found in repositories.
- Throws:
org.eclipse.aether.resolution.ArtifactResolutionException- if any
-
deletePseudoSiteDescriptorMarkerFile
private void deletePseudoSiteDescriptorMarkerFile(org.eclipse.aether.RepositorySystemSession repoSession, org.eclipse.aether.resolution.ArtifactRequest request) -
getSiteModel
private Map.Entry<SiteModel, org.apache.maven.project.MavenProject> getSiteModel(int depth, File siteDirectory, Locale locale, org.apache.maven.execution.MavenExecutionRequest request, org.apache.maven.project.MavenProject project, org.eclipse.aether.RepositorySystemSession repoSession, List<org.eclipse.aether.repository.RemoteRepository> remoteProjectRepositories) throws SiteToolException - Parameters:
depth- depth of projectsiteDirectory- , can be null if project.basedir is null, ie POM from repositorylocale- not nullproject- not nullrepoSession- not nullremoteProjectRepositories- not null- Returns:
- the site model depending the locale and the parent project
- Throws:
SiteToolException- if any
-
readSiteModel
private SiteModel readSiteModel(String siteDescriptorContent, org.apache.maven.project.MavenProject project, Locale locale) throws SiteToolException - Parameters:
siteDescriptorContent- not null- Returns:
- the site model object
- Throws:
SiteToolException- if any
-
convertOldToNewSiteModel
-
convertBanner
-
convertImage
-
convertLinkItem
-
convertMenuItems
-
isOldSiteModel
private boolean isOldSiteModel(String siteDescriptorContent) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException - Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
getDefaultSiteModel
- Throws:
SiteToolException
-
siteModelToString
- Throws:
SiteToolException
-
buildRelativePath
-
appendMenuItem
-
createCategoryMenu
-
isEmptyList
Convenience method.- Parameters:
list- could be null- Returns:
- true if the list is
nullor empty
-
getDistMgmntSiteUrl
Return distributionManagement.site.url if defined, null otherwise.- Parameters:
project- not null- Returns:
- could be null
-
getDistMgmntSiteUrl
-
getPlugin
private static org.apache.maven.model.Plugin getPlugin(org.apache.maven.project.MavenProject project, String pluginId) - Parameters:
project- the projectpluginId- The id of the plugin- Returns:
- The information about the plugin.
-
getPluginParameter
-
urlEncode
-