Shinsuke Sugaya 9 years ago
parent
commit
8e613d0cca

+ 2 - 3
src/main/java/jp/sf/fess/action/LoginAction.java

@@ -190,11 +190,10 @@ public class LoginAction implements Serializable {
     private String getAdminRootPath() {
     private String getAdminRootPath() {
         String returnPath = RequestUtil.getRequest().getContextPath();
         String returnPath = RequestUtil.getRequest().getContextPath();
         if (StringUtil.isEmpty(returnPath) || "/".equals(returnPath)) {
         if (StringUtil.isEmpty(returnPath) || "/".equals(returnPath)) {
-            returnPath = "/admin";
+            return "/admin";
         } else {
         } else {
-            returnPath = returnPath + "/admin";
+            return returnPath + "/admin";
         }
         }
-        return returnPath;
     }
     }
 
 
     @Execute(validator = false, input = "../index")
     @Execute(validator = false, input = "../index")

+ 1 - 1
src/main/java/jp/sf/fess/action/admin/dict/SynonymAction.java

@@ -437,7 +437,7 @@ public class SynonymAction {
             return;
             return;
         }
         }
         for (String value : values) {
         for (String value : values) {
-            if (value.indexOf(",") >= 0) {
+            if (value.indexOf(',') >= 0) {
                 throw new SSCActionMessagesException("errors.invalid_str_is_included", value, ",");
                 throw new SSCActionMessagesException("errors.invalid_str_is_included", value, ",");
             }
             }
             if (value.indexOf("=>") >= 0) {
             if (value.indexOf("=>") >= 0) {

+ 3 - 5
src/main/java/jp/sf/fess/api/BaseApiManager.java

@@ -16,6 +16,8 @@
 
 
 package jp.sf.fess.api;
 package jp.sf.fess.api;
 
 
+import java.util.Locale;
+
 public class BaseApiManager {
 public class BaseApiManager {
     protected static final String FAVORITES_API = "/favoritesApi";
     protected static final String FAVORITES_API = "/favoritesApi";
 
 
@@ -35,15 +37,11 @@ public class BaseApiManager {
         SEARCH, LABEL, SUGGEST, SPELLCHECK, ANALYSIS, HOTSEARCHWORD, FAVORITE, FAVORITES, OTHER, PING;
         SEARCH, LABEL, SUGGEST, SPELLCHECK, ANALYSIS, HOTSEARCHWORD, FAVORITE, FAVORITES, OTHER, PING;
     }
     }
 
 
-    public BaseApiManager() {
-        super();
-    }
-
     protected FormatType getFormatType(final String formatType) {
     protected FormatType getFormatType(final String formatType) {
         if (formatType == null) {
         if (formatType == null) {
             return FormatType.SEARCH;
             return FormatType.SEARCH;
         }
         }
-        final String type = formatType.toUpperCase();
+        final String type = formatType.toUpperCase(Locale.ENGLISH);
         if (FormatType.SEARCH.name().equals(type)) {
         if (FormatType.SEARCH.name().equals(type)) {
             return FormatType.SEARCH;
             return FormatType.SEARCH;
         } else if (FormatType.LABEL.name().equals(type)) {
         } else if (FormatType.LABEL.name().equals(type)) {

+ 3 - 3
src/main/java/jp/sf/fess/api/json/JsonApiManager.java

@@ -417,7 +417,7 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager {
             buf.append("\"recordCount\":");
             buf.append("\"recordCount\":");
             buf.append(suggestRecordCount);
             buf.append(suggestRecordCount);
 
 
-            if (suggestResultList.size() > 0) {
+            if (!suggestResultList.isEmpty()) {
                 buf.append(',');
                 buf.append(',');
                 buf.append("\"result\":[");
                 buf.append("\"result\":[");
                 boolean first1 = true;
                 boolean first1 = true;
@@ -501,7 +501,7 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager {
             buf.append("\"recordCount\":");
             buf.append("\"recordCount\":");
             buf.append(spellCheckRecordCount);
             buf.append(spellCheckRecordCount);
 
 
-            if (spellCheckResultList.size() > 0) {
+            if (!spellCheckResultList.isEmpty()) {
                 buf.append(',');
                 buf.append(',');
                 buf.append("\"result\":[");
                 buf.append("\"result\":[");
                 boolean first1 = true;
                 boolean first1 = true;
@@ -581,7 +581,7 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager {
             buf.append("\"recordCount\":");
             buf.append("\"recordCount\":");
             buf.append(fieldAnalysis.size());
             buf.append(fieldAnalysis.size());
 
 
-            if (fieldAnalysis.size() > 0) {
+            if (!fieldAnalysis.isEmpty()) {
                 buf.append(',');
                 buf.append(',');
                 buf.append("\"result\":[");
                 buf.append("\"result\":[");
                 boolean first1 = true;
                 boolean first1 = true;

+ 2 - 2
src/main/java/jp/sf/fess/api/xml/GsaApiManager.java

@@ -153,7 +153,7 @@ public class GsaApiManager extends BaseApiManager implements WebApiManager {
                                 .replace(".", " AND " + gsaMetaPrefix)
                                 .replace(".", " AND " + gsaMetaPrefix)
                                 .replace("|", " OR " + gsaMetaPrefix) + ")");
                                 .replace("|", " OR " + gsaMetaPrefix) + ")");
             }
             }
-            if (additional.size() > 0) {
+            if (!additional.isEmpty()) {
                 extraParams.put("additional", (String[]) additional
                 extraParams.put("additional", (String[]) additional
                         .toArray(new String[additional.size()]));
                         .toArray(new String[additional.size()]));
             }
             }
@@ -227,7 +227,7 @@ public class GsaApiManager extends BaseApiManager implements WebApiManager {
             buf.append("\" original_value=\"");
             buf.append("\" original_value=\"");
             buf.append(URLEncoder.encode(ie, Constants.UTF_8));
             buf.append(URLEncoder.encode(ie, Constants.UTF_8));
             buf.append("\"/>");
             buf.append("\"/>");
-            if (documentItems.size() > 0) {
+            if (!documentItems.isEmpty()) {
                 buf.append("<RES SN=\"");
                 buf.append("<RES SN=\"");
                 buf.append(startNumber);
                 buf.append(startNumber);
                 buf.append("\" EN=\"");
                 buf.append("\" EN=\"");

+ 3 - 3
src/main/java/jp/sf/fess/api/xml/XmlApiManager.java

@@ -361,7 +361,7 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager {
             buf.append("<record-count>");
             buf.append("<record-count>");
             buf.append(suggestRecordCount);
             buf.append(suggestRecordCount);
             buf.append("</record-count>");
             buf.append("</record-count>");
-            if (suggestResultList.size() > 0) {
+            if (!suggestResultList.isEmpty()) {
                 buf.append("<result>");
                 buf.append("<result>");
 
 
                 for (int i = 0; i < suggestResultList.size(); i++) {
                 for (int i = 0; i < suggestResultList.size(); i++) {
@@ -441,7 +441,7 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager {
             buf.append("<record-count>");
             buf.append("<record-count>");
             buf.append(spellCheckRecordCount);
             buf.append(spellCheckRecordCount);
             buf.append("</record-count>");
             buf.append("</record-count>");
-            if (spellCheckResultList.size() > 0) {
+            if (!spellCheckResultList.isEmpty()) {
                 buf.append("<result>");
                 buf.append("<result>");
 
 
                 for (int i = 0; i < spellCheckResultList.size(); i++) {
                 for (int i = 0; i < spellCheckResultList.size(); i++) {
@@ -517,7 +517,7 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager {
             buf.append("<record-count>");
             buf.append("<record-count>");
             buf.append(fieldAnalysis.size());
             buf.append(fieldAnalysis.size());
             buf.append("</record-count>");
             buf.append("</record-count>");
-            if (fieldAnalysis.size() > 0) {
+            if (!fieldAnalysis.isEmpty()) {
                 buf.append("<result>");
                 buf.append("<result>");
                 for (final Map.Entry<String, Map<String, List<Map<String, Object>>>> fEntry : fieldAnalysis
                 for (final Map.Entry<String, Map<String, List<Map<String, Object>>>> fEntry : fieldAnalysis
                         .entrySet()) {
                         .entrySet()) {

+ 3 - 3
src/main/java/jp/sf/fess/dict/synonym/SynonymFile.java

@@ -62,7 +62,7 @@ public class SynonymFile extends DictionaryFile<SynonymItem> {
     }
     }
 
 
     @Override
     @Override
-    public SynonymItem get(final long id) {
+    public synchronized SynonymItem get(final long id) {
         for (final SynonymItem synonymItem : synonymItemList) {
         for (final SynonymItem synonymItem : synonymItemList) {
             if (id == synonymItem.getId()) {
             if (id == synonymItem.getId()) {
                 return synonymItem;
                 return synonymItem;
@@ -148,7 +148,7 @@ public class SynonymFile extends DictionaryFile<SynonymItem> {
         }
         }
     }
     }
 
 
-    protected void reload(final SynonymUpdater updater) {
+    private void reload(final SynonymUpdater updater) {
         final List<SynonymItem> itemList = new ArrayList<SynonymItem>();
         final List<SynonymItem> itemList = new ArrayList<SynonymItem>();
         BufferedReader reader = null;
         BufferedReader reader = null;
         try {
         try {
@@ -393,7 +393,7 @@ public class SynonymFile extends DictionaryFile<SynonymItem> {
         return new BufferedInputStream(new FileInputStream(file));
         return new BufferedInputStream(new FileInputStream(file));
     }
     }
 
 
-    public void update(final InputStream in) throws IOException {
+    public synchronized void update(final InputStream in) throws IOException {
         StreamUtil.drain(in, file);
         StreamUtil.drain(in, file);
         reload(null);
         reload(null);
     }
     }

+ 3 - 3
src/main/java/jp/sf/fess/dict/userdict/UserDictFile.java

@@ -63,7 +63,7 @@ public class UserDictFile extends DictionaryFile<UserDictItem> {
     }
     }
 
 
     @Override
     @Override
-    public UserDictItem get(final long id) {
+    public synchronized UserDictItem get(final long id) {
         for (final UserDictItem userDictItem : userDictItemList) {
         for (final UserDictItem userDictItem : userDictItemList) {
             if (id == userDictItem.getId()) {
             if (id == userDictItem.getId()) {
                 return userDictItem;
                 return userDictItem;
@@ -149,7 +149,7 @@ public class UserDictFile extends DictionaryFile<UserDictItem> {
         }
         }
     }
     }
 
 
-    protected void reload(final UserDictUpdater updater) {
+    private void reload(final UserDictUpdater updater) {
         final List<UserDictItem> itemList = new ArrayList<UserDictItem>();
         final List<UserDictItem> itemList = new ArrayList<UserDictItem>();
         BufferedReader reader = null;
         BufferedReader reader = null;
         try {
         try {
@@ -320,7 +320,7 @@ public class UserDictFile extends DictionaryFile<UserDictItem> {
         return new BufferedInputStream(new FileInputStream(file));
         return new BufferedInputStream(new FileInputStream(file));
     }
     }
 
 
-    public void update(final InputStream in) throws IOException {
+    public synchronized void update(final InputStream in) throws IOException {
         StreamUtil.drain(in, file);
         StreamUtil.drain(in, file);
         reload(null);
         reload(null);
     }
     }

+ 4 - 2
src/main/java/jp/sf/fess/ds/impl/CsvDataStoreImpl.java

@@ -102,8 +102,10 @@ public class CsvDataStoreImpl extends AbstractDataStoreImpl {
                             return isCsvFile(file, name);
                             return isCsvFile(file, name);
                         }
                         }
                     });
                     });
-                    for (final File file : files) {
-                        fileList.add(file);
+                    if (files != null) {
+                        for (final File file : files) {
+                            fileList.add(file);
+                        }
                     }
                     }
                 } else {
                 } else {
                     logger.warn(path + " is not a directory.");
                     logger.warn(path + " is not a directory.");

+ 4 - 3
src/main/java/jp/sf/fess/job/JobScheduler.java

@@ -97,13 +97,14 @@ public class JobScheduler {
     }
     }
 
 
     public void register(final ScheduledJob scheduledJob) {
     public void register(final ScheduledJob scheduledJob) {
+        if (scheduledJob == null) {
+            throw new ScheduledJobException("No job.");
+        }
+
         final String cronExpression = scheduledJob.getCronExpression();
         final String cronExpression = scheduledJob.getCronExpression();
         if (StringUtil.isBlank(cronExpression)) {
         if (StringUtil.isBlank(cronExpression)) {
             return;
             return;
         }
         }
-        if (scheduledJob == null) {
-            throw new ScheduledJobException("No job.");
-        }
 
 
         if (!Constants.T.equals(scheduledJob.getAvailable())) {
         if (!Constants.T.equals(scheduledJob.getAvailable())) {
             logger.info("Inactive Job " + scheduledJob.getId() + ":"
             logger.info("Inactive Job " + scheduledJob.getId() + ":"