mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Changes on reviews
This commit is contained in:
parent
0f6db69c18
commit
2d1879d1b6
@ -92,12 +92,14 @@ public class MetadataManagementServiceImpl implements MetadataManagementService
|
||||
}
|
||||
try {
|
||||
MetadataManagementDAOFactory.openConnection();
|
||||
int tenantId;
|
||||
if (metaKey.equals("EVALUATE_TENANTS")){
|
||||
return metadataDAO.getMetadata(MultitenantConstants.SUPER_TENANT_ID, metaKey);
|
||||
// for getting evaluate tenant list to provide the live chat feature
|
||||
tenantId = MultitenantConstants.SUPER_TENANT_ID;
|
||||
} else {
|
||||
return metadataDAO.getMetadata(
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true), metaKey);
|
||||
tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||
}
|
||||
return metadataDAO.getMetadata(tenantId, metaKey);
|
||||
} catch (MetadataManagementDAOException e) {
|
||||
String msg = "Error occurred while retrieving the metadata entry for metaKey:" + metaKey;
|
||||
log.error(msg, e);
|
||||
|
||||
@ -1,3 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 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 io.entgra.ui.request.interceptor;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
@ -51,12 +69,10 @@ public class HubspotHandler extends HttpServlet {
|
||||
} catch (IOException e) {
|
||||
log.error("Error occurred when processing POST request.", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
|
||||
|
||||
try {
|
||||
if (validateRequest(req, resp)) {
|
||||
HttpGet getRequest = new HttpGet(HandlerUtil.generateBackendRequestURL(req,hubspotEndpoint));
|
||||
@ -80,7 +96,16 @@ public class HubspotHandler extends HttpServlet {
|
||||
*/
|
||||
private boolean validateRequest(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws IOException {
|
||||
|
||||
if (httpSession == null) {
|
||||
log.error("Unauthorized, You are not logged in. Please log in to the portal");
|
||||
HandlerUtil.handleError(resp, HttpStatus.SC_UNAUTHORIZED);
|
||||
return false;
|
||||
}
|
||||
if (req.getMethod() == null) {
|
||||
log.error("Bad Request, Request method is empty");
|
||||
HandlerUtil.handleError(resp, HttpStatus.SC_BAD_REQUEST);
|
||||
return false;
|
||||
}
|
||||
httpSession = req.getSession(false);
|
||||
gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR)
|
||||
+ HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme());
|
||||
@ -90,19 +115,6 @@ public class HubspotHandler extends HttpServlet {
|
||||
uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp);
|
||||
chatConfig = uiConfigJsonObject.get("chatConfig").getAsString();
|
||||
hubspotEndpoint = HandlerConstants.HTTPS_PROTOCOL + HandlerConstants.SCHEME_SEPARATOR + HandlerConstants.HUBSPOT_CHAT_URL;
|
||||
|
||||
if (httpSession == null) {
|
||||
log.error("Unauthorized, You are not logged in. Please log in to the portal");
|
||||
HandlerUtil.handleError(resp, HttpStatus.SC_UNAUTHORIZED);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (req.getMethod() == null) {
|
||||
log.error("Bad Request, Request method is empty");
|
||||
HandlerUtil.handleError(resp, HttpStatus.SC_BAD_REQUEST);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
<SessionTimeOut>3600</SessionTimeOut>
|
||||
<!-- maximum number of login cache entries -->
|
||||
<LoginCacheCapacity>10000</LoginCacheCapacity>
|
||||
<!-- access token for hubspot live chat feature - whenever the access token will be rotated, needs to be changed this with the new token -->
|
||||
<ChatConfig>pat-na1-33bc59e0-3526-45b0-b9cf-f353d0ae0ced</ChatConfig>
|
||||
<Billing>
|
||||
<HideBillGenerationInSuperTenant>false</HideBillGenerationInSuperTenant>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user