You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
481 lines
22 KiB
481 lines
22 KiB
package common.ecommerce.xincang.adapter; |
|
|
|
import common.ecommerce.http.HttpRequest; |
|
import common.ecommerce.http.HttpResponse; |
|
import common.ecommerce.http.HttpTransport; |
|
import common.ecommerce.http.JacksonJsonCodec; |
|
import common.ecommerce.http.TokenManager; |
|
import common.ecommerce.shared.error.PlatformBusinessException; |
|
import common.ecommerce.shared.spi.AccessToken; |
|
import common.ecommerce.shared.spi.ChannelSecret; |
|
import common.ecommerce.shared.spi.LockProvider; |
|
import common.ecommerce.shared.spi.TokenStore; |
|
import common.ecommerce.shared.support.Page; |
|
import common.ecommerce.warehouse.capability.OutboundCapable; |
|
import common.ecommerce.warehouse.capability.TransferCapable; |
|
import common.ecommerce.warehouse.capability.WarehouseProduct; |
|
import common.ecommerce.warehouse.capability.WarehouseProductCapable; |
|
import common.ecommerce.warehouse.enums.CancelEligibility; |
|
import common.ecommerce.warehouse.enums.OutboundStatus; |
|
import common.ecommerce.warehouse.enums.WarehouseCapability; |
|
import common.ecommerce.warehouse.enums.WarehouseProvider; |
|
import common.ecommerce.warehouse.error.OutboundCancelBlockedException; |
|
import common.ecommerce.warehouse.error.WarehouseException; |
|
import common.ecommerce.warehouse.model.CancelCommand; |
|
import common.ecommerce.warehouse.model.CancelResult; |
|
import common.ecommerce.warehouse.model.OutboundCommand; |
|
import common.ecommerce.warehouse.model.OutboundOrder; |
|
import common.ecommerce.warehouse.model.OutboundQuery; |
|
import common.ecommerce.warehouse.model.OutboundReceipt; |
|
import common.ecommerce.warehouse.model.OutboundRef; |
|
import common.ecommerce.warehouse.model.PackageResult; |
|
import common.ecommerce.warehouse.model.TransferCommand; |
|
import common.ecommerce.warehouse.model.TransferOrder; |
|
import common.ecommerce.warehouse.sdk.WarehouseContext; |
|
import common.ecommerce.xincang.XincangConstants; |
|
import common.ecommerce.xincang.auth.XincangTokenClient; |
|
import common.ecommerce.xincang.dto.XincangDtos; |
|
import common.ecommerce.xincang.http.XincangEnvelope; |
|
import common.ecommerce.xincang.http.XincangMultipart; |
|
import common.ecommerce.xincang.http.XincangRateLimiter; |
|
import common.ecommerce.xincang.http.XincangRequestFactory; |
|
|
|
import java.time.Clock; |
|
import java.util.EnumSet; |
|
import java.util.LinkedHashMap; |
|
import java.util.List; |
|
import java.util.Map; |
|
|
|
/** |
|
* 信仓适配器。 |
|
* |
|
* <p>文档确认的鉴权方式:{@code GET /api.login?appkey=&secret=} 换取客户级 token, |
|
* 有效期 2 小时、无 refresh 接口;业务请求把 token 放在 query 参数 {@code token} 里 |
|
* (新增 / 更新产品的请求体 schema 里也要求一份,见 {@link XincangRequestFactory})。</p> |
|
* |
|
* <p>已实现能力:商品建档 / 更新({@code PRODUCT})、出库下单({@code OUTBOUND})、 |
|
* 转运创建 / 审核({@code TRANSFER})。出库的查询 / 取消 / 包裹字段未接入, |
|
* 调用会显式抛不支持异常,不返回空集合。</p> |
|
* |
|
* <p>适配器只持有协议与基础设施,不持有端点与凭据——两者随每次调用经 |
|
* {@code WarehouseConnection} 传入。</p> |
|
*/ |
|
public final class XincangAdapter implements WarehouseProductCapable, OutboundCapable, |
|
TransferCapable { |
|
|
|
private static final String OP_PRODUCT_QUERY = "warehouse.product.query"; |
|
private static final String OP_PRODUCT_ADD = "warehouse.product.add"; |
|
private static final String OP_PRODUCT_UPDATE = "warehouse.product.update"; |
|
|
|
/** 查重时只取一页;按 SKU 过滤后通常 0~1 条。 */ |
|
private static final int PRODUCT_QUERY_LIMIT = 100; |
|
/** 信仓产品状态:0 临时产品。 */ |
|
private static final String STATE_TEMPORARY = XincangConstants.PRODUCT_STATE_TEMPORARY; |
|
|
|
private final HttpTransport transport; |
|
private final JacksonJsonCodec json; |
|
private final XincangTokenClient tokenClient; |
|
private final TokenManager tokenManager; |
|
private final XincangRequestFactory requestFactory; |
|
private final XincangRateLimiter rateLimiter; |
|
|
|
public XincangAdapter(HttpTransport transport, JacksonJsonCodec json, |
|
TokenStore tokenStore, LockProvider lockProvider, Clock clock) { |
|
this.transport = transport; |
|
this.json = json; |
|
this.tokenClient = new XincangTokenClient(transport, json, clock); |
|
// 信仓 token 2h、无 refresh 接口:到期前 10 分钟重新登录换取; |
|
// TokenManager 负责锁内防击穿与缓存读写,缓存键按 appkey(客户级)。 |
|
this.tokenManager = new TokenManager(tokenStore, lockProvider, clock, |
|
XincangConstants.TOKEN_EARLY_REFRESH_SECONDS) { |
|
@Override |
|
protected AccessToken refresh(ChannelSecret secret, AccessToken previous) { |
|
return tokenClient.fetch(secret.endpointBaseUrl(), secret.appKey(), secret.appSecret()); |
|
} |
|
}; |
|
this.requestFactory = new XincangRequestFactory(json); |
|
this.rateLimiter = new XincangRateLimiter(); |
|
} |
|
|
|
@Override |
|
public String adapterId() { |
|
return XincangConstants.ADAPTER_ID; |
|
} |
|
|
|
@Override |
|
public WarehouseProvider provider() { |
|
return WarehouseProvider.XINCANG; |
|
} |
|
|
|
@Override |
|
public EnumSet<WarehouseCapability> capabilities() { |
|
return EnumSet.of(WarehouseCapability.PRODUCT, WarehouseCapability.OUTBOUND, |
|
WarehouseCapability.TRANSFER, WarehouseCapability.SPLIT); |
|
} |
|
|
|
/** |
|
* 取一个可用 token(缓存命中则不登录)。 |
|
* |
|
* <p>供健康检查与联调探针使用;业务方法接入时也应经此取 token, |
|
* 不要在适配器外自行缓存。</p> |
|
* |
|
* @throws common.ecommerce.shared.error.AuthException 登录被拒或令牌结构不符合文档 |
|
*/ |
|
public AccessToken login(WarehouseContext ctx) { |
|
return tokenManager.getOrRefresh(tokenKey(ctx.secret()), ctx.secret()); |
|
} |
|
|
|
// ------------------------------------------------------------------ 商品 |
|
|
|
/** |
|
* 创建或更新商品。 |
|
* |
|
* <p>信仓没有 upsert 接口,按「先查临时产品、有则更新、无则新增」实现:</p> |
|
* <ul> |
|
* <li>{@code api.add_product} 新建的是<b>临时产品</b>({@code state=0}), |
|
* 要用于出库还需另行上架为正式产品({@code api.pub_product},本轮未接入)</li> |
|
* <li>{@code api.update_product} 只对临时产品有效;若同 SKU 已是正式产品, |
|
* 新增会返回「产品SKU已存在」,这里原样抛给调用方,不静默忽略</li> |
|
* </ul> |
|
* |
|
* @return {@code status} 为 {@code ADDED} / {@code UPDATED},{@code rawStatus} 为信仓产品状态码 |
|
* @throws PlatformBusinessException 信仓业务失败(SKU / 条码重复、参数不合法等) |
|
*/ |
|
@Override |
|
public ProductResult createOrUpdate(WarehouseContext ctx, WarehouseProduct product) { |
|
AccessToken token = login(ctx); |
|
XincangDtos.ProductRequest body = XincangProductMapper.toRequest(product, token.value()); |
|
|
|
boolean existsAsTemporary = findTemporaryProduct(ctx, token, body.productNo) != null; |
|
if (existsAsTemporary) { |
|
execute(ctx, XincangConstants.PATH_PRODUCT_UPDATE, body, token, OP_PRODUCT_UPDATE); |
|
return ProductResult.of(body.productNo, "UPDATED", STATE_TEMPORARY); |
|
} |
|
execute(ctx, XincangConstants.PATH_PRODUCT_ADD, body, token, OP_PRODUCT_ADD); |
|
return ProductResult.of(body.productNo, "ADDED", STATE_TEMPORARY); |
|
} |
|
|
|
/** |
|
* 查该 SKU 是否已是临时产品。 |
|
* |
|
* <p>{@code api.productlist} 的 {@code key} 是 SKU 过滤条件,但文档没说是否精确匹配, |
|
* 这里再按 {@code product_no} 精确比对一次。</p> |
|
*/ |
|
private XincangDtos.ProductListItem findTemporaryProduct(WarehouseContext ctx, AccessToken token, |
|
String sku) { |
|
Map<String, Object> params = new LinkedHashMap<>(); |
|
params.put("state", 0); |
|
params.put("page", 1); |
|
params.put("limit", PRODUCT_QUERY_LIMIT); |
|
params.put("key", sku); |
|
String raw = executeGet(ctx, XincangConstants.PATH_PRODUCT_LIST, params, token, OP_PRODUCT_QUERY); |
|
|
|
List<XincangDtos.ProductListItem> items = |
|
json.listAt(raw, "rst.data", XincangDtos.ProductListItem.class); |
|
for (XincangDtos.ProductListItem item : items) { |
|
if (sku.equals(item.productNo)) { |
|
return item; |
|
} |
|
} |
|
return null; |
|
} |
|
|
|
// ------------------------------------------------------------------ 出库 |
|
|
|
/** |
|
* 下发出库单(一单多件)。 |
|
* |
|
* <p>信仓下单有两个接口:{@code api.add_order}(一票一件)与 |
|
* {@code api.add_order_multiple}(一单多件)。统一模型允许一单多行, |
|
* 所以这里固定走多件接口;单行订单也走它。</p> |
|
* |
|
* <p>该接口是 {@code multipart/form-data},{@code products} 字段本身是一段 JSON; |
|
* 返回的 {@code rst.order_no} 是信仓系统单号({@code DS-...}), |
|
* {@code rst.order_id} 是内部 id,优先取单号。</p> |
|
* |
|
* <p>查询 / 取消 / 包裹等接口本轮未接入,调用会显式抛不支持异常。</p> |
|
*/ |
|
@Override |
|
public OutboundReceipt create(WarehouseContext ctx, OutboundCommand cmd) { |
|
Map<String, String> form = XincangOrderMapper.toForm(ctx, cmd, json); |
|
String raw = executeMultipart(ctx, XincangConstants.PATH_ORDER_ADD_MULTIPLE, form, |
|
"warehouse.outbound.create"); |
|
XincangDtos.OrderResult result = json.fromJson(raw, XincangDtos.OrderResponse.class).rst; |
|
if (result == null || blank(result.orderNo)) { |
|
throw WarehouseException.builder() |
|
.message("xincang create order returned no rst.order_no: " + safeRelay(raw)) |
|
.operation("warehouse.outbound.create") |
|
.warehouseCode(ctx.warehouseCode()) |
|
.provider(provider().name()) |
|
.requestId(ctx.requestId()) |
|
.retryable(false) |
|
.rawResponse(safeRelay(raw)) |
|
.build(); |
|
} |
|
return OutboundReceipt.of(cmd.outboundRequestNo(), result.orderNo, null); |
|
} |
|
|
|
/** |
|
* 查订单详情({@code GET api.get_order})。 |
|
* |
|
* <p>信仓按 {@code order_no}(系统单号)或 {@code ckh}(参考号)二选一查询。 |
|
* 引用里的 {@code providerOrderId} 优先当作 {@code order_no}, |
|
* {@code outboundRequestNo} 当作 {@code ckh}——两者都传时以 provider 侧为准, |
|
* 因为只有仓单号能唯一定位。</p> |
|
* |
|
* <p>查不到时信仓返回 {@code errno != 0},这里作为业务异常抛出,不返回 null—— |
|
* 「查不到」与「查到了但没有数据」对调用方的意义不同。</p> |
|
*/ |
|
@Override |
|
public OutboundOrder get(WarehouseContext ctx, OutboundRef ref) { |
|
Map<String, Object> params = new LinkedHashMap<String, Object>(); |
|
if (!blank(ref.providerOrderId())) { |
|
params.put("order_no", ref.providerOrderId()); |
|
} else if (!blank(ref.outboundRequestNo())) { |
|
params.put("ckh", ref.outboundRequestNo()); |
|
} |
|
String raw = executeGet(ctx, XincangConstants.PATH_ORDER_DETAIL, params, login(ctx), |
|
"warehouse.outbound.get"); |
|
XincangDtos.OrderDetail detail = json.fromJson(raw, XincangDtos.OrderDetailResponse.class).rst; |
|
if (detail == null) { |
|
throw XincangUnsupportedOutbound.businessError(ctx, "warehouse.outbound.get", |
|
"xincang get_order returned no rst"); |
|
} |
|
return XincangOrderDetailMapper.toOrder(detail, ctx); |
|
} |
|
|
|
@Override |
|
public Page<OutboundOrder> query(WarehouseContext ctx, OutboundQuery query) { |
|
throw XincangUnsupportedOutbound.queryUnsupported(ctx); |
|
} |
|
|
|
/** |
|
* 取消资格预判。 |
|
* |
|
* <p>信仓没有独立的取消预判接口,也没有收费取消:按订单详情状态推断。 |
|
* 文档「删除订单」的语义是——待审核→删除、待发货→已取消、拣货中/已拣货→已拦截; |
|
* 已发货、已取消、已删除、已拦截都不再接受删除,判为 {@link CancelEligibility#BLOCKED}。</p> |
|
* |
|
* <p>查询失败时直接抛出,不猜成 FREE——猜错会下发出一个注定被拒的删除请求。</p> |
|
*/ |
|
@Override |
|
public CancelEligibility checkCancel(WarehouseContext ctx, OutboundRef ref) { |
|
OutboundOrder order = get(ctx, ref); |
|
return cancelEligibilityOf(order.status()); |
|
} |
|
|
|
/** |
|
* 删除订单({@code POST api.delete_order})。 |
|
* |
|
* <p>信仓的「删除」按订单状态分流:待审核→删除、待发货→已取消、 |
|
* 拣货中/已拣货→已拦截,因此统一模型里映射为 {@link CancelResult}。 |
|
* 仓拒绝时按 {@link OutboundCancelBlockedException} 抛出,方便与参数错误区分。</p> |
|
*/ |
|
@Override |
|
public CancelResult cancel(WarehouseContext ctx, CancelCommand cmd) { |
|
Map<String, Object> params = new LinkedHashMap<String, Object>(); |
|
if (!blank(cmd.providerOrderId())) { |
|
params.put("order_no", cmd.providerOrderId()); |
|
} else if (!blank(cmd.outboundRequestNo())) { |
|
params.put("ckh", cmd.outboundRequestNo()); |
|
} |
|
try { |
|
executePostQuery(ctx, XincangConstants.PATH_ORDER_DELETE, params, |
|
"warehouse.outbound.cancel"); |
|
} catch (PlatformBusinessException e) { |
|
// 信仓失败只回 err 文本,无法细分原因;取消场景统一按「不可取消」表达 |
|
throw new OutboundCancelBlockedException(WarehouseException.builder() |
|
.message("xincang refused order deletion: " + e.getMessage()) |
|
.operation("warehouse.outbound.cancel") |
|
.warehouseCode(ctx.warehouseCode()) |
|
.provider(provider().name()) |
|
.requestId(ctx.requestId()) |
|
.platformCode(e.platformCode()) |
|
.rawResponse(e.rawResponse()) |
|
.retryable(false)); |
|
} |
|
return CancelResult.builder() |
|
.outboundRequestNo(cmd.outboundRequestNo()) |
|
.providerOrderId(cmd.providerOrderId()) |
|
.eligibility(CancelEligibility.FREE) |
|
.cancelled(true) |
|
.build(); |
|
} |
|
|
|
/** |
|
* 取消资格映射。 |
|
* |
|
* <p>只有「尚未进入不可逆阶段」的状态可删;{@link OutboundStatus#UNKNOWN} |
|
* 也判为 BLOCKED,避免拿不准就下写请求。</p> |
|
*/ |
|
static CancelEligibility cancelEligibilityOf(OutboundStatus status) { |
|
if (status == null) { |
|
return CancelEligibility.BLOCKED; |
|
} |
|
switch (status) { |
|
case SHIPPED: |
|
case CANCELLED: |
|
case INTERCEPTED: |
|
case DELETED: |
|
case UNKNOWN: |
|
return CancelEligibility.BLOCKED; |
|
default: |
|
return CancelEligibility.FREE; |
|
} |
|
} |
|
|
|
@Override |
|
public List<PackageResult> packages(WarehouseContext ctx, OutboundRef ref) { |
|
throw XincangUnsupportedOutbound.packagesUnsupported(ctx); |
|
} |
|
|
|
// ------------------------------------------------------------------ 调拨 / 转运 |
|
|
|
/** |
|
* 新增转运({@code POST fba.do_fba})。 |
|
* |
|
* <p>信仓的转运是从信仓发往平台仓,统一模型里用 {@code TransferType.OUTBOUND}。 |
|
* 字典字段(订单类型 / 转运类型 / 转运方式 / 标签需求)只接受信仓字典原值, |
|
* 由调用方传入,SDK 不做归一。</p> |
|
*/ |
|
@Override |
|
public TransferOrder create(WarehouseContext ctx, TransferCommand cmd) { |
|
String productsJson = json.toJson(XincangTransferMapper.products(cmd)); |
|
XincangDtos.TransferRequest body = XincangTransferMapper.toRequest(cmd, ctx, productsJson); |
|
String raw = execute(ctx, XincangConstants.PATH_TRANSFER_CREATE, body, login(ctx), |
|
"warehouse.transfer.create"); |
|
XincangDtos.TransferResult result = json.fromJson(raw, XincangDtos.TransferResponse.class).rst; |
|
if (result == null || blank(result.orderNo)) { |
|
throw WarehouseException.builder() |
|
.message("xincang transfer returned no rst.order_no: " + safeRelay(raw)) |
|
.operation("warehouse.transfer.create") |
|
.warehouseCode(ctx.warehouseCode()) |
|
.provider(provider().name()) |
|
.requestId(ctx.requestId()) |
|
.retryable(false) |
|
.rawResponse(safeRelay(raw)) |
|
.build(); |
|
} |
|
return XincangTransferMapper.toCreated(cmd, result.orderNo); |
|
} |
|
|
|
/** |
|
* 转运审核({@code POST fba.do_approve?token=&order_no=})。 |
|
* |
|
* <p>注意是 POST 但无请求体,参数全在 query。</p> |
|
* |
|
* @param transferRequestNo 信仓转运单号,即 {@link #create} 返回的 {@code providerTransferNo} |
|
*/ |
|
@Override |
|
public void approve(WarehouseContext ctx, String transferRequestNo) { |
|
Map<String, Object> params = new LinkedHashMap<String, Object>(); |
|
params.put("order_no", transferRequestNo); |
|
executePostQuery(ctx, XincangConstants.PATH_TRANSFER_APPROVE, params, |
|
"warehouse.transfer.approve"); |
|
} |
|
|
|
/** |
|
* 转运详情({@code GET fba.fba_detail})。 |
|
* |
|
* @param providerTransferNo 信仓转运单号 {@code order_no} |
|
*/ |
|
@Override |
|
public TransferOrder getTransfer(WarehouseContext ctx, String providerTransferNo) { |
|
if (blank(providerTransferNo)) { |
|
throw XincangUnsupportedOutbound.businessError(ctx, "warehouse.transfer.get", |
|
"providerTransferNo must not be blank"); |
|
} |
|
Map<String, Object> params = new LinkedHashMap<String, Object>(); |
|
params.put("order_no", providerTransferNo); |
|
String raw = executeGet(ctx, XincangConstants.PATH_TRANSFER_DETAIL, params, login(ctx), |
|
"warehouse.transfer.get"); |
|
XincangDtos.TransferDetail detail = |
|
json.fromJson(raw, XincangDtos.TransferDetailResponse.class).rst; |
|
if (detail == null) { |
|
throw XincangUnsupportedOutbound.businessError(ctx, "warehouse.transfer.get", |
|
"xincang fba_detail returned no rst"); |
|
} |
|
return XincangTransferDetailMapper.toOrder(detail); |
|
} |
|
|
|
/** |
|
* 删除转运({@code POST fba.delete_fba})。 |
|
* |
|
* <p>信仓<b>只允许待审核状态</b>删除,其余状态由仓方拒绝(errno != 0), |
|
* 这里原样抛出业务异常,不擅自退化成「取消」。</p> |
|
*/ |
|
@Override |
|
public void deleteTransfer(WarehouseContext ctx, String providerTransferNo) { |
|
if (blank(providerTransferNo)) { |
|
throw XincangUnsupportedOutbound.businessError(ctx, "warehouse.transfer.delete", |
|
"providerTransferNo must not be blank"); |
|
} |
|
Map<String, Object> params = new LinkedHashMap<String, Object>(); |
|
params.put("order_no", providerTransferNo); |
|
executePostQuery(ctx, XincangConstants.PATH_TRANSFER_DELETE, params, |
|
"warehouse.transfer.delete"); |
|
} |
|
|
|
// ------------------------------------------------------------------ internals |
|
|
|
/** 写接口:JSON 请求体(含 token)+ query token。 */ |
|
private String execute(WarehouseContext ctx, String path, Object body, |
|
AccessToken token, String operation) { |
|
rateLimiter.acquire(path, XincangConstants.PERMITS_PER_SECOND); |
|
HttpRequest req = requestFactory.postJsonWithToken(ctx.endpointBaseUrl(), path, |
|
json.toJson(body), token.value(), operation); |
|
HttpResponse resp = transport.execute(req); |
|
return XincangEnvelope.of(resp, json, operation, ctx.requestId()).body(); |
|
} |
|
|
|
/** 写接口:multipart 表单 + query token(信仓一单多件下单)。 */ |
|
private String executeMultipart(WarehouseContext ctx, String path, Map<String, String> form, |
|
String operation) { |
|
rateLimiter.acquire(path, XincangConstants.PERMITS_PER_SECOND); |
|
HttpRequest req = XincangMultipart.post(ctx.endpointBaseUrl(), path, form, |
|
login(ctx).value(), operation); |
|
HttpResponse resp = transport.execute(req); |
|
return XincangEnvelope.of(resp, json, operation, ctx.requestId()).body(); |
|
} |
|
|
|
/** POST 但无请求体:参数全在 query(转运审核)。 */ |
|
private String executePostQuery(WarehouseContext ctx, String path, Map<String, Object> params, |
|
String operation) { |
|
rateLimiter.acquire(path, XincangConstants.PERMITS_PER_SECOND); |
|
HttpRequest req = requestFactory.postWithoutBodyWithToken(ctx.endpointBaseUrl(), path, params, |
|
login(ctx).value(), operation); |
|
HttpResponse resp = transport.execute(req); |
|
return XincangEnvelope.of(resp, json, operation, ctx.requestId()).body(); |
|
} |
|
|
|
/** 读接口:query token。 */ |
|
private String executeGet(WarehouseContext ctx, String path, Map<String, Object> params, |
|
AccessToken token, String operation) { |
|
rateLimiter.acquire(path, XincangConstants.PERMITS_PER_SECOND); |
|
HttpRequest req = requestFactory.getWithToken(ctx.endpointBaseUrl(), path, params, |
|
token.value(), operation); |
|
HttpResponse resp = transport.execute(req); |
|
return XincangEnvelope.of(resp, json, operation, ctx.requestId()).body(); |
|
} |
|
|
|
/** |
|
* 令牌缓存维度:信仓 token 按客户(appkey)发放,同一 appkey 下多仓共用一个 token。 |
|
* |
|
* <p>用 appkey 而不是 {@code warehouseCode},避免同客户多仓重复登录。</p> |
|
*/ |
|
static String tokenKey(ChannelSecret secret) { |
|
return XincangConstants.ADAPTER_ID + ":" + secret.appKey(); |
|
} |
|
|
|
private static boolean blank(String v) { |
|
return v == null || v.trim().isEmpty(); |
|
} |
|
|
|
/** 原始响应可能含收件人信息,异常里只留首段。 */ |
|
private static String safeRelay(String raw) { |
|
if (raw == null) { |
|
return null; |
|
} |
|
return raw.length() <= 300 ? raw : raw.substring(0, 300) + "..."; |
|
} |
|
}
|
|
|