Package org.apache.maven.doxia.site.decoration

Examples of org.apache.maven.doxia.site.decoration.DecorationModel


        props.put( "reports", "<menu ref=\"reports\"/>\n" );
        props.put( "modules", "<menu ref=\"modules\"/>\n" );

        MavenProject parentProject = getParentProject( project, reactorProjects, localRepository );

        DecorationModel decorationModel =
            getDecorationModel( project, parentProject, reactorProjects, localRepository, repositories, siteDirectory,
                                llocale, props );

        if ( decorationModel == null )
        {
            String siteDescriptorContent;

            InputStream in = null;
            try
            {
                // Note the default is not a super class - it is used when nothing else is found
                in = getClass().getResourceAsStream( "/default-site.xml" );
                siteDescriptorContent = IOUtil.toString( in, "UTF-8" );
            }
            catch ( IOException e )
            {
                throw new SiteToolException( "Error reading default site descriptor: " + e.getMessage(), e );
            }
            finally
            {
                IOUtil.close( in );
            }

            siteDescriptorContent = getInterpolatedSiteDescriptorContent( props, project, siteDescriptorContent );

            decorationModel = readDecorationModel( siteDescriptorContent );
        }

        if ( parentProject != null )
        {
            populateParentMenu( decorationModel, llocale, project, parentProject, true );
        }

        populateModulesMenu( project, reactorProjects, localRepository, decorationModel, llocale, true );

        if ( decorationModel.getBannerLeft() == null )
        {
            // extra default to set
            Banner banner = new Banner();
            banner.setName( project.getName() );
            decorationModel.setBannerLeft( banner );
        }

        return decorationModel;
    }
View Full Code Here


        finally
        {
            IOUtil.close( siteDescriptorReader );
        }

        DecorationModel decoration = null;
        if ( siteDescriptorContent != null )
        {
            siteDescriptorContent = getInterpolatedSiteDescriptorContent( props, project, siteDescriptorContent );

            decoration = readDecorationModel( siteDescriptorContent );
            decoration.setLastModified( siteDescriptorLastModified );
        }

        if ( parentProject != null && ( decoration == null || decoration.isMergeParent() ) )
        {
            getLogger().debug( "Loading parent project site descriptor..." );

            MavenProject parentParentProject = getParentProject( parentProject, reactorProjects, localRepository );

            DecorationModel parent =
                getDecorationModel( parentProject, parentParentProject, reactorProjects, localRepository, repositories,
                                    siteDirectory, locale, props );

            // MSHARED-116 requires an empty decoration model (instead of a null one)
            // MSHARED-145 requires us to do this only if there is a parent to merge it with
            if ( decoration == null && parent != null )
            {
                // we have no site descriptor: merge the parent into an empty one
                decoration = new DecorationModel();
            }

            String name = project.getName();
            if ( decoration != null && StringUtils.isNotEmpty( decoration.getName() ) )
            {
View Full Code Here

     * @throws SiteToolException if any
     */
    private DecorationModel readDecorationModel( String siteDescriptorContent )
        throws SiteToolException
    {
        DecorationModel decoration;
        try
        {
            decoration = new DecorationXpp3Reader().read( new StringReader( siteDescriptorContent ) );
        }
        catch ( XmlPullParserException e )
View Full Code Here

    {
        SiteTool tool = (SiteTool) lookup( SiteTool.ROLE );
        assertNotNull( tool );

        SiteToolMavenProjectStub project = new SiteToolMavenProjectStub( "site-tool-test" );
        DecorationModel decorationModel = new DecorationModel();
        Skin skin = new Skin();
        skin.setGroupId( "org.apache.maven.skins" );
        skin.setArtifactId( "maven-stylus-skin" );
        decorationModel.setSkin( skin );
        assertNotNull( tool.getSkinArtifactFromRepository( getLocalRepo(), project.getRemoteArtifactRepositories(),
                                                           decorationModel ) );
    }
View Full Code Here

        String siteDirectory = "src/site";
        List<MavenProject> reactorProjects = new ArrayList<MavenProject>();

        project.setBasedir( null ); // get it from repo

        DecorationModel model =
            tool.getDecorationModel( project, reactorProjects, getLocalRepo(), project.getRemoteArtifactRepositories(),
                                     siteDirectory, Locale.getDefault() );
        assertNotNull( model );
        assertNotNull( model.getBannerLeft() );
        assertEquals( "Maven", model.getBannerLeft().getName() );
        assertEquals( "images/apache-maven-project-2.png", model.getBannerLeft().getSrc() );
        assertEquals( "http://maven.apache.org/", model.getBannerLeft().getHref() );
        assertNotNull( model.getBannerRight() );
        assertNull( model.getBannerRight().getName() );
        assertEquals( "images/maven-logo-2.gif", model.getBannerRight().getSrc() );
        assertNull( model.getBannerRight().getHref() );
    }
View Full Code Here

        SiteToolMavenProjectStub project = new SiteToolMavenProjectStub( "no-site-test" );
        String siteDirectory = "src/site";
        List<MavenProject> reactorProjects = new ArrayList<MavenProject>();

        DecorationModel model =
            tool.getDecorationModel( project, reactorProjects, getLocalRepo(), project.getRemoteArtifactRepositories(),
                                     siteDirectory, Locale.getDefault() );
        assertNotNull( model );
    }
View Full Code Here

  {
    final Locale reportLocale = determineLocale();

    try
    {
      final DecorationModel model = new DecorationModel();
      model.setBody(new Body());
      final Map<String, String> attributes = new HashMap<String, String>();
      attributes.put("outputEncoding", "UTF-8"); // TODO correct???
      final SiteRenderingContext siteContext =
          siteRenderer.createContextForSkin(ReportUtils.getSkinArtifactFile(
              project, localRepository, resolver, factory), attributes, model,
View Full Code Here

     * @throws XmlPullParserException
     */
    public void testInheritence()
        throws IOException, XmlPullParserException
    {
        DecorationModel childModel = readModel( "child.xml" );
        DecorationModel parentModel = readModel( "parent.xml" );

        assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/doxia",
                                            "http://maven.apache.org" );
        DecorationModel mergedModel = readModel( "merged.xml" );

        assertEquals( "Check result", mergedModel, childModel );

        // same with scp url, DOXIASITETOOLS-47
        childModel = readModel( "child.xml" );
View Full Code Here

     */
    public void testPathsResolvedWhenEmpty()
        throws IOException, XmlPullParserException
    {
        // Test an empty model avoids NPEs
        DecorationModel childModel = readModel( "empty.xml" );
        DecorationModel parentModel = readModel( "empty.xml" );

        assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/doxia",
                                            "http://maven.apache.org" );
        DecorationModel mergedModel = readModel( "empty.xml" );

        assertEquals( "Check result", mergedModel, childModel );

        // same with scp url, DOXIASITETOOLS-47
        childModel = readModel( "empty.xml" );
View Full Code Here

     * @throws XmlPullParserException
     */
    public void testPathsNotResolvedForExternalUrls()
        throws IOException, XmlPullParserException
    {
        DecorationModel parentModel = readModel( "external-urls.xml" );
        DecorationModel childModel = readModel( "empty.xml" );

        assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/doxia",
                                            "http://maven.apache.org" );
        assertPathsNotResolvedForExternalUrls( childModel );

View Full Code Here

TOP

Related Classes of org.apache.maven.doxia.site.decoration.DecorationModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.