Merge pull request #317 from kw-udon/lastaflute-dev
webAuth, fileAuth, suggestElevateWord (in progress)
This commit is contained in:
commit
2ee60a3710
17 changed files with 891 additions and 402 deletions
2
pom.xml
2
pom.xml
|
@ -120,12 +120,10 @@
|
|||
<exclude>org/codelibs/fess/app/web/admin/DataAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/CrawlingSessionAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/SuggestBadWordForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/FileAuthenticationAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/CrawlingSessionForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/CrawlForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/WizardForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/FailureUrlForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/FileAuthenticationForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/base/AbstractLoginAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/LoginAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/LoginForm.java</exclude>
|
||||
|
|
|
@ -278,11 +278,4 @@ public class WebConfigService implements Serializable {
|
|||
cb.query().docMeta().setId_Equal(id);
|
||||
}).orElse(null);//TODO
|
||||
}
|
||||
|
||||
public List<WebConfig> getWebConfigList() {
|
||||
return webConfigBhv.selectList(cb -> {
|
||||
// cb.query().addOrderBy_SortOrder_Asc();
|
||||
// cb.query().addOrderBy_Name_Asc();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,365 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin;
|
||||
|
||||
import java.beans.Beans;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.core.beans.util.BeanUtil;
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.annotation.Token;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.beans.FessBeans;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.es.exentity.FileAuthentication;
|
||||
import org.codelibs.fess.es.exentity.FileConfig;
|
||||
import org.codelibs.fess.exception.SSCActionMessagesException;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.app.pager.FileAuthenticationPager;
|
||||
import org.codelibs.fess.app.service.FileAuthenticationService;
|
||||
import org.codelibs.fess.app.service.FileConfigService;
|
||||
import org.lastaflute.web.util.LaRequestUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class FileAuthenticationAction extends FessAdminAction {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(FileAuthenticationAction.class);
|
||||
|
||||
// for list
|
||||
public List<FileAuthentication> fileAuthenticationItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
//@ActionForm
|
||||
@Resource
|
||||
protected FileAuthenticationForm fileAuthenticationForm;
|
||||
|
||||
@Resource
|
||||
protected FileConfigService fileConfigService;
|
||||
|
||||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
||||
@Resource
|
||||
protected FileAuthenticationService fileAuthenticationService;
|
||||
|
||||
@Resource
|
||||
protected FileAuthenticationPager fileAuthenticationPager;
|
||||
|
||||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("fileAuthentication");
|
||||
}
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
fileAuthenticationItems = fileAuthenticationService.getFileAuthenticationList(fileAuthenticationPager);
|
||||
|
||||
// restore from pager
|
||||
BeanUtil.copyBeanToBean(fileAuthenticationPager, fileAuthenticationForm.searchParams,
|
||||
option -> option.exclude(CommonConstants.PAGER_CONVERSION_RULE));
|
||||
|
||||
if (redirect) {
|
||||
return "index?redirect=true";
|
||||
} else {
|
||||
return "index.jsp";
|
||||
}
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String index() {
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp", urlPattern = "list/{pageNumber}")
|
||||
public String list() {
|
||||
// page navi
|
||||
if (StringUtil.isNotBlank(fileAuthenticationForm.pageNumber)) {
|
||||
try {
|
||||
fileAuthenticationPager.setCurrentPageNumber(Integer.parseInt(fileAuthenticationForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Invalid value: " + fileAuthenticationForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
BeanUtil.copyBeanToBean(fileAuthenticationForm.searchParams, fileAuthenticationPager,
|
||||
option -> option.exclude(CommonConstants.PAGER_CONVERSION_RULE));
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
fileAuthenticationPager.clear();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String back() {
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String editagain() {
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}")
|
||||
public String confirmpage() {
|
||||
if (fileAuthenticationForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
fileAuthenticationForm.crudMode });
|
||||
}
|
||||
|
||||
loadFileAuthentication();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
fileAuthenticationForm.initialize();
|
||||
fileAuthenticationForm.crudMode = CommonConstants.CREATE_MODE;
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}")
|
||||
public String editpage() {
|
||||
if (fileAuthenticationForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
fileAuthenticationForm.crudMode });
|
||||
}
|
||||
|
||||
loadFileAuthentication();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
fileAuthenticationForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadFileAuthentication();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
//@Execute(validator = true, input = "edit.jsp")
|
||||
public String confirmfromcreate() {
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
//@Execute(validator = true, input = "edit.jsp")
|
||||
public String confirmfromupdate() {
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}")
|
||||
public String deletepage() {
|
||||
if (fileAuthenticationForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
fileAuthenticationForm.crudMode });
|
||||
}
|
||||
|
||||
loadFileAuthentication();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
fileAuthenticationForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadFileAuthentication();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
//@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final FileAuthentication fileAuthentication = createFileAuthentication();
|
||||
fileAuthenticationService.store(fileAuthentication);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_create_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException("errors.crud_failed_to_create_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
//@Execute(validator = true, input = "edit.jsp")
|
||||
public String update() {
|
||||
try {
|
||||
final FileAuthentication fileAuthentication = createFileAuthentication();
|
||||
fileAuthenticationService.store(fileAuthentication);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_update_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException("errors.crud_failed_to_update_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadFileAuthentication() {
|
||||
|
||||
final FileAuthentication fileAuthentication = fileAuthenticationService.getFileAuthentication(createKeyMap());
|
||||
if (fileAuthentication == null) {
|
||||
// throw an exception
|
||||
throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { fileAuthenticationForm.id });
|
||||
}
|
||||
|
||||
BeanUtil.copyBeanToBean(fileAuthentication, fileAuthenticationForm, option -> option.excludes("searchParams", "mode"));
|
||||
if ("-1".equals(fileAuthenticationForm.port)) {
|
||||
fileAuthenticationForm.port = StringUtil.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
protected FileAuthentication createFileAuthentication() {
|
||||
FileAuthentication fileAuthentication;
|
||||
final String username = systemHelper.getUsername();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
if (fileAuthenticationForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
fileAuthentication = fileAuthenticationService.getFileAuthentication(createKeyMap());
|
||||
if (fileAuthentication == null) {
|
||||
// throw an exception
|
||||
throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { fileAuthenticationForm.id });
|
||||
}
|
||||
} else {
|
||||
fileAuthentication = new FileAuthentication();
|
||||
fileAuthentication.setCreatedBy(username);
|
||||
fileAuthentication.setCreatedTime(currentTime);
|
||||
}
|
||||
fileAuthentication.setUpdatedBy(username);
|
||||
fileAuthentication.setUpdatedTime(currentTime);
|
||||
if (StringUtil.isBlank(fileAuthenticationForm.port)) {
|
||||
fileAuthenticationForm.port = "-1";
|
||||
}
|
||||
BeanUtil.copyBeanToBean(fileAuthenticationForm, fileAuthentication,
|
||||
option -> option.exclude(CommonConstants.COMMON_CONVERSION_RULE));
|
||||
|
||||
return fileAuthentication;
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String delete() {
|
||||
if (fileAuthenticationForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new SSCActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
fileAuthenticationForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final FileAuthentication fileAuthentication = fileAuthenticationService.getFileAuthentication(createKeyMap());
|
||||
if (fileAuthentication == null) {
|
||||
// throw an exception
|
||||
throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { fileAuthenticationForm.id });
|
||||
}
|
||||
|
||||
fileAuthenticationService.delete(fileAuthentication);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_delete_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", fileAuthenticationForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
public boolean isDisplayCreateLink() {
|
||||
return !fileConfigService.getAllFileConfigList(false, false, false, null).isEmpty();
|
||||
}
|
||||
|
||||
public List<Map<String, String>> getFileConfigItems() {
|
||||
final List<Map<String, String>> items = new ArrayList<Map<String, String>>();
|
||||
final List<FileConfig> fileConfigList = fileConfigService.getAllFileConfigList(false, false, false, null);
|
||||
for (final FileConfig fileConfig : fileConfigList) {
|
||||
items.add(createItem(fileConfig.getName(), fileConfig.getId().toString()));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
public List<Map<String, String>> getProtocolSchemeItems() {
|
||||
final List<Map<String, String>> items = new ArrayList<Map<String, String>>();
|
||||
items.add(createItem(
|
||||
MessageResourcesUtil.getMessage(LaRequestUtil.getRequest().getLocale(), "labels.file_authentication_scheme_samba"),
|
||||
Constants.SAMBA));
|
||||
return items;
|
||||
}
|
||||
|
||||
protected Map<String, String> createItem(final String label, final String value) {
|
||||
final Map<String, String> map = new HashMap<String, String>(2);
|
||||
map.put("label", label);
|
||||
map.put("value", value);
|
||||
return map;
|
||||
}
|
||||
}
|
|
@ -55,7 +55,7 @@ public class SuggestElevateWordForm implements Serializable {
|
|||
public String targetLabel;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
@FloatType
|
||||
//@FloatType
|
||||
public String boost;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
|
|
|
@ -0,0 +1,337 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin.fileauthentication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.annotation.Token;
|
||||
import org.codelibs.fess.app.pager.FileAuthenticationPager;
|
||||
import org.codelibs.fess.app.service.FileAuthenticationService;
|
||||
import org.codelibs.fess.app.service.FileConfigService;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.es.exentity.FileAuthentication;
|
||||
import org.codelibs.fess.es.exentity.FileConfig;
|
||||
import org.codelibs.fess.es.exentity.WebConfig;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
import org.lastaflute.web.response.render.RenderData;
|
||||
import org.lastaflute.web.util.LaRequestUtil;
|
||||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
*/
|
||||
public class AdminFileauthenticationAction extends FessAdminAction {
|
||||
|
||||
// ===================================================================================
|
||||
// Attribute
|
||||
// =========
|
||||
@Resource
|
||||
private FileAuthenticationService fileAuthenticationService;
|
||||
@Resource
|
||||
private FileAuthenticationPager fileAuthenticationPager;
|
||||
@Resource
|
||||
private SystemHelper systemHelper;
|
||||
|
||||
@Resource
|
||||
protected FileConfigService fileConfigService;
|
||||
|
||||
// ===================================================================================
|
||||
// Hook
|
||||
// ======
|
||||
@Override
|
||||
protected void setupHtmlData(final ActionRuntime runtime) {
|
||||
super.setupHtmlData(runtime);
|
||||
runtime.registerData("helpLink", systemHelper.getHelpLink("fileAuthentication"));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final FileAuthenticationSearchForm form) {
|
||||
return asHtml(path_AdminFileauthentication_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse list(final Integer pageNumber, final FileAuthenticationSearchForm form) {
|
||||
fileAuthenticationPager.setCurrentPageNumber(pageNumber);
|
||||
return asHtml(path_AdminFileauthentication_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse search(final FileAuthenticationSearchForm form) {
|
||||
copyBeanToBean(form.searchParams, fileAuthenticationPager, op -> op.exclude(CommonConstants.PAGER_CONVERSION_RULE));
|
||||
return asHtml(path_AdminFileauthentication_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse reset(final FileAuthenticationSearchForm form) {
|
||||
fileAuthenticationPager.clear();
|
||||
return asHtml(path_AdminFileauthentication_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse back(final FileAuthenticationSearchForm form) {
|
||||
return asHtml(path_AdminFileauthentication_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
protected void searchPaging(final RenderData data, final FileAuthenticationSearchForm form) {
|
||||
data.register("fileAuthenticationItems", fileAuthenticationService.getFileAuthenticationList(fileAuthenticationPager)); // page navi
|
||||
data.register("displayCreateLink", !fileConfigService.getAllFileConfigList(false, false, false, null).isEmpty());
|
||||
// restore from pager
|
||||
copyBeanToBean(fileAuthenticationPager, form.searchParams, op -> op.exclude(CommonConstants.PAGER_CONVERSION_RULE));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Edit Execute
|
||||
// ============
|
||||
// -----------------------------------------------------
|
||||
// Entry Page
|
||||
// ----------
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse createpage(final FileAuthenticationEditForm form) {
|
||||
form.initialize();
|
||||
form.crudMode = CommonConstants.CREATE_MODE;
|
||||
return asHtml(path_AdminFileauthentication_EditJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerFileConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editpage(final int crudMode, final String id, final FileAuthenticationEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.EDIT_MODE);
|
||||
loadFileAuthentication(form);
|
||||
return asHtml(path_AdminFileauthentication_EditJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerFileConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editagain(final FileAuthenticationEditForm form) {
|
||||
return asHtml(path_AdminFileauthentication_EditJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerFileConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editfromconfirm(final FileAuthenticationEditForm form) {
|
||||
form.crudMode = CommonConstants.EDIT_MODE;
|
||||
loadFileAuthentication(form);
|
||||
return asHtml(path_AdminFileauthentication_EditJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerFileConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletepage(final int crudMode, final String id, final FileAuthenticationEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.DELETE_MODE);
|
||||
loadFileAuthentication(form);
|
||||
return asHtml(path_AdminFileauthentication_ConfirmJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerFileConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletefromconfirm(final FileAuthenticationEditForm form) {
|
||||
form.crudMode = CommonConstants.DELETE_MODE;
|
||||
loadFileAuthentication(form);
|
||||
return asHtml(path_AdminFileauthentication_ConfirmJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerFileConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Confirm
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id, final FileAuthenticationEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.CONFIRM_MODE);
|
||||
loadFileAuthentication(form);
|
||||
return asHtml(path_AdminFileauthentication_ConfirmJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerFileConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromcreate(final FileAuthenticationEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminFileauthentication_ConfirmJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerFileConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromupdate(final FileAuthenticationEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminFileauthentication_ConfirmJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerFileConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Actually Crud
|
||||
// -------------
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse create(final FileAuthenticationEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
fileAuthenticationService.store(createFileAuthentication(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse update(final FileAuthenticationEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
fileAuthenticationService.store(createFileAuthentication(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse delete(final FileAuthenticationEditForm form) {
|
||||
verifyCrudMode(form, CommonConstants.DELETE_MODE);
|
||||
fileAuthenticationService.delete(getFileAuthentication(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
protected void loadFileAuthentication(final FileAuthenticationEditForm form) {
|
||||
copyBeanToBean(getFileAuthentication(form), form, op -> op.exclude("crudMode"));
|
||||
}
|
||||
|
||||
protected FileAuthentication getFileAuthentication(final FileAuthenticationEditForm form) {
|
||||
final FileAuthentication fileAuthentication = fileAuthenticationService.getFileAuthentication(createKeyMap(form));
|
||||
if (fileAuthentication == null) {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
}
|
||||
return fileAuthentication;
|
||||
}
|
||||
|
||||
protected FileAuthentication createFileAuthentication(final FileAuthenticationEditForm form) {
|
||||
FileAuthentication fileAuthentication;
|
||||
final String username = systemHelper.getUsername();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
if (form.crudMode == CommonConstants.EDIT_MODE) {
|
||||
fileAuthentication = getFileAuthentication(form);
|
||||
} else {
|
||||
fileAuthentication = new FileAuthentication();
|
||||
fileAuthentication.setCreatedBy(username);
|
||||
fileAuthentication.setCreatedTime(currentTime);
|
||||
}
|
||||
fileAuthentication.setUpdatedBy(username);
|
||||
fileAuthentication.setUpdatedTime(currentTime);
|
||||
copyBeanToBean(form, fileAuthentication, op -> op.exclude(CommonConstants.COMMON_CONVERSION_RULE));
|
||||
return fileAuthentication;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap(final FileAuthenticationEditForm form) {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
keys.put("id", form.id);
|
||||
return keys;
|
||||
}
|
||||
|
||||
protected void registerProtocolSchemeItems(final RenderData data) {
|
||||
final List<Map<String, String>> itemList = new ArrayList<Map<String, String>>();
|
||||
final Locale locale = LaRequestUtil.getRequest().getLocale();
|
||||
itemList.add(createItem(ComponentUtil.getMessageManager().getMessage(locale, "labels.file_authentication_scheme_samba"),
|
||||
Constants.SAMBA));
|
||||
data.register("protocolSchemeItems", itemList);
|
||||
}
|
||||
|
||||
protected void registerFileConfigItems(final RenderData data) {
|
||||
final List<Map<String, String>> itemList = new ArrayList<Map<String, String>>();
|
||||
final List<FileConfig> fileConfigList = fileConfigService.getAllFileConfigList(false, false, false, null);
|
||||
for (final FileConfig fileConfig : fileConfigList) {
|
||||
itemList.add(createItem(fileConfig.getName(), fileConfig.getId().toString()));
|
||||
}
|
||||
data.register("fileConfigItems", itemList);
|
||||
}
|
||||
|
||||
protected Map<String, String> createItem(final String label, final String value) {
|
||||
final Map<String, String> map = new HashMap<String, String>(2);
|
||||
map.put(Constants.ITEM_LABEL, label);
|
||||
map.put(Constants.ITEM_VALUE, value);
|
||||
return map;
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
protected void verifyCrudMode(final FileAuthenticationEditForm form, final int expectedMode) {
|
||||
if (form.crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(form.crudMode));
|
||||
}, toEditHtml());
|
||||
}
|
||||
}
|
||||
|
||||
protected VaErrorHook toEditHtml() {
|
||||
return () -> {
|
||||
return asHtml(path_AdminFileauthentication_EditJsp);
|
||||
};
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin;
|
||||
package org.codelibs.fess.app.web.admin.fileauthentication;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
@ -22,7 +22,11 @@ import java.util.Map;
|
|||
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
||||
public class FileAuthenticationForm implements Serializable {
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
*/
|
||||
public class FileAuthenticationEditForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin.fileauthentication;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
*/
|
||||
public class FileAuthenticationSearchForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
}
|
|
@ -0,0 +1,305 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin.suggestelevateword;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.annotation.Token;
|
||||
import org.codelibs.fess.app.pager.SuggestElevateWordPager;
|
||||
import org.codelibs.fess.app.service.SuggestElevateWordService;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.es.exentity.SuggestElevateWord;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
import org.lastaflute.web.response.render.RenderData;
|
||||
import org.lastaflute.web.util.LaRequestUtil;
|
||||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
*/
|
||||
public class AdminSuggestelevatewordAction extends FessAdminAction {
|
||||
|
||||
// ===================================================================================
|
||||
// Attribute
|
||||
// =========
|
||||
@Resource
|
||||
private SuggestElevateWordService suggestElevateWordService;
|
||||
@Resource
|
||||
private SuggestElevateWordPager suggestElevateWordPager;
|
||||
@Resource
|
||||
private SystemHelper systemHelper;
|
||||
|
||||
// ===================================================================================
|
||||
// Hook
|
||||
// ======
|
||||
@Override
|
||||
protected void setupHtmlData(final ActionRuntime runtime) {
|
||||
super.setupHtmlData(runtime);
|
||||
runtime.registerData("helpLink", systemHelper.getHelpLink("suggestElevateWord"));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SuggestElevateWordSearchForm form) {
|
||||
return asHtml(path_AdminSuggestelevateword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse list(final Integer pageNumber, final SuggestElevateWordSearchForm form) {
|
||||
suggestElevateWordPager.setCurrentPageNumber(pageNumber);
|
||||
return asHtml(path_AdminSuggestelevateword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse search(final SuggestElevateWordSearchForm form) {
|
||||
copyBeanToBean(form.searchParams, suggestElevateWordPager, op -> op.exclude(CommonConstants.PAGER_CONVERSION_RULE));
|
||||
return asHtml(path_AdminSuggestelevateword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse reset(final SuggestElevateWordSearchForm form) {
|
||||
suggestElevateWordPager.clear();
|
||||
return asHtml(path_AdminSuggestelevateword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse back(final SuggestElevateWordSearchForm form) {
|
||||
return asHtml(path_AdminSuggestelevateword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
protected void searchPaging(final RenderData data, final SuggestElevateWordSearchForm form) {
|
||||
// TODO
|
||||
data.register("suggestElevateWordItems", suggestElevateWordService.getSuggestElevateWordList(suggestElevateWordPager)); // page navi
|
||||
// restore from pager
|
||||
copyBeanToBean(suggestElevateWordPager, form.searchParams, op -> op.exclude(CommonConstants.PAGER_CONVERSION_RULE));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Edit Execute
|
||||
// ============
|
||||
// -----------------------------------------------------
|
||||
// Entry Page
|
||||
// ----------
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse createpage(final SuggestElevateWordEditForm form) {
|
||||
form.initialize();
|
||||
form.crudMode = CommonConstants.CREATE_MODE;
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp).renderWith(data -> {
|
||||
// TODO
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editpage(final int crudMode, final String id, final SuggestElevateWordEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.EDIT_MODE);
|
||||
loadSuggestElevateWord(form);
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp).renderWith(data -> {
|
||||
// TODO
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editagain(final SuggestElevateWordEditForm form) {
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp).renderWith(data -> {
|
||||
// TODO
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editfromconfirm(final SuggestElevateWordEditForm form) {
|
||||
form.crudMode = CommonConstants.EDIT_MODE;
|
||||
loadSuggestElevateWord(form);
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp).renderWith(data -> {
|
||||
// TODO
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletepage(final int crudMode, final String id, final SuggestElevateWordEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.DELETE_MODE);
|
||||
loadSuggestElevateWord(form);
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp).renderWith(data -> {
|
||||
// TODO
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletefromconfirm(final SuggestElevateWordEditForm form) {
|
||||
form.crudMode = CommonConstants.DELETE_MODE;
|
||||
loadSuggestElevateWord(form);
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp).renderWith(data -> {
|
||||
// TODO
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Confirm
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id, final SuggestElevateWordEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.CONFIRM_MODE);
|
||||
loadSuggestElevateWord(form);
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp).renderWith(data -> {
|
||||
// TODO
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromcreate(final SuggestElevateWordEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp).renderWith(data -> {
|
||||
// TODO
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromupdate(final SuggestElevateWordEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp).renderWith(data -> {
|
||||
// TODO
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Actually Crud
|
||||
// -------------
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse create(final SuggestElevateWordEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
suggestElevateWordService.store(createSuggestElevateWord(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse update(final SuggestElevateWordEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
suggestElevateWordService.store(createSuggestElevateWord(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse delete(final SuggestElevateWordEditForm form) {
|
||||
verifyCrudMode(form, CommonConstants.DELETE_MODE);
|
||||
suggestElevateWordService.delete(getSuggestElevateWord(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
protected void loadSuggestElevateWord(final SuggestElevateWordEditForm form) {
|
||||
copyBeanToBean(getSuggestElevateWord(form), form, op -> op.exclude("crudMode"));
|
||||
}
|
||||
|
||||
protected SuggestElevateWord getSuggestElevateWord(final SuggestElevateWordEditForm form) {
|
||||
final SuggestElevateWord suggestElevateWord = suggestElevateWordService.getSuggestElevateWord(createKeyMap(form));
|
||||
if (suggestElevateWord == null) {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
}
|
||||
return suggestElevateWord;
|
||||
}
|
||||
|
||||
protected SuggestElevateWord createSuggestElevateWord(final SuggestElevateWordEditForm form) {
|
||||
SuggestElevateWord suggestElevateWord;
|
||||
final String username = systemHelper.getUsername();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
if (form.crudMode == CommonConstants.EDIT_MODE) {
|
||||
suggestElevateWord = getSuggestElevateWord(form);
|
||||
} else {
|
||||
suggestElevateWord = new SuggestElevateWord();
|
||||
suggestElevateWord.setCreatedBy(username);
|
||||
suggestElevateWord.setCreatedTime(currentTime);
|
||||
}
|
||||
suggestElevateWord.setUpdatedBy(username);
|
||||
suggestElevateWord.setUpdatedTime(currentTime);
|
||||
copyBeanToBean(form, suggestElevateWord, op -> op.exclude(CommonConstants.COMMON_CONVERSION_RULE));
|
||||
return suggestElevateWord;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap(final SuggestElevateWordEditForm form) {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
keys.put("id", form.id);
|
||||
return keys;
|
||||
}
|
||||
|
||||
protected Map<String, String> createItem(final String label, final String value) {
|
||||
final Map<String, String> map = new HashMap<String, String>(2);
|
||||
map.put(Constants.ITEM_LABEL, label);
|
||||
map.put(Constants.ITEM_VALUE, value);
|
||||
return map;
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
protected void verifyCrudMode(final SuggestElevateWordEditForm form, final int expectedMode) {
|
||||
if (form.crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(form.crudMode));
|
||||
}, toEditHtml());
|
||||
}
|
||||
}
|
||||
|
||||
protected VaErrorHook toEditHtml() {
|
||||
return () -> {
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp);
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin.suggestelevateword;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
*/
|
||||
public class SuggestElevateWordEditForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//@Required(target = "upload")
|
||||
//public FormFile suggestElevateWordFile;
|
||||
|
||||
//@IntegerType
|
||||
public String pageNumber;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
|
||||
//@IntegerType
|
||||
public int crudMode;
|
||||
|
||||
public String getCurrentPageNumber() {
|
||||
return pageNumber;
|
||||
}
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 1000)
|
||||
public String id;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
public String suggestWord;
|
||||
|
||||
public String reading;
|
||||
|
||||
public String targetRole;
|
||||
|
||||
public String targetLabel;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@FloatType
|
||||
public String boost;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 255)
|
||||
public String createdBy;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@LongType
|
||||
public String createdTime;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 255)
|
||||
public String updatedBy;
|
||||
|
||||
//@LongType
|
||||
public String updatedTime;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@IntegerType
|
||||
public String versionNo;
|
||||
|
||||
public void initialize() {
|
||||
id = null;
|
||||
suggestWord = null;
|
||||
reading = null;
|
||||
targetRole = null;
|
||||
targetLabel = null;
|
||||
boost = null;
|
||||
createdBy = "system";
|
||||
createdTime = Long.toString(ComponentUtil.getSystemHelper().getCurrentTimeAsLong());
|
||||
updatedBy = null;
|
||||
updatedTime = null;
|
||||
versionNo = null;
|
||||
boost = "100";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin.suggestelevateword;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
*/
|
||||
public class SuggestElevateWordSearchForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
}
|
|
@ -19,10 +19,12 @@ package org.codelibs.fess.app.web.admin.webauthentication;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.annotation.Token;
|
||||
import org.codelibs.fess.app.pager.WebAuthenticationPager;
|
||||
import org.codelibs.fess.app.service.WebAuthenticationService;
|
||||
|
@ -32,6 +34,7 @@ import org.codelibs.fess.crud.CommonConstants;
|
|||
import org.codelibs.fess.es.exentity.WebAuthentication;
|
||||
import org.codelibs.fess.es.exentity.WebConfig;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
|
@ -126,7 +129,8 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|||
form.initialize();
|
||||
form.crudMode = CommonConstants.CREATE_MODE;
|
||||
return asHtml(path_AdminWebauthentication_EditJsp).renderWith(data -> {
|
||||
// data.register("webConfigItems", webConfigService.getAllWebConfigList());
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -138,14 +142,18 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|||
verifyCrudMode(form, CommonConstants.EDIT_MODE);
|
||||
loadWebAuthentication(form);
|
||||
return asHtml(path_AdminWebauthentication_EditJsp).renderWith(data -> {
|
||||
// data.register("webConfigItems", webConfigService.getAllWebConfigList());
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editagain(final WebAuthenticationEditForm form) {
|
||||
return asHtml(path_AdminWebauthentication_EditJsp);
|
||||
return asHtml(path_AdminWebauthentication_EditJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
|
@ -153,7 +161,10 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|||
public HtmlResponse editfromconfirm(final WebAuthenticationEditForm form) {
|
||||
form.crudMode = CommonConstants.EDIT_MODE;
|
||||
loadWebAuthentication(form);
|
||||
return asHtml(path_AdminWebauthentication_EditJsp);
|
||||
return asHtml(path_AdminWebauthentication_EditJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
|
@ -163,7 +174,10 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.DELETE_MODE);
|
||||
loadWebAuthentication(form);
|
||||
return asHtml(path_AdminWebauthentication_ConfirmJsp);
|
||||
return asHtml(path_AdminWebauthentication_ConfirmJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
|
@ -171,7 +185,10 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|||
public HtmlResponse deletefromconfirm(final WebAuthenticationEditForm form) {
|
||||
form.crudMode = CommonConstants.DELETE_MODE;
|
||||
loadWebAuthentication(form);
|
||||
return asHtml(path_AdminWebauthentication_ConfirmJsp);
|
||||
return asHtml(path_AdminWebauthentication_ConfirmJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -183,21 +200,30 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.CONFIRM_MODE);
|
||||
loadWebAuthentication(form);
|
||||
return asHtml(path_AdminWebauthentication_ConfirmJsp);
|
||||
return asHtml(path_AdminWebauthentication_ConfirmJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromcreate(final WebAuthenticationEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminWebauthentication_ConfirmJsp);
|
||||
return asHtml(path_AdminWebauthentication_ConfirmJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromupdate(final WebAuthenticationEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminWebauthentication_ConfirmJsp);
|
||||
return asHtml(path_AdminWebauthentication_ConfirmJsp).renderWith(data -> {
|
||||
registerProtocolSchemeItems(data);
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -267,6 +293,34 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|||
return keys;
|
||||
}
|
||||
|
||||
protected void registerProtocolSchemeItems(final RenderData data) {
|
||||
final List<Map<String, String>> itemList = new ArrayList<Map<String, String>>();
|
||||
final Locale locale = LaRequestUtil.getRequest().getLocale();
|
||||
itemList.add(createItem(ComponentUtil.getMessageManager().getMessage(locale, "labels.web_authentication_scheme_basic"),
|
||||
Constants.BASIC));
|
||||
itemList.add(createItem(ComponentUtil.getMessageManager().getMessage(locale, "labels.web_authentication_scheme_digest"),
|
||||
Constants.DIGEST));
|
||||
itemList.add(createItem(ComponentUtil.getMessageManager().getMessage(locale, "labels.web_authentication_scheme_ntlm"),
|
||||
Constants.NTLM));
|
||||
data.register("protocolSchemeItems", itemList);
|
||||
}
|
||||
|
||||
protected void registerWebConfigItems(final RenderData data) {
|
||||
final List<Map<String, String>> itemList = new ArrayList<Map<String, String>>();
|
||||
final List<WebConfig> webConfigList = webConfigService.getAllWebConfigList(false, false, false, null);
|
||||
for (final WebConfig webConfig : webConfigList) {
|
||||
itemList.add(createItem(webConfig.getName(), webConfig.getId().toString()));
|
||||
}
|
||||
data.register("webConfigItems", itemList);
|
||||
}
|
||||
|
||||
protected Map<String, String> createItem(final String label, final String value) {
|
||||
final Map<String, String> map = new HashMap<String, String>(2);
|
||||
map.put(Constants.ITEM_LABEL, label);
|
||||
map.put(Constants.ITEM_VALUE, value);
|
||||
return map;
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
|
@ -280,7 +334,9 @@ public class AdminWebauthenticationAction extends FessAdminAction {
|
|||
|
||||
protected VaErrorHook toEditHtml() {
|
||||
return () -> {
|
||||
return asHtml(path_AdminWebauthentication_EditJsp);
|
||||
return asHtml(path_AdminWebauthentication_EditJsp).renderWith(data -> {
|
||||
registerWebConfigItems(data);
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.DELETE_MODE);
|
||||
loadWebConfig(form);
|
||||
return asHtml(path_AdminWebconfig_EditJsp).renderWith(data -> {
|
||||
return asHtml(path_AdminWebconfig_ConfirmJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
public HtmlResponse deletefromconfirm(final WebConfigEditForm form) {
|
||||
form.crudMode = CommonConstants.DELETE_MODE;
|
||||
loadWebConfig(form);
|
||||
return asHtml(path_AdminWebconfig_EditJsp).renderWith(data -> {
|
||||
return asHtml(path_AdminWebconfig_ConfirmJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.CONFIRM_MODE);
|
||||
loadWebConfig(form);
|
||||
return asHtml(path_AdminWebconfig_EditJsp).renderWith(data -> {
|
||||
return asHtml(path_AdminWebconfig_ConfirmJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
} catch (final Exception e) {
|
||||
|
@ -204,7 +204,7 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse confirmfromcreate(final WebConfigEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminWebconfig_EditJsp).renderWith(data -> {
|
||||
return asHtml(path_AdminWebconfig_ConfirmJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ public class AdminWebconfigAction extends FessAdminAction {
|
|||
@Execute
|
||||
public HtmlResponse confirmfromupdate(final WebConfigEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminWebconfig_EditJsp).renderWith(data -> {
|
||||
return asHtml(path_AdminWebconfig_ConfirmJsp).renderWith(data -> {
|
||||
registerRolesAndLabels(data);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
<c:if test="${data.expiredTime==null}"><la:message key="labels.none" /></c:if>
|
||||
<c:if test="${data.expiredTime!=null}">${f:h(data.expiredTime)}</c:if>
|
||||
</td>
|
||||
<td style="overflow-x: auto;>
|
||||
<td style="overflow-x: auto;">
|
||||
<la:link href="confirmpage/4/${f:u(data.id)}">
|
||||
<la:message key="labels.crawling_session_link_details" />
|
||||
</la:link>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<c:if test="${!displayCreateLink}">
|
||||
<la:link href="../fileConfig/index" styleClass="btn btn-primary">
|
||||
<la:link href="../fileconfig/index" styleClass="btn btn-primary">
|
||||
<la:message key="labels.file_authentication_create_file_config" />
|
||||
</la:link>
|
||||
</c:if>
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
<c:if test="${data.endTime!=null}"><fmt:formatDate value="${data.endTime}" pattern="yyyy-MM-dd'T'HH:mm:ss" /></c:if>
|
||||
<c:if test="${data.endTime==null}"><la:message key="labels.none" /></c:if>
|
||||
</td>
|
||||
<td style="overflow-x: auto;>
|
||||
<td style="overflow-x: auto;">
|
||||
<la:link href="confirmpage/4/${f:u(data.id)}">
|
||||
<la:message key="labels.joblog_link_details" />
|
||||
</la:link>
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
<td>
|
||||
<la:link href="download/${f:u(logFile.logFileName)}">${f:h(logFile.name)}</la:link>
|
||||
</td>
|
||||
<td style="overflow-x: auto;>
|
||||
<td style="overflow-x: auto;">
|
||||
<fmt:formatDate value="${logFile.lastModified}" type="BOTH" dateStyle="MEDIUM" />
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -111,12 +111,12 @@
|
|||
<span><la:message key="labels.menu.web_authentication" /></span>
|
||||
</la:link></li>
|
||||
|
||||
<li <c:if test="${param.menuType=='fileAuthentication'}">class="active"</c:if>><todo:link
|
||||
href="/admin/fileAuthentication/index"
|
||||
<li <c:if test="${param.menuType=='fileAuthentication'}">class="active"</c:if>><la:link
|
||||
href="/admin/fileauthentication/index"
|
||||
>
|
||||
<i class='fa fa-angle-right'></i>
|
||||
<span><la:message key="labels.menu.file_authentication" /></span>
|
||||
</todo:link></li>
|
||||
</la:link></li>
|
||||
|
||||
<li <c:if test="${param.menuType=='requestHeader'}">class="active"</c:if>><la:link
|
||||
href="/admin/requestheader/index"
|
||||
|
@ -143,12 +143,12 @@
|
|||
></i> <span><la:message key="labels.menu_suggest" /></span> <i class="fa fa-angle-left pull-right"></i></a>
|
||||
<ul class="treeview-menu">
|
||||
|
||||
<li <c:if test="${param.menuType=='suggestElevateWord'}">class="active"</c:if>><todo:link
|
||||
href="/admin/suggestElevateWord/index"
|
||||
<li <c:if test="${param.menuType=='suggestElevateWord'}">class="active"</c:if>><la:link
|
||||
href="/admin/suggestelevateword/index"
|
||||
>
|
||||
<i class='fa fa-angle-right'></i>
|
||||
<span><la:message key="labels.menu.suggest_elevate_word" /></span>
|
||||
</todo:link></li>
|
||||
</la:link></li>
|
||||
|
||||
<li <c:if test="${param.menuType=='suggestBadWord'}">class="active"</c:if>><todo:link
|
||||
href="/admin/suggestBadWord/index"
|
||||
|
|
Loading…
Add table
Reference in a new issue