Add docUrl into metadata.

Nipuni Kavindya 2 months ago
parent fade158e6d
commit dbd0a04723

@ -65,6 +65,13 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ
initializeWhiteLabelThemes();
}
/**
* Initializes white label themes for a tenant by retrieving white label metadata and updating it if necessary.
* If the white label metadata is found and the "DocUrl" is missing,it updates the metadata with the default value
* for DocUrl.
*
* @throws MetadataManagementException if an error occurs while managing metadata or transactions.
*/
private void initializeWhiteLabelThemes() throws MetadataManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
WhiteLabelTheme defaultTheme = getDefaultWhiteLabelTheme();
@ -83,8 +90,7 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ
log.debug("WhiteLabel theme's DocUrl was missing and has been updated to the default value " +
"for tenant: " + tenantId);
}
}
catch (MetadataManagementDAOException e) {
} catch (MetadataManagementDAOException e) {
MetadataManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred while fetching white label metadata for tenant: " + tenantId;
log.error(msg, e);
@ -165,9 +171,9 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ
/**
* Useful to get white label image file response from provided url
*/
private FileResponse getImageFileResponseFromUrl(String url) throws IOException, NotFoundException {
private FileResponse getImageFileResponseFromUrl(String url) throws IOException, NotFoundException {
FileResponse fileResponse = new FileResponse();
try(CloseableHttpClient client = HttpClients.createDefault()) {
try (CloseableHttpClient client = HttpClients.createDefault()) {
HttpGet imageGetRequest = new HttpGet(url);
HttpResponse response = client.execute(imageGetRequest);
InputStream imageStream = response.getEntity().getContent();
@ -389,9 +395,9 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ
* those can be passed to this method in order to restore.
*
* @param existingFavicon existing favicon image file
* @param existingLogo existing logo image file
* @param existingLogo existing logo image file
*/
private void restoreWhiteLabelImages(File existingFavicon, File existingLogo, File existingLogoIcon, int tenantId)
private void restoreWhiteLabelImages(File existingFavicon, File existingLogo, File existingLogoIcon, int tenantId)
throws MetadataManagementException {
WhiteLabelStorageUtil.deleteWhiteLabelImageForTenantIfExists(tenantId);
if (existingFavicon != null) {
@ -410,7 +416,7 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ
* For example if the provided white label image is of URL type it doesn't need to be stored
*
* @param whiteLabelImage image to be stored
* @param imageName (i.e: FAVICON)
* @param imageName (i.e: FAVICON)
*/
private void storeWhiteLabelImageIfRequired(WhiteLabelImageRequestPayload whiteLabelImage,
WhiteLabelImage.ImageName imageName, int tenantId)
@ -474,7 +480,7 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ
* updates the given WhiteLabelTheme with default value for docUrl
*
* @param whiteLabelTheme the WhiteLabelTheme to be updated with defaults if necessary.
* @param tenantId the ID of the tenant whose metadata is being updated.
* @param tenantId the ID of the tenant whose metadata is being updated.
* @throws MetadataManagementException exception for an error occurs during the update or transaction commit.
*/
private void updateWhiteLabelThemeWithDefaults(WhiteLabelTheme whiteLabelTheme, int tenantId)
@ -528,12 +534,13 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ
/**
* Load White label Meta Data for given tenant Id.
*
* @param tenantId Id of the tenant
* @return {@link Metadata}
* @throws MetadataManagementException if an error occurred while getting Meta-Data info from Database for a
* given tenant ID.
* given tenant ID.
*/
private Metadata getWhiteLabelMetaData (int tenantId) throws MetadataManagementException {
private Metadata getWhiteLabelMetaData(int tenantId) throws MetadataManagementException {
try {
MetadataManagementDAOFactory.openConnection();
return metadataDAO.getMetadata(tenantId, MetadataConstants.WHITELABEL_META_KEY);

Loading…
Cancel
Save