Skip to content

Commit

Permalink
Merge pull request #12656 from ashera96/master
Browse files Browse the repository at this point in the history
Fix export flow to detect thumbnail changes from the current API as opposed to the latest revision
  • Loading branch information
RakhithaRR authored Oct 12, 2024
2 parents 53ad6db + e5817e5 commit 66db498
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public static File exportApi(APIProvider apiProvider, APIIdentifier apiIdentifie

CommonUtil.createDirectory(archivePath);
if (preserveDocs) {
addThumbnailToArchive(archivePath, apiIdentifier, apiProvider);
addThumbnailToArchive(archivePath, apiIdentifier, apiProvider, currentApiUuid);
addDocumentationToArchive(archivePath, apiIdentifier, exportFormat, apiProvider,
APIConstants.API_IDENTIFIER_TYPE);
}
Expand Down Expand Up @@ -313,7 +313,8 @@ public static File exportApiProduct(APIProvider apiProvider, APIProductIdentifie
CommonUtil.createDirectory(archivePath);

if (preserveDocs) {
addThumbnailToArchive(archivePath, apiProductIdentifier, apiProvider);
addThumbnailToArchive(archivePath, apiProductIdentifier, apiProvider,
apiProductDtoToReturn.getRevisionedApiProductId());
addDocumentationToArchive(archivePath, apiProductIdentifier, exportFormat, apiProvider,
APIConstants.API_PRODUCT_IDENTIFIER_TYPE);
}
Expand Down Expand Up @@ -345,16 +346,17 @@ public static File exportApiProduct(APIProvider apiProvider, APIProductIdentifie
* @param archivePath File path to export the thumbnail image
* @param identifier ID of the requesting API or API Product
* @param apiProvider API Provider
* @throws APIImportExportException If an error occurs while retrieving image from the registry or
* storing in the archive directory
* @param currentUuid UUID of the API or API Product
* @throws APIImportExportException If an error occurs while retrieving image from the registry or storing in the
* archive directory
*/
public static void addThumbnailToArchive(String archivePath, Identifier identifier, APIProvider apiProvider)
throws APIImportExportException, APIManagementException {
public static void addThumbnailToArchive(String archivePath, Identifier identifier, APIProvider apiProvider,
String currentUuid) throws APIImportExportException, APIManagementException {

String tenantDomain = RestApiCommonUtil.getLoggedInUserTenantDomain();
String localImagePath = archivePath + File.separator + ImportExportConstants.IMAGE_RESOURCE;
try {
ResourceFile thumbnailResource = apiProvider.getIcon(identifier.getUUID(), tenantDomain);
ResourceFile thumbnailResource = apiProvider.getIcon(currentUuid, tenantDomain);
if (thumbnailResource != null) {
String mediaType = thumbnailResource.getContentType();
String extension = ImportExportConstants.fileExtensionMapping.get(mediaType);
Expand Down

0 comments on commit 66db498

Please sign in to comment.