Add modifications

try_it
Thashmi-nil 2 years ago
parent 2d1879d1b6
commit 798e851922

@ -0,0 +1,54 @@
package org.wso2.carbon.device.mgt.core.config.ui;
import javax.xml.bind.annotation.XmlElement;
public class HubspotChat {
private boolean isEnableHubspot;
private String trackingUrl;
private String accessToken;
private String senderActorId;
private long channelAccountId;
@XmlElement(name = "EnableHubspot")
public boolean isEnableHubspot() {
return isEnableHubspot;
}
public void setEnableHubspot(boolean enableHubspot) {
isEnableHubspot = enableHubspot;
}
@XmlElement(name = "TrackingUrl")
public String getTrackingUrl() {
return trackingUrl;
}
public void setTrackingUrl(String trackingUrl) {
this.trackingUrl = trackingUrl;
}
@XmlElement(name = "AccessToken")
public String getAccessToken() {
return accessToken;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
@XmlElement(name = "SenderActorId")
public String getSenderActorId() {
return senderActorId;
}
public void setSenderActorId(String senderActorId) {
this.senderActorId = senderActorId;
}
@XmlElement(name = "ChannelAccountId")
public long getChannelAccountId() {
return channelAccountId;
}
public void setChannelAccountId(long channelAccountId) {
this.channelAccountId = channelAccountId;
}
}

@ -34,7 +34,7 @@ public class UIConfiguration {
private int sessionTimeOut; private int sessionTimeOut;
private int loginCacheCapacity; private int loginCacheCapacity;
private Billing billing; private Billing billing;
private String chatConfig; private HubspotChat hubspotChat;
@XmlElement(name = "AppRegistration", required=true) @XmlElement(name = "AppRegistration", required=true)
public AppRegistration getAppRegistration() { public AppRegistration getAppRegistration() {
@ -64,15 +64,14 @@ public class UIConfiguration {
isSsoEnable = ssoEnable; isSsoEnable = ssoEnable;
} }
@XmlElement(name = "ChatConfig", required = true) @XmlElement(name = "HubspotChat", required = true)
public String getChatConfig() { public HubspotChat getHubspotChat() {
return chatConfig; return hubspotChat;
} }
public void setChatConfig(String chatConfig) { public void setHubspotChat(HubspotChat hubspotChat) {
this.chatConfig = chatConfig; this.hubspotChat = hubspotChat;
} }
@XmlElement(name = "Billing", required=true) @XmlElement(name = "Billing", required=true)
public Billing getBilling() { public Billing getBilling() {
return billing; return billing;

@ -96,6 +96,7 @@ public class HubspotHandler extends HttpServlet {
*/ */
private boolean validateRequest(HttpServletRequest req, HttpServletResponse resp) private boolean validateRequest(HttpServletRequest req, HttpServletResponse resp)
throws IOException { throws IOException {
httpSession = req.getSession(false);
if (httpSession == null) { if (httpSession == null) {
log.error("Unauthorized, You are not logged in. Please log in to the portal"); log.error("Unauthorized, You are not logged in. Please log in to the portal");
HandlerUtil.handleError(resp, HttpStatus.SC_UNAUTHORIZED); HandlerUtil.handleError(resp, HttpStatus.SC_UNAUTHORIZED);
@ -106,14 +107,13 @@ public class HubspotHandler extends HttpServlet {
HandlerUtil.handleError(resp, HttpStatus.SC_BAD_REQUEST); HandlerUtil.handleError(resp, HttpStatus.SC_BAD_REQUEST);
return false; return false;
} }
httpSession = req.getSession(false);
gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR)
+ HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme());
iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_CORE_HOST_ENV_VAR) iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_CORE_HOST_ENV_VAR)
+ HandlerConstants.COLON + HandlerUtil.getCorePort(req.getScheme()); + HandlerConstants.COLON + HandlerUtil.getCorePort(req.getScheme());
String uiConfigUrl = iotsCoreUrl + HandlerConstants.UI_CONFIG_ENDPOINT; String uiConfigUrl = iotsCoreUrl + HandlerConstants.UI_CONFIG_ENDPOINT;
uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp); uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp);
chatConfig = uiConfigJsonObject.get("chatConfig").getAsString(); chatConfig = uiConfigJsonObject.get("hubspotChat").getAsJsonObject().get("accessToken").getAsString();
hubspotEndpoint = HandlerConstants.HTTPS_PROTOCOL + HandlerConstants.SCHEME_SEPARATOR + HandlerConstants.HUBSPOT_CHAT_URL; hubspotEndpoint = HandlerConstants.HTTPS_PROTOCOL + HandlerConstants.SCHEME_SEPARATOR + HandlerConstants.HUBSPOT_CHAT_URL;
return true; return true;
} }

@ -24,8 +24,15 @@
<SessionTimeOut>3600</SessionTimeOut> <SessionTimeOut>3600</SessionTimeOut>
<!-- maximum number of login cache entries --> <!-- maximum number of login cache entries -->
<LoginCacheCapacity>10000</LoginCacheCapacity> <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 --> <!-- hubspot account info for live chat -->
<ChatConfig>pat-na1-33bc59e0-3526-45b0-b9cf-f353d0ae0ced</ChatConfig> <HubspotChat>
<EnableHubspot>false</EnableHubspot>
<TrackingUrl>tracking_url</TrackingUrl>
<!-- access token - whenever the access token will be rotated, needs to be changed this with the new token -->
<AccessToken>access_token</AccessToken>
<SenderActorId>sender_actorId</SenderActorId>
<ChannelAccountId>channel_AccountId</ChannelAccountId>
</HubspotChat>
<Billing> <Billing>
<HideBillGenerationInSuperTenant>false</HideBillGenerationInSuperTenant> <HideBillGenerationInSuperTenant>false</HideBillGenerationInSuperTenant>
<HideBillGenerationInSubTenant>true</HideBillGenerationInSubTenant> <HideBillGenerationInSubTenant>true</HideBillGenerationInSubTenant>

Loading…
Cancel
Save