<?xml version="1.0"?>
<ruleset id="jboss-eap5-xml"
         xmlns="http://windup.jboss.org/schema/jboss-ruleset"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd">

    <!-- Rules converted from XmlJBoss5Rules.windup. -->

    <metadata>
        <description>
            This ruleset provides analysis of JBoss EAP 5 configuration XML files that may require individual attention
            when migrating to JBoss EAP 6+. Mainly deals with datasources, JBoss Web and EJB configuration.
        </description>
        <dependencies>
            <addon id="org.jboss.windup.rules,windup-rules-javaee,2.3.0.Final"/>
            <addon id="org.jboss.windup.rules,windup-rules-java,2.3.0.Final"/>
        </dependencies>
        <sourceTechnology id="eap" versionRange="[5,6)"/>
        <targetTechnology id="eap" versionRange="[6,7)"/>
        <tag>jboss-eap5</tag>
        <tag>ejb</tag>
        <tag>seam</tag>
    </metadata>

    <rules>
        <rule id="jboss-eap5-xml-01000">
            <when>
                <xmlfile matches="//mbean[@code='org.jboss.cache.TreeCache']"/>
            </when>
            <perform>
                <classification issue-display-mode="all" title="JBoss Cache" effort="3">
                    <description>
                        JBoss Cache TreeCache is a distributed tree-like structure that is replicated across several members.
                        Updates will be multicast to all group members reliably and in the same order.
                    </description>
                    <link title="JBoss Cache User Guide" href="https://access.redhat.com/documentation/en-us/jboss_enterprise_application_platform/5/html-single/cache_user_guide/"/>
                    <link title="JBoss Cache Tutorial" href="https://access.redhat.com/documentation/en-us/jboss_enterprise_application_platform/5/html-single/cache_tutorial/"/>
                    <tag>cache</tag>
                    <tag>distributed</tag>
                    <tag>cluster</tag>
                    <tag>jboss-eap5</tag>
                </classification>
            </perform>
        </rule>
        <!-- Rule jboss-eap5-xml-02000 will need to be deduplicated, see jboss-eap5-xml-08000 below and WINDUPRULE-164. -->
        <rule id="jboss-eap5-xml-03000">
            <when>
                <xmlfile matches="/classloading"/>
            </when>
            <perform>
                <classification issue-display-mode="all" title="JBoss Classloading configuration, typically in jboss-classloading.xml." effort="1">
                    <description>
                        JBoss EAP 5 allows detailed classloading configuration.
                    </description>
                    <link title="JBoss EAP 5 Classloading" href="https://access.redhat.com/documentation/en-us/JBoss_Enterprise_Application_Platform/5/html/Microcontainer_User_Guide/sect-JBoss_Microcontainer_User_Guide-The_ClassLoading_Layer-ClassLoading.html"/>
                    <tag>jboss-eap5</tag>
                </classification>
            </perform>
        </rule>

        <!-- merged into jboss-eap5-xml-10000 -->
