|
|
@ -65,6 +65,13 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ
|
|
|
|
initializeWhiteLabelThemes();
|
|
|
|
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 {
|
|
|
|
private void initializeWhiteLabelThemes() throws MetadataManagementException {
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
WhiteLabelTheme defaultTheme = getDefaultWhiteLabelTheme();
|
|
|
|
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 " +
|
|
|
|
log.debug("WhiteLabel theme's DocUrl was missing and has been updated to the default value " +
|
|
|
|
"for tenant: " + tenantId);
|
|
|
|
"for tenant: " + tenantId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (MetadataManagementDAOException e) {
|
|
|
|
catch (MetadataManagementDAOException e) {
|
|
|
|
|
|
|
|
MetadataManagementDAOFactory.rollbackTransaction();
|
|
|
|
MetadataManagementDAOFactory.rollbackTransaction();
|
|
|
|
String msg = "Error occurred while fetching white label metadata for tenant: " + tenantId;
|
|
|
|
String msg = "Error occurred while fetching white label metadata for tenant: " + tenantId;
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
@ -165,9 +171,9 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Useful to get white label image file response from provided url
|
|
|
|
* 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();
|
|
|
|
FileResponse fileResponse = new FileResponse();
|
|
|
|
try(CloseableHttpClient client = HttpClients.createDefault()) {
|
|
|
|
try (CloseableHttpClient client = HttpClients.createDefault()) {
|
|
|
|
HttpGet imageGetRequest = new HttpGet(url);
|
|
|
|
HttpGet imageGetRequest = new HttpGet(url);
|
|
|
|
HttpResponse response = client.execute(imageGetRequest);
|
|
|
|
HttpResponse response = client.execute(imageGetRequest);
|
|
|
|
InputStream imageStream = response.getEntity().getContent();
|
|
|
|
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.
|
|
|
|
* those can be passed to this method in order to restore.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param existingFavicon existing favicon image file
|
|
|
|
* @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 {
|
|
|
|
throws MetadataManagementException {
|
|
|
|
WhiteLabelStorageUtil.deleteWhiteLabelImageForTenantIfExists(tenantId);
|
|
|
|
WhiteLabelStorageUtil.deleteWhiteLabelImageForTenantIfExists(tenantId);
|
|
|
|
if (existingFavicon != null) {
|
|
|
|
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
|
|
|
|
* 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 whiteLabelImage image to be stored
|
|
|
|
* @param imageName (i.e: FAVICON)
|
|
|
|
* @param imageName (i.e: FAVICON)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void storeWhiteLabelImageIfRequired(WhiteLabelImageRequestPayload whiteLabelImage,
|
|
|
|
private void storeWhiteLabelImageIfRequired(WhiteLabelImageRequestPayload whiteLabelImage,
|
|
|
|
WhiteLabelImage.ImageName imageName, int tenantId)
|
|
|
|
WhiteLabelImage.ImageName imageName, int tenantId)
|
|
|
@ -474,7 +480,7 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ
|
|
|
|
* updates the given WhiteLabelTheme with default value for docUrl
|
|
|
|
* updates the given WhiteLabelTheme with default value for docUrl
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param whiteLabelTheme the WhiteLabelTheme to be updated with defaults if necessary.
|
|
|
|
* @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.
|
|
|
|
* @throws MetadataManagementException exception for an error occurs during the update or transaction commit.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void updateWhiteLabelThemeWithDefaults(WhiteLabelTheme whiteLabelTheme, int tenantId)
|
|
|
|
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.
|
|
|
|
* Load White label Meta Data for given tenant Id.
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param tenantId Id of the tenant
|
|
|
|
* @param tenantId Id of the tenant
|
|
|
|
* @return {@link Metadata}
|
|
|
|
* @return {@link Metadata}
|
|
|
|
* @throws MetadataManagementException if an error occurred while getting Meta-Data info from Database for a
|
|
|
|
* @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 {
|
|
|
|
try {
|
|
|
|
MetadataManagementDAOFactory.openConnection();
|
|
|
|
MetadataManagementDAOFactory.openConnection();
|
|
|
|
return metadataDAO.getMetadata(tenantId, MetadataConstants.WHITELABEL_META_KEY);
|
|
|
|
return metadataDAO.getMetadata(tenantId, MetadataConstants.WHITELABEL_META_KEY);
|
|
|
|