<?xml version="1.0"?>
<ruleset id="weblogic-catchall" 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">
    <metadata>
        <description>
            This ruleset provides analysis of Oracle WebLogic proprietary classes and constructs that may require individual attention when
            migrating to JBoss EAP 6+.
        </description>
        <dependencies>
            <addon id="org.jboss.windup.rules,windup-rules-javaee,2.7.0.Final" />
            <addon id="org.jboss.windup.rules,windup-rules-java,2.7.0.Final" />
        </dependencies>
        <sourceTechnology id="weblogic" />
        <targetTechnology id="eap" versionRange="[6,8)" />
        <phase>PostMigrationRulesPhase</phase>
    </metadata>
    <rules>
        <rule id="weblogic-catchall-hackrule">
            <!--
                HACK - This rule exists only to insure that the prefilter knows
                about these patterns. weblogic-catchall-01000 uses a very broad
                regex that is incompatible with the prefilter. Without this
                stub rule, the prefilter would not fire.
            -->

            <when>
                <and>
                    <javaclass references="com.weblogic.{*}"/>
                    <javaclass references="com.bea.{*}"/>
                    <javaclass references="bea.{*}"/>
                    <javaclass references="weblogic.{*}"/>
                </and>
            </when>
            <perform>
            </perform>
        </rule>
        <rule id="weblogic-catchall-01000">
            <when>
                <javaclass references="{prefix}{remainder}" />
            </when>
            <perform>
                <iteration>
                    <when>
                        <not>
                            <has-hint />
                        </not>
                    </when>
                    <perform>
                        <hint title="WebLogic proprietary type reference" effort="0" category-id="potential">
                            <message>
                                This is a WebLogic proprietary type (`{prefix}{remainder}`) and needs to be migrated to a compatible API. There is currently no detailed information about this type.
                            </message>
                            <tag>catchall</tag>
                        </hint>
                    </perform>
                </iteration>
            </perform>
            <where param="prefix">
                <matches pattern="(com\.weblogic[^.]*\.)|(com\.bea[^.]*\.)|(bea\.)|(weblogic\.)"/>
            </where>
            <where param="remainder">
                <matches pattern=".*"/>
            </where>
        </rule>
        <rule id="weblogic-catchall-02000">
            <when>
                <javaclass references="oracle.sql.{remainder}" />
            </when>
            <perform>
                <iteration>
                    <when>
                        <not>
                            <has-hint />
                        </not>
                    </when>
                    <perform>
                        <hint title="Oracle proprietary SQL type reference" effort="0" category-id="optional">
                            <message>
                              <![CDATA[
                              This is an Oracle proprietary SQL type (`oracle.sql.{remainder}`).

                              It should be migrated to a compatible API either if you consider replacing your Oracle database or if you want to get rid of the Oracle proprietary API usage.
                              ]]>
                            </message>
                            <tag>catchall</tag>
                        </hint>
                    </perform>
                </iteration>
            </perform>
            <where param="remainder">
                <matches pattern=".*"/>
            </where>
        </rule>
        <rule id="weblogic-catchall-03000">
            <when>
                <javaclass references="com.tangosol{subpackage}.{type}" />
            </when>
            <perform>
                <iteration>
                    <when>
                        <not>
                            <has-hint />
                        </not>
                    </when>
                    <perform>
                        <hint title="Tangosol Proprietary type reference" effort="0" category-id="potential" >
                            <message>
                                This is an Oracle proprietary type (`com.tangosol{subpackage}.{type}`) and needs to be migrated to a compatible API. There is currently no detailed information about this type.
                            </message>
                            <tag>catchall</tag>
                        </hint>
                    </perform>
                </iteration>
            </perform>
            <where param="subpackage">
                <matches pattern="(\..*)?" />
            </where>
            <where param="type">
                <matches pattern="[^.]+" />
            </where>
        </rule>
        <rule id="weblogic-catchall-06000">
            <when>
                   <javaclass references="{com}oracle{subpackage}.{type}" />
            </when>
            <perform>
                <iteration>
                    <when>
                        <not>
                            <has-hint />
                        </not>
                    </when>
                    <perform>
                        <hint title="Oracle proprietary type reference" effort="0" category-id="potential">
                            <message>
                                This is an Oracle proprietary type (`{com}oracle{subpackage}.{type}`) and needs to be migrated to a compatible API. There is currently no detailed information about this type.
                            </message>
                            <tag>catchall</tag>
                        </hint>
                    </perform>
                </iteration>
            </perform>
            <where param="com">
                <matches pattern="(com\.)?"/>
            </where>
            <where param="subpackage">
                <matches pattern="(\..*)?" />
            </where>
            <where param="type">
                <matches pattern="[^.]+" />
            </where>
        </rule>
        <rule id="weblogic-catchall-06500">
            <when>
                <javaclass references="oracle.jdbc.{remainder}" />
            </when>
            <perform>
                <iteration>
                    <when>
                        <not>
                            <has-hint />
                        </not>
                    </when>
                    <perform>
                        <hint title="Oracle proprietary JDBC type reference" effort="0" category-id="optional">
                            <message>
                              <![CDATA[
                              This is an Oracle proprietary JDBC type (`oracle.sql.{remainder}`).

                              It should be replaced by standard Java EE JCA, datasource and JDBC types.
                              ]]>
                            </message>
                            <tag>catchall</tag>
                        </hint>
                    </perform>
                </iteration>
            </perform>
            <where param="remainder">
                <matches pattern=".*"/>
            </where>
        </rule>
    </rules>
</ruleset>
