Skip to content

Commit

Permalink
Merge pull request #2230 from hth/minor-modification
Browse files Browse the repository at this point in the history
Minor modification
  • Loading branch information
hth authored Mar 5, 2021
2 parents 3e00878 + 03dea37 commit 063d6d6
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public enum LowestSupportedAppEnum {
"Version iPhone"),
/* 1.1.10 is not released. */

VACL("1.2.700", //Oldest Supported App Version in String
VACL("1.2.721", //Oldest Supported App Version in String
DeviceTypeEnum.A,
AppFlavorEnum.NQCL,
"1.2.721", //Latest App Version on Play Store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static com.noqapp.common.errors.MobileSystemErrorCodeEnum.JOINING_NOT_PRE_APPROVED_QUEUE;
import static com.noqapp.common.errors.MobileSystemErrorCodeEnum.JOINING_QUEUE_PERMISSION_DENIED;
import static com.noqapp.common.errors.MobileSystemErrorCodeEnum.JOIN_PRE_APPROVED_QUEUE_ONLY;
import static com.noqapp.common.errors.MobileSystemErrorCodeEnum.MOBILE_UPGRADE;
import static com.noqapp.common.errors.MobileSystemErrorCodeEnum.ORDER_PAYMENT_PAID_ALREADY_FAILED;
import static com.noqapp.common.errors.MobileSystemErrorCodeEnum.PURCHASE_ORDER_FAILED_TO_CANCEL;
import static com.noqapp.common.errors.MobileSystemErrorCodeEnum.PURCHASE_ORDER_FAILED_TO_CANCEL_AS_EXTERNALLY_PAID;
Expand Down Expand Up @@ -454,8 +455,55 @@ public String allHistoricalJoinedQueues(
* Join the queue.
* Note: /queue is obsolete since 1.2.700. After support, always return message to upgrade app.
*/
@Deprecated
@PostMapping (
value = {"/queue", "/joinQueue"},
value = "/queue",
produces = MediaType.APPLICATION_JSON_VALUE
)
public String joinQueueObsolete(
@RequestHeader ("X-R-DID")
ScrubbedInput did,

@RequestHeader ("X-R-DT")
ScrubbedInput deviceType,

@RequestHeader ("X-R-MAIL")
ScrubbedInput mail,

@RequestHeader ("X-R-AUTH")
ScrubbedInput auth,

@RequestBody
JoinQueue joinQueue,

HttpServletResponse response
) throws IOException {
boolean methodStatusSuccess = true;
Instant start = Instant.now();
LOG.info("Join queue did={} dt={}", did, deviceType);
String qid = authenticateMobileService.getQueueUserId(mail.getText(), auth.getText());
if (authorizeRequest(response, qid)) return null;

try {
LOG.warn("Sent warning to upgrade qid={}", qid);
return getErrorReason("To continue, please upgrade to latest version", MOBILE_UPGRADE);
} catch (Exception e) {
LOG.error("Failed joining queue qid={}, reason={}", qid, e.getLocalizedMessage(), e);
methodStatusSuccess = false;
return getErrorReason("Something went wrong. Engineers are looking into this.", SEVERE);
} finally {
apiHealthService.insert(
"/joinQueue",
"joinQueue",
TokenQueueAPIController.class.getName(),
Duration.between(start, Instant.now()),
methodStatusSuccess ? HealthStatusEnum.G : HealthStatusEnum.F);
}
}

/** Join the queue. */
@PostMapping (
value = "/joinQueue",
produces = MediaType.APPLICATION_JSON_VALUE
)
public String joinQueue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,14 @@ public String registerDeviceObsolete(
appFlavor.getText(),
tokenJson);

DeviceTypeEnum deviceTypeEnum;
try {
deviceTypeEnum = DeviceTypeEnum.valueOf(deviceType.getText());
} catch (Exception e) {
LOG.error("Failed parsing deviceType, reason={}", e.getLocalizedMessage(), e);
return getErrorReason("Incorrect device type.", USER_INPUT);
}

try {
LOG.warn("Older registration process version deviceType={} appFlavor={}", deviceType, appFlavor);
return getErrorReason("To continue, please upgrade to latest version", MOBILE_UPGRADE);
} catch (DeviceDetailMissingException e) {
LOG.error("Failed registering deviceType={}, reason={}", deviceTypeEnum, e.getLocalizedMessage(), e);
LOG.error("Failed registering deviceType={}, reason={}", deviceType, e.getLocalizedMessage(), e);
return getErrorReason("Missing device details", DEVICE_DETAIL_MISSING);
} catch (Exception e) {
LOG.error("Failed registering deviceType={}, reason={}", deviceTypeEnum, e.getLocalizedMessage(), e);
LOG.error("Failed registering deviceType={}, reason={}", deviceType, e.getLocalizedMessage(), e);
methodStatusSuccess = false;
return getErrorReason("Something went wrong. Engineers are looking into this.", SEVERE);
} finally {
Expand Down Expand Up @@ -254,31 +246,8 @@ public String versionObsolete(
LOG.info("Supported device deviceType={} appFlavor={} versionRelease={}", deviceType, appFlavor, versionRelease);

try {
//TODO remove me
if (null != did) {
LOG.warn("Old app version did={} versionRelease={}", did, versionRelease);
return getErrorReason("To continue, please upgrade to latest version", MOBILE_UPGRADE);
}

DeviceTypeEnum deviceTypeEnum = DeviceTypeEnum.valueOf(deviceType.getText());
AppFlavorEnum appFlavorEnum = AppFlavorEnum.valueOf(appFlavor.getText());
LOG.info("Check if supported app version {} {} versionRelease={}", deviceTypeEnum.getDescription(), appFlavor, versionRelease);

try {
LowestSupportedAppEnum lowestSupportedApp = LowestSupportedAppEnum.findBasedOnDeviceType(deviceTypeEnum, appFlavorEnum);
if (!LowestSupportedAppEnum.isSupportedVersion(lowestSupportedApp, versionRelease.getText())) {
LOG.warn("Sent warning to upgrade versionNumber={}", versionRelease.getText());
return getErrorReason("To continue, please upgrade to latest version", MOBILE_UPGRADE);
}

return new JsonLatestAppVersion(lowestSupportedApp.getLatestAppVersion()).asJson();
} catch (NumberFormatException e) {
LOG.error("Failed parsing API version, reason={}", e.getLocalizedMessage(), e);
return getErrorReason("Failed to read API version type.", USER_INPUT);
} catch (Exception e) {
LOG.error("Failed parsing API version, reason={}", e.getLocalizedMessage(), e);
return getErrorReason("Incorrect API version type.", USER_INPUT);
}
LOG.warn("Sent warning to upgrade versionNumber={}", versionRelease.getText());
return getErrorReason("To continue, please upgrade to latest version", MOBILE_UPGRADE);
} catch (Exception e) {
LOG.error("Failed parsing deviceType, reason={}", e.getLocalizedMessage(), e);
methodStatusSuccess = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.mockito.Mockito;

import java.io.IOException;
import java.math.BigDecimal;
import java.math.MathContext;
import java.time.DayOfWeek;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
Expand Down

0 comments on commit 063d6d6

Please sign in to comment.