/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2015 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/signin.xml');

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/signin.xml',
'<View sendBasicAuth="true" sendToken="true" basicAuthUsernameField="USERNAME" basicAuthPasswordField="PASSWORD" tokenField="TOKEN" postToHref="/OA_HTML/applaud/auth/signin" formHelp="{message.XXAS_SIGNIN_HELP}" title="Signin" clientAutosave="false">

  <CreateFields>
    <TextInput id="USERNAME" label="{message.XXAS_SIGNIN_EMAIL}" emptyValue="{message.XXAS_FORGOT_UNAME_PROMPT}" description="{message.XXAS_SIGNIN_UN_DESC}" required="true" disableAutoCorrect="true" disableAutocapitalize="true" disableSpellcheck="true"/>
    <Password id="PASSWORD" label="{message.XXAS_SIGNIN_PASSWORD}" emptyValue="{message.XXAS_SIGNIN_PASSWORD_PROMPT}" required="true"/>
    <Hidden id="AUTH_USE_2FA" fixedValue="PROFILE:XXAS_AUTH_USE_2FA"/>
    <TextInput id="TOKEN" label="{message.XXAS_RB_COM_TOKEN}" emptyValue="{message.XXAS_RB_COM_TOKEN_PROMPT}" required="true" hideIf="!model.AUTH_USE_2FA.value || model.AUTH_USE_2FA.value == &apos;N&apos;"/>
    <Poplist id="LANGUAGE" refreshOnChange="true" label="{message.XXAS_SIGNIN_LANGUAGE}" listProvider="VALUE_SET_NAME:XXAS_Installed_Languages" enabled="true" hideIf="!field.values || field.values.length &lt;= 1"/>
    <Submit label="{message.XXAS_PG_SIGN_IN_T}"/>
    <Link label="{message.XXAS_SIGNIN_RESET_PWD}" pageId="reset-password" target="modal"/>
    <Html id="PRIVACY_POLICY" value="{message.XXAS_COM_PRIVACY_POLICY}"/>
  </CreateFields>

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