Brett Smith asked, "Does anyone know how, via code, to check to see if a particular Verity collection already exists on the ColdFusion server?"
First Answer (Marian Dumitrascu, of GYRATE Internet Solutions):
I would use <CFREGISTRY> to list all collections or verify if a partcular one exists:
To get all collection names into a query:
<CFREGISTRY ACTION="GetAll"
BRANCH="HKEY_LOCAL_MACHINE\SOFTWARE\Allaire\ColdFusion\CurrentVersion\Collec tions"
NAME="q_Collections"
TYPE="String"
SORT="value ASC, entry ASC">
You will get a query with #Entry#, #Type#, and #Value# columns.
or:
<CFREGISTRY ACTION="Get"
BRANCH="HKEY_LOCAL_MACHINE\SOFTWARE\Allaire\ColdFusion\CurrentVersion\Collec tions\MyCollection"
ENTRY="TopLevelDirectory"
TYPE="String"
VARIABLE="RegValue">
If "RegValue" is defined, then that registry key exists, which means that "MyCollection" exists.
Second Answer (Yonah Wolf):
Although I haven't really worked much with dynamic collection creation, off the top of my head, I'd say use a simple CFSearch (i.e., search for something you know should not exist) and wedge it in a CTRY/CFCATCH block. If the try executes properly, the collection exists; if the catch code executes, then the error indicates that the collection does not exist.
For example:
<CFSET Exists=FALSE>
<CFTRY
<CFSEARCH Collection="#Coll_to_Check#"... Criteria="FOO"
<CFSET Exists=TRUE
<CFCATCH type="ANY"
<CFSET Exists=FALSE
</CFCATCH
</CFTRY
<CFIF Exists
Collection Exists
<CFELSE
Collection doesn't exist
</CFIF>
Third Answer (Michael Dinowitz):
You can use CFDIRECTORY to read the c:\cfusion\verity directory to see all the collections there. If the collection is in another location, then you need to use CFREGISTRY to read all the collections contained there.