Skip to content

Commit

Permalink
release 3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
frwiqueueit committed Dec 18, 2017
1 parent 22329f0 commit e46de06
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 106 deletions.
1 change: 1 addition & 0 deletions SDK/src/queueit/knownuserv3/sdk/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ final class ActionType {

public static final String CANCEL_ACTION = "Cancel";
public static final String QUEUE_ACTION = "Queue";
public static final String IGNORE_ACTION = "Ignore";
}
95 changes: 56 additions & 39 deletions SDK/src/queueit/knownuserv3/sdk/KnownUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class KnownUser {
public static final String QueueITDebugKey = "queueitdebug";
private static IUserInQueueService _userInQueueService;

private static IUserInQueueService createUserInQueueService(HttpServletRequest request, HttpServletResponse response) {
private static IUserInQueueService getUserInQueueService(HttpServletRequest request, HttpServletResponse response) {
if (_userInQueueService == null) {
return new UserInQueueService(new UserInQueueStateCookieRepository(new CookieManager(request, response)));
}
Expand Down Expand Up @@ -71,44 +71,16 @@ public static RequestValidationResult validateRequestByIntegrationConfig(String
return new RequestValidationResult(null, null, null, null);
}

// unspecified or 'Queue' specified
if(Utils.isNullOrWhiteSpace(matchedConfig.ActionType) || ActionType.QUEUE_ACTION.equals(matchedConfig.ActionType)) {
String targetUrl;
switch (matchedConfig.RedirectLogic) {
case "ForecedTargetUrl": // suuport for typo (fall through)
case "ForcedTargetUrl":
targetUrl = matchedConfig.ForcedTargetUrl;
break;
case "EventTargetUrl":
targetUrl = "";
break;
default:
targetUrl = currentUrlWithoutQueueITToken;
break;
}

QueueEventConfig queueConfig = new QueueEventConfig();
queueConfig.setQueueDomain(matchedConfig.QueueDomain);
queueConfig.setCulture(matchedConfig.Culture);
queueConfig.setEventId(matchedConfig.EventId);
queueConfig.setExtendCookieValidity(matchedConfig.ExtendCookieValidity);
queueConfig.setLayoutName(matchedConfig.LayoutName);
queueConfig.setCookieValidityMinute(matchedConfig.CookieValidityMinute);
queueConfig.setCookieDomain(matchedConfig.CookieDomain);
queueConfig.setVersion(customerIntegrationInfo.Version);

return resolveQueueRequestByLocalConfig(
targetUrl, queueitToken, queueConfig, customerId, request, response, secretKey, debugEntries);
return handleQueueAction(matchedConfig, currentUrlWithoutQueueITToken, customerIntegrationInfo, queueitToken, customerId, request, response, secretKey, debugEntries);
}
// CancelQueueAction
else if (ActionType.CANCEL_ACTION.equals(matchedConfig.ActionType)){
return handleCancelAction(matchedConfig, customerIntegrationInfo, currentUrlWithoutQueueITToken, queueitToken, customerId, request, response, secretKey, debugEntries);
}
// for all unknown types default to 'Ignore'
else {
CancelEventConfig cancelConfig = new CancelEventConfig();
cancelConfig.setQueueDomain(matchedConfig.QueueDomain);
cancelConfig.setEventId(matchedConfig.EventId);
cancelConfig.setCookieDomain(matchedConfig.CookieDomain);
cancelConfig.setVersion(customerIntegrationInfo.Version);

return cancelRequestByLocalConfig(
currentUrlWithoutQueueITToken, queueitToken, cancelConfig, customerId, request, response, secretKey, debugEntries);
return handleIgnoreAction(request, response);
}
}
finally {
Expand Down Expand Up @@ -166,7 +138,7 @@ private static RequestValidationResult cancelRequestByLocalConfig(
throw new Exception("QueueDomain from cancelConfig can not be null or empty.");
}

IUserInQueueService userInQueueService = createUserInQueueService(request, response);
IUserInQueueService userInQueueService = getUserInQueueService(request, response);
return userInQueueService.validateCancelRequest(targetUrl, cancelConfig, customerId, secretKey);
}

Expand Down Expand Up @@ -223,7 +195,7 @@ private static RequestValidationResult resolveQueueRequestByLocalConfig(
queueitToken = "";
}

IUserInQueueService userInQueueService = createUserInQueueService(request, response);
IUserInQueueService userInQueueService = getUserInQueueService(request, response);
return userInQueueService.validateQueueRequest(targetUrl, queueitToken, queueConfig, customerId, secretKey);
}

Expand All @@ -244,7 +216,7 @@ public static void extendQueueCookie(String eventId,
throw new Exception("secretKey can not be null or empty.");
}

IUserInQueueService userInQueueService = createUserInQueueService(request, response);
IUserInQueueService userInQueueService = getUserInQueueService(request, response);
userInQueueService.extendQueueCookie(eventId, cookieValidityMinute, cookieDomain, secretKey);
}

