Skip to main content
Participant
Mar 8, 2023 1:42 AM UTC
Answered

CF Admin API - collections

I am trying to access the collections api for the CF Admin and have a question.  I am executing a call to the reloadCollection method but it does not appear to return any value.  Here is a sample snippet of the code I am trying to execute/

collectionObj = createObject("component","cfide.adminapi.collections");
collectionObj.reloadCollection("testCollection");

The above executes without issue but if I try setting the method call to a variable and then try and dump the variable the code generates an error that the variable was undefined.

tempTest = collectionObj.reloadCollection("testCollection");
writeDump(var="#tempTest#",format="html");

Is there a way to determine if the call has executed successfully? 

This topic is closed to new replies. Start a new post to keep the conversation going.
BKBK
BKBKCorrect answer
Community Expert
Mar 8, 2023 2:03 PM UTC

The variable is undefined because reloadCollection() has void return-type.

You could test for a successful reload as follows:

 

try {
	collectionObj = createObject("component","cfide.adminapi.collections");
	collectionObj.reloadCollection("testCollection");	
	collectionReloaded=true;
} catch (any xception) {
	collectionReloaded=false;
	//writedump(var=xception, label="ReloadCollection failure");
}
writeoutput("<p>Is testCollection reloaded: " & collectionReloaded & "</p>");

 

 

4 replies

BKBK
Community Expert
Community Expert
Mar 8, 2023 4:52 PM UTC

Is there a way to determine if the call has executed successfully? 


By @usmc-ret

 

There is a workaround that does not involve code. It goes as follows:

  1.  Open the ColdFusion Administrator. Navigate to Data & Services > Solr Server. Read off the Solr port number. Mine is 8993.

     




     
     
  2.  Launch the following URL in the browser: http://127.0.0.1:{portNumber}/solr/#/ 
         In my case, this is: http://127.0.0.1:8993/solr/#/ 

     


     

     

    3. Click on the Core Admin menu. Select the collection and press the Reload button.

     


     
Translate
BKBK
Community Expert
BKBKCommunity ExpertCorrect answer
Community Expert
Mar 8, 2023 2:03 PM UTC

The variable is undefined because reloadCollection() has void return-type.

You could test for a successful reload as follows:

 

try {
	collectionObj = createObject("component","cfide.adminapi.collections");
	collectionObj.reloadCollection("testCollection");	
	collectionReloaded=true;
} catch (any xception) {
	collectionReloaded=false;
	//writedump(var=xception, label="ReloadCollection failure");
}
writeoutput("<p>Is testCollection reloaded: " & collectionReloaded & "</p>");

 

 

Translate
usmc-retAuthor
Participant
Mar 8, 2023 2:39 PM UTC

BKBK - okay I was expect some type of return as when I dump the collectionObj it says the return type is "Any".  Definitely appreciate the code snippet. 

Translate
BKBK
Community Expert
Community Expert
Mar 8, 2023 3:20 PM UTC

I can see the confusion. It is caused because a returntype of "any" includes "void".

 

That API documentation should indeed have been more specific. I have created a bug report: https://tracker.adobe.com/#/view/CF-4217254 

Translate