diff --git a/src/main/java/org/codelibs/fess/app/web/admin/group/CreateForm.java b/src/main/java/org/codelibs/fess/app/web/admin/group/CreateForm.java index 0b34ec1ec..9cb3ca0d2 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/group/CreateForm.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/group/CreateForm.java @@ -15,6 +15,9 @@ */ package org.codelibs.fess.app.web.admin.group; +import java.util.HashMap; +import java.util.Map; + import javax.validation.constraints.Size; import org.lastaflute.web.validation.Required; @@ -33,8 +36,7 @@ public class CreateForm { @Size(max = 100) public String name; - @ValidateTypeFailure - public Long gidNumber; + public Map attributes = new HashMap<>(); public void initialize() { } diff --git a/src/main/java/org/codelibs/fess/app/web/admin/role/CreateForm.java b/src/main/java/org/codelibs/fess/app/web/admin/role/CreateForm.java index ec5a4171d..c974fdec8 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/role/CreateForm.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/role/CreateForm.java @@ -15,6 +15,9 @@ */ package org.codelibs.fess.app.web.admin.role; +import java.util.HashMap; +import java.util.Map; + import javax.validation.constraints.Size; import org.lastaflute.web.validation.Required; @@ -33,6 +36,8 @@ public class CreateForm { @Size(max = 100) public String name; + public Map attributes = new HashMap<>(); + public void initialize() { } } diff --git a/src/main/java/org/codelibs/fess/app/web/admin/user/CreateForm.java b/src/main/java/org/codelibs/fess/app/web/admin/user/CreateForm.java index 251b8bf21..b1af32603 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/user/CreateForm.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/user/CreateForm.java @@ -15,9 +15,11 @@ */ package org.codelibs.fess.app.web.admin.user; +import java.util.HashMap; +import java.util.Map; + import javax.validation.constraints.Size; -import org.hibernate.validator.constraints.Email; import org.lastaflute.web.validation.Required; import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure; @@ -40,114 +42,7 @@ public class CreateForm { @Size(max = 100) public String confirmPassword; - @Size(max = 1000) - public String surname; - - @Size(max = 1000) - public String givenName; - - @Email - @Size(max = 1000) - public String mail; - - @Size(max = 1000) - public String employeeNumber; - - @Size(max = 1000) - public String telephoneNumber; - - @Size(max = 1000) - public String homePhone; - - @Size(max = 1000) - public String homePostalAddress; - - @Size(max = 1000) - public String labeledURI; - - @Size(max = 1000) - public String roomNumber; - - @Size(max = 1000) - public String description; - - @Size(max = 1000) - public String title; - - @Size(max = 1000) - public String pager; - - @Size(max = 1000) - public String street; - - @Size(max = 1000) - public String postalCode; - - @Size(max = 1000) - public String physicalDeliveryOfficeName; - - @Size(max = 1000) - public String destinationIndicator; - - @Size(max = 1000) - public String internationaliSDNNumber; - - @Size(max = 1000) - public String state; - - @Size(max = 1000) - public String employeeType; - - @Size(max = 1000) - public String facsimileTelephoneNumber; - - @Size(max = 1000) - public String postOfficeBox; - - @Size(max = 1000) - public String initials; - - @Size(max = 1000) - public String carLicense; - - @Size(max = 1000) - public String mobile; - - @Size(max = 1000) - public String postalAddress; - - @Size(max = 1000) - public String city; - - @Size(max = 1000) - public String teletexTerminalIdentifier; - - @Size(max = 1000) - public String x121Address; - - @Size(max = 1000) - public String businessCategory; - - @Size(max = 1000) - public String registeredAddress; - - @Size(max = 1000) - public String displayName; - - @Size(max = 1000) - public String preferredLanguage; - - @Size(max = 1000) - public String departmentNumber; - - @ValidateTypeFailure - public Long uidNumber; - - @ValidateTypeFailure - public Long gidNumber; - - @Size(max = 1000) - public String homeDirectory; + public Map attributes = new HashMap<>(); public String[] roles; diff --git a/src/main/java/org/codelibs/fess/es/user/exbhv/GroupBhv.java b/src/main/java/org/codelibs/fess/es/user/exbhv/GroupBhv.java index feb007fff..214e92c5c 100644 --- a/src/main/java/org/codelibs/fess/es/user/exbhv/GroupBhv.java +++ b/src/main/java/org/codelibs/fess/es/user/exbhv/GroupBhv.java @@ -15,11 +15,32 @@ */ package org.codelibs.fess.es.user.exbhv; +import java.util.Map; +import java.util.stream.Collectors; + +import org.codelibs.core.misc.Pair; import org.codelibs.fess.es.user.bsbhv.BsGroupBhv; +import org.codelibs.fess.es.user.exentity.Group; +import org.dbflute.exception.IllegalBehaviorStateException; +import org.dbflute.util.DfTypeUtil; /** * @author FreeGen */ public class GroupBhv extends BsGroupBhv { + @Override + protected RESULT createEntity(Map source, Class entityType) { + try { + final RESULT result = entityType.newInstance(); + result.setName(DfTypeUtil.toString(source.get("name"))); + result.setAttributes(source.entrySet().stream().filter(e -> !"name".equals(e.getKey())) + .map(e -> new Pair<>(e.getKey(), (String) e.getValue())) + .collect(Collectors.toMap(t -> t.getFirst(), t -> t.getSecond()))); + return result; + } catch (InstantiationException | IllegalAccessException e) { + final String msg = "Cannot create a new instance: " + entityType.getName(); + throw new IllegalBehaviorStateException(msg, e); + } + } } diff --git a/src/main/java/org/codelibs/fess/es/user/exbhv/RoleBhv.java b/src/main/java/org/codelibs/fess/es/user/exbhv/RoleBhv.java index 6f1e380ca..ae5f6cfb8 100644 --- a/src/main/java/org/codelibs/fess/es/user/exbhv/RoleBhv.java +++ b/src/main/java/org/codelibs/fess/es/user/exbhv/RoleBhv.java @@ -15,11 +15,31 @@ */ package org.codelibs.fess.es.user.exbhv; +import java.util.Map; +import java.util.stream.Collectors; + +import org.codelibs.core.misc.Pair; import org.codelibs.fess.es.user.bsbhv.BsRoleBhv; +import org.codelibs.fess.es.user.exentity.Role; +import org.dbflute.exception.IllegalBehaviorStateException; +import org.dbflute.util.DfTypeUtil; /** * @author FreeGen */ public class RoleBhv extends BsRoleBhv { - + @Override + protected RESULT createEntity(Map source, Class entityType) { + try { + final RESULT result = entityType.newInstance(); + result.setName(DfTypeUtil.toString(source.get("name"))); + result.setAttributes(source.entrySet().stream().filter(e -> !"name".equals(e.getKey())) + .map(e -> new Pair<>(e.getKey(), (String) e.getValue())) + .collect(Collectors.toMap(t -> t.getFirst(), t -> t.getSecond()))); + return result; + } catch (InstantiationException | IllegalAccessException e) { + final String msg = "Cannot create a new instance: " + entityType.getName(); + throw new IllegalBehaviorStateException(msg, e); + } + } } diff --git a/src/main/java/org/codelibs/fess/es/user/exbhv/UserBhv.java b/src/main/java/org/codelibs/fess/es/user/exbhv/UserBhv.java index 607099b85..ac0293d73 100644 --- a/src/main/java/org/codelibs/fess/es/user/exbhv/UserBhv.java +++ b/src/main/java/org/codelibs/fess/es/user/exbhv/UserBhv.java @@ -15,11 +15,45 @@ */ package org.codelibs.fess.es.user.exbhv; +import java.util.Map; +import java.util.stream.Collectors; + +import org.codelibs.core.misc.Pair; import org.codelibs.fess.es.user.bsbhv.BsUserBhv; +import org.codelibs.fess.es.user.exentity.User; +import org.dbflute.exception.IllegalBehaviorStateException; +import org.dbflute.util.DfTypeUtil; /** * @author FreeGen */ public class UserBhv extends BsUserBhv { + private static final String ROLES = "roles"; + private static final String GROUPS = "groups"; + private static final String PASSWORD = "password"; + private static final String NAME = "name"; + + @Override + protected RESULT createEntity(Map source, Class entityType) { + try { + final RESULT result = entityType.newInstance(); + result.setName(DfTypeUtil.toString(source.get(NAME))); + result.setPassword(DfTypeUtil.toString(source.get(PASSWORD))); + result.setGroups(toStringArray(source.get(GROUPS))); + result.setRoles(toStringArray(source.get(ROLES))); + result.setAttributes(source.entrySet().stream().filter(e -> isAttribute(e.getKey())) + .map(e -> new Pair<>(e.getKey(), (String) e.getValue())) + .collect(Collectors.toMap(t -> t.getFirst(), t -> t.getSecond()))); + return result; + } catch (InstantiationException | IllegalAccessException e) { + final String msg = "Cannot create a new instance: " + entityType.getName(); + throw new IllegalBehaviorStateException(msg, e); + } + } + + private boolean isAttribute(final String key) { + return !NAME.equals(key) && !PASSWORD.equals(key) && !GROUPS.equals(key) && !ROLES.equals(key); + } + } diff --git a/src/main/java/org/codelibs/fess/es/user/exentity/Group.java b/src/main/java/org/codelibs/fess/es/user/exentity/Group.java index 9968aa1b1..b542c4ab5 100644 --- a/src/main/java/org/codelibs/fess/es/user/exentity/Group.java +++ b/src/main/java/org/codelibs/fess/es/user/exentity/Group.java @@ -15,6 +15,9 @@ */ package org.codelibs.fess.es.user.exentity; +import java.util.HashMap; +import java.util.Map; + import org.codelibs.fess.es.user.bsentity.BsGroup; /** @@ -24,6 +27,8 @@ public class Group extends BsGroup { private static final long serialVersionUID = 1L; + private Map attributes; + public Long getVersionNo() { return asDocMeta().version(); } @@ -45,4 +50,23 @@ public class Group extends BsGroup { return "Group [name=" + name + "]"; } + public Map getAttributes() { + return attributes; + } + + public void setAttributes(Map attributes) { + this.attributes = attributes; + } + + @Override + public Map toSource() { + Map sourceMap = new HashMap<>(); + if (name != null) { + sourceMap.put("name", name); + } + if (attributes != null) { + sourceMap.putAll(attributes); + } + return sourceMap; + } } diff --git a/src/main/java/org/codelibs/fess/es/user/exentity/Role.java b/src/main/java/org/codelibs/fess/es/user/exentity/Role.java index 294300710..fceafaabf 100644 --- a/src/main/java/org/codelibs/fess/es/user/exentity/Role.java +++ b/src/main/java/org/codelibs/fess/es/user/exentity/Role.java @@ -15,6 +15,9 @@ */ package org.codelibs.fess.es.user.exentity; +import java.util.HashMap; +import java.util.Map; + import org.codelibs.fess.es.user.bsentity.BsRole; /** @@ -24,6 +27,8 @@ public class Role extends BsRole { private static final long serialVersionUID = 1L; + private Map attributes; + public Long getVersionNo() { return asDocMeta().version(); } @@ -44,4 +49,24 @@ public class Role extends BsRole { public String toString() { return "Role [name=" + name + "]"; } + + public Map getAttributes() { + return attributes; + } + + public void setAttributes(Map attributes) { + this.attributes = attributes; + } + + @Override + public Map toSource() { + Map sourceMap = new HashMap<>(); + if (name != null) { + sourceMap.put("name", name); + } + if (attributes != null) { + sourceMap.putAll(attributes); + } + return sourceMap; + } } diff --git a/src/main/java/org/codelibs/fess/es/user/exentity/User.java b/src/main/java/org/codelibs/fess/es/user/exentity/User.java index d7df97564..479ad337f 100644 --- a/src/main/java/org/codelibs/fess/es/user/exentity/User.java +++ b/src/main/java/org/codelibs/fess/es/user/exentity/User.java @@ -20,7 +20,9 @@ import static org.codelibs.core.stream.StreamUtil.stream; import java.util.ArrayList; import java.util.Arrays; import java.util.Base64; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.codelibs.fess.Constants; import org.codelibs.fess.entity.FessUser; @@ -37,6 +39,8 @@ public class User extends BsUser implements FessUser { private String originalPassword; + private Map attributes; + public Long getVersionNo() { return asDocMeta().version(); } @@ -96,4 +100,32 @@ public class User extends BsUser implements FessUser { return true; } + public Map getAttributes() { + return attributes; + } + + public void setAttributes(Map attributes) { + this.attributes = attributes; + } + + @Override + public Map toSource() { + Map sourceMap = new HashMap<>(); + if (name != null) { + sourceMap.put("name", name); + } + if (password != null) { + sourceMap.put("password", password); + } + if (groups != null) { + sourceMap.put("groups", groups); + } + if (roles != null) { + sourceMap.put("roles", roles); + } + if (attributes != null) { + sourceMap.putAll(attributes); + } + return sourceMap; + } } diff --git a/src/main/webapp/WEB-INF/view/admin/group/admin_group_details.jsp b/src/main/webapp/WEB-INF/view/admin/group/admin_group_details.jsp index 906799702..ee496332a 100644 --- a/src/main/webapp/WEB-INF/view/admin/group/admin_group_details.jsp +++ b/src/main/webapp/WEB-INF/view/admin/group/admin_group_details.jsp @@ -54,7 +54,7 @@ - ${f:h(gidNumber)} + ${f:h(attributes.gidNumber)} diff --git a/src/main/webapp/WEB-INF/view/admin/group/admin_group_edit.jsp b/src/main/webapp/WEB-INF/view/admin/group/admin_group_edit.jsp index 488807f71..1041663cd 100644 --- a/src/main/webapp/WEB-INF/view/admin/group/admin_group_edit.jsp +++ b/src/main/webapp/WEB-INF/view/admin/group/admin_group_edit.jsp @@ -58,8 +58,8 @@
- - + +
diff --git a/src/main/webapp/WEB-INF/view/admin/user/admin_user_details.jsp b/src/main/webapp/WEB-INF/view/admin/user/admin_user_details.jsp index 1a7ac2fe1..8d00607d9 100644 --- a/src/main/webapp/WEB-INF/view/admin/user/admin_user_details.jsp +++ b/src/main/webapp/WEB-INF/view/admin/user/admin_user_details.jsp @@ -52,148 +52,148 @@ - ${f:h(surname)} + ${f:h(attributes.surname)} - ${f:h(givenName)} + ${f:h(attributes.givenName)} - ${f:h(mail)} + ${f:h(attributes.mail)} - ${f:h(employeeNumber)} + ${f:h(attributes.employeeNumber)} - ${f:h(telephoneNumber)} + ${f:h(attributes.telephoneNumber)} - ${f:h(homePhone)} + ${f:h(attributes.homePhone)} - ${f:h(homePostalAddress)} + ${f:h(attributes.homePostalAddress)} - ${f:h(labeledURI)} + ${f:h(attributes.labeledURI)} - ${f:h(roomNumber)} + ${f:h(attributes.roomNumber)} - ${f:h(description)} + ${f:h(attributes.description)} - ${f:h(title)} + ${f:h(attributes.title)} - ${f:h(pager)} + ${f:h(attributes.pager)} - ${f:h(street)} + ${f:h(attributes.street)} - ${f:h(postalCode)} + ${f:h(attributes.postalCode)} - ${f:h(physicalDeliveryOfficeName)} + ${f:h(attributes.physicalDeliveryOfficeName)} - ${f:h(destinationIndicator)} + ${f:h(attributes.destinationIndicator)} - ${f:h(internationaliSDNNumber)} + ${f:h(attributes.internationaliSDNNumber)} - ${f:h(state)} + ${f:h(attributes.state)} - ${f:h(facsimileTelephoneNumber)} + ${f:h(attributes.facsimileTelephoneNumber)} - ${f:h(facsimileTelephoneNumber)} + ${f:h(attributes.facsimileTelephoneNumber)} - ${f:h(postOfficeBox)} + ${f:h(attributes.postOfficeBox)} - ${f:h(initials)} + ${f:h(attributes.initials)} - ${f:h(carLicense)} + ${f:h(attributes.carLicense)} - ${f:h(mobile)} + ${f:h(attributes.mobile)} - ${f:h(postalAddress)} + ${f:h(attributes.postalAddress)} - ${f:h(city)} + ${f:h(attributes.city)} - ${f:h(teletexTerminalIdentifier)} + ${f:h(attributes.teletexTerminalIdentifier)} - ${f:h(x121Address)} + ${f:h(attributes.x121Address)} - ${f:h(businessCategory)} + ${f:h(attributes.businessCategory)} - ${f:h(registeredAddress)} + ${f:h(attributes.registeredAddress)} - ${f:h(displayName)} + ${f:h(attributes.displayName)} - ${f:h(preferredLanguage)} + ${f:h(attributes.preferredLanguage)} - ${f:h(departmentNumber)} + ${f:h(attributes.departmentNumber)} - ${f:h(uidNumber)} + ${f:h(attributes.uidNumber)} - ${f:h(gidNumber)} + ${f:h(attributes.gidNumber)} - ${f:h(homeDirectory)} + ${f:h(attributes.homeDirectory)} diff --git a/src/main/webapp/WEB-INF/view/admin/user/admin_user_edit.jsp b/src/main/webapp/WEB-INF/view/admin/user/admin_user_edit.jsp index 87fbf4494..e8f4f40a5 100644 --- a/src/main/webapp/WEB-INF/view/admin/user/admin_user_edit.jsp +++ b/src/main/webapp/WEB-INF/view/admin/user/admin_user_edit.jsp @@ -77,24 +77,24 @@
- - + +
- - + +
- - + +
@@ -102,264 +102,264 @@
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +