<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one
  ~ or more contributor license agreements.  See the NOTICE file
  ~ distributed with this work for additional information
  ~ regarding copyright ownership.  The ASF licenses this file
  ~ to you under the Apache License, Version 2.0 (the
  ~ "License"); you may not use this file except in compliance
  ~ with the License.  You may obtain a copy of the License at
  ~
  ~   http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing,
  ~ software distributed under the License is distributed on an
  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  ~ KIND, either express or implied.  See the License for the
  ~ specific language governing permissions and limitations
  ~ under the License.
  -->

<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.1//EN"
    "http://www.opensymphony.com/xwork/xwork-1.1.dtd">

<xwork>
  <!-- TODO: better error handling for exceptions needed [MRM-490] -->
  <include file="webwork-default.xml"/>

  <!-- Include plexus-security xwork configurations. -->
  <include file="xwork-security.xml"/>

  <package name="base" extends="webwork-default">
    <interceptors>
      <interceptor name="configuration" class="configurationInterceptor"/>
      <interceptor name="redbackForceAdminUser" class="redbackForceAdminUserInterceptor"/>
      <interceptor name="redbackSecureActions" class="redbackSecureActionInterceptor"/>
      <interceptor name="redbackAutoLogin" class="redbackAutoLoginInterceptor"/>
      <interceptor name="redbackPolicyEnforcement" class="redbackPolicyEnforcementInterceptor"/>
      <interceptor name="paramFilter" class="com.opensymphony.xwork.interceptor.ParameterFilterInterceptor"/>

      <interceptor-stack name="configuredArchivaStack">
        <interceptor-ref name="redbackForceAdminUser"/>
        <interceptor-ref name="redbackAutoLogin"/>
        <interceptor-ref name="defaultStack"/>
        <interceptor-ref name="paramFilter">
          <param name="blocked">externalResult</param>
        </interceptor-ref>
        <interceptor-ref name="redbackSecureActions"/>
        <interceptor-ref name="redbackPolicyEnforcement"/>
        <interceptor-ref name="configuration"/>
        <interceptor-ref name="validation">
          <param name="excludeMethods">input,back,cancel,browse</param>
        </interceptor-ref>
        <interceptor-ref name="workflow">
          <param name="excludeMethods">input,back,cancel,browse</param>
        </interceptor-ref>
      </interceptor-stack>

      <interceptor-stack name="unconfiguredArchivaStack">
        <interceptor-ref name="redbackForceAdminUser"/>
        <interceptor-ref name="redbackAutoLogin"/>
        <interceptor-ref name="defaultStack"/>
        <interceptor-ref name="redbackPolicyEnforcement"/>
        <interceptor-ref name="redbackSecureActions"/>
        <interceptor-ref name="validation">
          <param name="excludeMethods">input,back,cancel,browse</param>
        </interceptor-ref>
        <interceptor-ref name="workflow">
          <param name="excludeMethods">input,back,cancel,browse</param>
        </interceptor-ref>
      </interceptor-stack>

      <interceptor-stack name="configuredPrepareParamsStack">
        <!-- <interceptor-ref name="prepare" /> -->
        <interceptor-ref name="params"/>
        <interceptor-ref name="configuredArchivaStack"/>
      </interceptor-stack>
    </interceptors>

    <!-- Default interceptor stack. -->
    <default-interceptor-ref name="configuredArchivaStack"/>

    <global-results>
      <!-- The following security-* result names arrive from the plexus-security package -->

      <result name="security-login-success" type="redirect-action">index</result>
      <result name="security-login-cancel" type="redirect-action">index</result>
      <result name="security-login-locked" type="redirect-action">
        <param name="infoMessage">Account Locked</param>
        <param name="actionName">index</param>
      </result>
      <result name="security-logout" type="redirect-action">index</result>
      <result name="requires-authentication" type="redirect-action">
        <param name="actionName">login</param>
        <param name="namespace">/security</param>
      </result>
      <result name="requires-authorization" type="redirect-action">
        <param name="actionName">login</param>
        <param name="namespace">/security</param>
      </result>
      <result name="security-register-success" type="redirect-action">
        <param name="actionName">login</param>
        <param name="namespace">/security</param>
      </result>
      <result name="security-register-cancel" type="redirect-action">
        <param name="actionName">login</param>
        <param name="namespace">/security</param>
      </result>
      <result name="security-account-success" type="redirect-action">index</result>
      <result name="security-account-cancel" type="redirect-action">
        <param name="actionName">login</param>
        <param name="namespace">/security</param>
      </result>
      <result name="security-admin-user-created" type="redirect-action">
        <param name="actionName">login</param>
        <param name="namespace">/security</param>
      </result>
      <result name="security-admin-user-needed" type="redirect-action">
        <param name="actionName">addadmin</param>
        <param name="namespace">/security</param>
      </result>
      <result name="security-must-change-password" type="redirect-action">
        <param name="actionName">password</param>
        <param name="namespace">/security</param>
      </result>

      <!-- Generic Catchall for those action configurations that forget to
           include a result for 'error' -->
      <result name="error">/WEB-INF/jsp/generalError.jsp</result>
      <result name="access_to_no_repos">/WEB-INF/jsp/accessToNoRepos.jsp</result>
    </global-results>
  </package>
  
  <!-- Configuration for the default package. -->
  <package name="default" extends="base" namespace="/">

    <!-- This is the redirection facility for plexus-security,
         allowing plexus-security to call out from its own set of actions
         into the application webapp, using global result names. -->
    <action name="redbackRedirect" class="redback-redirect" method="redirect">
      <result type="redirect-action">browse</result>
    </action>

    <action name="index" class="searchAction" method="input">
      <result name="input">/WEB-INF/jsp/quickSearch.jsp</result>
    </action>
	
    <action name="quickSearch" class="searchAction" method="quickSearch">
      <result name="input">/WEB-INF/jsp/quickSearch.jsp</result>
      <result>/WEB-INF/jsp/results.jsp</result>
      <result name="error">/WEB-INF/jsp/quickSearch.jsp</result>
    </action>

    <action name="findArtifact" class="searchAction" method="input">
      <result name="input">/WEB-INF/jsp/findArtifact.jsp</result>
    </action>

	<action name="upload" class="uploadAction" method="input">      
      <result name="input">/WEB-INF/jsp/upload.jsp</result>
      <result name="error">/WEB-INF/jsp/upload.jsp</result>
      <result name="success">/WEB-INF/jsp/upload.jsp</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
      <interceptor-ref name="fileUpload"/>
    </action>

    <action name="checksumSearch" class="searchAction" method="findArtifact">
      <result name="input">/WEB-INF/jsp/findArtifact.jsp</result>
      <result name="results">/WEB-INF/jsp/results.jsp</result>
      <result name="error">/WEB-INF/jsp/findArtifact.jsp</result>
      <result name="artifact" type="redirect">
        /browse/${databaseResults.get(0).getGroupId()}/${databaseResults.get(0).getArtifactId()}/${databaseResults.get(0).getVersion()}
      </result>
    </action>    

    <action name="browse" class="browseAction" method="browse">
      <result>/WEB-INF/jsp/browse.jsp</result>
    </action>

    <action name="browseGroup" class="browseAction" method="browseGroup">
      <result>/WEB-INF/jsp/browse.jsp</result>
    </action>

    <action name="browseArtifact" class="browseAction" method="browseArtifact">
      <result>/WEB-INF/jsp/browse.jsp</result>
    </action>

    <action name="showArtifact" class="showArtifactAction" method="artifact">
      <result name="error">/WEB-INF/jsp/generalError.jsp</result>
      <result name="success">/WEB-INF/jsp/showArtifact.jsp</result>
    </action>

    <action name="showArtifactMailingLists" class="showArtifactAction" method="mailingLists">
      <result>/WEB-INF/jsp/showArtifact.jsp</result>
    </action>

    <action name="showArtifactReports" class="showArtifactAction" method="reports">
      <result>/WEB-INF/jsp/showArtifact.jsp</result>
    </action>

    <action name="showArtifactDependencies" class="showArtifactAction" method="dependencies">
      <result>/WEB-INF/jsp/showArtifact.jsp</result>
    </action>

    <action name="showArtifactDependees" class="showArtifactAction" method="dependees">
      <result>/WEB-INF/jsp/showArtifact.jsp</result>
    </action>

    <action name="showArtifactDependencyTree" class="showArtifactAction" method="dependencyTree">
      <result>/WEB-INF/jsp/artifact/dependencyTree.jsp</result>
    </action>

  </package>

  <package name="components" namespace="/components" extends="webwork-default">
    <default-interceptor-ref name="basicStack"/>
    <action name="companyInfo" class="organisationInfo">
      <result>/WEB-INF/jsp/components/companyLogo.jsp</result>
    </action>
  </package>

  <!-- Configuration for the admin package. -->
  <package name="admin" namespace="/admin" extends="base">

    <action name="index" class="repositoriesAction" method="input">
      <result name="input">/WEB-INF/jsp/admin/repositories.jsp</result>
    </action>
    
    <!-- .\ REPOSITORY GROUPS \._______________________________________ -->
    
    <action name="repositoryGroups" class="repositoryGroupsAction" method="input">
      <result name="input">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
    </action>
    
    <action name="addRepositoryGroup" class="repositoryGroupsAction" method="addRepositoryGroup">
      <result name="input">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
      <result name="error">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
      <result name="success" type="redirect-action">repositoryGroups</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>
    
    <action name="confirmDeleteRepositoryGroup" class="deleteRepositoryGroupAction" method="confirmDelete">
      <result name="input">/WEB-INF/jsp/admin/deleteRepositoryGroup.jsp</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>
    
    <action name="deleteRepositoryGroup" class="deleteRepositoryGroupAction" method="delete">
      <result name="input">/WEB-INF/jsp/admin/deleteRepositoryGroup.jsp</result>
      <result name="error">/WEB-INF/jsp/admin/deleteRepositoryGroup.jsp</result>
      <result name="success" type="redirect-action">repositoryGroups</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>
	
    <action name="addRepositoryToGroup" class="repositoryGroupsAction" method="addRepositoryToGroup">
      <result name="input">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
      <result name="error">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
      <result name="success" type="redirect-action">repositoryGroups</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>
	
    <action name="removeRepositoryFromGroup" class="repositoryGroupsAction" method="removeRepositoryFromGroup">
      <result name="input">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
      <result name="error">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
      <result name="success" type="redirect-action">repositoryGroups</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>
	
    <action name="sortDownRepositoryFromGroup" class="sortRepositoriesAction" method="sortDown">
      <result name="input">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
      <result name="error">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
      <result name="success" type="redirect-action">repositoryGroups</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>
	
    <action name="sortUpRepositoryFromGroup" class="sortRepositoriesAction" method="sortUp">
      <result name="input">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
      <result name="error">/WEB-INF/jsp/admin/repositoryGroups.jsp</result>
      <result name="success" type="redirect-action">repositoryGroups</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <!-- .\ REPOSITORIES \.____________________________________________ -->

    <action name="repositories" class="repositoriesAction" method="input">
      <result name="input">/WEB-INF/jsp/admin/repositories.jsp</result>
      <result name="confirm" type="redirect-action">deleteRepository</result>
    </action>

    <action name="indexRepository" class="schedulerAction" method="scanRepository">
      <result type="redirect-action">repositories</result>
    </action>
    
    <action name="addRepository" class="addManagedRepositoryAction" method="input">
      <result name="input">/WEB-INF/jsp/admin/addRepository.jsp</result>
      <result name="error">/WEB-INF/jsp/admin/addRepository.jsp</result>
      <result name="confirm">/WEB-INF/jsp/admin/confirmAddRepository.jsp</result>
      <result name="success" type="redirect-action">repositories</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <action name="editRepository" class="editManagedRepositoryAction" method="input">
      <result name="input">/WEB-INF/jsp/admin/editRepository.jsp</result>
      <result name="error">/WEB-INF/jsp/admin/editRepository.jsp</result>
      <result name="success" type="redirect-action">repositories</result>
      <result name="confirm">/WEB-INF/jsp/admin/confirmAddRepository.jsp</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <action name="confirmDeleteRepository" class="deleteManagedRepositoryAction" method="confirmDelete">
      <result name="input">/WEB-INF/jsp/admin/deleteRepository.jsp</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <action name="deleteRepository" class="deleteManagedRepositoryAction" method="delete">
      <result name="input">/WEB-INF/jsp/admin/deleteRepository.jsp</result>
      <result name="error">/WEB-INF/jsp/admin/deleteRepository.jsp</result>
      <result name="success" type="redirect-action">repositories</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <action name="addRemoteRepository" class="addRemoteRepositoryAction" method="input">
      <result name="input">/WEB-INF/jsp/admin/addRemoteRepository.jsp</result>
      <result name="error">/WEB-INF/jsp/admin/addRemoteRepository.jsp</result>
      <result name="success" type="redirect-action">repositories</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <action name="editRemoteRepository" class="editRemoteRepositoryAction" method="input">
      <result name="input">/WEB-INF/jsp/admin/editRemoteRepository.jsp</result>
      <result name="error">/WEB-INF/jsp/admin/editRemoteRepository.jsp</result>
      <result name="success" type="redirect-action">repositories</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <action name="confirmDeleteRemoteRepository" class="deleteRemoteRepositoryAction" method="confirmDelete">
      <result name="input">/WEB-INF/jsp/admin/deleteRemoteRepository.jsp</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <action name="deleteRemoteRepository" class="deleteRemoteRepositoryAction" method="delete">
      <result name="input">/WEB-INF/jsp/admin/deleteRemoteRepository.jsp</result>
      <result name="error">/WEB-INF/jsp/admin/deleteRemoteRepository.jsp</result>
      <result name="success" type="redirect-action">repositories</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <!-- .\ PROXY CONNECTORS \.________________________________________ -->

    <action name="proxyConnectors" class="proxyConnectorsAction" method="input">
      <result name="input">/WEB-INF/jsp/admin/proxyConnectors.jsp</result>
    </action>

    <action name="addProxyConnector" class="addProxyConnectorAction" method="input">
      <result name="input">/WEB-INF/jsp/admin/addProxyConnector.jsp</result>
      <result name="success" type="redirect-action">proxyConnectors</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <action name="editProxyConnector" class="editProxyConnectorAction" method="input">
      <result name="input">/WEB-INF/jsp/admin/editProxyConnector.jsp</result>
      <result name="success" type="redirect-action">proxyConnectors</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <action name="sortUpProxyConnector" class="sortProxyConnectorsAction" method="sortUp">
      <result name="input">/WEB-INF/jsp/admin/editProxyConnector.jsp</result>
      <result name="success" type="redirect-action">proxyConnectors</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <action name="sortDownProxyConnector" class="sortProxyConnectorsAction" method="sortDown">
      <result name="input">/WEB-INF/jsp/admin/editProxyConnector.jsp</result>
      <result name="success" type="redirect-action">proxyConnectors</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <action name="deleteProxyConnector" class="deleteProxyConnectorAction" method="confirm">
      <result name="input">/WEB-INF/jsp/admin/deleteProxyConnector.jsp</result>
      <result name="success" type="redirect-action">proxyConnectors</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>
    
    <action name="enableProxyConnector" class="enableProxyConnectorAction" method="confirm">
      <result name="input">/WEB-INF/jsp/admin/enableProxyConnector.jsp</result>
      <result name="success" type="redirect-action">proxyConnectors</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <action name="disableProxyConnector" class="disableProxyConnectorAction" method="confirm">
      <result name="input">/WEB-INF/jsp/admin/disableProxyConnector.jsp</result>
      <result name="success" type="redirect-action">proxyConnectors</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>


    <!-- .\ NETWORK PROXIES \._________________________________________ -->

    <action name="networkProxies" class="networkProxiesAction" method="input">
      <result name="input">/WEB-INF/jsp/admin/networkProxies.jsp</result>
    </action>

    <action name="addNetworkProxy" class="configureNetworkProxyAction" method="add">
      <result name="input">/WEB-INF/jsp/admin/editNetworkProxy.jsp</result>
      <result name="success" type="redirect-action">networkProxies</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <action name="editNetworkProxy" class="configureNetworkProxyAction" method="edit">
      <result name="input">/WEB-INF/jsp/admin/editNetworkProxy.jsp</result>
      <result name="success" type="redirect-action">networkProxies</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <action name="saveNetworkProxy" class="configureNetworkProxyAction" method="save">
      <result name="input">/WEB-INF/jsp/admin/editNetworkProxy.jsp</result>
      <result name="success" type="redirect-action">networkProxies</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <action name="deleteNetworkProxy" class="configureNetworkProxyAction" method="confirm">
      <result name="input">/WEB-INF/jsp/admin/deleteNetworkProxy.jsp</result>
      <result name="success" type="redirect-action">networkProxies</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <!-- .\ REPOSITORY SCANNING \._____________________________________ -->

    <action name="repositoryScanning" class="repositoryScanningAction" method="input">
      <result name="input">/WEB-INF/jsp/admin/repositoryScanning.jsp</result>
      <result name="success" type="redirect-action">
        <param name="actionName">repositoryScanning</param>
      </result>
    </action>

    <!-- .\ DATABASE \.________________________________________________ -->

    <action name="database" class="databaseAction" method="input">
      <result name="input">/WEB-INF/jsp/admin/database.jsp</result>
      <result name="success" type="redirect-action">
        <param name="actionName">database</param>
      </result>
    </action>

    <action name="updateDatabase" class="schedulerAction" method="updateDatabase">
      <result type="redirect-action">database</result>
    </action>

    <!-- .\ CONFIGURATION \.___________________________________________ -->

    <action name="configureAppearance" class="organisationInfo">
      <result name="success">/WEB-INF/jsp/admin/appearance.jsp</result>
    </action>

    <action name="editAppearance" class="editOrganisationInfo" method="input">
      <result name="input">/WEB-INF/jsp/admin/editAppearance.jsp</result>
    </action>

    <action name="saveAppearance" class="editOrganisationInfo">
      <result name="input">/WEB-INF/jsp/admin/editAppearance.jsp</result>
      <result type="redirect-action">
        <param name="actionName">configureAppearance</param>
        <param name="namespace">/admin</param>
      </result>
    </action>

    <!-- .\ LEGACY SUPPORT \.__________________________________________ -->

    <action name="legacyArtifactPath" class="legacyArtifactPathAction" method="input">
      <result name="input">/WEB-INF/jsp/admin/legacyArtifactPath.jsp</result>
      <result name="success" type="redirect-action">
        <param name="actionName">legacyArtifactPath</param>
      </result>
    </action>

    <action name="addLegacyArtifactPath" class="addLegacyArtifactPathAction" method="input">
      <result name="input">/WEB-INF/jsp/admin/addLegacyArtifactPath.jsp</result>
      <result name="error">/WEB-INF/jsp/admin/addLegacyArtifactPath.jsp</result>
      <result name="success" type="redirect-action">legacyArtifactPath</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

    <action name="deleteLegacyArtifactPath" class="deleteLegacyArtifactPathAction" method="delete">
      <result name="input">/WEB-INF/jsp/admin/legacyArtifactPath.jsp</result>
      <result name="error">/WEB-INF/jsp/admin/legacyArtifactPath.jsp</result>
      <result name="success" type="redirect-action">legacyArtifactPath</result>
      <interceptor-ref name="configuredPrepareParamsStack"/>
    </action>

  </package>

  <package name="report" namespace="/report" extends="base">
    <action name="pickReport" class="generateReport" method="input">
      <result name="input">/WEB-INF/jsp/reports/pickReport.jsp</result>
    </action>

    <action name="generateReport" class="generateReport">
      <result name="jasper" type="jasper">
        <param name="location">/WEB-INF/jasperreports/report.jasper</param>
        <param name="dataSource">reports</param>
        <param name="format">HTML</param>
      </result>
      <result name="input">/WEB-INF/jsp/reports/pickReport.jsp</result>
      <result name="blank">/WEB-INF/jsp/reports/blankReport.jsp</result>
      <result>/WEB-INF/jsp/reports/basicReport.jsp</result>
    </action>
  </package>
</xwork>

