Skip to content

Content of file LayoutJaxbMarshallable.java.html

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../../jacoco-resources/report.gif" type="image/gif"/><title>LayoutJaxbMarshallable.java</title><link rel="stylesheet" href="../../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../../index.html" class="el_report">NorthernWind :: Frontend :: Webapp :: Spring MVC</a> &gt; <a href="../index.html" class="el_bundle">it-tidalwave-northernwind-core-marshalling-default</a> &gt; <a href="index.source.html" class="el_package">it.tidalwave.northernwind.core.impl.io</a> &gt; <span class="el_source">LayoutJaxbMarshallable.java</span></div><h1>LayoutJaxbMarshallable.java</h1><pre class="source lang-java linenums">/*
 * #%L
 * *********************************************************************************************************************
 *
 * NorthernWind - lightweight CMS
 * http://northernwind.tidalwave.it - git clone https://bitbucket.org/tidalwave/northernwind-src.git
 * %%
 * Copyright (C) 2011 - 2023 Tidalwave s.a.s. (http://tidalwave.it)
 * %%
 * *********************************************************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations under the License.
 *
 * *********************************************************************************************************************
 *
 *
 * *********************************************************************************************************************
 * #L%
 */
package it.tidalwave.northernwind.core.impl.io;

import javax.annotation.Nonnull;
import javax.inject.Inject;
import java.io.IOException;
import java.io.OutputStream;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller;
import org.springframework.beans.factory.annotation.Configurable;
import it.tidalwave.role.io.Marshallable;
import it.tidalwave.dci.annotation.DciRole;
import it.tidalwave.northernwind.frontend.ui.Layout;
import it.tidalwave.northernwind.core.impl.io.jaxb.ComponentJaxb;
import it.tidalwave.northernwind.core.impl.io.jaxb.ComponentsJaxb;
import it.tidalwave.northernwind.core.impl.io.jaxb.ObjectFactory;
import lombok.extern.slf4j.Slf4j;

/***********************************************************************************************************************
 *
 * @author  Fabrizio Giudici
 *
 **********************************************************************************************************************/
<span class="nc" id="L49">@DciRole(datumType = Layout.class) @Configurable @Slf4j</span>
public class LayoutJaxbMarshallable implements Marshallable
  {
    @Nonnull
    private final Layout ownerLayout;

    @Inject
    private ObjectFactory objectFactory;

    @Inject
    private Marshaller marshaller;

    /*******************************************************************************************************************
     *
     *
     *
     ******************************************************************************************************************/
    public LayoutJaxbMarshallable (@Nonnull final Layout ownerLayout)
<span class="nc bnc" id="L67" title="All 18 branches missed.">      {</span>
<span class="nc" id="L68">        this.ownerLayout = ownerLayout;</span>
<span class="nc bnc" id="L69" title="All 4 branches missed.">      }</span>

    /*******************************************************************************************************************
     *
     * {@inheritDoc}
     *
     ******************************************************************************************************************/
    @Override
    public void marshal (@Nonnull final OutputStream os)
      throws IOException
      {
        try
          {
<span class="nc" id="L82">            final ComponentsJaxb componentsJaxb = objectFactory.createComponentsJaxb();</span>
<span class="nc" id="L83">            componentsJaxb.setVersion(&quot;1.0&quot;);</span>
<span class="nc" id="L84">            componentsJaxb.setComponent(marshal(ownerLayout));</span>
<span class="nc" id="L85">            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // FIXME: set in Spring</span>
set in Spring
<span class="nc" id="L86"> marshaller.marshal(objectFactory.createComponents(componentsJaxb), os);</span> } <span class="nc" id="L88"> catch (JAXBException e)</span> { <span class="nc" id="L90"> throw new IOException(&quot;&quot;, e);</span> <span class="nc" id="L91"> }</span> <span class="nc" id="L92"> }</span> /******************************************************************************************************************* * * ******************************************************************************************************************/ @Nonnull private ComponentJaxb marshal (@Nonnull final Layout layout) { <span class="nc" id="L101"> final ComponentJaxb componentJaxb = objectFactory.createComponentJaxb();</span> <span class="nc" id="L102"> componentJaxb.setId(layout.getId().stringValue());</span> <span class="nc" id="L103"> componentJaxb.setType(layout.getTypeUri());</span> <span class="nc bnc" id="L105" title="All 2 branches missed."> for (final Layout child : layout.findChildren().results())</span> { <span class="nc" id="L107"> componentJaxb.getComponent().add(marshal(child));</span> <span class="nc" id="L108"> }</span> <span class="nc" id="L110"> return componentJaxb;</span> } } </pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.7.202105040129</span></div></body></html>