--
set echo on
--
declare
  res boolean; 
begin

  if (dbms_xdb.existsResource('/home/%USER%/ImageLibrary')) then
    dbms_xdb.deleteResource('/home/%USER%/ImageLibrary',dbms_xdb.DELETE_RECURSIVE_FORCE);
  end if;
  
  if (dbms_xdb.existsResource('/publishedContent/allImages/camera')) then
    dbms_xdb.deleteResource('/publishedContent/allImages/camera',dbms_xdb.DELETE_RECURSIVE_FORCE);
  end if;

  if (dbms_xdb.existsResource('/publishedContent/allImages/dateTaken')) then
    dbms_xdb.deleteResource('/publishedContent/allImages/dateTaken',dbms_xdb.DELETE_RECURSIVE_FORCE);
  end if;

  if not dbms_xdb.existsResource('/publishedContent/allImages') then
    res := dbms_xdb.createFolder('/publishedContent/allImages');
  end if;

  dbms_xdb.setAcl('/publishedContent/allImages','/sys/acls/bootstrap_acl.xml');

  res := dbms_xdb.createFolder('/publishedContent/allImages/camera');
  res := dbms_xdb.createFolder('/publishedContent/allImages/dateTaken');

end;
/
quit