<!--         <rule id="jboss-eap5-xml-04000"> -->
<!--             <when> -->
<!--                 <xmlfile matches="/jbc:classloading"> -->
<!--                     <namespace prefix="jbc" uri="urn:jboss:classloading:1.0"/> -->
<!--                 </xmlfile> -->
<!--             </when> -->
<!--             <perform> -->
<!--                 <classification issue-display-mode="all" title="JBoss EAP 5 Classloading Configuration" effort="5"> -->
<!--                     <description> -->
<!--                         JBoss EAP 5 allows detailed classloading configuration. -->
<!--                     </description> -->
<!--                     <link title="JBoss EAP 5 Classloading documentation" href="https://access.redhat.com/documentation/en-us/JBoss_Enterprise_Application_Platform/5/html/Microcontainer_User_Guide/sect-JBoss_Microcontainer_User_Guide-The_ClassLoading_Layer-ClassLoading.html"/> -->
<!--                     <tag>jboss-eap5</tag> -->
<!--                 </classification> -->
<!--             </perform> -->
<!--         </rule> -->

        <!-- Seam -->
        <rule id="jboss-eap5-xml-05000">
            <when>
                <xmlfile matches="/sc:components">
                    <namespace prefix="sc" uri="http://jboss.com/products/seam/components"/>
                </xmlfile>
            </when>
            <perform>
                <classification issue-display-mode="all" title="JBoss Seam Components (components.xml)" effort="5">
                    <description>
                        Allows to configure a Seam component using XML: to isolate deployment-specific information from
                        the Java code, to enable the creation of re-usable frameworks, to configure Seam's built-in functionality, etc.
                        Seam provides two basic approaches to configuring components:
                        configuration via property settings in a properties file or in `web.xml`,
                        and configuration via `components.xml`.
                    </description>
                    <link title="JBoss Seam Reference Guide - Configuring Seam components" href="https://access.redhat.com/documentation/en-us/jboss_enterprise_application_platform/5/html-single/seam_reference_guide/#xml"/>
                    <tag>seam</tag>
                    <tag>jboss-eap5</tag>
                </classification>
            </perform>
        </rule>
        <rule id="jboss-eap5-xml-06000">
            <when>
                <xmlfile matches="/sp:pages">
                    <namespace prefix="sp" uri="http://jboss.com/products/seam/pages"/>
                </xmlfile>
            </when>
            <perform>
                <classification issue-display-mode="all" title="JBoss Seam Pages" effort="5">
                    <description>
                        The `pages.xml` file specifies the page flow and other configuration of the Seam Framework.
                    </description>
                    <link href="https://access.redhat.com/documentation/en-us/jboss_enterprise_application_platform/5/html-single/seam_reference_guide/" title="Seam Framework Reference Guide"/>
                    <tag>seam</tag>
                    <tag>jboss-eap5</tag>
                </classification>
            </perform>
        </rule>
        <rule id="jboss-eap5-xml-07000">
            <when>
                <xmlfile matches="/page" in="{*}.page.xml"/>
            </when>
            <perform>
                <classification issue-display-mode="all" title="JBoss Seam Page" effort="3">
                    <tag>seam</tag>
                    <tag>jboss-eap5</tag>
                </classification>
            </perform>
        </rule>


        <!-- The following 2 rules need to be deduplicated - see WINDUPRULE-164.
             But currently we have no means for that. See WINDUP-1051 and WINDUP-1050. -->
        <rule id="jboss-eap5-xml-02000">
            <when>
                <xmlfile public-id=".*JBoss.+DTD Java EE.+5.*"/>
            </when>
            <perform>
                <classification issue-display-mode="all" title="JBoss 5.x EAR descriptor" effort="5">
                    <description>
                        A JBoss specific EAR descriptor allows extensions to Java EE EAR archives configuration.
                    </description>
                    <link title="JBoss DTD's" href="http://www.jboss.org/j2ee/dtd/"/>
                    <tag>jboss-eap5</tag>
                </classification>
            </perform>
        </rule>
        <rule id="jboss-eap5-xml-08000">
            <when>
                <xmlfile matches="//*[local-name()='jboss-app']" in="jboss-app.xml"/>
            </when>
            <perform>
                <iteration>
                    <xslt title="JBoss application descriptor - JBoss 5 (MTA-generated)" template="resources/jboss-app-to-jboss5.xsl" extension="-jboss5.xml"/>
                </iteration>
                <iteration>
                    <when>
                        <not>
                            <xmlfile public-id=".*JBoss.+DTD Java EE.+5.*"/>
                        </not>
                    </when>
                    <classification issue-display-mode="all" title="JBoss EAR descriptor" effort="1">
                        <description>
                            The `jboss-app.xml` file configures a Java EE application deployments specifically for JBoss EAP.
                        </description>
                        <!--<link href="" title=""> TODO: ESSC-25 -->
                        <tag>configuration</tag>
                        <tag>deployment</tag>
                        <tag>descriptor</tag>
                        <tag>jboss-eap5</tag>
                    </classification>
                </iteration>
            </perform>
        </rule>

        <rule id="jboss-eap5-xml-09000">
            <when>
                <xmlfile matches="//*[local-name()='jboss-web']" in="jboss-web.xml"/>
            </when>
            <perform>
                <classification issue-display-mode="detail-only" title="JBoss web application descriptor (jboss-web.xml)" effort="1">
                    <description>
                        The `jboss-web.xml` file configures a Java EE web application specifically for JBoss EAP.
                        It is an extension to standard `web.xml`.
                    </description>
                    <link title="jboss-web.xml Configuration Reference" href="https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/6.4/html-single/development_guide/#jboss-webxml_Configuration_Reference"/>
                    <tag>web</tag>
                    <tag>configuration</tag>
                    <tag>deployment</tag>
                    <tag>descriptor</tag>
                    <tag>jboss-eap5</tag>
                </classification>
            </perform>
        </rule>
        <rule id="jboss-eap5-7-xml-10000">
           <when>
                <xmlfile matches="/jbc:classloading">
                    <namespace prefix="jbc" uri="urn:jboss:classloading:1.0"/>
                </xmlfile>
            </when>
            <perform>
                <classification issue-display-mode="detail-only" title="JBoss 5 classloader configuration (jboss-classloading.xml)" effort="0" category-id="mandatory">
                    <description>The `jboss-classloading.xml` file allows customization of classloading in JBoss EAP 5.</description>
                    <link title="JBoss EAP 6 Class Loading and Modules" href="https://access.redhat.com/documentation/en-us/JBoss_Enterprise_Application_Platform/6.4/html/Development_Guide/chap-Class_Loading_and_Modules.html"/>
                    <link title="JBoss EAP 5 Class Loading and Modules" href="https://access.redhat.com/documentation/en-us/JBoss_Enterprise_Application_Platform/5/html/Microcontainer_User_Guide/sect-JBoss_Microcontainer_User_Guide-The_ClassLoading_Layer-ClassLoading.html"/>
                    <tag>classloading</tag>
                </classification>
                <hint title="JBoss 5 classloader configuration (jboss-classloading.xml)" effort="5" category-id="mandatory">
                    <message>
                        In JBoss EAP 6, the classloading configuration is not done through `jboss-classloading.xml`.
                        Since EAP 6 it is of modular nature, based on JBoss Modules.
                        Learn how to divide your application's dependencies into modules
                        and what dependencies and APIs are available automatically.
                    </message>
                    <link title="JBoss EAP 6 Class Loading and Modules" href="https://access.redhat.com/documentation/en-us/JBoss_Enterprise_Application_Platform/6.4/html/Development_Guide/chap-Class_Loading_and_Modules.html"/>
                    <link title="JBoss EAP 5 Class Loading and Modules" href="https://access.redhat.com/documentation/en-us/JBoss_Enterprise_Application_Platform/5/html/Microcontainer_User_Guide/sect-JBoss_Microcontainer_User_Guide-The_ClassLoading_Layer-ClassLoading.html"/>
                    <tag>classloading</tag>
                    <tag>jboss-eap5</tag>
                </hint>
            </perform>
        </rule>

        <rule id="jboss-eap5-xml-11000">
            <when>
                <xmlfile matches="//*[local-name()='jboss-deployment-structure']" in="jboss-deployment-structure.xml"/>
            </when>
            <perform>
                <classification issue-display-mode="all" title="JBoss module and classloading configuration (jboss-deployment-structure.xml)" effort="1">
                    <description>
                        The `jboss-deployment-structure.xml` file allows the creator of the deployment to control the dependencies
                        and classloading of deployments.
                    </description>
                    <!-- TODO: There's no such page for EAP 5. -->
                    <link title="Class Loading and Modules" href="https://access.redhat.com/documentation/en-us/JBoss_Enterprise_Application_Platform/6.4/html/Development_Guide/chap-Class_Loading_and_Modules.html"/>
                    <tag>classloading</tag>
                    <tag>jboss-eap5</tag>
                </classification>
            </perform>
        </rule>
        <rule id="jboss-eap5-xml-12000">
            <when>
                <xmlfile matches="//*[local-name()='jbosscmp-jdbc']" in="jbosscmp-jdbc.xml"/>
            </when>
            <perform>
                <classification issue-display-mode="all" title="JBoss EJB 2 CMP Deployment descriptor (jbosscmp-jdbc.xml)" effort="5" category-id="mandatory">
                    <description>
                        The `jbosscmp-jdbc.xml` is a deployment decriptor controlling the Container Managed Persistence (CMP).
                    </description>
                    <link title="JBoss EAP 5 - The jbosscmp-jdbc Structure" href="https://access.redhat.com/documentation/en-us/jboss_enterprise_application_platform/5/html-single/administration_and_configuration_guide/index#The_CMP_Engine-The_jbosscmp_jdbc_Structure"/>
                    <tag>jdbc</tag>
                    <tag>ejb2</tag>
                    <tag>jboss-eap5</tag>
                </classification>
            </perform>
        </rule>
        <rule id="jboss-eap5-xml-13000">
            <when>
                <xmlfile matches="//*[local-name()='jboss']" in="jboss.xml"/>
            </when>
            <perform>
                <classification issue-display-mode="all" title="JBoss EJB XML deployment descriptor prior to EAP 6" effort="0" category-id="mandatory">
                    <description>
                        The `jboss.xml` descriptor in deployments is ignored by JBoss AS 7+ or JBoss EAP 6+.
                        Replace it with `jboss-ejb3.xml`.
                    </description>
                    <link title="JBoss EAP 5 - EJB References with jboss.xml and jboss-web.xml" href="https://access.redhat.com/documentation/en-us/jboss_enterprise_application_platform/5/html-single/administration_and_configuration_guide/#ENC_Usage_Conventions-EJB_References_with_jboss.xml_and_jboss_web.xml"/>
                    <link title="JBoss EAP 6 - Replace the jboss.xml File" href="https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/6.4/html-single/migration_guide/#Replace_the_jboss.xml_File"/>
                    <tag>descriptor</tag>
                    <tag>jboss-eap5</tag>
                </classification>
            </perform>
        </rule>
        <rule id="jboss-eap5-xml-14000">
            <when>
                <xmlfile matches="//*[local-name()='security-domain' and starts-with(text(), 'java:/jaas/')]"/>
            </when>
            <perform>
                <hint title="JBoss EAP security-domain configuration - java:/jaas/" effort="3" category-id="mandatory">
                    <message>
                        `java:/jaas/` is a JBoss EAP `security-domain` URI.
                        Remove the `java:/jaas/` prefix for `security-domain` elements in AS 7 / EAP 6.
                    </message>
                    <link title="Java Authentication and Authorization Service (JAAS) Reference Guide" href="http://docs.oracle.com/javase/7/docs/technotes/guides/security/jaas/JAASRefGuide.html"/>
                    <tag>security</tag>
                    <tag>jaas</tag>
                    <tag>jboss-eap5</tag>
                </hint>
            </perform>
        </rule>
        <rule id="jboss-eap5-xml-16000">
            <when>
                <xmlfile matches="//*[local-name()='policy']" in="login-config.xml"/>
            </when>
            <perform>
                <classification issue-display-mode="detail-only" title="JBoss security configuration descriptor (prior to AS 7 / EAP 6)" effort="0">
                    <link title="JBoss EAP 5 - Login Modules" href="https://access.redhat.com/documentation/en-us/jboss_enterprise_application_platform/5/html-single/security_guide/#idm139921681412720"/>
                    <tag>security</tag>
                </classification>
                <hint title="JBoss security configuration descriptor (login-config.xml)" effort="5" category-id="mandatory">
                    <message>Before JBoss EAP 6, authentication security domains and login modules could be configured in a `login-config.xml` file.
                    JBoss EAP 6+ does not support the `login-config.xml` descriptor. Security is now configured inside the server configuration. Please refer to the corresponding server security guide.
                    </message>
                    <link title="JBoss EAP 6.4 - How To Configure Server Security" href="https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/6.4/html-single/how_to_configure_server_security/"/>
                    <tag>security</tag>
                    <tag>jboss-eap5</tag>
                </hint>
            </perform>
        </rule>

        <!-- EAP 6 -->
        <rule id="jboss-eap5-xml-17000">
            <when>
                <xmlfile matches="//*[local-name()='ejb-jar']" in="jboss-ejb3.xml"/>
            </when>
            <perform>
                <classification issue-display-mode="all" title="JBoss EJB 3 deployment descriptor (jboss-ejb3.xml)" effort="5">
                    <description>
                        A JBoss specific EJB 3 configuration allows extensions of Java EE EJB 3.
                    </description>
                    <link title="jboss-ejb3.xml Deployment Descriptor Reference" href="https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/6.4/html-single/development_guide/index#jboss-ejb3xml_Deployment_Descriptor_Reference"/>
                    <tag>jboss-eap5</tag>
                </classification>
            </perform>
        </rule>

        <!-- EAP 6 -->
        <rule id="jboss-eap5-xml-18000">
            <when>
                <xmlfile matches="//*[local-name()='webservices']" in="jboss-webservices.xml"/>
            </when>
            <perform>
                <classification issue-display-mode="all" title="JBoss web-services deployment descriptor (jboss-webservices.xml)" effort="5">
                    <description>
                        JBossWS 4.0 introduces a new deployment descriptor to configure web services.
                        The `jboss-webservices.xml` file provides additional information for the given deployment
                        and partially replaces the obsolete `jboss.xml` file.

                        For EJB webservice deployments, the expected location of the `jboss-webservices.xml` descriptor file
                        is in the `META-INF/` directory. For POJO and EJB webservice endpoints bundled in WAR file,
                        the expected location of the `jboss-webservices.xml` file is in the `WEB-INF/` directory.
                    </description>
                    <link title="JBoss web-services deployment descriptor (jboss-webservices.xml)" href="https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/6.4/html-single/migration_guide/index#sect-Web_Services_Changes"/>
                    <tag>jboss-ws</tag>
                    <tag>descriptor</tag>
                    <tag>webservice</tag>
                    <tag>jboss-eap5</tag>
                </classification>
            </perform>
        </rule>

        <!-- EAP 4 -> EAP 5 transformation? -->
        <rule id="jboss-eap5-xml-20000">
            <when>
                <xmlfile matches="//server/mbean[@code='org.jboss.mq.server.jmx.Queue']"/>
            </when>
            <perform>
                <classification issue-display-mode="all" title="JBoss EAP 4 JMS configuration" effort="5">
                    <tag>jboss-eap5</tag>
                </classification>
                <xslt title="Queue Destinations Service (MTA-generated)" template="resources/jboss4-mq-to-jboss5.xsl" extension="-jboss5.xml"/>
            </perform>
        </rule>
    </rules>
</ruleset>
