DocHtmlService.java
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.peony.netty.service;
import com.peony.netty.util.HbaseFileSystem;
import com.peony.util.StringUtils;
import com.qingcloud.qingstor.Qingstor;
import org.apache.hadoop.hbase.TableName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DocHtmlService {
private static DocHtmlService instance = new DocHtmlService();
private final TableName tableContent = TableName.valueOf("doc_html");
private final String bucketHtml = "doc-html";
private Logger logger = LoggerFactory.getLogger(DocHtmlService.class);
private HbaseFileSystem fileSystem = HbaseFileSystem.getInstance();
public static DocHtmlService getInstance() {
return instance;
}
public String get(String id, boolean depress) {
String html = null;
try {
// html = fileSystem.get(id, tableContent, depress);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
if (StringUtils.isEmpty(html)) {
try {
String htmlCompress = Qingstor.getObject(bucketHtml, id);
html = depress ? StringUtils.depressString(htmlCompress) : htmlCompress;
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
if (html == null) {
logger.warn("查询id: " + id + " HTML为空");
return null;
}
return html;
}
}