code cleanup

This commit is contained in:
Shinsuke Sugaya 2015-12-29 21:04:52 +09:00
parent 7393fc6bd3
commit c547da68bb
26 changed files with 24 additions and 786 deletions

View file

@ -21,12 +21,9 @@ import java.io.Serializable;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelibs.core.beans.util.BeanUtil;
import org.codelibs.core.lang.StringUtil;
import org.codelibs.fess.Constants;
@ -38,6 +35,8 @@ import org.codelibs.fess.util.ComponentUtil;
import org.dbflute.bhv.readable.EntityRowHandler;
import org.dbflute.cbean.result.PagingResultBean;
import org.dbflute.optional.OptionalEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.orangesignal.csv.CsvConfig;
import com.orangesignal.csv.CsvReader;
@ -49,7 +48,7 @@ public class BadWordService implements Serializable {
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(BadWordService.class);
private static final Logger logger = LoggerFactory.getLogger(BadWordService.class);
@Resource
protected BadWordBhv badWordBhv;
@ -79,7 +78,6 @@ public class BadWordService implements Serializable {
}
public void store(final BadWord badWord) {
setupStoreCondition(badWord);
badWordBhv.insertOrUpdate(badWord, op -> {
op.setRefresh(true);
@ -88,7 +86,6 @@ public class BadWordService implements Serializable {
}
public void delete(final BadWord badWord) {
setupDeleteCondition(badWord);
badWordBhv.delete(badWord, op -> {
op.setRefresh(true);
@ -109,25 +106,8 @@ public class BadWordService implements Serializable {
}
protected void setupEntityCondition(final BadWordCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final BadWord badWord) {
// setup condition
}
protected void setupDeleteCondition(final BadWord badWord) {
// setup condition
}
public void importCsv(final Reader reader) {
@SuppressWarnings("resource")
final CsvReader csvReader = new CsvReader(reader, new CsvConfig());
try {
List<String> list;
@ -163,11 +143,11 @@ public class BadWordService implements Serializable {
badWordBhv.update(badWord);
}
} catch (final Exception e) {
log.warn("Failed to read a sugget elevate word: " + list, e);
logger.warn("Failed to read a sugget elevate word: " + list, e);
}
}
} catch (final IOException e) {
log.warn("Failed to read a sugget elevate word.", e);
logger.warn("Failed to read a sugget elevate word.", e);
}
}
@ -192,7 +172,7 @@ public class BadWordService implements Serializable {
try {
csvWriter.writeValues(list);
} catch (final IOException e) {
log.warn("Failed to write a sugget bad word: " + entity, e);
logger.warn("Failed to write a sugget bad word: " + entity, e);
}
}
@ -207,7 +187,7 @@ public class BadWordService implements Serializable {
csvWriter.flush();
} catch (final IOException e) {
log.warn("Failed to write a sugget bad word.", e);
logger.warn("Failed to write a sugget bad word.", e);
}
}

View file

@ -17,7 +17,6 @@ package org.codelibs.fess.app.service;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -62,7 +61,6 @@ public class BoostDocumentRuleService implements Serializable {
}
public void store(final BoostDocumentRule boostDocumentRule) {
setupStoreCondition(boostDocumentRule);
boostDocumentRuleBhv.insertOrUpdate(boostDocumentRule, op -> {
op.setRefresh(true);
@ -71,7 +69,6 @@ public class BoostDocumentRuleService implements Serializable {
}
public void delete(final BoostDocumentRule boostDocumentRule) {
setupDeleteCondition(boostDocumentRule);
boostDocumentRuleBhv.delete(boostDocumentRule, op -> {
op.setRefresh(true);
@ -92,24 +89,6 @@ public class BoostDocumentRuleService implements Serializable {
}
protected void setupEntityCondition(final BoostDocumentRuleCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final BoostDocumentRule boostDocumentRule) {
// setup condition
}
protected void setupDeleteCondition(final BoostDocumentRule boostDocumentRule) {
// setup condition
}
public List<BoostDocumentRule> getAvailableBoostDocumentRuleList() {
return boostDocumentRuleBhv.selectList(cb -> {
cb.query().matchAll();

View file

@ -26,14 +26,11 @@ import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelibs.core.CoreLibConstants;
import org.codelibs.core.beans.util.BeanUtil;
import org.codelibs.core.lang.StringUtil;
@ -50,6 +47,8 @@ import org.dbflute.bhv.readable.EntityRowHandler;
import org.dbflute.cbean.result.ListResultBean;
import org.dbflute.cbean.result.PagingResultBean;
import org.dbflute.optional.OptionalEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.orangesignal.csv.CsvConfig;
import com.orangesignal.csv.CsvReader;
@ -59,7 +58,7 @@ public class CrawlingInfoService implements Serializable {
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(CrawlingInfoService.class);
private static final Logger logger = LoggerFactory.getLogger(CrawlingInfoService.class);
@Resource
protected CrawlingInfoParamBhv crawlingInfoParamBhv;
@ -67,10 +66,6 @@ public class CrawlingInfoService implements Serializable {
@Resource
protected CrawlingInfoBhv crawlingInfoBhv;
public CrawlingInfoService() {
super();
}
public List<CrawlingInfo> getCrawlingInfoList(final CrawlingInfoPager crawlingInfoPager) {
final PagingResultBean<CrawlingInfo> crawlingInfoList = crawlingInfoBhv.selectPage(cb -> {
@ -109,9 +104,6 @@ public class CrawlingInfoService implements Serializable {
}
protected void setupEntityCondition(final CrawlingInfoCB cb, final Map<String, String> keys) {
}
protected void setupListCondition(final CrawlingInfoCB cb, final CrawlingInfoPager crawlingInfoPager) {
if (crawlingInfoPager.id != null) {
cb.query().docMeta().setId_Equal(crawlingInfoPager.id);
@ -271,11 +263,11 @@ public class CrawlingInfoService implements Serializable {
op.setRefresh(true);
});
} catch (final Exception e) {
log.warn("Failed to read a click log: " + list, e);
logger.warn("Failed to read a click log: " + list, e);
}
}
} catch (final IOException e) {
log.warn("Failed to read a click log.", e);
logger.warn("Failed to read a click log.", e);
}
}
@ -315,7 +307,7 @@ public class CrawlingInfoService implements Serializable {
try {
csvWriter.writeValues(list);
} catch (final IOException e) {
log.warn("Failed to write a crawling session info: " + entity, e);
logger.warn("Failed to write a crawling session info: " + entity, e);
}
}
@ -331,7 +323,7 @@ public class CrawlingInfoService implements Serializable {
});
csvWriter.flush();
} catch (final IOException e) {
log.warn("Failed to write a crawling session info.", e);
logger.warn("Failed to write a crawling session info.", e);
}
}

View file

@ -18,7 +18,6 @@ package org.codelibs.fess.app.service;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -48,10 +47,6 @@ public class DataConfigService implements Serializable {
@Resource
protected DataConfigBhv dataConfigBhv;
public DataConfigService() {
super();
}
public List<DataConfig> getDataConfigList(final DataConfigPager dataConfigPager) {
final PagingResultBean<DataConfig> dataConfigList = dataConfigBhv.selectPage(cb -> {
@ -70,7 +65,6 @@ public class DataConfigService implements Serializable {
}
public void delete(final DataConfig dataConfig) {
setupDeleteCondition(dataConfig);
dataConfigBhv.delete(dataConfig, op -> {
op.setRefresh(true);
@ -136,7 +130,6 @@ public class DataConfigService implements Serializable {
final boolean isNew = dataConfig.getId() == null;
final String[] labelTypeIds = dataConfig.getLabelTypeIds();
final String[] roleTypeIds = dataConfig.getRoleTypeIds();
setupStoreCondition(dataConfig);
dataConfigBhv.insertOrUpdate(dataConfig, op -> {
op.setRefresh(true);
@ -248,22 +241,4 @@ public class DataConfigService implements Serializable {
}
protected void setupEntityCondition(final DataConfigCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final DataConfig dataConfig) {
// setup condition
}
protected void setupDeleteCondition(final DataConfig dataConfig) {
// setup condition
}
}

View file

@ -17,7 +17,6 @@ package org.codelibs.fess.app.service;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -37,10 +36,6 @@ public class DuplicateHostService implements Serializable {
@Resource
protected DuplicateHostBhv duplicateHostBhv;
public DuplicateHostService() {
super();
}
public List<DuplicateHost> getDuplicateHostList(final DuplicateHostPager duplicateHostPager) {
final PagingResultBean<DuplicateHost> duplicateHostList = duplicateHostBhv.selectPage(cb -> {
@ -62,7 +57,6 @@ public class DuplicateHostService implements Serializable {
}
public void store(final DuplicateHost duplicateHost) {
setupStoreCondition(duplicateHost);
duplicateHostBhv.insertOrUpdate(duplicateHost, op -> {
op.setRefresh(true);
@ -71,7 +65,6 @@ public class DuplicateHostService implements Serializable {
}
public void delete(final DuplicateHost duplicateHost) {
setupDeleteCondition(duplicateHost);
duplicateHostBhv.delete(duplicateHost, op -> {
op.setRefresh(true);
@ -101,22 +94,4 @@ public class DuplicateHostService implements Serializable {
}
protected void setupEntityCondition(final DuplicateHostCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final DuplicateHost duplicateHost) {
// setup condition
}
protected void setupDeleteCondition(final DuplicateHost duplicateHost) {
// setup condition
}
}

View file

@ -21,12 +21,9 @@ import java.io.Serializable;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelibs.core.beans.util.BeanUtil;
import org.codelibs.core.lang.StringUtil;
import org.codelibs.fess.Constants;
@ -40,6 +37,8 @@ import org.codelibs.fess.util.ComponentUtil;
import org.dbflute.bhv.readable.EntityRowHandler;
import org.dbflute.cbean.result.PagingResultBean;
import org.dbflute.optional.OptionalEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.orangesignal.csv.CsvConfig;
import com.orangesignal.csv.CsvReader;
@ -49,7 +48,7 @@ public class ElevateWordService implements Serializable {
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(ElevateWordService.class);
private static final Logger logger = LoggerFactory.getLogger(ElevateWordService.class);
@Resource
protected ElevateWordToLabelBhv elevateWordToLabelBhv;
@ -57,10 +56,6 @@ public class ElevateWordService implements Serializable {
@Resource
protected ElevateWordBhv elevateWordBhv;
public ElevateWordService() {
super();
}
public List<ElevateWord> getElevateWordList(final ElevateWordPager elevateWordPager) {
final PagingResultBean<ElevateWord> elevateWordList = elevateWordBhv.selectPage(cb -> {
@ -97,7 +92,6 @@ public class ElevateWordService implements Serializable {
public void store(final ElevateWord elevateWord) {
final boolean isNew = elevateWord.getId() == null;
final String[] labelTypeIds = elevateWord.getLabelTypeIds();
setupStoreCondition(elevateWord);
elevateWordBhv.insertOrUpdate(elevateWord, op -> {
op.setRefresh(true);
@ -154,7 +148,6 @@ public class ElevateWordService implements Serializable {
}
public void delete(final ElevateWord elevateWord) {
setupDeleteCondition(elevateWord);
elevateWordBhv.delete(elevateWord, op -> {
op.setRefresh(true);
@ -175,25 +168,8 @@ public class ElevateWordService implements Serializable {
}
protected void setupEntityCondition(final ElevateWordCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final ElevateWord elevateWord) {
// setup condition
}
protected void setupDeleteCondition(final ElevateWord elevateWord) {
// setup condition
}
public void importCsv(final Reader reader) {
@SuppressWarnings("resource")
final CsvReader csvReader = new CsvReader(reader, new CsvConfig());
try {
List<String> list;
@ -239,11 +215,11 @@ public class ElevateWordService implements Serializable {
elevateWordBhv.update(elevateWord);
}
} catch (final Exception e) {
log.warn("Failed to read a sugget elevate word: " + list, e);
logger.warn("Failed to read a sugget elevate word: " + list, e);
}
}
} catch (final IOException e) {
log.warn("Failed to read a sugget elevate word.", e);
logger.warn("Failed to read a sugget elevate word.", e);
}
}
@ -276,7 +252,7 @@ public class ElevateWordService implements Serializable {
try {
csvWriter.writeValues(list);
} catch (final IOException e) {
log.warn("Failed to write a sugget elevate word: " + entity, e);
logger.warn("Failed to write a sugget elevate word: " + entity, e);
}
}
@ -291,7 +267,7 @@ public class ElevateWordService implements Serializable {
csvWriter.flush();
} catch (final IOException e) {
log.warn("Failed to write a sugget elevate word.", e);
logger.warn("Failed to write a sugget elevate word.", e);
}
}

View file

@ -20,7 +20,6 @@ import java.io.Serializable;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import javax.annotation.Resource;
@ -52,10 +51,6 @@ public class FailureUrlService implements Serializable {
@Resource
protected FailureUrlBhv failureUrlBhv;
public FailureUrlService() {
super();
}
public List<FailureUrl> getFailureUrlList(final FailureUrlPager failureUrlPager) {
final PagingResultBean<FailureUrl> failureUrlList = failureUrlBhv.selectPage(cb -> {
@ -77,7 +72,6 @@ public class FailureUrlService implements Serializable {
}
public void store(final FailureUrl failureUrl) {
setupStoreCondition(failureUrl);
failureUrlBhv.insertOrUpdate(failureUrl, op -> {
op.setRefresh(true);
@ -86,7 +80,6 @@ public class FailureUrlService implements Serializable {
}
public void delete(final FailureUrl failureUrl) {
setupDeleteCondition(failureUrl);
failureUrlBhv.delete(failureUrl, op -> {
op.setRefresh(true);
@ -106,24 +99,6 @@ public class FailureUrlService implements Serializable {
buildSearchCondition(failureUrlPager, cb);
}
protected void setupEntityCondition(final FailureUrlCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final FailureUrl failureUrl) {
// setup condition
}
protected void setupDeleteCondition(final FailureUrl failureUrl) {
// setup condition
}
public void deleteAll(final FailureUrlPager failureUrlPager) {
failureUrlBhv.queryDelete(cb -> {
buildSearchCondition(failureUrlPager, cb);

View file

@ -17,7 +17,6 @@ package org.codelibs.fess.app.service;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -37,10 +36,6 @@ public class FileAuthenticationService implements Serializable {
@Resource
protected FileAuthenticationBhv fileAuthenticationBhv;
public FileAuthenticationService() {
super();
}
public List<FileAuthentication> getFileAuthenticationList(final FileAuthPager fileAuthenticationPager) {
final PagingResultBean<FileAuthentication> fileAuthenticationList = fileAuthenticationBhv.selectPage(cb -> {
@ -62,7 +57,6 @@ public class FileAuthenticationService implements Serializable {
}
public void store(final FileAuthentication fileAuthentication) {
setupStoreCondition(fileAuthentication);
fileAuthenticationBhv.insertOrUpdate(fileAuthentication, op -> {
op.setRefresh(true);
@ -71,7 +65,6 @@ public class FileAuthenticationService implements Serializable {
}
public void delete(final FileAuthentication fileAuthentication) {
setupDeleteCondition(fileAuthentication);
fileAuthenticationBhv.delete(fileAuthentication, op -> {
op.setRefresh(true);
@ -92,24 +85,6 @@ public class FileAuthenticationService implements Serializable {
}
protected void setupEntityCondition(final FileAuthenticationCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final FileAuthentication fileAuthentication) {
// setup condition
}
protected void setupDeleteCondition(final FileAuthentication fileAuthentication) {
// setup condition
}
public List<FileAuthentication> getFileAuthenticationList(final String fileConfigId) {
return fileAuthenticationBhv.selectList(cb -> {
cb.query().setFileConfigId_Equal(fileConfigId);

View file

@ -18,7 +18,6 @@ package org.codelibs.fess.app.service;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -48,10 +47,6 @@ public class FileConfigService implements Serializable {
@Resource
protected FileConfigBhv fileConfigBhv;
public FileConfigService() {
super();
}
public List<FileConfig> getFileConfigList(final FileConfigPager fileConfigPager) {
final PagingResultBean<FileConfig> fileConfigList = fileConfigBhv.selectPage(cb -> {
@ -69,7 +64,6 @@ public class FileConfigService implements Serializable {
}
public void delete(final FileConfig fileConfig) {
setupDeleteCondition(fileConfig);
fileConfigBhv.delete(fileConfig, op -> {
op.setRefresh(true);
@ -134,7 +128,6 @@ public class FileConfigService implements Serializable {
final boolean isNew = fileConfig.getId() == null;
final String[] labelTypeIds = fileConfig.getLabelTypeIds();
final String[] roleTypeIds = fileConfig.getRoleTypeIds();
setupStoreCondition(fileConfig);
fileConfigBhv.insertOrUpdate(fileConfig, op -> {
op.setRefresh(true);
@ -246,22 +239,4 @@ public class FileConfigService implements Serializable {
}
protected void setupEntityCondition(final FileConfigCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final FileConfig fileConfig) {
// setup condition
}
protected void setupDeleteCondition(final FileConfig fileConfig) {
// setup condition
}
}

View file

@ -17,7 +17,6 @@ package org.codelibs.fess.app.service;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -62,7 +61,6 @@ public class GroupService implements Serializable {
}
public void store(final Group group) {
setupStoreCondition(group);
groupBhv.insertOrUpdate(group, op -> {
op.setRefresh(true);
@ -71,7 +69,6 @@ public class GroupService implements Serializable {
}
public void delete(final Group group) {
setupDeleteCondition(group);
groupBhv.delete(group, op -> {
op.setRefresh(true);
@ -92,24 +89,6 @@ public class GroupService implements Serializable {
}
protected void setupEntityCondition(final GroupCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final Group group) {
// setup condition
}
protected void setupDeleteCondition(final Group group) {
// setup condition
}
public List<Group> getAvailableGroupList() {
return groupBhv.selectList(cb -> {
cb.query().matchAll();

View file

@ -17,7 +17,6 @@ package org.codelibs.fess.app.service;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -38,10 +37,6 @@ public class JobLogService implements Serializable {
@Resource
protected JobLogBhv jobLogBhv;
public JobLogService() {
super();
}
public List<JobLog> getJobLogList(final JobLogPager jobLogPager) {
final PagingResultBean<JobLog> jobLogList = jobLogBhv.selectPage(cb -> {
@ -63,7 +58,6 @@ public class JobLogService implements Serializable {
}
public void store(final JobLog jobLog) {
setupStoreCondition(jobLog);
jobLogBhv.insertOrUpdate(jobLog, op -> {
op.setRefresh(true);
@ -72,7 +66,6 @@ public class JobLogService implements Serializable {
}
public void delete(final JobLog jobLog) {
setupDeleteCondition(jobLog);
jobLogBhv.delete(jobLog, op -> {
op.setRefresh(true);
@ -94,24 +87,6 @@ public class JobLogService implements Serializable {
}
protected void setupEntityCondition(final JobLogCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final JobLog jobLog) {
// setup condition
}
protected void setupDeleteCondition(final JobLog jobLog) {
// setup condition
}
public void deleteBefore(final int days) {
final long oneday = 24 * 60 * 60 * 1000;
final long targetTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong() - days * oneday;

View file

@ -17,7 +17,6 @@ package org.codelibs.fess.app.service;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -62,7 +61,6 @@ public class KeyMatchService implements Serializable {
}
public void store(final KeyMatch keyMatch) {
setupStoreCondition(keyMatch);
keyMatchBhv.insertOrUpdate(keyMatch, op -> {
op.setRefresh(true);
@ -71,7 +69,6 @@ public class KeyMatchService implements Serializable {
}
public void delete(final KeyMatch keyMatch) {
setupDeleteCondition(keyMatch);
keyMatchBhv.delete(keyMatch, op -> {
op.setRefresh(true);
@ -92,24 +89,6 @@ public class KeyMatchService implements Serializable {
}
protected void setupEntityCondition(final KeyMatchCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final KeyMatch keyMatch) {
// setup condition
}
protected void setupDeleteCondition(final KeyMatch keyMatch) {
// setup condition
}
public List<KeyMatch> getAvailableKeyMatchList() {
return keyMatchBhv.selectList(cb -> {
cb.query().matchAll();

View file

@ -18,7 +18,6 @@ package org.codelibs.fess.app.service;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -50,10 +49,6 @@ public class LabelTypeService implements Serializable {
@Resource
protected FessConfig fessConfig;
public LabelTypeService() {
super();
}
public List<LabelType> getLabelTypeList(final LabelTypePager labelTypePager) {
final PagingResultBean<LabelType> labelTypeList = labelTypeBhv.selectPage(cb -> {
@ -71,7 +66,6 @@ public class LabelTypeService implements Serializable {
}
public void delete(final LabelType labelType) {
setupDeleteCondition(labelType);
labelTypeBhv.delete(labelType, op -> {
op.setRefresh(true);
@ -95,24 +89,6 @@ public class LabelTypeService implements Serializable {
}
protected void setupEntityCondition(final LabelTypeCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final LabelType labelType) {
// setup condition
}
protected void setupDeleteCondition(final LabelType labelType) {
// setup condition
}
public List<LabelType> getLabelTypeList() {
return labelTypeBhv.selectList(cb -> {
cb.query().addOrderBy_SortOrder_Asc();
@ -134,7 +110,6 @@ public class LabelTypeService implements Serializable {
public void store(final LabelType labelType) {
final boolean isNew = labelType.getId() == null;
final String[] roleTypeIds = labelType.getRoleTypeIds();
setupStoreCondition(labelType);
labelTypeBhv.insertOrUpdate(labelType, op -> {
op.setRefresh(true);

View file

@ -18,7 +18,6 @@ package org.codelibs.fess.app.service;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -59,7 +58,6 @@ public class PathMappingService implements Serializable {
}
public void store(final PathMapping pathMapping) {
setupStoreCondition(pathMapping);
pathMappingBhv.insertOrUpdate(pathMapping, op -> {
op.setRefresh(true);
@ -68,7 +66,6 @@ public class PathMappingService implements Serializable {
}
public void delete(final PathMapping pathMapping) {
setupDeleteCondition(pathMapping);
pathMappingBhv.delete(pathMapping, op -> {
op.setRefresh(true);
@ -97,22 +94,4 @@ public class PathMappingService implements Serializable {
}
protected void setupEntityCondition(final PathMappingCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final PathMapping pathMapping) {
// setup condition
}
protected void setupDeleteCondition(final PathMapping pathMapping) {
// setup condition
}
}

View file

@ -17,7 +17,6 @@ package org.codelibs.fess.app.service;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -37,10 +36,6 @@ public class RequestHeaderService implements Serializable {
@Resource
protected RequestHeaderBhv requestHeaderBhv;
public RequestHeaderService() {
super();
}
public List<RequestHeader> getRequestHeaderList(final ReqHeaderPager requestHeaderPager) {
final PagingResultBean<RequestHeader> requestHeaderList = requestHeaderBhv.selectPage(cb -> {
@ -62,7 +57,6 @@ public class RequestHeaderService implements Serializable {
}
public void store(final RequestHeader requestHeader) {
setupStoreCondition(requestHeader);
requestHeaderBhv.insertOrUpdate(requestHeader, op -> {
op.setRefresh(true);
@ -71,7 +65,6 @@ public class RequestHeaderService implements Serializable {
}
public void delete(final RequestHeader requestHeader) {
setupDeleteCondition(requestHeader);
requestHeaderBhv.delete(requestHeader, op -> {
op.setRefresh(true);
@ -92,24 +85,6 @@ public class RequestHeaderService implements Serializable {
}
protected void setupEntityCondition(final RequestHeaderCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final RequestHeader requestHeader) {
// setup condition
}
protected void setupDeleteCondition(final RequestHeader requestHeader) {
// setup condition
}
public List<RequestHeader> getRequestHeaderList(final String webConfigId) {
return requestHeaderBhv.selectList(cb -> {
cb.query().setWebConfigId_Equal(webConfigId);

View file

@ -17,7 +17,6 @@ package org.codelibs.fess.app.service;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -62,7 +61,6 @@ public class RoleService implements Serializable {
}
public void store(final Role role) {
setupStoreCondition(role);
roleBhv.insertOrUpdate(role, op -> {
op.setRefresh(true);
@ -71,7 +69,6 @@ public class RoleService implements Serializable {
}
public void delete(final Role role) {
setupDeleteCondition(role);
roleBhv.delete(role, op -> {
op.setRefresh(true);
@ -92,24 +89,6 @@ public class RoleService implements Serializable {
}
protected void setupEntityCondition(final RoleCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final Role role) {
// setup condition
}
protected void setupDeleteCondition(final Role role) {
// setup condition
}
public List<Role> getAvailableRoleList() {
return roleBhv.selectList(cb -> {
cb.query().matchAll();

View file

@ -17,7 +17,6 @@ package org.codelibs.fess.app.service;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -41,10 +40,6 @@ public class RoleTypeService implements Serializable {
@Resource
protected FessConfig fessConfig;
public RoleTypeService() {
super();
}
public List<RoleType> getRoleTypeList(final RoleTypePager roleTypePager) {
final PagingResultBean<RoleType> roleTypeList = roleTypeBhv.selectPage(cb -> {
@ -66,7 +61,6 @@ public class RoleTypeService implements Serializable {
}
public void store(final RoleType roleType) {
setupStoreCondition(roleType);
roleTypeBhv.insertOrUpdate(roleType, op -> {
op.setRefresh(true);
@ -75,7 +69,6 @@ public class RoleTypeService implements Serializable {
}
public void delete(final RoleType roleType) {
setupDeleteCondition(roleType);
roleTypeBhv.delete(roleType, op -> {
op.setRefresh(true);
@ -96,24 +89,6 @@ public class RoleTypeService implements Serializable {
}
protected void setupEntityCondition(final RoleTypeCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final RoleType roleType) {
// setup condition
}
protected void setupDeleteCondition(final RoleType roleType) {
// setup condition
}
public List<RoleType> getRoleTypeList() {
return roleTypeBhv.selectList(cb -> {
cb.query().addOrderBy_SortOrder_Asc();

View file

@ -17,7 +17,6 @@ package org.codelibs.fess.app.service;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -38,10 +37,6 @@ public class ScheduledJobService implements Serializable {
@Resource
protected ScheduledJobBhv scheduledJobBhv;
public ScheduledJobService() {
super();
}
public List<ScheduledJob> getScheduledJobList(final SchedulerPager scheduledJobPager) {
final PagingResultBean<ScheduledJob> scheduledJobList = scheduledJobBhv.selectPage(cb -> {
@ -63,7 +58,6 @@ public class ScheduledJobService implements Serializable {
}
public void delete(final ScheduledJob scheduledJob) {
setupDeleteCondition(scheduledJob);
scheduledJobBhv.delete(scheduledJob, op -> {
op.setRefresh(true);
@ -88,24 +82,6 @@ public class ScheduledJobService implements Serializable {
}
protected void setupEntityCondition(final ScheduledJobCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final ScheduledJob scheduledJob) {
// setup condition
}
protected void setupDeleteCondition(final ScheduledJob scheduledJob) {
// setup condition
}
public List<ScheduledJob> getScheduledJobList() {
return scheduledJobBhv.selectList(cb -> {
cb.query().addOrderBy_SortOrder_Asc();
@ -115,7 +91,6 @@ public class ScheduledJobService implements Serializable {
public void store(final ScheduledJob scheduledJob) {
final boolean isNew = scheduledJob.getId() == null;
setupStoreCondition(scheduledJob);
scheduledJobBhv.insertOrUpdate(scheduledJob, op -> {
op.setRefresh(true);

View file

@ -17,7 +17,6 @@ package org.codelibs.fess.app.service;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -37,10 +36,6 @@ public class UserService implements Serializable {
@Resource
protected UserBhv userBhv;
public UserService() {
super();
}
public List<User> getUserList(final UserPager userPager) {
final PagingResultBean<User> userList = userBhv.selectPage(cb -> {
@ -62,7 +57,6 @@ public class UserService implements Serializable {
}
public void store(final User user) {
setupStoreCondition(user);
userBhv.insertOrUpdate(user, op -> {
op.setRefresh(true);
@ -71,7 +65,6 @@ public class UserService implements Serializable {
}
public void delete(final User user) {
setupDeleteCondition(user);
userBhv.delete(user, op -> {
op.setRefresh(true);
@ -92,24 +85,6 @@ public class UserService implements Serializable {
}
protected void setupEntityCondition(final UserCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final User user) {
// setup condition
}
protected void setupDeleteCondition(final User user) {
// setup condition
}
public List<User> getAvailableUserList() {
return userBhv.selectList(cb -> {
cb.query().matchAll();

View file

@ -17,7 +17,6 @@ package org.codelibs.fess.app.service;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -37,10 +36,6 @@ public class WebAuthenticationService implements Serializable {
@Resource
protected WebAuthenticationBhv webAuthenticationBhv;
public WebAuthenticationService() {
super();
}
public List<WebAuthentication> getWebAuthenticationList(final WebAuthPager webAuthenticationPager) {
final PagingResultBean<WebAuthentication> webAuthenticationList = webAuthenticationBhv.selectPage(cb -> {
@ -62,7 +57,6 @@ public class WebAuthenticationService implements Serializable {
}
public void store(final WebAuthentication webAuthentication) {
setupStoreCondition(webAuthentication);
webAuthenticationBhv.insertOrUpdate(webAuthentication, op -> {
op.setRefresh(true);
@ -71,7 +65,6 @@ public class WebAuthenticationService implements Serializable {
}
public void delete(final WebAuthentication webAuthentication) {
setupDeleteCondition(webAuthentication);
webAuthenticationBhv.delete(webAuthentication, op -> {
op.setRefresh(true);
@ -92,24 +85,6 @@ public class WebAuthenticationService implements Serializable {
}
protected void setupEntityCondition(final WebAuthenticationCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final WebAuthentication webAuthentication) {
// setup condition
}
protected void setupDeleteCondition(final WebAuthentication webAuthentication) {
// setup condition
}
public List<WebAuthentication> getWebAuthenticationList(final String webConfigId) {
return webAuthenticationBhv.selectList(cb -> {
cb.query().setWebConfigId_Equal(webConfigId);

View file

@ -18,7 +18,6 @@ package org.codelibs.fess.app.service;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@ -48,10 +47,6 @@ public class WebConfigService implements Serializable {
@Resource
protected WebConfigBhv webConfigBhv;
public WebConfigService() {
super();
}
public List<WebConfig> getWebConfigList(final WebConfigPager webConfigPager) {
final PagingResultBean<WebConfig> webConfigList = webConfigBhv.selectPage(cb -> {
@ -69,7 +64,6 @@ public class WebConfigService implements Serializable {
}
public void delete(final WebConfig webConfig) {
setupDeleteCondition(webConfig);
webConfigBhv.delete(webConfig, op -> {
op.setRefresh(true);
@ -135,7 +129,6 @@ public class WebConfigService implements Serializable {
final boolean isNew = webConfig.getId() == null;
final String[] labelTypeIds = webConfig.getLabelTypeIds();
final String[] roleTypeIds = webConfig.getRoleTypeIds();
setupStoreCondition(webConfig);
webConfigBhv.insertOrUpdate(webConfig, op -> {
op.setRefresh(true);
@ -248,21 +241,4 @@ public class WebConfigService implements Serializable {
}
protected void setupEntityCondition(final WebConfigCB cb, final Map<String, String> keys) {
// setup condition
}
protected void setupStoreCondition(final WebConfig webConfig) {
// setup condition
}
protected void setupDeleteCondition(final WebConfig webConfig) {
// setup condition
}
}

View file

@ -1,121 +0,0 @@
/*
* Copyright 2012-2015 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.filter;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.codelibs.core.lang.StringUtil;
import org.codelibs.fess.Constants;
import org.codelibs.fess.entity.LoginInfo;
import org.codelibs.fess.helper.AdRoleHelper;
import org.codelibs.fess.util.ComponentUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// TODO refactoring
public class AdLoginInfoFilter implements Filter {
private static final Logger logger = LoggerFactory.getLogger(AdLoginInfoFilter.class);
private long updateInterval = 60 * 60 * 1000L; // 1h
private boolean redirectLoginError;
private boolean useTestUser;
private String testUserName;
@Override
public void init(final FilterConfig filterConfig) throws ServletException {
redirectLoginError = "true".equalsIgnoreCase(filterConfig.getInitParameter("redirectLoginError"));
final String value = filterConfig.getInitParameter("updateInterval");
if (value != null) {
updateInterval = Long.parseLong(value);
}
useTestUser = "true".equalsIgnoreCase(filterConfig.getInitParameter("useTestUser"));
testUserName = filterConfig.getInitParameter("testUserName");
}
@Override
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException,
ServletException {
if (request instanceof HttpServletRequest) {
final HttpServletRequest httpRequest = (HttpServletRequest) request;
final HttpSession session = httpRequest.getSession();
String userId = httpRequest.getRemoteUser();
if (useTestUser) {
userId = testUserName;
}
if (StringUtil.isEmpty(userId)) {
final String servletPath = ((HttpServletRequest) request).getServletPath();
if (redirectLoginError && "/index.do".equals(servletPath)) {
((HttpServletResponse) response).sendRedirect(httpRequest.getContextPath() + "error/badRequest");
return;
}
}
LoginInfo loginInfo = (LoginInfo) session.getAttribute(Constants.USER_INFO);
if (loginInfo == null) {
loginInfo = new LoginInfo();
loginInfo.setUsername(userId);
updateRoleList(userId, loginInfo);
session.setAttribute(Constants.USER_INFO, loginInfo);
} else {
final long now = System.currentTimeMillis();
if (now - loginInfo.getUpdatedTime() > updateInterval) {
loginInfo.setUsername(userId);
updateRoleList(userId, loginInfo);
loginInfo.setUpdatedTime(now);
}
}
}
chain.doFilter(request, response);
}
@Override
public void destroy() {
}
private void updateRoleList(final String userId, final LoginInfo loginInfo) {
final AdRoleHelper adRoleHelper = ComponentUtil.getAdRoleHelper();
final List<String> roleList = adRoleHelper.getRoleList(userId);
final Set<String> roleSet = new HashSet<>();
for (final String role : roleList) {
roleSet.add(role);
}
loginInfo.setRoleSet(roleSet);
if (logger.isDebugEnabled()) {
logger.debug(loginInfo.toString());
}
}
}

View file

@ -1,106 +0,0 @@
/*
* Copyright 2012-2015 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.helper;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// TODO refactoring
public class AdRoleHelper {
private static final Logger logger = LoggerFactory.getLogger(AdRoleHelper.class);
public String domain;
public Properties adProperties;
public void setAdProperties(final Properties adProperties) {
this.adProperties = adProperties;
}
public List<String> getRoleList(final String userId) {
final List<String> rolelist = new ArrayList<String>();
DirContext ctx = null;
try {
ctx = new InitialDirContext(adProperties);
//set search conditions
final String filter = "cn=" + userId;
final SearchControls controls = new SearchControls();
controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
String name = domain;
name = "dc=" + name;
name = name.replace(".", ",dc=");
//search
final NamingEnumeration<SearchResult> rslt = ctx.search(name, filter, controls);
while (rslt.hasMoreElements()) {
final SearchResult srcrslt = rslt.next();
final Attributes attrs = srcrslt.getAttributes();
//get group attr
final Attribute attr = attrs.get("memberOf");
if (attr == null) {
continue;
}
for (int i = 0; i < attr.size(); i++) {
String strTmp = (String) attr.get(i);
int strStart = 0;
int strEnd = 0;
strStart = strTmp.indexOf("CN=");
strStart += "CN=".length();
strEnd = strTmp.indexOf(',');
strTmp = strTmp.substring(strStart, strEnd);
rolelist.add(strTmp);
}
}
} catch (final Exception e) {
logger.warn("Failed to resolve roles: " + userId, e);
} finally {
if (ctx != null) {
try {
ctx.close();
} catch (final NamingException e) {
// ignored
logger.warn("Failed to close: " + userId, e);
}
}
}
logger.debug("ADGroup:" + rolelist.toString());
return rolelist;
}
}

View file

@ -31,7 +31,6 @@ import javax.naming.directory.SearchResult;
import org.codelibs.core.lang.StringUtil;
import org.codelibs.fess.entity.FessUser;
import org.codelibs.fess.filter.AdLoginInfoFilter;
import org.codelibs.fess.helper.SambaHelper;
import org.codelibs.fess.mylasta.direction.FessConfig;
import org.codelibs.fess.util.ComponentUtil;
@ -40,7 +39,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LdapManager {
private static final Logger logger = LoggerFactory.getLogger(AdLoginInfoFilter.class);
private static final Logger logger = LoggerFactory.getLogger(LdapManager.class);
public OptionalEntity<FessUser> login(final String username, final String password) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();

View file

@ -24,7 +24,6 @@ import org.codelibs.fess.crawler.service.DataService;
import org.codelibs.fess.dict.DictionaryManager;
import org.codelibs.fess.ds.DataStoreFactory;
import org.codelibs.fess.es.client.FessEsClient;
import org.codelibs.fess.helper.AdRoleHelper;
import org.codelibs.fess.helper.CrawlingConfigHelper;
import org.codelibs.fess.helper.CrawlingInfoHelper;
import org.codelibs.fess.helper.DuplicateHostHelper;
@ -111,8 +110,6 @@ public final class ComponentUtil {
private static final String SYSTEM_HELPER = "systemHelper";
private static final String AD_ROLE_HELPER = "adRoleHelper";
private static final String CRAWLER_PROPERTIES = "crawlerProperties";
private static final String PROPERTIES_SUFFIX = "Properties";
@ -222,10 +219,6 @@ public final class ComponentUtil {
return SingletonLaContainer.getComponent(FILE_TYPE_HELPER);
}
public static AdRoleHelper getAdRoleHelper() {
return SingletonLaContainer.getComponent(AD_ROLE_HELPER);
}
public static IndexUpdater getIndexUpdater() {
return SingletonLaContainer.getComponent(INDEX_UPDATER);
}

View file

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE components PUBLIC "-//DBFLUTE//DTD LastaDi 1.0//EN"
"http://dbflute.org/meta/lastadi10.dtd">
<components>
<component name="adProperties" class="java.util.Properties">
<postConstruct name="put">
<arg>"java.naming.factory.initial"</arg>
<arg>"com.sun.jndi.ldap.LdapCtxFactory"</arg>
</postConstruct>
<postConstruct name="put">
<arg>"java.naming.provider.url"</arg>
<arg>"ldap://[host]:[port]"</arg>
</postConstruct>
<postConstruct name="put">
<arg>"java.naming.security.principal"</arg>
<arg>"[loginId]@[domain]"</arg>
</postConstruct>
<postConstruct name="put">
<arg>"java.naming.security.credentials"</arg>
<arg>"password"</arg>
</postConstruct>
<postConstruct name="put">
<arg>"com.sun.jndi.ldap.connect.timeout"</arg>
<arg>"10000"</arg>
</postConstruct>
<postConstruct name="put">
<arg>"com.sun.jndi.ldap.connect.pool"</arg>
<arg>"true"</arg>
</postConstruct>
<postConstruct name="put">
<arg>"com.sun.jndi.connect.pool.timeout"</arg>
<arg>"30000"</arg>
</postConstruct>
<postConstruct name="put">
<arg>"com.sun.jndi.connect.pool.debug"</arg>
<arg>"all"</arg>
</postConstruct>
</component>
<component name="adRoleHelper" class="org.codelibs.fess.helper.AdRoleHelper">
<postConstruct name="setAdProperties">
<arg>adProperties</arg>
</postConstruct>
</component>
</components>