Class DefaultSiteTool

  • All Implemented Interfaces:
    SiteTool

    @Singleton
    @Named
    public class DefaultSiteTool
    extends java.lang.Object
    implements SiteTool
    Default implementation of the site tool.
    Author:
    Vincent Siveton
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.apache.maven.doxia.site.inheritance.SiteModelInheritanceAssembler assembler
      The component for assembling inheritance.
      protected org.codehaus.plexus.i18n.I18N i18n
      Internationalization.
      protected org.eclipse.aether.RepositorySystem repositorySystem
      The component that is used to resolve additional required artifacts.
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultSiteTool()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.String getInterpolatedSiteDescriptorContent​(java.util.Map<java.lang.String,​java.lang.String> props, org.apache.maven.project.MavenProject aProject, java.lang.String siteDescriptorContent)
      Interpolating several expressions in the site descriptor content.
      protected static java.lang.String getNormalizedPath​(java.lang.String path)  
      java.lang.String getRelativePath​(java.lang.String to, java.lang.String from)
      Deprecated.
      java.io.File getSiteDescriptor​(java.io.File siteDirectory, java.util.Locale locale)
      Get a site descriptor from the project's site directory.
      java.util.List<java.util.Locale> getSiteLocales​(java.lang.String locales)
      Extracts from a comma-separated list the locales that are available in site-tool resource bundle.
      org.apache.maven.doxia.site.SiteModel getSiteModel​(java.io.File siteDirectory, java.util.Locale locale, org.apache.maven.project.MavenProject project, java.util.List<org.apache.maven.project.MavenProject> reactorProjects, org.eclipse.aether.RepositorySystemSession repoSession, java.util.List<org.eclipse.aether.repository.RemoteRepository> remoteProjectRepositories)
      Get a site model for a project.
      org.apache.maven.artifact.Artifact getSkinArtifactFromRepository​(org.eclipse.aether.RepositorySystemSession repoSession, java.util.List<org.eclipse.aether.repository.RemoteRepository> remoteProjectRepositories, org.apache.maven.doxia.site.Skin skin)
      Get a skin artifact from one of the repositories.
      void populateReportsMenu​(org.apache.maven.doxia.site.SiteModel siteModel, java.util.Locale locale, java.util.Map<java.lang.String,​java.util.List<org.apache.maven.reporting.MavenReport>> categories)
      Populate the pre-defined reports menu of the site model, if used through <menu ref="reports"/>.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • repositorySystem

        @Inject
        protected org.eclipse.aether.RepositorySystem repositorySystem
        The component that is used to resolve additional required artifacts.
      • i18n

        @Inject
        protected org.codehaus.plexus.i18n.I18N i18n
        Internationalization.
      • assembler

        @Inject
        protected org.apache.maven.doxia.site.inheritance.SiteModelInheritanceAssembler assembler
        The component for assembling inheritance.
    • Constructor Detail

      • DefaultSiteTool

        public DefaultSiteTool()
    • Method Detail

      • getSkinArtifactFromRepository

        public org.apache.maven.artifact.Artifact getSkinArtifactFromRepository​(org.eclipse.aether.RepositorySystemSession repoSession,
                                                                                java.util.List<org.eclipse.aether.repository.RemoteRepository> remoteProjectRepositories,
                                                                                org.apache.maven.doxia.site.Skin skin)
                                                                         throws SiteToolException
        Get a skin artifact from one of the repositories.
        Specified by:
        getSkinArtifactFromRepository in interface SiteTool
        Parameters:
        repoSession - the repository system session, not null.
        remoteProjectRepositories - the Maven remote project repositories, not null.
        skin - the Skin model, not null.
        Returns:
        the Skin artifact defined in a SiteModel from a given project
        Throws:
        SiteToolException - if any
      • getRelativePath

        @Deprecated
        public java.lang.String getRelativePath​(java.lang.String to,
                                                java.lang.String from)
        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:
        getRelativePath in interface SiteTool
        Parameters:
        to - the to url of file as string
        from - the from url of file as string
        Returns:
        a relative path from from to to.
      • getSiteDescriptor

        public java.io.File getSiteDescriptor​(java.io.File siteDirectory,
                                              java.util.Locale locale)
        Get a site descriptor from the project's site directory.
        Specified by:
        getSiteDescriptor in interface SiteTool
        Parameters:
        siteDirectory - the site directory, not null
        locale - the locale wanted for the site descriptor, not null. Most specific to least specific lookup from site_language_country_variant.xml, site_language_country.xml, site_language.xml}, to site.xml as last resort for Locale.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
      • getSiteModel

        public org.apache.maven.doxia.site.SiteModel getSiteModel​(java.io.File siteDirectory,
                                                                  java.util.Locale locale,
                                                                  org.apache.maven.project.MavenProject project,
                                                                  java.util.List<org.apache.maven.project.MavenProject> reactorProjects,
                                                                  org.eclipse.aether.RepositorySystemSession repoSession,
                                                                  java.util.List<org.eclipse.aether.repository.RemoteRepository> remoteProjectRepositories)
                                                           throws SiteToolException
        Get a site model for a project.
        Specified by:
        getSiteModel in interface SiteTool
        Parameters:
        siteDirectory - the site directory, may be null if project from repository
        locale - the locale used for the i18n in SiteModel, not null. See SiteTool.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 SiteModel object corresponding to the site.xml file with some interpolations.
        Throws:
        SiteToolException - if any
      • getInterpolatedSiteDescriptorContent

        public java.lang.String getInterpolatedSiteDescriptorContent​(java.util.Map<java.lang.String,​java.lang.String> props,
                                                                     org.apache.maven.project.MavenProject aProject,
                                                                     java.lang.String siteDescriptorContent)
                                                              throws SiteToolException
        Interpolating several expressions in the site descriptor content. Actually, the expressions can be in the project, the environment variables and the specific properties like encoding.

        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:
        getInterpolatedSiteDescriptorContent in interface SiteTool
        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.
      • populateReportsMenu

        public void populateReportsMenu​(org.apache.maven.doxia.site.SiteModel siteModel,
                                        java.util.Locale locale,
                                        java.util.Map<java.lang.String,​java.util.List<org.apache.maven.reporting.MavenReport>> categories)
        Populate the pre-defined reports menu 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:
        populateReportsMenu in interface SiteTool
        Parameters:
        siteModel - the Doxia Sitetools SiteModel, not null.
        locale - the locale used for the i18n in SiteModel, not null. See SiteTool.getSiteDescriptor(File, Locale) for details.
        categories - reports per category to put in "Reports" or "Information" menus, not null.
        See Also:
        MavenReport.CATEGORY_PROJECT_INFORMATION, MavenReport.CATEGORY_PROJECT_REPORTS
      • getSiteLocales

        public java.util.List<java.util.Locale> getSiteLocales​(java.lang.String locales)
        Extracts from a comma-separated list the locales that are available in site-tool resource bundle.
        Specified by:
        getSiteLocales in interface SiteTool
        Parameters:
        locales - A comma separated list of locales
        Returns:
        a list of Locales.
      • getNormalizedPath

        protected static java.lang.String getNormalizedPath​(java.lang.String path)
        Parameters:
        path - could be null.
        Returns:
        the path normalized, i.e. by eliminating "/../" and "/./" in the path.
        See Also:
        FilenameUtils.normalize(String)