Browse Source

add timestamp and fix fileupload validation

Shinsuke Sugaya 9 năm trước cách đây
mục cha
commit
c1967193cb

+ 1 - 1
pom.xml

@@ -39,7 +39,7 @@
 
 		<!-- Main Framework -->
 		<dbflute.version>1.1.0-sp8</dbflute.version>
-		<lastaflute.version>0.6.6</lastaflute.version>
+		<lastaflute.version>0.6.7-A-SNAPSHOT</lastaflute.version>
 		<lasta.taglib.version>0.6.1</lasta.taglib.version>
 		<servlet.version>3.1.0</servlet.version>
 		<jsp.version>2.3.1</jsp.version>

+ 5 - 8
src/main/java/org/codelibs/fess/app/service/CrawlingSessionService.java

@@ -207,14 +207,11 @@ public class CrawlingSessionService implements Serializable {
     }
 
     public void deleteOldSessions(final Set<String> activeSessionId) {
-        final List<CrawlingSession> activeSessionList = crawlingSessionBhv.selectList(cb -> {
-            if (activeSessionId.isEmpty()) {
-                cb.query().matchAll();
-            } else {
-                cb.query().setSessionId_InScope(activeSessionId);
-            }
-            cb.specify().columnId();
-        });
+        final List<CrawlingSession> activeSessionList =
+                activeSessionId.isEmpty() ? Collections.emptyList() : crawlingSessionBhv.selectList(cb -> {
+                    cb.query().setSessionId_InScope(activeSessionId);
+                    cb.specify().columnId();
+                });
         final List<String> idList = activeSessionList.stream().map(session -> session.getId()).collect(Collectors.toList());
         if (!idList.isEmpty()) {
             crawlingSessionInfoBhv.queryDelete(cb1 -> {

+ 10 - 3
src/main/java/org/codelibs/fess/crawler/transformer/AbstractFessFileTransformer.java

@@ -244,7 +244,8 @@ public abstract class AbstractFessFileTransformer extends AbstractFessXpathTrans
         // url
         putResultDataBody(dataMap, fessConfig.getIndexFieldUrl(), url);
         // created
-        putResultDataBody(dataMap, fessConfig.getIndexFieldCreated(), systemHelper.getCurrentTime());
+        Date now = systemHelper.getCurrentTime();
+        putResultDataBody(dataMap, fessConfig.getIndexFieldCreated(), now);
         // TODO anchor
         putResultDataBody(dataMap, fessConfig.getIndexFieldAnchor(), StringUtil.EMPTY);
         // mimetype
@@ -256,8 +257,14 @@ public abstract class AbstractFessFileTransformer extends AbstractFessXpathTrans
         // contentLength
         putResultDataBody(dataMap, fessConfig.getIndexFieldContentLength(), Long.toString(responseData.getContentLength()));
         //  lastModified
-        if (responseData.getLastModified() != null) {
-            putResultDataBody(dataMap, fessConfig.getIndexFieldLastModified(), responseData.getLastModified());
+        Date lastModified = responseData.getLastModified();
+        if (lastModified != null) {
+            putResultDataBody(dataMap, fessConfig.getIndexFieldLastModified(), lastModified);
+            // timestamp
+            putResultDataBody(dataMap, fessConfig.getIndexFieldTimestamp(), lastModified);
+        } else {
+            // timestamp
+            putResultDataBody(dataMap, fessConfig.getIndexFieldTimestamp(), now);
         }
         // indexingTarget
         putResultDataBody(dataMap, Constants.INDEXING_TARGET, indexingTarget);

+ 10 - 3
src/main/java/org/codelibs/fess/crawler/transformer/FessXpathTransformer.java

@@ -256,7 +256,8 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer {
         // url
         putResultDataBody(dataMap, fessConfig.getIndexFieldUrl(), url);
         // created
-        putResultDataBody(dataMap, fessConfig.getIndexFieldCreated(), systemHelper.getCurrentTime());
+        Date now = systemHelper.getCurrentTime();
+        putResultDataBody(dataMap, fessConfig.getIndexFieldCreated(), now);
         // anchor
         putResultDataBody(dataMap, fessConfig.getIndexFieldAnchor(), getAnchorList(document, responseData));
         // mimetype
@@ -269,8 +270,14 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer {
         // contentLength
         putResultDataBody(dataMap, fessConfig.getIndexFieldContentLength(), Long.toString(responseData.getContentLength()));
         //  lastModified
-        if (responseData.getLastModified() != null) {
-            putResultDataBody(dataMap, fessConfig.getIndexFieldLastModified(), responseData.getLastModified());
+        Date lastModified = responseData.getLastModified();
+        if (lastModified != null) {
+            putResultDataBody(dataMap, fessConfig.getIndexFieldLastModified(), lastModified);
+            // timestamp
+            putResultDataBody(dataMap, fessConfig.getIndexFieldTimestamp(), lastModified);
+        } else {
+            // timestamp
+            putResultDataBody(dataMap, fessConfig.getIndexFieldTimestamp(), now);
         }
         // indexingTarget
         putResultDataBody(dataMap, Constants.INDEXING_TARGET, indexingTarget);

+ 25 - 19
src/main/java/org/codelibs/fess/helper/QueryHelper.java

@@ -166,21 +166,21 @@ public class QueryHelper implements Serializable {
             responseFields =
                     new String[] { SCORE_FIELD, fessConfig.getIndexFieldId(), fessConfig.getIndexFieldDocId(),
                             fessConfig.getIndexFieldBoost(), fessConfig.getIndexFieldContentLength(), fessConfig.getIndexFieldHost(),
-                            fessConfig.getIndexFieldSite(), fessConfig.getIndexFieldLastModified(), fessConfig.getIndexFieldMimetype(),
-                            fessConfig.getIndexFieldFiletype(), fessConfig.getIndexFieldCreated(), fessConfig.getIndexFieldTitle(),
-                            fessConfig.getIndexFieldDigest(), fessConfig.getIndexFieldUrl(), fessConfig.getIndexFieldClickCount(),
-                            fessConfig.getIndexFieldFavoriteCount(), fessConfig.getIndexFieldConfigId(), fessConfig.getIndexFieldLang(),
-                            fessConfig.getIndexFieldHasCache() };
+                            fessConfig.getIndexFieldSite(), fessConfig.getIndexFieldLastModified(), fessConfig.getIndexFieldTimestamp(),
+                            fessConfig.getIndexFieldMimetype(), fessConfig.getIndexFieldFiletype(), fessConfig.getIndexFieldCreated(),
+                            fessConfig.getIndexFieldTitle(), fessConfig.getIndexFieldDigest(), fessConfig.getIndexFieldUrl(),
+                            fessConfig.getIndexFieldClickCount(), fessConfig.getIndexFieldFavoriteCount(),
+                            fessConfig.getIndexFieldConfigId(), fessConfig.getIndexFieldLang(), fessConfig.getIndexFieldHasCache() };
         }
         if (cacheResponseFields == null) {
             cacheResponseFields =
                     new String[] { SCORE_FIELD, fessConfig.getIndexFieldId(), fessConfig.getIndexFieldDocId(),
                             fessConfig.getIndexFieldBoost(), fessConfig.getIndexFieldContentLength(), fessConfig.getIndexFieldHost(),
-                            fessConfig.getIndexFieldSite(), fessConfig.getIndexFieldLastModified(), fessConfig.getIndexFieldMimetype(),
-                            fessConfig.getIndexFieldFiletype(), fessConfig.getIndexFieldCreated(), fessConfig.getIndexFieldTitle(),
-                            fessConfig.getIndexFieldDigest(), fessConfig.getIndexFieldUrl(), fessConfig.getIndexFieldClickCount(),
-                            fessConfig.getIndexFieldFavoriteCount(), fessConfig.getIndexFieldConfigId(), fessConfig.getIndexFieldLang(),
-                            fessConfig.getIndexFieldCache() };
+                            fessConfig.getIndexFieldSite(), fessConfig.getIndexFieldLastModified(), fessConfig.getIndexFieldTimestamp(),
+                            fessConfig.getIndexFieldMimetype(), fessConfig.getIndexFieldFiletype(), fessConfig.getIndexFieldCreated(),
+                            fessConfig.getIndexFieldTitle(), fessConfig.getIndexFieldDigest(), fessConfig.getIndexFieldUrl(),
+                            fessConfig.getIndexFieldClickCount(), fessConfig.getIndexFieldFavoriteCount(),
+                            fessConfig.getIndexFieldConfigId(), fessConfig.getIndexFieldLang(), fessConfig.getIndexFieldCache() };
         }
         if (responseDocValuesFields == null) {
             responseDocValuesFields = new String[] { fessConfig.getIndexFieldClickCount(), fessConfig.getIndexFieldFavoriteCount() };
@@ -193,22 +193,31 @@ public class QueryHelper implements Serializable {
                     new String[] { INURL_FIELD, fessConfig.getIndexFieldUrl(), fessConfig.getIndexFieldDocId(),
                             fessConfig.getIndexFieldHost(), fessConfig.getIndexFieldTitle(), fessConfig.getIndexFieldContent(),
                             fessConfig.getIndexFieldContentLength(), fessConfig.getIndexFieldLastModified(),
-                            fessConfig.getIndexFieldMimetype(), fessConfig.getIndexFieldFiletype(), fessConfig.getIndexFieldLabel(),
-                            fessConfig.getIndexFieldSegment(), fessConfig.getIndexFieldClickCount(),
+                            fessConfig.getIndexFieldTimestamp(), fessConfig.getIndexFieldMimetype(), fessConfig.getIndexFieldFiletype(),
+                            fessConfig.getIndexFieldLabel(), fessConfig.getIndexFieldSegment(), fessConfig.getIndexFieldClickCount(),
                             fessConfig.getIndexFieldFavoriteCount(), fessConfig.getIndexFieldLang() };
         }
         if (facetFields == null) {
             facetFields =
                     new String[] { fessConfig.getIndexFieldUrl(), fessConfig.getIndexFieldHost(), fessConfig.getIndexFieldTitle(),
                             fessConfig.getIndexFieldContent(), fessConfig.getIndexFieldContentLength(),
-                            fessConfig.getIndexFieldLastModified(), fessConfig.getIndexFieldMimetype(), fessConfig.getIndexFieldFiletype(),
-                            fessConfig.getIndexFieldLabel(), fessConfig.getIndexFieldSegment() };
+                            fessConfig.getIndexFieldLastModified(), fessConfig.getIndexFieldTimestamp(),
+                            fessConfig.getIndexFieldMimetype(), fessConfig.getIndexFieldFiletype(), fessConfig.getIndexFieldLabel(),
+                            fessConfig.getIndexFieldSegment() };
         }
         if (supportedSortFields == null) {
             supportedSortFields =
                     new String[] { fessConfig.getIndexFieldCreated(), fessConfig.getIndexFieldContentLength(),
-                            fessConfig.getIndexFieldLastModified(), fessConfig.getIndexFieldClickCount(),
-                            fessConfig.getIndexFieldFavoriteCount() };
+                            fessConfig.getIndexFieldLastModified(), fessConfig.getIndexFieldTimestamp(),
+                            fessConfig.getIndexFieldClickCount(), fessConfig.getIndexFieldFavoriteCount() };
+        }
+        if (apiResponseFieldSet == null) {
+            setApiResponseFields(new String[] { "urlLink", "contentDescription", fessConfig.getIndexFieldId(),
+                    fessConfig.getIndexFieldDocId(), fessConfig.getIndexFieldBoost(), fessConfig.getIndexFieldContentLength(),
+                    fessConfig.getIndexFieldHost(), fessConfig.getIndexFieldSite(), fessConfig.getIndexFieldLastModified(),
+                    fessConfig.getIndexFieldTimestamp(), fessConfig.getIndexFieldMimetype(), fessConfig.getIndexFieldFiletype(),
+                    fessConfig.getIndexFieldCreated(), fessConfig.getIndexFieldTitle(), fessConfig.getIndexFieldDigest(),
+                    fessConfig.getIndexFieldUrl() });
         }
     }
 
@@ -636,9 +645,6 @@ public class QueryHelper implements Serializable {
     }
 
     public boolean isApiResponseField(final String field) {
-        if (apiResponseFieldSet == null) {
-            return true;
-        }
         return apiResponseFieldSet.contains(field);
     }
 

+ 6 - 6
src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java

@@ -707,20 +707,20 @@ public class FessLabels extends ActionMessages {
     /** The key of the message: Label */
     public static final String LABELS_facet_label_title = "{labels.facet_label_title}";
 
-    /** The key of the message: Term */
-    public static final String LABELS_facet_lastModified_title = "{labels.facet_lastModified_title}";
+    /** The key of the message: Date Range */
+    public static final String LABELS_facet_timestamp_title = "{labels.facet_timestamp_title}";
 
     /** The key of the message: Past 24 Hours */
-    public static final String LABELS_facet_lastModified_1day = "{labels.facet_lastModified_1day}";
+    public static final String LABELS_facet_timestamp_1day = "{labels.facet_timestamp_1day}";
 
     /** The key of the message: Past Week */
-    public static final String LABELS_facet_lastModified_1week = "{labels.facet_lastModified_1week}";
+    public static final String LABELS_facet_timestamp_1week = "{labels.facet_timestamp_1week}";
 
     /** The key of the message: Past Month */
-    public static final String LABELS_facet_lastModified_1month = "{labels.facet_lastModified_1month}";
+    public static final String LABELS_facet_timestamp_1month = "{labels.facet_timestamp_1month}";
 
     /** The key of the message: Past Year */
-    public static final String LABELS_facet_lastModified_1year = "{labels.facet_lastModified_1year}";
+    public static final String LABELS_facet_timestamp_1year = "{labels.facet_timestamp_1year}";
 
     /** The key of the message: Size */
     public static final String LABELS_facet_contentLength_title = "{labels.facet_contentLength_title}";

+ 14 - 0
src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java

@@ -73,6 +73,9 @@ public interface FessConfig extends FessEnv {
     /** The key of the configuration. e.g. created */
     String INDEX_FIELD_CREATED = "index.field.created";
 
+    /** The key of the configuration. e.g. timestamp */
+    String INDEX_FIELD_TIMESTAMP = "index.field.timestamp";
+
     /** The key of the configuration. e.g. label */
     String INDEX_FIELD_LABEL = "index.field.label";
 
@@ -394,6 +397,13 @@ public interface FessConfig extends FessEnv {
      */
     String getIndexFieldCreated();
 
+    /**
+     * Get the value for the key 'index.field.timestamp'. <br>
+     * The value is, e.g. timestamp <br>
+     * @return The value of found property. (NotNull: if not found, exception but basically no way)
+     */
+    String getIndexFieldTimestamp();
+
     /**
      * Get the value for the key 'index.field.label'. <br>
      * The value is, e.g. label <br>
@@ -977,6 +987,10 @@ public interface FessConfig extends FessEnv {
             return get(FessConfig.INDEX_FIELD_CREATED);
         }
 
+        public String getIndexFieldTimestamp() {
+            return get(FessConfig.INDEX_FIELD_TIMESTAMP);
+        }
+
         public String getIndexFieldLabel() {
             return get(FessConfig.INDEX_FIELD_LABEL);
         }

+ 4 - 1
src/main/java/org/codelibs/fess/mylasta/direction/sponsor/FessMultipartRequestHandler.java

@@ -179,7 +179,10 @@ public class FessMultipartRequestHandler implements MultipartRequestHandler {
                 addTextParameter(request, item);
             } else {
                 showFileFieldParameter(item);
-                addFileParameter(item);
+                final String itemName = item.getName();
+                if (itemName != null && !itemName.isEmpty()) {
+                    addFileParameter(item);
+                }
             }
         }
     }

+ 2 - 1
src/main/java/org/codelibs/fess/util/FacetResponse.java

@@ -17,6 +17,7 @@ package org.codelibs.fess.util;
 
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -54,7 +55,7 @@ public class FacetResponse {
     }
 
     public static class Field {
-        protected Map<String, Long> valueCountMap;
+        protected Map<String, Long> valueCountMap = new HashMap<>();
 
         protected String name;
 

+ 13 - 18
src/main/resources/app.xml

@@ -29,10 +29,10 @@
 				<property name="minCount">1</property>
 				<property name="field">["label"]</property>
 				<property name="query">[
-					"last_modified:[now/d-1d TO now]",
-					"last_modified:[now/d-7d TO now]",
-					"last_modified:[now/d-1M TO now]",
-					"last_modified:[now/d-1y TO now]",
+					"timestamp:[now/d-1d TO now]",
+					"timestamp:[now/d-7d TO now]",
+					"timestamp:[now/d-1M TO now]",
+					"timestamp:[now/d-1y TO now]",
 					"content_length:[0 TO 9999]",
 					"content_length:[10000 TO 99999]",
 					"content_length:[100000 TO 499999]",
@@ -63,11 +63,6 @@
 			<arg>"ko"</arg>
 			<arg>"cjk"</arg>
 		</postConstruct>
-		<postConstruct name="setApiResponseFields">
-			<arg>(String[])["id", "docId", "score", "boost",
-            "contentLength", "host", "site", "lastModified", "mimetype", "filetype_s",
-            "created", "title", "digest", "url", "urlLink", "contentDescription"]</arg>
-		</postConstruct>
 		<postConstruct name="addHighlightField">
 			<arg>"title"</arg>
 		</postConstruct>
@@ -83,22 +78,22 @@
 		<postConstruct name="addFacetQueryView">
 			<arg>
 				<component class="org.codelibs.fess.entity.FacetQueryView">
-					<property name="title">"labels.facet_lastModified_title"</property>
+					<property name="title">"labels.facet_timestamp_title"</property>
 					<postConstruct name="addQuery">
-						<arg>"labels.facet_lastModified_1day"</arg>
-						<arg>"last_modified:[now/d-1d TO now]"</arg>
+						<arg>"labels.facet_timestamp_1day"</arg>
+						<arg>"timestamp:[now/d-1d TO now]"</arg>
 					</postConstruct>
 					<postConstruct name="addQuery">
-						<arg>"labels.facet_lastModified_1week"</arg>
-						<arg>"last_modified:[now/d-7d TO now]"</arg>
+						<arg>"labels.facet_timestamp_1week"</arg>
+						<arg>"timestamp:[now/d-7d TO now]"</arg>
 					</postConstruct>
 					<postConstruct name="addQuery">
-						<arg>"labels.facet_lastModified_1month"</arg>
-						<arg>"last_modified:[now/d-1M TO now]"</arg>
+						<arg>"labels.facet_timestamp_1month"</arg>
+						<arg>"timestamp:[now/d-1M TO now]"</arg>
 					</postConstruct>
 					<postConstruct name="addQuery">
-						<arg>"labels.facet_lastModified_1year"</arg>
-						<arg>"last_modified:[now/d-1y TO now]"</arg>
+						<arg>"labels.facet_timestamp_1year"</arg>
+						<arg>"timestamp:[now/d-1y TO now]"</arg>
 					</postConstruct>
 				</component>
 			</arg>

+ 1 - 0
src/main/resources/fess_config.properties

@@ -31,6 +31,7 @@ index.field.segment=segment
 index.field.role=role
 index.field.boost=boost
 index.field.created=created
+index.field.timestamp=timestamp
 index.field.label=label
 index.field.mimetype=mimetype
 index.field.parent_id=parent_id

+ 4 - 0
src/main/resources/fess_indices/fess/doc.json

@@ -458,6 +458,10 @@
         "type": "date",
         "format": "date_optional_time"
       },
+      "timestamp": {
+        "type": "date",
+        "format": "date_optional_time"
+      },
       "digest": {
         "type": "string"
       },

+ 5 - 5
src/main/resources/fess_label.properties

@@ -230,11 +230,11 @@ labels.search_click_count=Clicked ({0})
 labels.search_result_more=more..
 labels.search_result_cache=Cache
 labels.facet_label_title=Label
-labels.facet_lastModified_title=Term
-labels.facet_lastModified_1day=Past 24 Hours
-labels.facet_lastModified_1week=Past Week
-labels.facet_lastModified_1month=Past Month
-labels.facet_lastModified_1year=Past Year
+labels.facet_timestamp_title=Date Range
+labels.facet_timestamp_1day=Past 24 Hours
+labels.facet_timestamp_1week=Past Week
+labels.facet_timestamp_1month=Past Month
+labels.facet_timestamp_1year=Past Year
 labels.facet_contentLength_title=Size
 labels.facet_contentLength_10k=&nbsp; - 10kb
 labels.facet_contentLength_10kto100k=10kb - 100kb

+ 7 - 0
src/main/webapp/WEB-INF/view/admin/badword/admin_badword_download.jsp

@@ -60,6 +60,13 @@
 								</div>
 								<!-- /.box-header -->
 								<div class="box-body">
+									<%-- Message --%>
+									<div>
+										<la:info id="msg" message="true">
+											<div class="alert alert-info">${msg}</div>
+										</la:info>
+										<la:errors />
+									</div>
 									<div class="form-group">
 										<label for="name" class="col-sm-12 control-label"><la:message
 												key="labels.suggest_bad_word_file" /></label>

+ 7 - 0
src/main/webapp/WEB-INF/view/admin/badword/admin_badword_upload.jsp

@@ -59,6 +59,13 @@
 							</div>
 							<!-- /.box-header -->
 							<div class="box-body">
+								<%-- Message --%>
+								<div>
+									<la:info id="msg" message="true">
+										<div class="alert alert-info">${msg}</div>
+									</la:info>
+									<la:errors />
+								</div>
 								<la:form action="/admin/badword/upload/" enctype="multipart/form-data">
 									<table class="table table-bordered">
 										<tbody>

+ 7 - 0
src/main/webapp/WEB-INF/view/admin/elevateword/admin_elevateword_download.jsp

@@ -61,6 +61,13 @@
 								</div>
 								<!-- /.box-header -->
 								<div class="box-body">
+									<%-- Message --%>
+									<div>
+										<la:info id="msg" message="true">
+											<div class="alert alert-info">${msg}</div>
+										</la:info>
+										<la:errors />
+									</div>
 									<div class="form-group">
 										<label for="name" class="col-sm-12 control-label"><la:message
 												key="labels.suggest_elevate_word_file" /></label>

+ 7 - 0
src/main/webapp/WEB-INF/view/admin/elevateword/admin_elevateword_upload.jsp

@@ -59,6 +59,13 @@
 							</div>
 							<!-- /.box-header -->
 							<div class="box-body">
+								<%-- Message --%>
+								<div>
+									<la:info id="msg" message="true">
+										<div class="alert alert-info">${msg}</div>
+									</la:info>
+									<la:errors />
+								</div>
 								<la:form action="/admin/elevateword/upload/"
 									enctype="multipart/form-data">
 									<table class="table table-bordered">

+ 1 - 1
src/main/webapp/WEB-INF/view/searchResults.jsp

@@ -90,7 +90,7 @@
 						<c:forEach var="countEntry" items="${fieldData.valueCountMap}">
 							<c:if test="${countEntry.value != 0 && fe:labelexists(countEntry.key)}">
 								<li class="list-group-item"><la:link
-										href="/search/search?query=${f:u(query)}&additional=label:${f:u(countEntry.key)}${pagingQuery}${fe:facetQuery()}${fe:geoQuery()}"
+										href="/search/search?query=${f:u(query)}&additional=label%3a${f:u(countEntry.key)}${pagingQuery}${fe:facetQuery()}${fe:geoQuery()}"
 									>
 											${f:h(fe:label(countEntry.key))} 
 											<span class="label label-default label-pill pull-right">${f:h(countEntry.value)}</span>