Adress feedback

Add missing licenses
pr/feature/whitelabel
Mohamed Rashd 3 years ago
parent 1d84adbb4f
commit 1559af9660

@ -87,7 +87,6 @@ import io.entgra.application.mgt.core.lifecycle.LifecycleStateManager;
import io.entgra.application.mgt.core.util.ConnectionManagerUtil;
import io.entgra.application.mgt.core.util.Constants;
import org.wso2.carbon.device.mgt.core.common.exception.StorageManagementException;
import org.wso2.carbon.device.mgt.core.common.util.StorageManagementUtil;
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
@ -611,7 +610,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
return md5OfApp;
} catch(StorageManagementException e) {
String msg = "Error occurred while generating md5sum value of " + applicationArtifact.getInstallerName();
log.error(msg);
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
}
}
@ -713,8 +712,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
} catch (StorageManagementException e) {
String msg = "Error occurred while md5sum value retrieving process: application UUID "
+ applicationReleaseDTO.getUuid();
log.error(msg);
throw new ApplicationStorageManagementException(msg);
log.error(msg, e);
throw new ApplicationStorageManagementException(msg, e);
} catch (DBConnectionException e) {
String msg = "Error occurred when getting database connection for verifying app release data.";
log.error(msg, e);
@ -828,8 +827,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
} catch (StorageManagementException e) {
String msg = "Error occurred while retrieving md5sum value from the binary file for application "
+ "release UUID " + applicationReleaseDTO.getUuid();
log.error(msg);
throw new ApplicationStorageManagementException(msg);
log.error(msg, e);
throw new ApplicationStorageManagementException(msg, e);
} catch (IOException e) {
String msg = "Error occurred when getting byte array of binary file. Installer name: " + applicationArtifact
.getInstallerName();
@ -3310,8 +3309,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
} catch (StorageManagementException e) {
String msg = "Error occurred while retrieving md5sum value from the binary file for "
+ "application release UUID " + applicationReleaseDTO.get().getUuid();
log.error(msg);
throw new ApplicationStorageManagementException(msg);
log.error(msg, e);
throw new ApplicationStorageManagementException(msg, e);
} catch (IOException e) {
String msg = "Error occurred when getting byte array of binary file. Installer name: "
+ applicationArtifact.getInstallerName();

@ -1,4 +1,5 @@
/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. *
/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.

@ -136,7 +136,6 @@ public class WhiteLabelServiceImpl implements WhiteLabelService {
Response.ResponseBuilder response = Response
.ok(binaryDuplicate, MediaType.APPLICATION_OCTET_STREAM);
response.status(Response.Status.OK);
// response.header("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
response.header("Content-Length", content.length);
return response.build();
} catch (IOException e) {

@ -662,17 +662,11 @@ public class RequestValidationUtil {
}
}
public static void validateWhiteLabelArtifactDownloadRequest(String whiteLabelImage) {
if (!EnumUtils.isValidEnum(WhiteLabelImage.ImageName.class, whiteLabelImage)) {
String msg = "Invalid white label image requested. Image: " + whiteLabelImage;
log.error(msg);
throw new InputValidationException(new ErrorResponse.ErrorResponseBuilder()
.setCode(HttpStatus.SC_BAD_REQUEST)
.setMessage(msg).build());
}
}
/**
* Check if whitelabel theme create request contains valid payload and all required payload
*
* @param whiteLabelThemeCreateRequest {@link WhiteLabelThemeCreateRequest}
*/
public static void validateWhiteLabelTheme(WhiteLabelThemeCreateRequest whiteLabelThemeCreateRequest) {
if (whiteLabelThemeCreateRequest.getFavicon() == null) {
String msg = "Favicon is required to whitelabel";
@ -700,7 +694,7 @@ public class RequestValidationUtil {
validateWhiteLabelImage(whiteLabelThemeCreateRequest.getLogo());
} catch (InputValidationException e) {
String msg = "Payload contains invalid base64 files";
log.error(msg);
log.error(msg, e);
throw e;
}
}
@ -723,14 +717,13 @@ public class RequestValidationUtil {
} catch (JsonSyntaxException e) {
String msg = "Invalid image payload found with the request. Image object does not represent a Base64 File. " +
"Hence verify the request payload object.";
log.error(msg);
log.error(msg, e);
throw new InputValidationException(
new ErrorResponse.ErrorResponseBuilder()
.setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build());
}
return;
}
if (whiteLabelImage.getImageType() == WhiteLabelImageRequestPayload.ImageType.URL) {
else if (whiteLabelImage.getImageType() == WhiteLabelImageRequestPayload.ImageType.URL) {
try {
String imageUrl = new Gson().fromJson(whiteLabelImage.getImage(), String.class);
if (!HttpUtil.isHttpUrlValid(imageUrl)) {
@ -742,11 +735,17 @@ public class RequestValidationUtil {
}
} catch (JsonSyntaxException e) {
String msg = "Invalid payload found with the request. Hence verify the request payload object.";
log.error(msg);
log.error(msg, e);
throw new InputValidationException(
new ErrorResponse.ErrorResponseBuilder()
.setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build());
}
} else {
String msg = "Invalid payload found with the request. Unknown white label imageType " + whiteLabelImage.getImageType();
log.error(msg);
throw new InputValidationException(
new ErrorResponse.ErrorResponseBuilder()
.setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build());
}
}

@ -526,7 +526,7 @@ public class DeviceMgtAPIUtils {
whiteLabelManagementService = (WhiteLabelManagementService) ctx.getOSGiService(
WhiteLabelManagementService.class, null);
if (whiteLabelManagementService == null) {
throw new IllegalStateException("Metadata Management service not initialized.");
throw new IllegalStateException("Whitelabel Management service not initialized.");
}
}
}

@ -1,6 +1,3 @@
package org.wso2.carbon.device.mgt.common.exceptions;
/*
* Copyright (c) 2022, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
*
@ -19,6 +16,8 @@ package org.wso2.carbon.device.mgt.common.exceptions;
* under the License.
*/
package org.wso2.carbon.device.mgt.common.exceptions;
/**
* This exception will be thrown when the requested application or platform not found.
*/

@ -1,3 +1,21 @@
/*
* Copyright (c) 2022, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
*
* Entgra (pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.common.metadata.mgt;
public class WhiteLabelImage {

@ -1,3 +1,21 @@
/*
* Copyright (c) 2022, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
*
* Entgra (pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.common.metadata.mgt;
import com.google.gson.Gson;

@ -17,9 +17,9 @@
*/
package org.wso2.carbon.device.mgt.common.metadata.mgt;
import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException;
import org.wso2.carbon.device.mgt.common.exceptions.NotFoundException;
import java.io.IOException;
/**
* Defines the contract of WhiteLabelManagementService.

@ -1,3 +1,21 @@
/*
* Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.config.tenant.whitelabel;
import javax.xml.bind.annotation.XmlElement;

@ -1,3 +1,21 @@
/*
* Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.config.tenant.whitelabel;
import javax.xml.bind.annotation.XmlElement;

@ -1,3 +1,21 @@
/*
* Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.config.tenant.whitelabel;
import javax.xml.bind.annotation.XmlElement;

@ -70,7 +70,6 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ
try {
WhiteLabelTheme whiteLabelTheme = getWhiteLabelTheme();
return getImageContent(whiteLabelTheme.getFaviconImage(), WhiteLabelImage.ImageName.FAVICON);
} catch (IOException e) {
String msg = "Error occurred while getting byte content of favicon";
log.error(msg, e);
@ -179,6 +178,11 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ
return whiteLabelConfiguration.getFooterText();
}
/**
* This is useful to construct and get the default favicon whitelabel image
*
* @return {@link WhiteLabelImage}
*/
private WhiteLabelImage constructDefaultFaviconImage() {
MetaDataConfiguration metaDataConfiguration = DeviceConfigurationManager.getInstance().
getDeviceManagementConfig().getMetaDataConfiguration();
@ -189,6 +193,11 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ
return favicon;
}
/**
* This is useful to construct and get the default logo whitelabel image
*
* @return {@link WhiteLabelImage}
*/
private WhiteLabelImage constructDefaultLogoImage() {
MetaDataConfiguration metaDataConfiguration = DeviceConfigurationManager.getInstance().
getDeviceManagementConfig().getMetaDataConfiguration();

@ -88,7 +88,7 @@ public class WhiteLabelStorageUtil {
storeWhiteLabelImage(FileUtil.fileToBase64File(image), imageName, tenantId);
} catch (IOException e) {
String msg = "Error occurred when converting provided File object to Base64File class";
log.error(msg);
log.error(msg, e);
throw new MetadataManagementException(msg, e);
}
}
@ -178,7 +178,9 @@ public class WhiteLabelStorageUtil {
try {
StorageManagementUtil.delete(artifact);
} catch (IOException e) {
throw new MetadataManagementException("Error occurred while deleting whitelabel artifacts", e);
String msg = "Error occurred while deleting whitelabel artifacts";
log.error(msg, e);
throw new MetadataManagementException(msg, e);
}
}
}
@ -193,7 +195,9 @@ public class WhiteLabelStorageUtil {
try {
StorageManagementUtil.delete(artifact);
} catch (IOException e) {
throw new MetadataManagementException("Error occurred while deleting whitelabel artifacts", e);
String msg = "Error occurred while deleting whitelabel artifacts";
log.error(msg, e);
throw new MetadataManagementException(msg, e);
}
}
}

Loading…
Cancel
Save