use of com.bc.pmpheep.general.runnable.WechatArticleCrawlerTask in project pmph by BCSquad.
the class WechatArticleService method runCrawler.
public String runCrawler(String url) throws CheckedServiceException {
if (StringUtil.isEmpty(url)) {
throw new CheckedServiceException(CheckedExceptionBusiness.WECHAT_ARTICLE, CheckedExceptionResult.NULL_PARAM, "给定链接不能为空");
}
if (url.length() < 25) {
throw new CheckedServiceException(CheckedExceptionBusiness.WECHAT_ARTICLE, CheckedExceptionResult.ILLEGAL_PARAM, "同步失败,请检查链接地址是否正确,或者其他原因");
} else {
String httpStr = url.substring(0, 23);
String httpsStr = url.substring(0, 24);
if (!"http://mp.weixin.qq.com".equals(httpStr) && !"https://mp.weixin.qq.com".equals(httpsStr)) {
throw new CheckedServiceException(CheckedExceptionBusiness.WECHAT_ARTICLE, CheckedExceptionResult.ILLEGAL_PARAM, "同步失败,请检查链接地址是否正确,或者其他原因");
}
}
String guid = String.valueOf(System.currentTimeMillis()).concat(String.valueOf(RandomUtil.getRandomNum()));
taskExecutor.execute(new WechatArticleCrawlerTask(new WechatArticle(guid, url)));
return guid;
}
Aggregations