Skip to content

Commit

Permalink
Added deprecated to joinQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
hth committed Mar 5, 2021
1 parent deb4965 commit 03dea37
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
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 @@ -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 03dea37

Please sign in to comment.