fix #98
This commit is contained in:
parent
1e1bb470c5
commit
52cedac783
11 changed files with 234 additions and 13 deletions
42
src/main/java/jp/sf/fess/helper/FileTypeHelper.java
Normal file
42
src/main/java/jp/sf/fess/helper/FileTypeHelper.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package jp.sf.fess.helper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.seasar.framework.util.StringUtil;
|
||||
|
||||
public class FileTypeHelper {
|
||||
protected String fieldName = "filetype_s";
|
||||
|
||||
protected String defaultValue = "others";
|
||||
|
||||
protected Map<String, String> mimetypeMap = new HashMap<String, String>();
|
||||
|
||||
public void add(final String mimetype, final String filetype) {
|
||||
mimetypeMap.put(mimetype, filetype);
|
||||
}
|
||||
|
||||
public String get(final String mimetype) {
|
||||
final String filetype = mimetypeMap.get(mimetype);
|
||||
if (StringUtil.isBlank(filetype)) {
|
||||
return defaultValue;
|
||||
}
|
||||
return filetype;
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
public void setFieldName(final String fieldName) {
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setDefaultValue(final String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
}
|
|
@ -82,7 +82,7 @@ public class QueryHelperImpl implements QueryHelper, Serializable {
|
|||
|
||||
protected String[] responseFields = new String[] { "id", "docId", "score",
|
||||
"boost", "contentLength", "host", "site", "lastModified",
|
||||
"mimetype", "created", "title", "digest", "url",
|
||||
"mimetype", "filetype_s", "created", "title", "digest", "url",
|
||||
"clickCount_l_x_dv", "favoriteCount_l_x_dv", "screenshot_s_s",
|
||||
"cid_s_s" };
|
||||
|
||||
|
@ -93,12 +93,12 @@ public class QueryHelperImpl implements QueryHelper, Serializable {
|
|||
|
||||
protected String[] searchFields = new String[] { "url", "docId", "host",
|
||||
"title", "content", "contentLength", "lastModified", "mimetype",
|
||||
"label", "segment", "clickCount_l_x_dv", "favoriteCount_l_x_dv",
|
||||
"inurl" };
|
||||
"filetype_s", "label", "segment", "clickCount_l_x_dv",
|
||||
"favoriteCount_l_x_dv", "inurl" };
|
||||
|
||||
protected String[] facetFields = new String[] { "url", "host", "title",
|
||||
"content", "contentLength", "lastModified", "mimetype", "label",
|
||||
"segment" };
|
||||
"content", "contentLength", "lastModified", "mimetype",
|
||||
"filetype_s", "label", "segment" };
|
||||
|
||||
protected String sortPrefix = "sort:";
|
||||
|
||||
|
@ -1095,6 +1095,7 @@ public class QueryHelperImpl implements QueryHelper, Serializable {
|
|||
this.responseFields = responseFields;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getResponseDocValuesFields() {
|
||||
return responseDocValuesFields;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import jp.sf.fess.Constants;
|
|||
import jp.sf.fess.db.exentity.CrawlingConfig;
|
||||
import jp.sf.fess.helper.CrawlingConfigHelper;
|
||||
import jp.sf.fess.helper.CrawlingSessionHelper;
|
||||
import jp.sf.fess.helper.FileTypeHelper;
|
||||
import jp.sf.fess.helper.LabelTypeHelper;
|
||||
import jp.sf.fess.helper.PathMappingHelper;
|
||||
import jp.sf.fess.helper.SambaHelper;
|
||||
|
@ -113,7 +114,8 @@ public abstract class AbstractFessFileTransformer extends
|
|||
final Map<String, String> params = new HashMap<String, String>();
|
||||
params.put(TikaMetadataKeys.RESOURCE_NAME_KEY,
|
||||
getResourceName(responseData));
|
||||
params.put(HttpHeaders.CONTENT_TYPE, responseData.getMimeType());
|
||||
final String mimeType = responseData.getMimeType();
|
||||
params.put(HttpHeaders.CONTENT_TYPE, mimeType);
|
||||
params.put(HttpHeaders.CONTENT_ENCODING, responseData.getCharSet());
|
||||
final StringBuilder contentBuf = new StringBuilder(1000);
|
||||
final StringBuilder contentMetaBuf = new StringBuilder(1000);
|
||||
|
@ -187,6 +189,8 @@ public abstract class AbstractFessFileTransformer extends
|
|||
final CrawlingConfig crawlingConfig = crawlingConfigHelper
|
||||
.get(responseData.getSessionId());
|
||||
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
|
||||
final FileTypeHelper fileTypeHelper = ComponentUtil.getFileTypeHelper();
|
||||
|
||||
String urlEncoding;
|
||||
final UrlQueue urlQueue = CrawlingParameterUtil.getUrlQueue();
|
||||
if (urlQueue != null && urlQueue.getEncoding() != null) {
|
||||
|
@ -262,7 +266,12 @@ public abstract class AbstractFessFileTransformer extends
|
|||
// TODO anchor
|
||||
putResultDataBody(dataMap, "anchor", "");
|
||||
// mimetype
|
||||
putResultDataBody(dataMap, "mimetype", responseData.getMimeType());
|
||||
putResultDataBody(dataMap, "mimetype", mimeType);
|
||||
if (fileTypeHelper != null) {
|
||||
// filetype
|
||||
putResultDataBody(dataMap, fileTypeHelper.getFieldName(),
|
||||
fileTypeHelper.get(mimeType));
|
||||
}
|
||||
// contentLength
|
||||
putResultDataBody(dataMap, "contentLength",
|
||||
Long.toString(responseData.getContentLength()));
|
||||
|
|
|
@ -40,6 +40,7 @@ import jp.sf.fess.Constants;
|
|||
import jp.sf.fess.db.exentity.CrawlingConfig;
|
||||
import jp.sf.fess.helper.CrawlingConfigHelper;
|
||||
import jp.sf.fess.helper.CrawlingSessionHelper;
|
||||
import jp.sf.fess.helper.FileTypeHelper;
|
||||
import jp.sf.fess.helper.LabelTypeHelper;
|
||||
import jp.sf.fess.helper.OverlappingHostHelper;
|
||||
import jp.sf.fess.helper.PathMappingHelper;
|
||||
|
@ -224,6 +225,8 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer {
|
|||
final CrawlingConfig crawlingConfig = crawlingConfigHelper
|
||||
.get(responseData.getSessionId());
|
||||
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
|
||||
final FileTypeHelper fileTypeHelper = ComponentUtil.getFileTypeHelper();
|
||||
|
||||
String urlEncoding;
|
||||
final UrlQueue urlQueue = CrawlingParameterUtil.getUrlQueue();
|
||||
if (urlQueue != null && urlQueue.getEncoding() != null) {
|
||||
|
@ -268,7 +271,13 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer {
|
|||
putResultDataBody(dataMap, "anchor",
|
||||
getAnchorList(document, responseData));
|
||||
// mimetype
|
||||
putResultDataBody(dataMap, "mimetype", responseData.getMimeType());
|
||||
final String mimeType = responseData.getMimeType();
|
||||
putResultDataBody(dataMap, "mimetype", mimeType);
|
||||
if (fileTypeHelper != null) {
|
||||
// filetype
|
||||
putResultDataBody(dataMap, fileTypeHelper.getFieldName(),
|
||||
fileTypeHelper.get(mimeType));
|
||||
}
|
||||
// contentLength
|
||||
putResultDataBody(dataMap, "contentLength",
|
||||
Long.toString(responseData.getContentLength()));
|
||||
|
|
|
@ -23,6 +23,7 @@ import jp.sf.fess.helper.CrawlingConfigHelper;
|
|||
import jp.sf.fess.helper.CrawlingSessionHelper;
|
||||
import jp.sf.fess.helper.DatabaseHelper;
|
||||
import jp.sf.fess.helper.DocumentHelper;
|
||||
import jp.sf.fess.helper.FileTypeHelper;
|
||||
import jp.sf.fess.helper.HotSearchWordHelper;
|
||||
import jp.sf.fess.helper.IntervalControlHelper;
|
||||
import jp.sf.fess.helper.JobHelper;
|
||||
|
@ -53,6 +54,8 @@ public final class ComponentUtil {
|
|||
|
||||
private static final String MAIL_HELPER = "mailHelper";
|
||||
|
||||
private static final String FILE_TYPE_HELPER = "fileTypeHelper";
|
||||
|
||||
private static final String EXTRACTOR_FACTORY = "extractorFactory";
|
||||
|
||||
private static final String INTERVAL_CONTROL_HELPER = "intervalControlHelper";
|
||||
|
@ -203,6 +206,10 @@ public final class ComponentUtil {
|
|||
return SingletonS2Container.getComponent(MAIL_HELPER);
|
||||
}
|
||||
|
||||
public static FileTypeHelper getFileTypeHelper() {
|
||||
return SingletonS2Container.getComponent(FILE_TYPE_HELPER);
|
||||
}
|
||||
|
||||
public static DatabaseHelper getDatabaseHelper() {
|
||||
return SingletonS2Container.getComponent(DATABASE_HELPER);
|
||||
}
|
||||
|
|
|
@ -50,6 +50,40 @@
|
|||
</initMethod>
|
||||
-->
|
||||
</component>
|
||||
<component name="fileTypeHelper" class="jp.sf.fess.helper.FileTypeHelper">
|
||||
<initMethod name="add">
|
||||
<arg>"text/html"</arg>
|
||||
<arg>"html"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/msword"</arg>
|
||||
<arg>"word"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/vnd.openxmlformats-officedocument.wordprocessingml.document"</arg>
|
||||
<arg>"word"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/vnd.ms-excel"</arg>
|
||||
<arg>"excel"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"</arg>
|
||||
<arg>"excel"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/vnd.ms-powerpoint"</arg>
|
||||
<arg>"powerpoint"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/vnd.openxmlformats-officedocument.presentationml.presentation"</arg>
|
||||
<arg>"powerpoint"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/pdf"</arg>
|
||||
<arg>"pdf"</arg>
|
||||
</initMethod>
|
||||
</component>
|
||||
<component name="databaseHelper" class="jp.sf.fess.helper.impl.DatabaseHelperImpl">
|
||||
<aspect pointcut="optimize">
|
||||
j2ee.requiresNewTx
|
||||
|
|
|
@ -50,6 +50,40 @@
|
|||
</initMethod>
|
||||
-->
|
||||
</component>
|
||||
<component name="fileTypeHelper" class="jp.sf.fess.helper.FileTypeHelper">
|
||||
<initMethod name="add">
|
||||
<arg>"text/html"</arg>
|
||||
<arg>"html"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/msword"</arg>
|
||||
<arg>"word"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/vnd.openxmlformats-officedocument.wordprocessingml.document"</arg>
|
||||
<arg>"word"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/vnd.ms-excel"</arg>
|
||||
<arg>"excel"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"</arg>
|
||||
<arg>"excel"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/vnd.ms-powerpoint"</arg>
|
||||
<arg>"powerpoint"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/vnd.openxmlformats-officedocument.presentationml.presentation"</arg>
|
||||
<arg>"powerpoint"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/pdf"</arg>
|
||||
<arg>"pdf"</arg>
|
||||
</initMethod>
|
||||
</component>
|
||||
<component name="databaseHelper" class="jp.sf.fess.helper.impl.DatabaseHelperImpl">
|
||||
<aspect pointcut="optimize">
|
||||
j2ee.requiresNewTx
|
||||
|
|
|
@ -41,7 +41,13 @@
|
|||
"contentLength:[10000 TO 99999]",
|
||||
"contentLength:[100000 TO 499999]",
|
||||
"contentLength:[500000 TO 999999]",
|
||||
"contentLength:[1000000 TO *]"
|
||||
"contentLength:[1000000 TO *]",
|
||||
"filetype_s:html",
|
||||
"filetype_s:word",
|
||||
"filetype_s:excel",
|
||||
"filetype_s:powerpoint",
|
||||
"filetype_s:pdf",
|
||||
"filetype_s:others"
|
||||
}</property>
|
||||
</component>
|
||||
</property>
|
||||
|
@ -63,22 +69,22 @@
|
|||
</initMethod>
|
||||
<initMethod name="setApiResponseFields">
|
||||
<arg>new String[]{"id", "docId", "score", "boost",
|
||||
"contentLength", "host", "site", "lastModified", "mimetype",
|
||||
"contentLength", "host", "site", "lastModified", "mimetype", "filetype_s",
|
||||
"created", "title", "digest", "url"}</arg>
|
||||
</initMethod>
|
||||
<!--
|
||||
<property name="additionalGeoQuery">"location_i_i:1"</property>
|
||||
<property name="responseFields">new String[]{"id", "docId", "score", "boost",
|
||||
"contentLength", "host", "site", "lastModified", "mimetype",
|
||||
"contentLength", "host", "site", "lastModified", "mimetype", "filetype_s",
|
||||
"created", "title", "digest", "url", "screenshot_s_s", "cid_s_s"}</property>
|
||||
<property name="responseDocValuesFields">new String[]{
|
||||
"clickCount_l_x_dv", "favoriteCount_l_x_dv"}</property>
|
||||
<property name="highlightingFields">new String[]{"digest", "cache" }</property>
|
||||
<property name="searchFields">new String[]{"url", "docId", "host",
|
||||
"title", "content", "contentLength", "lastModified", "mimetype",
|
||||
"title", "content", "contentLength", "lastModified", "mimetype", "filetype_s",
|
||||
"label", "segment" }</property>
|
||||
<property name="facetFields">new String[]{"url", "host",
|
||||
"title", "content", "contentLength", "lastModified", "mimetype",
|
||||
"title", "content", "contentLength", "lastModified", "mimetype", "filetype_s",
|
||||
"label", "segment" }</property>
|
||||
<property name="sortPrefix">"sort:"</property>
|
||||
<property name="supportedSortFields">new String[]{"created",
|
||||
|
@ -161,6 +167,37 @@
|
|||
</component>
|
||||
</arg>
|
||||
</initMethod>
|
||||
<initMethod name="addFacetQueryView">
|
||||
<arg>
|
||||
<component class="jp.sf.fess.entity.FacetQueryView">
|
||||
<property name="title">"label.facet_filetype_title"</property>
|
||||
<initMethod name="addQuery">
|
||||
<arg>"label.facet_filetype_html"</arg>
|
||||
<arg>"filetype_s:html"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="addQuery">
|
||||
<arg>"label.facet_filetype_word"</arg>
|
||||
<arg>"filetype_s:word"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="addQuery">
|
||||
<arg>"label.facet_filetype_excel"</arg>
|
||||
<arg>"filetype_s:excel"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="addQuery">
|
||||
<arg>"label.facet_filetype_powerpoint"</arg>
|
||||
<arg>"filetype_s:powerpoint"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="addQuery">
|
||||
<arg>"label.facet_filetype_pdf"</arg>
|
||||
<arg>"filetype_s:pdf"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="addQuery">
|
||||
<arg>"label.facet_filetype_others"</arg>
|
||||
<arg>"filetype_s:others"</arg>
|
||||
</initMethod>
|
||||
</component>
|
||||
</arg>
|
||||
</initMethod>
|
||||
<!--
|
||||
<property name="encodeUrlLink">false</property>
|
||||
<property name="mobileDescriptionLength">50</property>
|
||||
|
|
|
@ -371,6 +371,13 @@ label.facet_contentLength_10kto100k=10kb - 100kb
|
|||
label.facet_contentLength_100kto500k=100kb - 500kb
|
||||
label.facet_contentLength_500kto1m=500kb - 1mb
|
||||
label.facet_contentLength_1m=1mb -
|
||||
label.facet_filetype_title=File Type
|
||||
label.facet_filetype_html=HTML
|
||||
label.facet_filetype_word=Word
|
||||
label.facet_filetype_excel=Excel
|
||||
label.facet_filetype_powerpoint=PowerPoint
|
||||
label.facet_filetype_pdf=PDF
|
||||
label.facet_filetype_others=PDF
|
||||
|
||||
# view/error.jsp
|
||||
labels.error_title=Error
|
||||
|
|
|
@ -371,6 +371,13 @@ label.facet_contentLength_10kto100k=10KB - 100KB
|
|||
label.facet_contentLength_100kto500k=100KB - 500KB
|
||||
label.facet_contentLength_500kto1m=500KB - 1MB
|
||||
label.facet_contentLength_1m=1MB -
|
||||
label.facet_filetype_title=\u30d5\u30a1\u30a4\u30eb\u306e\u7a2e\u985e
|
||||
label.facet_filetype_html=HTML
|
||||
label.facet_filetype_word=Word
|
||||
label.facet_filetype_excel=Excel
|
||||
label.facet_filetype_powerpoint=PowerPoint
|
||||
label.facet_filetype_pdf=PDF
|
||||
label.facet_filetype_others=\u305d\u306e\u4ed6
|
||||
|
||||
# view/error.jsp
|
||||
labels.error_title=\u30a8\u30e9\u30fc
|
||||
|
|
|
@ -50,6 +50,40 @@
|
|||
</initMethod>
|
||||
-->
|
||||
</component>
|
||||
<component name="fileTypeHelper" class="jp.sf.fess.helper.FileTypeHelper">
|
||||
<initMethod name="add">
|
||||
<arg>"text/html"</arg>
|
||||
<arg>"html"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/msword"</arg>
|
||||
<arg>"word"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/vnd.openxmlformats-officedocument.wordprocessingml.document"</arg>
|
||||
<arg>"word"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/vnd.ms-excel"</arg>
|
||||
<arg>"excel"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"</arg>
|
||||
<arg>"excel"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/vnd.ms-powerpoint"</arg>
|
||||
<arg>"powerpoint"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/vnd.openxmlformats-officedocument.presentationml.presentation"</arg>
|
||||
<arg>"powerpoint"</arg>
|
||||
</initMethod>
|
||||
<initMethod name="add">
|
||||
<arg>"application/pdf"</arg>
|
||||
<arg>"pdf"</arg>
|
||||
</initMethod>
|
||||
</component>
|
||||
<!-- for H2 -->
|
||||
<component name="databaseHelper" class="jp.sf.fess.helper.impl.H2DatabaseHelperImpl">
|
||||
<!--
|
||||
|
|
Loading…
Add table
Reference in a new issue