<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN"
        "http://tuckey.org/res/dtds/urlrewrite3.2.dtd">
<!-- http://tuckey.org/urlrewrite/ -->

<!--
 These rules are processed in order, so ordering *is* significant.
 If a rule have a to element that forwards, the new URL will be picked
 up by subsequent rules.
-->
<urlrewrite>


  <!-- this "never" cache rule is first, so that later rules may override them if needed -->
  <class-rule class="com.appiancorp.tempo.urlrewrite.AddNoCacheHeadersToRestApiResponse"/>
  <rule>
    <note>This is after the 'nevercache' ones above as this typically forwards to a /api call, but in this case it should cache</note>
    <from>^/s/(.*)/_/(.*)</from>
    <run class="com.appiancorp.plugins.servlet.ResourceDownloadUtils" method="addPublicCachingHeaders" />
    <to type="forward">/$2</to>
  </rule>

  <rule>
    <from>/api/feed/(.*)</from>
    <to type="forward">/plugins/servlet/abdera/feed/$1</to>
  </rule>

  <!-- BEGIN: Legacy Mobile Rules
    These rules are responsible for re-routing requests made by legacy mobile clients where the URLs were hardcoded.
    With each entry, include the ticket in which it was introduced
  -->

  <!-- Remove after SASAs are fully converted or 19.3 -->
  <rule>
    <from>/rest/a/applications/latest/sites/(.*)</from>
    <to>/rest/a/applications/latest/legacy/sites/$1</to>
  </rule>

  <!-- END: Legacy Mobile Rules -->

  <class-rule class="com.appiancorp.process.design.presentation.SmartServiceIconRewriteRule"/>
  <class-rule class="com.appiancorp.react.urlrewrite.ReactTempoFilterForwarder"/>
  <class-rule class="com.appiancorp.tempo.urlrewrite.TempoFilterForwarder"/>
  <class-rule class="com.appiancorp.tempo.urlrewrite.CustomLandingPageRewriteRule"/>
  <class-rule class="com.appiancorp.sailapp.urlrewrite.SailApplicationFilterForwarder"/>
  <class-rule class="com.appiancorp.sailapp.urlrewrite.QuickAppsManagementFilterForwarder"/>
  <class-rule class="com.appiancorp.react.urlrewrite.ReactSitesFilterForwarder"/>
  <class-rule class="com.appiancorp.sailapp.urlrewrite.AdminConsoleFilterForwarder"/>
  <class-rule class="com.appiancorp.sailapp.urlrewrite.FeatureFlagManagementFilterForwarder"/>
  <class-rule class="com.appiancorp.react.urlrewrite.ReactOperationsConsoleFilterForwarder"/>
  <class-rule class="com.appiancorp.sailapp.urlrewrite.ProcessHQFilterForwarder"/>
  <class-rule class="com.appiancorp.sailapp.urlrewrite.DocumentChatFilterForwarder"/>
  <class-rule class="com.appiancorp.sailapp.urlrewrite.StudioFilterForwarder"/>

  <rule>
    <from>^/tempo(/?)$</from>
    <to type="forward">/tempo/index.jsp</to>
  </rule>

  <!-- Allow Administrator access to the Interface Designer. Administrator is not in the designers group
    because otherwise users could remove Administrator and have no access to the designer UI, which means
    we have to call out access explicitly -->
  <rule>
    <condition type="remote-user">Administrator</condition>
    <from>^/design(/?|/.*)$</from>
    <to type="forward">/tempo/index.jsp</to>
  </rule>

  <!-- Allow designers access to the Interface Designer -->
  <rule>
    <condition name="designer" type="user-in-role" />
    <from>^/design(/?|/.*)$</from>
    <to type="forward">/tempo/index.jsp</to>
  </rule>

  <rule>
    <from>^/dataFabric/syncStatus$</from>
    <to type="forward">/records/record-data-sync-status.html</to>
  </rule>

  <rule>
    <from>^/admin(/?)$</from>
    <to type="forward">/tempo/index.jsp</to>
  </rule>

  <rule>
    <from>^/satask(/?)$</from>
    <to type="forward">/tempo/index.jsp</to>
  </rule>

  <!-- Allow Administrator user access to Application Designer -->
  <rule>
    <note>Ensure that the clients do not cache the GWT nocache.js files.</note>
    <from>^(.*)nocache.js$</from>
    <run class="com.appiancorp.plugins.servlet.ResourceDownloadUtils" method="addNeverCacheHeaders" />
  </rule>

  <rule>
    <note>
      AN-42672
      This JSP renders an form to upload a file, the form has a multipart token (see com.appiancorp.security.csrf.CsrfTokenManager.generateMultipartToken(HttpServletRequest))
      IE caches this JSP and doesn't re-request it even when changing sessions.
    </note>
    <from>^/forms/templates/controls/inlinefileupload.jsp$</from>
    <run class="com.appiancorp.plugins.servlet.ResourceDownloadUtils" method="addNeverCacheHeaders" />
  </rule>

</urlrewrite>
