<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/webflow
    http://www.springframework.org/schema/webflow/spring-webflow-1.0.xsd">

  <start-state idref="init"/>

  <action-state id="init">
    <action bean="profile.friendSubscribeAction" method="init"/>
    <transition to="decide"/>
  </action-state>

  <action-state id="decide">
    <action bean="profile.friendSubscribeAction" method="decide"/>
    <transition on="done" to="friendAllow"/>
    <transition on="form" to="initMailForm"/>
  </action-state>

  <end-state id="friendAllow" view="externalRedirect:/profile/friendAllow.html?userCode=${flowScope.to.code}"/>

  <action-state id="initMailForm">
    <action bean="profile.friendSubscribeAction" method="initMailForm"/>
    <transition on="success" to="mailSend"/>
  </action-state>

  <subflow-state id="mailSend" flow="mail/create-sub-flow">
    <attribute-mapper>
      <input-mapper>
        <input-attribute name="mail" required="true"/>
        <input-attribute name="unmodifiableTo" required="true"/>
        <input-attribute name="pageTitleCode" required="true"/>
        <input-attribute name="pageDescriptionCode" required="true"/>
        <input-attribute name="formSubmitCode" required="true"/>
      </input-mapper>
    </attribute-mapper>
    <transition on="finish" to="subscribe"/>
  </subflow-state>

  <action-state id="subscribe">
    <action bean="profile.friendSubscribeAction" method="subscribe"/>
    <transition to="finish"/>
  </action-state>

  <end-state id="finish" view="profile.FriendSubscribeSuccess"/>

</flow>