<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Copyright 2008 IHE International (http://www.ihe.net)
 *
 * Licensed 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.
 -->

 <pages xmlns="http://jboss.com/products/seam/pages"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns:ui="http://java.sun.com/jsf/facelets"
		xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.2.xsd"
		login-view-id="login.xhtml">


	<page view-id="*">
		<navigation from-action="#{identity.logout}">
			<redirect view-id="/home.xhtml"/>
		</navigation>
	</page>


	<exception
		class="org.jboss.seam.framework.EntityNotFoundException">
		<redirect view-id="/error.xhtml">
			<message>Not found</message>
		</redirect>
	</exception>

	<exception class="javax.persistence.EntityNotFoundException">
		<redirect view-id="/error.xhtml">
			<message>Not found</message>
		</redirect>
	</exception>

	<exception class="javax.persistence.OptimisticLockException">
		<end-conversation />
		<redirect view-id="/error.xhtml">
			<message>
				Another user changed the same data, please try again
			</message>
		</redirect>
	</exception>

	<exception class="org.jboss.seam.security.AuthorizationException">
		<redirect view-id="/error.xhtml">
			<message>You don't have permission to do this</message>
		</redirect>
	</exception>
	<exception class="javax.faces.application.ViewExpiredException">
		<redirect view-id="/home.xhtml">
           <message>Your session has timed out, please try again</message>
		</redirect>
	</exception>
	<!--<exception class="javax.faces.application.ViewExpiredException">
		<redirect view-id="/error.xhtml">
           <message>Your session has timed out, please try again</message>
		</redirect>
	</exception>

	--><exception>
		<redirect view-id="/error.xhtml">
			<message>Unexpected error, please try again</message>
		</redirect>
	</exception>

	
	<!-- Home - Database checking    -->
	<page view-id="/home.xhtml"
		action="#{applicationPreferenceManager.getApplicationDatabaseInitializationFlag()}">
		
		<navigation>
			<rule if-outcome='false'>
				<redirect view-id="/initializationError.xhtml">
										
				</redirect>
			</rule>
			
		</navigation>
	</page>
	
</pages>
