Skip to main content
Participant
March 8, 2023
Answered

CF Admin API - collections

  • March 8, 2023
  • 2 replies
  • 439 views

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 has been closed for replies.
Correct answer BKBK

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>");

 

 

2 replies

BKBK
Community Expert
Community Expert
March 8, 2023

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.

     


     
BKBK
Community Expert
BKBKCommunity ExpertCorrect answer
Community Expert
March 8, 2023

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>");

 

 

usmc-retAuthor
Participant
March 8, 2023

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. 

BKBK
Community Expert
Community Expert
March 8, 2023

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