Expand Down Expand Up @@ -288,6 +260,51 @@ private static String getOriginalUrl(HttpServletRequest request){
? String.join("", request.getRequestURL(), "?",request.getQueryString())
: request.getRequestURL().toString();
}

private static RequestValidationResult handleQueueAction(IntegrationConfigModel matchedConfig, String currentUrlWithoutQueueITToken, CustomerIntegration customerIntegrationInfo, String queueitToken, String customerId, HttpServletRequest request, HttpServletResponse response, String secretKey, Map<String, String> debugEntries) throws Exception {
String targetUrl;
switch (matchedConfig.RedirectLogic) {
case "ForecedTargetUrl": // suuport for typo (fall through)
case "ForcedTargetUrl":
targetUrl = matchedConfig.ForcedTargetUrl;
break;
case "EventTargetUrl":
targetUrl = "";
break;
default:
targetUrl = currentUrlWithoutQueueITToken;
break;
}

QueueEventConfig queueConfig = new QueueEventConfig();
queueConfig.setQueueDomain(matchedConfig.QueueDomain);
queueConfig.setCulture(matchedConfig.Culture);
queueConfig.setEventId(matchedConfig.EventId);
queueConfig.setExtendCookieValidity(matchedConfig.ExtendCookieValidity);
queueConfig.setLayoutName(matchedConfig.LayoutName);
queueConfig.setCookieValidityMinute(matchedConfig.CookieValidityMinute);
queueConfig.setCookieDomain(matchedConfig.CookieDomain);
queueConfig.setVersion(customerIntegrationInfo.Version);

return resolveQueueRequestByLocalConfig(
targetUrl, queueitToken, queueConfig, customerId, request, response, secretKey, debugEntries);
}

private static RequestValidationResult handleCancelAction(IntegrationConfigModel matchedConfig, CustomerIntegration customerIntegrationInfo, String currentUrlWithoutQueueITToken, String queueitToken, String customerId, HttpServletRequest request, HttpServletResponse response, String secretKey, Map<String, String> debugEntries) throws Exception {
CancelEventConfig cancelConfig = new CancelEventConfig();
cancelConfig.setQueueDomain(matchedConfig.QueueDomain);
cancelConfig.setEventId(matchedConfig.EventId);
cancelConfig.setCookieDomain(matchedConfig.CookieDomain);
cancelConfig.setVersion(customerIntegrationInfo.Version);

return cancelRequestByLocalConfig(
currentUrlWithoutQueueITToken, queueitToken, cancelConfig, customerId, request, response, secretKey, debugEntries);
}

private static RequestValidationResult handleIgnoreAction(HttpServletRequest request, HttpServletResponse response) {
IUserInQueueService userInQueueService = getUserInQueueService(request, response);
return userInQueueService.getIgnoreActionResult();
}
}

interface ICookieManager {
Expand Down
14 changes: 12 additions & 2 deletions SDK/src/queueit/knownuserv3/sdk/UserInQueueService.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ void extendQueueCookie(
String cookieDomain,
String secretKey
);

RequestValidationResult getIgnoreActionResult();
}

class UserInQueueService implements IUserInQueueService {

public static final String SDK_VERSION = "3.3.2";
public static final String SDK_VERSION = "3.4.0";
private final IUserInQueueStateRepository _userInQueueStateRepository;

public UserInQueueService(
Expand Down Expand Up @@ -168,7 +170,10 @@ public void extendQueueCookie(

@Override
public RequestValidationResult validateCancelRequest(
String targetUrl, CancelEventConfig config, String customerId, String secretKey) throws Exception {
String targetUrl,
CancelEventConfig config,
String customerId,
String secretKey) throws Exception {

StateInfo state = _userInQueueStateRepository.getState(config.getEventId(), secretKey);

Expand All @@ -193,4 +198,9 @@ public RequestValidationResult validateCancelRequest(
return new RequestValidationResult(ActionType.CANCEL_ACTION, config.getEventId(), null, null);
}
}

@Override
public RequestValidationResult getIgnoreActionResult() {
return new RequestValidationResult(ActionType.IGNORE_ACTION, null, null, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ final class ComparisonOperatorType {
public static final String STARTS_WITH = "StartsWith";
public static final String ENDS_WITH = "EndsWith";
public static final String MATCHES_WITH = "MatchesWith";
public static final String EQUALS_ANY = "EqualsAny";
public static final String CONTAINS_ANY = "ContainsAny";
}

final class LogicalOperatorType {
Expand Down
Loading

0 comments on commit e46de06

Please sign in to comment.