The code looks reasonable enough, but I would call fn:error() if $forest-name 
does not exist. Or at least xdmp:log a message. That way it will be easier to 
debug a typo in the forest name.

Have you checked ErrorLog.txt for messages?

On the filesystem, do you see an update to assignments.xml? If so, can you 
'diff -u assignments_1.xml assignments.xml '?

-- Mike

On 21 May 2013, at 03:35 , Jakob Fix <[email protected]> wrote:

> Hello,
> 
> I'd like to create and delete forests programmatically. Creation is fine, and 
> deletion kind of works ... but here is the problem:
> 
> If I call the script below via the ML ant task <ml:query> it returns without 
> error, but the forest still exists.
> If I call the script from the query console, the forest gets deleted just 
> fine.
> 
> The XCC connection string used specifies the admin user for this task. Also, 
> all other tasks (database creation, deletion, attachment of database to 
> forest, etc.) using the same XCC connection all work fine, except the forest 
> deletion.
> 
> Thanks for any ideas you may have ...
> 
> cheers,
> Jakob.
> 
> xquery version "1.0-ml";
> 
> (:
>   delete a forest and all its data
>   
>   TODO: This doesn't actually delete an existing forest. 
>         If you call this from within qconsole it works, though ...
>         I don't understand!
> :)
> 
> import module namespace admin = "http://marklogic.com/xdmp/admin"; 
>   at "/MarkLogic/admin.xqy";
> 
> declare variable $forest-name as xs:string external;
> 
> (: -------------------------------------------------------------------------- 
> :)
> (: delete forest ------------------------------------------------------------ 
> :)
> (: -------------------------------------------------------------------------- 
> :)
> 
> let $config := admin:get-configuration()
> 
> let $config := if (admin:forest-exists($config, $forest-name))
>   then
>     admin:forest-delete(
>        $config
>       ,(admin:forest-get-id($config, $forest-name))
>       ,fn:true() (: force data deletion :)
>     )
>   else
>     $config
> 
> (: -------------------------------------------------------------------------- 
> :)
> (: commit changes ----------------------------------------------------------- 
> :)
> (: -------------------------------------------------------------------------- 
> :)
> 
> return admin:save-configuration($config);
> 
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to