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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;
  
    result := DBMS_XDB.createresource('/public/xxas/emp/view/edit_rest_method.xml',
'<View title="Edit rest method" defaultFormHandler="xxas_rest_method_pkg.post_method_update" submitLabel="{message.XXAS_RB_COM_SAVE}">
  <CreateFields>
  <Hidden    id="SERVICE_NAME"/>
  <Combolist id="METHOD_NAME" label="Method name" required="true" longlist="true" enabled="false" listProvider="REST:rest-method/getmethodname?q={searchText}"/>
  <TextInput id="DESCRIPTION" label="Description" />
  <Poplist   id="METHOD" label="Method" required="true" listProvider="VALUE_SET_NAME:Applaud Rest Method Type"/>
  <TextInput id="PATH_TEMPLATE" label="Path"/>
  <TextInput id="CONSUMES" label="Consumes" required="true"/>
  <TextInput id="PRODUCES" label="Produces" required="true"/>
  <Poplist   id="PROVIDER_TYPE" label="Provider" required="true" listProvider="VALUE_SET_NAME:Applaud Rest Provider Type"/>
  <Poplist   id="ROOT_ELE" label="Remove root element" required="true" showAsBoolean="true" value="Y" listProvider="LOOKUP_TYPE:YES_NO" positiveBooleanValue="Y" hideIf="(model.PROVIDER_TYPE.value.id != &apos;SQL&apos;)"/>
  <TextArea  id="SQL" label="SQL" description="For samples and help on writing this, please see &lt;a href=&quot;http://docs.applaudsolutions.com/rest-apis&quot; target=&quot;_blank&quot;&gt; REST APIs &lt;/&gt;" maxChars="4000" required="true" hideIf="(model.PROVIDER_TYPE.value.id != &apos;SQL&apos;)" />
  <TextArea  id="PLSQL" label="PLSQL" description="For samples and help on writing this, please see &lt;a href=&quot;http://docs.applaudsolutions.com/rest-apis&quot; target=&quot;_blank&quot;&gt; REST APIs &lt;/&gt;" maxChars="4000" required="true" hideIf="(model.PROVIDER_TYPE.value.id != &apos;PLSQL&apos;)" />
  <Combolist id="XMLDEF" label="XML Publisher Data Definition" description="Set this to support dynamic XML Publisher documents when requesting with the Content Type application/pdf" longlist="true" listProvider="REST:rest-method/getddcode?q={searchText}"/>
  </CreateFields>
</View>' );
xxas_forms_pkg.update_forms_resource('/public/xxas/emp/view/edit_rest_method.xml');
END;
/
COMMIT;
EXIT;