/* $Id:*/
/*============================================================================*
 |                 Copyright (c) 2014 Applaud Solutions UK Ltd                |
 |                             All rights reserved                            |
 *===========================================================================*/

SET VERIFY OFF
SET FEEDBACK OFF
SET SCAN OFF
WHENEVER OSERROR  EXIT FAILURE ROLLBACK
WHENEVER SQLERROR EXIT FAILURE ROLLBACK



DECLARE 

  e_dir_exists EXCEPTION;
  PRAGMA EXCEPTION_INIT(e_dir_exists, -31003);

  e_does_not_exists EXCEPTION;
  PRAGMA EXCEPTION_INIT(e_does_not_exists , -31001);

  result boolean;
  
BEGIN

  BEGIN

    result := DBMS_XDB.createfolder('/public/xxas/');
    result := DBMS_XDB.createfolder('/public/xxas/emp/');
    result := DBMS_XDB.createfolder('/public/xxas/emp/view/');

  EXCEPTION
    WHEN e_dir_exists THEN
      NULL;
  END;

  
  BEGIN

    DBMS_XDB.DeleteResource('/public/xxas/emp/view/troubleshoot-authentication.xml');

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/troubleshoot-authentication.xml',
'<View title="{message.XXAS_2FA_TROUBLESHOOT_AUTH}" showSubmit="true" defaultFormHandler="xxas_com_2fa_pkg.troubleshoot_form_handler" submitLabel="{message.XXAS_RB_COM_NEXT}">

   <EditFields>

		<Poplist id="OPTIONS" label="{message.XXAS_2FA_OPTIONS}" enabled="true" listProvider="LOOKUP_TYPE:XXAS_2FA_OPTIONS_FOR_CODE" visible="true" required="true" style="radio" refreshOnChange="true" />
		<Combolist id="PHONE_LIST" label="{message.XXAS_2FA_NUMBERS}" listProvider="REST:2FA/phoneNumber" required="true" />
		<Poplist id="NUMBER_EXISTS" label="{message.XXAS_2FA_NUMBER_EXISTS}" listProvider="LOOKUP_TYPE:YES_NO" showAsRadio="false" showAsBoolean="true" positiveBooleanValue="Y" refreshOnChange="true" />
		<Html id="ERR_MESSAGE" enabled="false" value="{message.XXAS_2FA_ERROR_MSG}" />
		<TextInput id="ENTER_BACKUP_CODE" label="{message.XXAS_2FA_ONE_TIME_CODE}" required="true" placeholder="{message.XXAS_2FA_ENTER_BACKUP_CODE}" />
		<Html id="WRN_MESSAGE" enabled="false" value="{message.XXAS_2FA_WRN_MSG}"/>
   </EditFields>

</View>' );
  xxas_forms_pkg.update_forms_resource('/public/xxas/emp/view/troubleshoot-authentication.xml');
END;
/
COMMIT;
EXIT;
