<?xml version="1.0"?>
<ruleset id="weblogic-webapp-eap7" 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 WebLogic proprietary code related to web-apps that may require individual
            attention when
            migrating to JBoss EAP 7+.
        </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" />
            <addon id="org.jboss.windup.rules,windup-rules-xml,2.7.0.Final" />
        </dependencies>
        <sourceTechnology id="weblogic" />
        <targetTechnology id="eap" versionRange="[7,8)" />
        <tag>web-app</tag>
        <tag>weblogic</tag>
    </metadata>

    <rules>
        <rule id="weblogic-webapp-eap7-01000">
            <when>
                <xmlfile in="weblogic.xml" matches="//wl:virtual-directory-mapping">
                    <namespace prefix="wl" uri="http://xmlns.oracle.com/weblogic/weblogic-web-app" />
                </xmlfile>
            </when>
            <perform>
                <hint title="WebLogic Virtual directory mapping" effort="1" category-id="mandatory">
                    <message>Virtual directories supported in WebLogic are not supported in JBoss EAP.</message>
                    <link href="https://access.redhat.com/articles/1332613" title="Detailed description of how to migrate virtual directories." />
                    <tag>file-system</tag>
                    <tag>weblogic</tag>
                </hint>
            </perform>
        </rule>
        <rule id="weblogic-webapp-eap7-02000">
            <when>
                <javaclass references="weblogic.servlet.annotation.WLServlet">
                    <location>ANNOTATION</location>
                </javaclass>
            </when>
            <perform>
                <hint title="WebLogic proprietary servlet annotations" effort="1" category-id="mandatory">
                    <message>
                      <![CDATA[
                      Replace the proprietary WebLogic `@WLServlet` annotation with the Java EE standard `@WebServlet` annotation.

                      See the [javax.servlet.annotation JavaDoc](http://docs.oracle.com/javaee/7/api/javax/servlet/annotation/package-summary.html) for more information.
                      ]]>
                    </message>
                    <link href="https://access.redhat.com/articles/1249423" title="Migrate WebLogic Proprietary Servlet Annotations" />
                    <tag>servlet</tag>
                    <tag>weblogic</tag>
                    <quickfix name="WebServlet" type="REPLACE">
                        <replacement>WebServlet</replacement>
                        <search>WLServlet</search>
                    </quickfix>
                    <quickfix name="Mapping Attribute" type="REPLACE">
                        <replacement>urlPatterns</replacement>
                        <search>mapping</search>
                    </quickfix>
                </hint>
            </perform>
        </rule>
        <rule id="weblogic-webapp-eap7-03000">
            <when>
                <javaclass references="weblogic.servlet.annotation.WLInitParam">
                    <location>ANNOTATION</location>
                </javaclass>
            </when>
            <perform>
                <hint title="WebLogic proprietary servlet annotations" effort="1" category-id="mandatory">
                    <message>
                      <![CDATA[
                      Replace the proprietary WebLogic `@WLInitParam` annotation with the Java EE standard `@WebInitParam` annotation.

                      See the [javax.servlet.annotation JavaDoc](http://docs.oracle.com/javaee/7/api/javax/servlet/annotation/package-summary.html) for more information.
                      ]]>
                    </message>
                    <link href="https://access.redhat.com/articles/1249423" title="Migrate WebLogic Proprietary Servlet Annotations" />
                    <tag>servlet</tag>
                    <tag>weblogic</tag>
                    <quickfix name="WebInitParam" type="REPLACE">
                        <replacement>WebInitParam</replacement>
                        <search>WLInitParam</search>
                    </quickfix>
                </hint>
            </perform>
        </rule>
        <rule id="weblogic-webapp-eap7-04000">
            <when>
                <javaclass references="weblogic.servlet.annotation.WLFilter">
                    <location>ANNOTATION</location>
                </javaclass>
            </when>
            <perform>
                <hint title="WebLogic proprietary servlet annotations" effort="3" category-id="mandatory">
                    <message>
                      <![CDATA[
                      Replace the proprietary WebLogic `@WLFilter` annotation with the Java EE standard `@WebFilter` annotation.

                      See the [javax.servlet.annotation JavaDoc](http://docs.oracle.com/javaee/7/api/javax/servlet/annotation/package-summary.html) for more information.
                      ]]>
                    </message>
                    <link href="https://access.redhat.com/articles/1249423" title="Migrate WebLogic Proprietary Servlet Annotations" />
                    <tag>servlet</tag>
                    <tag>weblogic</tag>
                    <quickfix name="WebFilter" type="REPLACE">
                        <replacement>WebFilter</replacement>
                        <search>WLFilter</search>
                    </quickfix>
                </hint>
            </perform>
        </rule>
        <rule id="weblogic-webapp-eap7-05000">
            <when>
                <javaclass references="weblogic.application.ApplicationLifecycleEvent">
                    <location>IMPLEMENTS_TYPE</location>
                    <location>INHERITANCE</location>
                    <location>IMPORT</location>
                </javaclass>
            </when>
            <perform>
                <hint title="WebLogic ApplicationLifecycleEvent" effort="3" category-id="mandatory">
                    <message>
                      <![CDATA[
                      WebLogic `ApplicationLifecycleEvent` must be replaced with standard Java EE `ServletContextEvent`. Otherwise, a custom solution using CDI's `ApplicationScoped` beans or EJB's `@Startup` beans is required in order to propagate a custom event object because `ServletContextEvent` types are not extendible in the standard Java EE programming model.

                      Use a `javax.servlet.ServletContextListener` with `@javax.annotation.servlet.WebListener`, or an EJB 3.1 `@javax.ejb.Startup` `@javax.ejb.Singleton` service bean.
                      ]]>
                    </message>
                    <link href="https://access.redhat.com/articles/1326703" title="Migrate WebLogic ApplicationLifecycleEvent to standard EJB with JBoss EAP" />
                    <link href="http://docs.oracle.com/javaee/7/api/javax/servlet/ServletContextEvent.html" title="Java EE ServletContextEvent JavaDoc" />
                    <link href="http://docs.oracle.com/cd/E13222_01/wls/docs90/programming/lifecycle.html" title="WebLogic custom ApplicationLifecycleEvent Documentation" />
                    <tag>lifecycle</tag>
                    <tag>weblogic</tag>
                </hint>
            </perform>
        </rule>
        <rule id="weblogic-webapp-eap7-06000">
            <when>
                <javaclass references="weblogic.application.ApplicationLifecycleListener">
                    <location>IMPLEMENTS_TYPE</location>
                    <location>INHERITANCE</location>
                </javaclass>
            </when>
            <perform>
                <hint title="WebLogic ApplicationLifecycleListener" effort="3" category-id="mandatory">
                    <message>
                      <![CDATA[
                      WebLogic `ApplicationLifecycleListener` must be replaced with standard Java EE `ServletContextListener` types. Otherwise, a solution using CDI's `ApplicationScoped` beans or EJB's `@Startup` beans is required.

                      Use a `javax.servlet.ServletContextListener` with `@javax.annotation.servlet.WebListener`, or an EJB 3.1 `@javax.ejb.Startup` `@javax.ejb.Singleton` service bean.
                      ]]>
                    </message>
                    <link href="https://access.redhat.com/articles/1326703" title="Migrate Oracle WebLogic Server ApplicationLifecycleListener Code to Red Hat JBoss EAP 6+" />
                    <link href="http://docs.oracle.com/javaee/7/api/javax/servlet/ServletContextEvent.html" title="Java EE ServletContextEvent JavaDoc" />
                    <link href="http://docs.oracle.com/cd/E13222_01/wls/docs90/programming/lifecycle.html" title="WebLogic custom ApplicationLifecycleEvent Documentation" />
                    <tag>lifecycle</tag>
                    <tag>weblogic</tag>
                </hint>
            </perform>
        </rule>
        <rule id="weblogic-webapp-eap7-07000">
            <when>
                <javaclass references="weblogic.security.{*}" />
            </when>
            <perform>
              <iteration>
                <when>
                    <not>
                        <has-hint />
                    </not>
                </when>
                <hint title="WebLogic proprietary security API" effort="3" category-id="mandatory">
                    <message>The usage of the WebLogic proprietary security API should be replaced by standard Java EE mechanisms or the ones provided by JBoss EAP.</message>
                    <link href="http://docs.oracle.com/cd/E12839_01/apirefs.1111/e13941/weblogic/security/Security.html" title="WebLogic security API documentation" />
                    <link href="https://access.redhat.com/documentation/en-us/red-hat-jboss-enterprise-application-platform?category=security&amp;version=7.0" title="EAP 7 security documentation" />
                    <tag>security</tag>
                    <tag>weblogic</tag>
                </hint>
              </iteration>
            </perform>
        </rule>
        <rule id="weblogic-webapp-eap7-08000">
            <when>
                <javaclass references="weblogic.security.Security" />
            </when>
            <perform>
                <hint title="WebLogic proprietary security reference to weblogic.security.Security" effort="3" category-id="mandatory">
                    <message>Migrate to JBoss EAP 7: `org.jboss.security.SecurityContextAssociation`.</message>
                    <link href="https://access.redhat.com/webassets/avalon/d/red-hat-jboss-enterprise-application-platform/7.0.0/javadocs/org/jboss/security/SecurityContextAssociation.html" title="Security Context - JBoss EAP 7" />
                    <link href="https://access.redhat.com/solutions/55114" title="Security context retrieval in POJOs" />
                    <tag>security</tag>
                    <tag>weblogic</tag>
                </hint>
            </perform>
        </rule>
        <rule id="weblogic-webapp-eap7-09000">
            <when>
                <javaclass references="weblogic.servlet.security.ServletAuthentication"/>
            </when>
            <perform>
                <hint effort="3" category-id="mandatory" title="WebLogic proprietary ServletAuthentication annotation">
                    <message>
                      <![CDATA[
                      Oracle WebLogic Server provides a proprietary `ServletAuthentication` class to perform programmatic login.

                      In Red Hat JBoss EAP 7, you can use the standard Java EE servlet security 3.1 `HttpServletRequest.login()` method or you can define a `<security-constraint>` element in the web.xml file. You must also replace code that uses the Oracle WebLogic Server proprietary `ServletAuthentication` class.
                      ]]>
                    </message>
                    <link href="https://access.redhat.com/articles/1329213" title="Migrate Oracle WebLogic programmatic login to JBoss EAP 7" />
                    <tag>security</tag>
                    <tag>weblogic</tag>
                </hint>
            </perform>
        </rule>
    </rules>
</ruleset>
