use of org.codelibs.fess.helper.PermissionHelper in project fess by codelibs.
the class ElevateWordService method exportCsv.
public void exportCsv(final Writer writer) {
final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
final CsvConfig cfg = new CsvConfig(',', '"', '"');
cfg.setEscapeDisabled(false);
cfg.setQuoteDisabled(false);
@SuppressWarnings("resource") final CsvWriter csvWriter = new CsvWriter(writer, cfg);
try {
final List<String> list = new ArrayList<>();
list.add("SuggestWord");
list.add("Reading");
list.add("Permissions");
list.add("Label");
list.add("Boost");
csvWriter.writeValues(list);
elevateWordBhv.selectCursor(cb -> cb.query().matchAll(), new EntityRowHandler<ElevateWord>() {
@Override
public void handle(final ElevateWord entity) {
final List<String> list = new ArrayList<>();
final String permissions = stream(entity.getPermissions()).get(stream -> stream.map(s -> permissionHelper.decode(s)).filter(StringUtil::isNotBlank).distinct().collect(Collectors.joining(",")));
addToList(list, entity.getSuggestWord());
addToList(list, entity.getReading());
addToList(list, permissions);
addToList(list, entity.getTargetLabel());
addToList(list, entity.getBoost());
try {
csvWriter.writeValues(list);
} catch (final IOException e) {
logger.warn("Failed to write a sugget elevate word: " + entity, e);
}
}
private void addToList(final List<String> list, final Object value) {
if (value == null) {
list.add(StringUtil.EMPTY);
} else {
list.add(value.toString());
}
}
});
csvWriter.flush();
} catch (final IOException e) {
logger.warn("Failed to write a sugget elevate word.", e);
}
}
use of org.codelibs.fess.helper.PermissionHelper in project fess by codelibs.
the class AdminFileconfigAction method getFileConfig.
public static OptionalEntity<FileConfig> getFileConfig(final CreateForm form) {
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
copyBeanToBean(form, entity, op -> op.exclude(Stream.concat(Stream.of(Constants.COMMON_CONVERSION_RULE), Stream.of(Constants.PERMISSIONS)).toArray(n -> new String[n])));
final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
entity.setPermissions(split(form.permissions, "\n").get(stream -> stream.map(s -> permissionHelper.encode(s)).filter(StringUtil::isNotBlank).distinct().toArray(n -> new String[n])));
return entity;
});
}
use of org.codelibs.fess.helper.PermissionHelper in project fess by codelibs.
the class AdminLabeltypeAction method getLabelType.
public static OptionalEntity<LabelType> getLabelType(final CreateForm form) {
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
copyBeanToBean(form, entity, op -> op.exclude(Stream.concat(Stream.of(Constants.COMMON_CONVERSION_RULE), Stream.of(Constants.PERMISSIONS)).toArray(n -> new String[n])));
final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
entity.setPermissions(split(form.permissions, "\n").get(stream -> stream.map(s -> permissionHelper.encode(s)).filter(StringUtil::isNotBlank).distinct().toArray(n -> new String[n])));
return entity;
});
}
use of org.codelibs.fess.helper.PermissionHelper in project fess by codelibs.
the class ApiAdminElevatewordAction method createEditBody.
protected EditBody createEditBody(final ElevateWord entity) {
final EditBody body = new EditBody();
body.id = entity.getId();
body.versionNo = entity.getVersionNo();
body.createdBy = entity.getCreatedBy();
body.createdTime = entity.getCreatedTime();
body.suggestWord = entity.getSuggestWord();
body.updatedBy = entity.getUpdatedBy();
body.updatedTime = entity.getUpdatedTime();
body.labelTypeIds = entity.getLabelTypeIds();
final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
body.permissions = stream(entity.getPermissions()).get(stream -> stream.map(s -> permissionHelper.decode(s)).filter(StringUtil::isNotBlank).distinct().collect(Collectors.joining("\n")));
body.targetLabel = entity.getTargetLabel();
body.reading = entity.getReading();
return body;
}
use of org.codelibs.fess.helper.PermissionHelper in project fess by codelibs.
the class FessProp method getSearchGuestPermissionList.
public default default List<String> getSearchGuestPermissionList() {
@SuppressWarnings("unchecked") List<String> list = (List<String>) propMap.get(SEARCH_GUEST_PERMISSION_LIST);
if (list == null) {
final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
list = split(getRoleSearchGuestPermissions(), ",").get(stream -> stream.map(s -> permissionHelper.encode(s)).filter(StringUtil::isNotBlank).collect(Collectors.toList()));
list.add(getRoleSearchUserPrefix() + Constants.GUEST_USER);
propMap.put(SEARCH_GUEST_PERMISSION_LIST, list);
}
return list;
}
Aggregations