fix #367 reload path mappings after the modification

This commit is contained in:
Shinsuke Sugaya 2016-02-18 16:22:45 +09:00
parent df788ca09c
commit 0567339b82
2 changed files with 14 additions and 4 deletions

View file

@ -27,6 +27,7 @@ import org.codelibs.fess.app.pager.PathMapPager;
import org.codelibs.fess.es.config.cbean.PathMappingCB;
import org.codelibs.fess.es.config.exbhv.PathMappingBhv;
import org.codelibs.fess.es.config.exentity.PathMapping;
import org.codelibs.fess.util.ComponentUtil;
import org.dbflute.cbean.result.PagingResultBean;
import org.dbflute.optional.OptionalEntity;
@ -63,6 +64,7 @@ public class PathMappingService implements Serializable {
op.setRefresh(true);
});
ComponentUtil.getPathMappingHelper().init();
}
public void delete(final PathMapping pathMapping) {
@ -71,6 +73,7 @@ public class PathMappingService implements Serializable {
op.setRefresh(true);
});
ComponentUtil.getPathMappingHelper().init();
}
public List<PathMapping> getPathMappingList(final Collection<String> processTypeList) {

View file

@ -20,6 +20,8 @@ import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Map;
import javax.annotation.Resource;
import org.codelibs.core.lang.StringUtil;
import org.codelibs.core.net.URLUtil;
import org.codelibs.fess.Constants;
@ -27,6 +29,7 @@ import org.codelibs.fess.app.web.base.FessSearchAction;
import org.codelibs.fess.app.web.error.ErrorAction;
import org.codelibs.fess.crawler.util.CharUtil;
import org.codelibs.fess.es.log.exentity.ClickLog;
import org.codelibs.fess.helper.PathMappingHelper;
import org.codelibs.fess.helper.SearchLogHelper;
import org.codelibs.fess.helper.ViewHelper;
import org.codelibs.fess.util.ComponentUtil;
@ -47,6 +50,9 @@ public class GoAction extends FessSearchAction {
//
private static final Logger logger = LoggerFactory.getLogger(GoAction.class);
@Resource
protected PathMappingHelper pathMappingHelper;
// ===================================================================================
// Attribute
//
@ -126,21 +132,22 @@ public class GoAction extends FessSearchAction {
hash = StringUtil.EMPTY;
}
if (isFileSystemPath(url)) {
final String targetUrl = pathMappingHelper.replaceUrl(url);
if (isFileSystemPath(targetUrl)) {
if (Constants.TRUE.equals(systemProperties.getProperty(Constants.SEARCH_FILE_PROXY_PROPERTY, Constants.TRUE))) {
final ViewHelper viewHelper = ComponentUtil.getViewHelper();
try {
return viewHelper.asContentResponse(doc);
} catch (final Exception e) {
logger.debug("Failed to load: " + doc, e);
saveError(messages -> messages.addErrorsNotLoadFromServer(GLOBAL, url));
saveError(messages -> messages.addErrorsNotLoadFromServer(GLOBAL, targetUrl));
return redirect(ErrorAction.class);
}
} else {
return HtmlResponse.fromRedirectPathAsIs(url + hash);
return HtmlResponse.fromRedirectPathAsIs(targetUrl + hash);
}
} else {
return HtmlResponse.fromRedirectPathAsIs(url + hash);
return HtmlResponse.fromRedirectPathAsIs(targetUrl + hash);
}
}