ResponseEntity unlockDrawer()

in service/src/main/java/org/apache/fineract/cn/teller/service/rest/TellerOperationRestController.java [110:134]


  ResponseEntity<Teller> unlockDrawer(@PathVariable("tellerCode") final String tellerCode,
                                      @RequestBody @Valid final UnlockDrawerCommand unlockDrawerCommand) {
    final Teller teller = this.verifyTeller(tellerCode);

    if (teller.getState().equals(Teller.State.CLOSED.name())) {
      throw ServiceException.badRequest("Teller {0} is closed.", teller.getCode());
    }

    if (!teller.getAssignedEmployee().equals(unlockDrawerCommand.getEmployeeIdentifier())) {
      throw ServiceException.badRequest("User {0} is not assigned to teller.", unlockDrawerCommand.getEmployeeIdentifier());
    }

    this.verifyEmployee(teller);

    try {
      final String unlockedTeller =
          this.commandGateway.process(new DrawerUnlockCommand(tellerCode, unlockDrawerCommand), String.class).get();

      this.logger.debug("Drawer {0} unlocked", unlockedTeller);

      return ResponseEntity.ok(teller);
    } catch (final Exception e) {
      throw ServiceException.notFound("Teller {0} not found.", teller.getCode());
    }
  }