Skip to content

Commit

Permalink
#26633 Refactor finding site by name into a separate method
Browse files Browse the repository at this point in the history
  • Loading branch information
jgambarios committed Jan 31, 2024
1 parent 8fafdce commit 000acdd
Showing 1 changed file with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ private SiteView verifyAndReturnSiteAfterCompletion(final String operation,
* @param isArchived whether the site is archived
* @return A completable future with the site view
*/
@ActivateRequestContext
private CompletableFuture<SiteView> verifyAndReturnSiteAfterCompletion(
final String siteName, final boolean isSiteLive, final boolean isArchived
) {
Expand All @@ -329,8 +330,6 @@ private CompletableFuture<SiteView> verifyAndReturnSiteAfterCompletion(

CompletableFuture<SiteView> future = new CompletableFuture<>();

final SiteAPI siteAPI = clientFactory.getClient(SiteAPI.class);

// The task we are scheduling (status polling)
Runnable task = new Runnable() {

Expand All @@ -342,9 +341,7 @@ public void run() {

if (System.currentTimeMillis() < end) {
try {
var response = siteAPI.findByName(
GetSiteByNameRequest.builder().siteName(siteName).build()
);
var response = findSiteByName(siteName);
if ((response != null && response.entity() != null) &&
((response.entity().isLive() != null &&
response.entity().isLive().equals(isSiteLive)) &&
Expand Down Expand Up @@ -387,4 +384,21 @@ public void run() {
return future;
}

/**
* Retrieves a site by its name.
*
* @param siteName The name of the site.
* @return The ResponseEntityView containing the SiteView object representing the site.
*/
@ActivateRequestContext
public ResponseEntityView<SiteView> findSiteByName(final String siteName) {

final SiteAPI siteAPI = clientFactory.getClient(SiteAPI.class);

// Execute the REST call to retrieve folder contents
return siteAPI.findByName(
GetSiteByNameRequest.builder().siteName(siteName).build()
);
}

}

0 comments on commit 000acdd

Please sign in to comment.