<?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="community.entryCreateAction"/>
    <transition on="success" to="anonymousOrNot"/>
  </action-state>

  <decision-state id="anonymousOrNot">
    <if test="${flowScope.isAnonymous}" then="captcha" else="form"/>
  </decision-state>

  <subflow-state flow="captcha-sub-flow" id="captcha">
    <transition on="finish" to="form"/>
  </subflow-state>

  <subflow-state flow="thread/entryForm-sub-flow" id="form">
    <attribute-mapper>
      <input-mapper>
        <input-attribute name="threadId" required="true"/>
        <input-attribute name="subjectDisabled" required="true"/>
      </input-mapper>
    </attribute-mapper>
    <transition on="finish" to="finish"/>
  </subflow-state>

  <decision-state id="finish">
    <if test="${flowScope.community.class.simpleName == 'SingleThreadCommunity'}" then="singleThreadFinish"/>
    <if test="${flowScope.community.class.simpleName == 'MultiThreadCommunity'}" then="multiThreadFinish"/>
  </decision-state>

  <end-state id="singleThreadFinish" view="externalRedirect:/community/${flowScope.community.code}/index.html"/>
  <end-state id="multiThreadFinish" view="externalRedirect:/community/${flowScope.community.code}/${flowScope.threadId}/index.html"/>

</flow>
