src/main/java/org/edgegallery/appstore/interfaces/order/facade/OrderServiceFacade.java
public ResponseEntity<ResponseObject> activateOrder(String userId, String userName, String orderId, String token) {
        Order order = orderRepository.findByOrderId(orderId)
            .orElseThrow(() -> new EntityNotFoundException(Order.class, orderId, ResponseConst.RET_ORDER_NOT_FOUND));
        if (order.getStatus() != EnumOrderStatus.DEACTIVATED && order.getStatus() != EnumOrderStatus.ACTIVATE_FAILED) {
            throw new AppException("unsubscribed orders can't be activated.",
                ResponseConst.RET_NOT_ALLOWED_ACTIVATE_ORDER);
        }
        if (!userId.equals(order.getUserId()) && !Consts.SUPER_ADMIN_NAME.equals(userName)) {
            throw new PermissionNotAllowedException("can not activate order",
                ResponseConst.RET_NO_ACCESS_ACTIVATE_ORDER, userName);
        }
        // upload package to north, if return mecm packageId is not empty, update status to Activating
        Release release = appService.getRelease(order.getAppId(), order.getAppPackageId());
        orderService.startActivatingOrder(release, order, token, userId);
        return ResponseEntity.ok(new ResponseObject("activate order success",
            new ErrorMessage(ResponseConst.RET_SUCCESS, null), "activate order success."));
    }
/**
     * activate order.
     *
     * @param userId user id
     * @param userName user name
     * @param orderId order id
     * @return result
     */
activate order.
@param userId user id
@param userName user name
@param orderId order id
@return result
activate order . @param userId user id @param userName user name @param orderId order id @return result
public ResponseEntity<ResponseObject> activateOrder(String userId, String userName, String orderId, String token) {
        Order order = orderRepository.findByOrderId(orderId)
            .orElseThrow(() -> new EntityNotFoundException(Order.class, orderId, ResponseConst.RET_ORDER_NOT_FOUND));
        if (order.getStatus() != EnumOrderStatus.DEACTIVATED && order.getStatus() != EnumOrderStatus.ACTIVATE_FAILED) {
            throw new AppException("unsubscribed orders can't be activated.",
                ResponseConst.RET_NOT_ALLOWED_ACTIVATE_ORDER);
        }
        if (!userId.equals(order.getUserId()) && !Consts.SUPER_ADMIN_NAME.equals(userName)) {
            throw new PermissionNotAllowedException("can not activate order",
                ResponseConst.RET_NO_ACCESS_ACTIVATE_ORDER, userName);
        }
        Release release = appService.getRelease(order.getAppId(), order.getAppPackageId());
        orderService.startActivatingOrder(release, order, token, userId);
        return ResponseEntity.ok(new ResponseObject("activate order success",
            new ErrorMessage(ResponseConst.RET_SUCCESS, null), "activate order success."));
    }
public ResponseEntity < ResponseObject > activateOrder ( String userId , String userName , String orderId , String token ) { Order order = orderRepository . findByOrderId ( orderId ) . orElseThrow ( ( ) -> new EntityNotFoundException ( Order . class , orderId , ResponseConst . RET_ORDER_NOT_FOUND ) ) ; if ( order . getStatus ( ) != EnumOrderStatus . DEACTIVATED && order . getStatus ( ) != EnumOrderStatus . ACTIVATE_FAILED ) { throw new AppException ( "unsubscribed orders can't be activated." , ResponseConst . RET_NOT_ALLOWED_ACTIVATE_ORDER ) ; } if ( ! userId . equals ( order . getUserId ( ) ) && ! Consts . SUPER_ADMIN_NAME . equals ( userName ) ) { throw new PermissionNotAllowedException ( "can not activate order" , ResponseConst . RET_NO_ACCESS_ACTIVATE_ORDER , userName ) ; } Release release = appService . getRelease ( order . getAppId ( ) , order . getAppPackageId ( ) ) ; orderService . startActivatingOrder ( release , order , token , userId ) ; return ResponseEntity . ok ( new ResponseObject ( "activate order success" , new ErrorMessage ( ResponseConst . RET_SUCCESS , null ) , "activate order success." ) ) ; }
activate order.
activate order .
// upload package to north, if return mecm packageId is not empty, update status to Activating