use of org.codelibs.core.lang.StringUtil in project fess by codelibs.
the class LdapManager method addUserAttributes.
protected void addUserAttributes(final BasicAttributes entry, final User user) {
entry.put(new BasicAttribute("cn", user.getName()));
entry.put(new BasicAttribute("userPassword", user.getOriginalPassword()));
OptionalUtil.ofNullable(user.getSurname()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrSurname(), s)));
OptionalUtil.ofNullable(user.getGivenName()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrGivenName(), s)));
OptionalUtil.ofNullable(user.getMail()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrMail(), s)));
OptionalUtil.ofNullable(user.getEmployeeNumber()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrEmployeeNumber(), s)));
OptionalUtil.ofNullable(user.getTelephoneNumber()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrTelephoneNumber(), s)));
OptionalUtil.ofNullable(user.getHomePhone()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrHomePhone(), s)));
OptionalUtil.ofNullable(user.getHomePostalAddress()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrHomePostalAddress(), s)));
OptionalUtil.ofNullable(user.getLabeledURI()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrLabeledURI(), s)));
OptionalUtil.ofNullable(user.getRoomNumber()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrRoomNumber(), s)));
OptionalUtil.ofNullable(user.getDescription()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrDescription(), s)));
OptionalUtil.ofNullable(user.getTitle()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrTitle(), s)));
OptionalUtil.ofNullable(user.getPager()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrPager(), s)));
OptionalUtil.ofNullable(user.getStreet()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrStreet(), s)));
OptionalUtil.ofNullable(user.getPostalCode()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrPostalCode(), s)));
OptionalUtil.ofNullable(user.getPhysicalDeliveryOfficeName()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrPhysicalDeliveryOfficeName(), s)));
OptionalUtil.ofNullable(user.getDestinationIndicator()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrDestinationIndicator(), s)));
OptionalUtil.ofNullable(user.getInternationaliSDNNumber()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrInternationaliSDNNumber(), s)));
OptionalUtil.ofNullable(user.getState()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrState(), s)));
OptionalUtil.ofNullable(user.getEmployeeType()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrEmployeeType(), s)));
OptionalUtil.ofNullable(user.getFacsimileTelephoneNumber()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrFacsimileTelephoneNumber(), s)));
OptionalUtil.ofNullable(user.getPostOfficeBox()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrPostOfficeBox(), s)));
OptionalUtil.ofNullable(user.getInitials()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrInitials(), s)));
OptionalUtil.ofNullable(user.getCarLicense()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrCarLicense(), s)));
OptionalUtil.ofNullable(user.getMobile()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrMobile(), s)));
OptionalUtil.ofNullable(user.getPostalAddress()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrPostalAddress(), s)));
OptionalUtil.ofNullable(user.getCity()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrCity(), s)));
OptionalUtil.ofNullable(user.getTeletexTerminalIdentifier()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrTeletexTerminalIdentifier(), s)));
OptionalUtil.ofNullable(user.getX121Address()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrX121Address(), s)));
OptionalUtil.ofNullable(user.getBusinessCategory()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrBusinessCategory(), s)));
OptionalUtil.ofNullable(user.getRegisteredAddress()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrRegisteredAddress(), s)));
OptionalUtil.ofNullable(user.getDisplayName()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrDisplayName(), s)));
OptionalUtil.ofNullable(user.getPreferredLanguage()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrPreferredLanguage(), s)));
OptionalUtil.ofNullable(user.getDepartmentNumber()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrDepartmentNumber(), s)));
OptionalUtil.ofNullable(user.getUidNumber()).filter(s -> StringUtil.isNotBlank(s.toString())).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrUidNumber(), s)));
OptionalUtil.ofNullable(user.getGidNumber()).filter(s -> StringUtil.isNotBlank(s.toString())).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrGidNumber(), s)));
OptionalUtil.ofNullable(user.getHomeDirectory()).filter(StringUtil::isNotBlank).ifPresent(s -> entry.put(new BasicAttribute(fessConfig.getLdapAttrHomeDirectory(), s)));
}
use of org.codelibs.core.lang.StringUtil in project fess by codelibs.
the class AdminElevatewordAction method details.
// -----------------------------------------------------
// Details
// -------
@Execute
@Secured({ ROLE, ROLE + VIEW })
public HtmlResponse details(final int crudMode, final String id) {
verifyCrudMode(crudMode, CrudMode.DETAILS);
saveToken();
final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
return asHtml(path_AdminElevateword_AdminElevatewordDetailsJsp).useForm(EditForm.class, op -> op.setup(form -> {
elevateWordService.getElevateWord(id).ifPresent(entity -> {
copyBeanToBean(entity, form, copyOp -> {
copyOp.excludeNull();
copyOp.exclude(Constants.PERMISSIONS);
});
form.permissions = stream(entity.getPermissions()).get(stream -> stream.map(permissionHelper::decode).filter(StringUtil::isNotBlank).distinct().collect(Collectors.joining("\n")));
form.crudMode = crudMode;
}).orElse(() -> throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), this::asListHtml));
})).renderWith(this::registerLabels);
}
use of org.codelibs.core.lang.StringUtil in project fess by codelibs.
the class AdminElevatewordAction method getElevateWord.
public static OptionalEntity<ElevateWord> getElevateWord(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);
BeanUtil.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(permissionHelper::encode).filter(StringUtil::isNotBlank).distinct().toArray(n -> new String[n])));
return entity;
});
}
use of org.codelibs.core.lang.StringUtil in project fess by codelibs.
the class AdminLabeltypeAction method details.
// -----------------------------------------------------
// Details
// -------
@Execute
@Secured({ ROLE, ROLE + VIEW })
public HtmlResponse details(final int crudMode, final String id) {
verifyCrudMode(crudMode, CrudMode.DETAILS);
saveToken();
return asHtml(path_AdminLabeltype_AdminLabeltypeDetailsJsp).useForm(EditForm.class, op -> {
op.setup(form -> {
labelTypeService.getLabelType(id).ifPresent(entity -> {
copyBeanToBean(entity, form, copyOp -> {
copyOp.excludeNull();
copyOp.exclude(Constants.PERMISSIONS);
});
final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
form.permissions = stream(entity.getPermissions()).get(stream -> stream.map(s -> permissionHelper.decode(s)).filter(StringUtil::isNotBlank).distinct().collect(Collectors.joining("\n")));
form.crudMode = crudMode;
}).orElse(() -> {
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), this::asListHtml);
});
});
}).renderWith(data -> {
registerRoleTypeItems(data);
});
}
use of org.codelibs.core.lang.StringUtil in project fess by codelibs.
the class AdminFileconfigAction method edit.
@Execute
@Secured({ ROLE })
public HtmlResponse edit(final EditForm form) {
validate(form, messages -> {
}, this::asListHtml);
final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
final String id = form.id;
fileConfigService.getFileConfig(id).ifPresent(entity -> {
copyBeanToBean(entity, form, copyOp -> {
copyOp.excludeNull();
copyOp.exclude(Constants.PERMISSIONS, Constants.VIRTUAL_HOSTS);
});
form.permissions = stream(entity.getPermissions()).get(stream -> stream.map(permissionHelper::decode).filter(StringUtil::isNotBlank).distinct().collect(Collectors.joining("\n")));
form.virtualHosts = stream(entity.getVirtualHosts()).get(stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).collect(Collectors.joining("\n")));
}).orElse(() -> throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), this::asListHtml));
saveToken();
if (form.crudMode.intValue() == CrudMode.EDIT) {
// back
form.crudMode = CrudMode.DETAILS;
return asDetailsHtml();
}
form.crudMode = CrudMode.EDIT;
return asEditHtml();
}
Aggregations