<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 4, 2016 at 4:22 AM, Stan Silvert <span dir="ltr">&lt;<a href="mailto:ssilvert@redhat.com" target="_blank">ssilvert@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF"><span>
    <div>On 8/3/2016 3:58 PM, James Perkins
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr"><br>
        <div class="gmail_extra"><br>
          <div class="gmail_quote">On Wed, Aug 3, 2016 at 6:53 AM, Stan
            Silvert <span dir="ltr">&lt;<a href="mailto:ssilvert@redhat.com" target="_blank">ssilvert@redhat.com</a>&gt;</span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The
              Keycloak server is currently configured via a
              keycloak-server.json<br>
              file.  We are converting this to configuration through<br>
              standalone.xml/domain.xml.<br>
              <br>
              To automatically upgrade, I need to read
              keycloak-server.json and write<br>
              back to standalone.xml.  I can easily add the operations
              to do this at<br>
              parse time.  The parser has this method:<br>
              <br>
              @Override<br>
              public void readElement(final XMLExtendedStreamReader
              reader, final<br>
              List&lt;ModelNode&gt; list) throws XMLStreamException<br>
            </blockquote>
            <div><br>
            </div>
            <div>Reading an external resource from the subsystem parsing
              doesn&#39;t feel right to me. Is the goal to move away from
              the keycloak-server.json to using the management model?</div>
          </div>
        </div>
      </div>
    </blockquote></span>
    Yes, that&#39;s the goal.  I&#39;d like it to happen automatically when the
    server is upgraded to a new version of the Keycloak subsystem.  So
    we need to read keyclaok-server.json and write to
    standalone.xml/domain.xml.<span><br>
    <blockquote type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div><br>
            </div>
            <div>If that is the goal then a better solution might be to
              have some sort of migration operation that would read the
              file and create the subsystem model. Then after that the
              keycloak-server.json is ignored and the *.xml file will be
              used.</div>
          </div>
        </div>
      </div>
    </blockquote></span>
    That&#39;s exactly what I am trying to accomplish.  I can create the
    subsystem model easily.  But a write to standalone.xml doesn&#39;t
    happen during server startup.</div></blockquote><div><br></div><div>It&#39;s designed to never write at startup because during boot the the configuration is read and we shouldn&#39;t modify without the user acknowledging there is going to be a change. That&#39;s why a migration operation would be preferred as it&#39;s explicit.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><span><br>
    <blockquote type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
              <br>
              So one way to do this is to parse keycloak-server.json at
              this time and<br>
              add operations to the list.<br>
              <br>
              That puts everything into the management model.  But
              nothing will be<br>
              written to standalone.xml unless someone manually does a
              write operation<br>
              from CLI.<br>
            </blockquote>
            <div><br>
            </div>
            <div>A write will be triggered if you make a change to the
              management model.</div>
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
              <br>
              So my question is, what is the best way to accomplish
              this?  Is there a<br>
              good, safe way to manually trigger a flush to
              standalone.xml at this<br>
              point or at some later point during startup?<br>
            </blockquote>
            <div><br>
            </div>
            <div>Not really an answer, but I hope there is not a way to
              trigger a write :)</div>
          </div>
        </div>
      </div>
    </blockquote></span>
    This could be done without harm as long as it is managed properly. 
</div></blockquote><div><br></div><div>The only time this would ever be needed is during a boot. I really think it&#39;s a bad idea to modify persistent configuration during a boot. The user has no idea this is being done.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">    <br>
    <br>
    If there is no way to do it then I&#39;ll have to make it a separate
    operation that the administrator has to run using offline CLI. 
    That&#39;s far from ideal as I would rather it happen automatically as
    part of the upgrade.</div></blockquote><div><br></div><div>IMO an upgrade or patch is an explicit action. It requires some kind of interaction and expecting a user to execute an operation after a component upgrade doesn&#39;t seem unreasonable to me.</div><div><br></div><div>An option for the future will be to use the new provisioning [1].</div><div><br></div><div>[1]: <a href="https://github.com/stuartwdouglas/wildfly-provisioning/blob/master/docs/src/main/asciidoc/design-doc.asciidoc">https://github.com/stuartwdouglas/wildfly-provisioning/blob/master/docs/src/main/asciidoc/design-doc.asciidoc</a></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><span><br>
    <blockquote type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
              <br>
              Stan<br>
              ______________________________<wbr>_________________<br>
              wildfly-dev mailing list<br>
              <a href="mailto:wildfly-dev@lists.jboss.org" target="_blank">wildfly-dev@lists.jboss.org</a><br>
              <a href="https://lists.jboss.org/mailman/listinfo/wildfly-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailma<wbr>n/listinfo/wildfly-dev</a><br>
            </blockquote>
          </div>
          <br>
          <br clear="all">
          <div><br>
          </div>
          -- <br>
          <div data-smartmail="gmail_signature">
            <div dir="ltr">
              <div>
                <div dir="ltr">
                  <div>James R. Perkins</div>
                  <div>JBoss by Red Hat</div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </span></div>

</blockquote></div><br><br clear="all"><div><br></div>-- <br><div data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>James R. Perkins</div><div>JBoss by Red Hat</div></div></div></div></div>
</div></div>