Skip to content

Commit b5c65d6

Browse files
Bug #3780 : max length limitations around specific user values
- adding max length handling on database domain table creation (SP and SQL domains only) - adding tools to retrieve property max length - modifying the display of extra user informations in user profile - modifying the display of user informations in back-office - wiring the max length handling with user csv import functionality in back-office Conflicts: war-core/src/main/webapp/socialNetwork/jsp/myProfil/myProfile.jsp
1 parent efbe91a commit b5c65d6

File tree

15 files changed

+386
-231
lines changed

15 files changed

+386
-231
lines changed

config-core/src/main/config/properties/org/silverpeas/domains/domainSP.properties

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,43 +42,54 @@ property.ResourceFile = com.stratelia.silverpeas.domains.multilang.domainSPBundl
4242
property_1.Name = title
4343
property_1.Type = STRING
4444
property_1.MapParameter = title
45+
property_1.MaxLength = 100
4546

4647
property_2.Name = company
4748
property_2.Type = STRING
4849
property_2.MapParameter = company
50+
property_2.MaxLength = 100
4951

5052
property_3.Name = position
5153
property_3.Type = STRING
5254
property_3.MapParameter = position
55+
property_3.MaxLength = 100
5356

5457
property_4.Name = boss
5558
property_4.Type = USERID
5659
property_4.MapParameter = boss
60+
property_4.MaxLength = 100
5761

5862
property_5.Name = phone
5963
property_5.Type = STRING
6064
property_5.MapParameter = phone
65+
property_5.MaxLength = 20
6166

6267
property_6.Name = homePhone
6368
property_6.Type = STRING
6469
property_6.MapParameter = homePhone
70+
property_6.MaxLength = 20
6571

6672
property_7.Name = fax
6773
property_7.Type = STRING
6874
property_7.MapParameter = fax
75+
property_7.MaxLength = 20
6976

7077
property_8.Name = cellularPhone
7178
property_8.Type = STRING
7279
property_8.MapParameter = cellPhone
80+
property_8.MaxLength = 20
7381

7482
property_9.Name = address
7583
property_9.Type = STRING
7684
property_9.MapParameter = address
85+
property_9.MaxLength = 500
7786

7887
property_10.Name = password
7988
property_10.Type = STRING
8089
property_10.MapParameter = password
90+
property_10.MaxLength = 123
8191

8292
property_11.Name = passwordValid
8393
property_11.Type = STRING
8494
property_11.MapParameter = passwordValid
95+
property_11.MaxLength = 1

config-core/src/main/config/properties/org/silverpeas/domains/domainSQL.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,37 +69,46 @@ property.ResourceFile = com.stratelia.silverpeas.domains.multilang.templateDomai
6969
property_1.Name = title
7070
property_1.Type = STRING
7171
property_1.MapParameter = title
72+
property_1.MaxLength = 100
7273

7374
property_2.Name = company
7475
property_2.Type = STRING
7576
property_2.MapParameter = company
77+
property_2.MaxLength = 100
7678

7779
property_3.Name = position
7880
property_3.Type = STRING
7981
property_3.MapParameter = position
82+
property_3.MaxLength = 100
8083

8184
property_4.Name = boss
8285
property_4.Type = USERID
8386
property_4.MapParameter = boss
87+
property_4.MaxLength = 100
8488

8589
property_5.Name = phone
8690
property_5.Type = STRING
8791
property_5.MapParameter = phone
92+
property_5.MaxLength = 20
8893

8994
property_6.Name = homePhone
9095
property_6.Type = STRING
9196
property_6.MapParameter = homePhone
97+
property_6.MaxLength = 20
9298

9399
property_7.Name = fax
94100
property_7.Type = STRING
95101
property_7.MapParameter = fax
102+
property_7.MaxLength = 20
96103

97104
property_8.Name = cellularPhone
98105
property_8.Type = STRING
99106
property_8.MapParameter = cellPhone
107+
property_8.MaxLength = 20
100108

101109
property_9.Name = address
102110
property_9.Type = STRING
103111
property_9.MapParameter = address
112+
property_9.MaxLength = 500
104113

105114
property.Grouping =

config-core/src/main/config/resources/StringTemplates/core/admin/sqlDomain/templateDomainSQL.st

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,37 +77,46 @@ property.ResourceFile = org.silverpeas.domains.multilang.templateDomainSQLBundle
7777
property_1.Name = title
7878
property_1.Type = STRING
7979
property_1.MapParameter = title
80+
property_1.MaxLength = 100
8081

8182
property_2.Name = company
8283
property_2.Type = STRING
8384
property_2.MapParameter = company
85+
property_2.MaxLength = 100
8486

8587
property_3.Name = position
8688
property_3.Type = STRING
8789
property_3.MapParameter = position
90+
property_3.MaxLength = 100
8891

8992
property_4.Name = boss
9093
property_4.Type = USERID
9194
property_4.MapParameter = boss
95+
property_4.MaxLength = 100
9296

9397
property_5.Name = phone
9498
property_5.Type = STRING
9599
property_5.MapParameter = phone
100+
property_5.MaxLength = 20
96101

97102
property_6.Name = homePhone
98103
property_6.Type = STRING
99104
property_6.MapParameter = homePhone
105+
property_6.MaxLength = 20
100106

101107
property_7.Name = fax
102108
property_7.Type = STRING
103109
property_7.MapParameter = fax
110+
property_7.MaxLength = 20
104111

105112
property_8.Name = cellularPhone
106113
property_8.Type = STRING
107114
property_8.MapParameter = cellPhone
115+
property_8.MaxLength = 20
108116

109117
property_9.Name = address
110118
property_9.Type = STRING
111119
property_9.MapParameter = address
120+
property_9.MaxLength = 500
112121

113122
property.Grouping =

lib-core/src/main/java/com/silverpeas/util/csv/CSVReader.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package com.silverpeas.util.csv;
2626

2727
import com.stratelia.silverpeas.silvertrace.SilverTrace;
28+
import com.stratelia.webactiv.beans.admin.DomainProperty;
2829
import com.stratelia.webactiv.util.ResourceLocator;
2930
import com.stratelia.webactiv.util.exception.SilverpeasException;
3031
import com.stratelia.webactiv.util.exception.UtilException;
@@ -51,6 +52,7 @@ public class CSVReader {
5152
// properties specifiques eventuellement en plus
5253
protected int m_specificNbCols = 0;
5354
protected String[] m_specificColNames;
55+
protected int[] m_specificColMaxLengthes;
5456
protected String[] m_specificColTypes;
5557
protected String[] m_specificColMandatory;
5658
protected String[] m_specificParameterNames;
@@ -110,7 +112,9 @@ public void initCSVFormat(String propertiesFile, String rootPropertyName,
110112

111113
m_specificColTypes = specificRs.getStringArray(specificRootPropertyName,
112114
".Type", m_specificNbCols);
115+
m_specificColMaxLengthes = new int[m_specificNbCols];
113116
for (int i = 0; i < m_specificNbCols; i++) {
117+
// Type
114118
if (!Variant.TYPE_STRING.equals(m_specificColTypes[i])
115119
&& !Variant.TYPE_INT.equals(m_specificColTypes[i])
116120
&& !Variant.TYPE_BOOLEAN.equals(m_specificColTypes[i])
@@ -122,6 +126,10 @@ public void initCSVFormat(String propertiesFile, String rootPropertyName,
122126

123127
m_specificColTypes[i] = Variant.TYPE_STRING;
124128
}
129+
// Max Length
130+
m_specificColMaxLengthes[i] = specificRs
131+
.getInteger(specificRootPropertyName + (i + 1) + ".MaxLength",
132+
DomainProperty.DEFAULT_MAX_LENGTH);
125133
}
126134

127135
m_specificColMandatory = specificRs.getStringArray(specificRootPropertyName, ".Mandatory",
@@ -480,4 +488,18 @@ public String[] getM_specificParameterNames() {
480488
public String getM_specificParameterName(int i) {
481489
return m_specificParameterNames[i];
482490
}
491+
492+
/**
493+
* @return Returns the m_specificColMaxLengthes.
494+
*/
495+
public int[] getM_specificColMaxLengthes() {
496+
return m_specificColMaxLengthes;
497+
}
498+
499+
/**
500+
* @return Returns the m_specificColMaxLengthes[i].
501+
*/
502+
public int getM_specificColMaxLength(int i) {
503+
return m_specificColMaxLengthes[i];
504+
}
483505
}

lib-core/src/main/java/com/stratelia/webactiv/beans/admin/DomainProperty.java

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ public class DomainProperty {
3131
final static public String PROPERTY_TYPE_USERID = "USERID";
3232
final static public String PROPERTY_TYPE_BOOLEAN = "BOOLEAN";
3333

34+
final static public int DEFAULT_MAX_LENGTH = 50;
35+
3436
final static public String PROPERTY_UPDATEALLOWED_ADMIN = "A";
3537
final static public String PROPERTY_UPDATEALLOWED_USER = "U";
3638
final static public String PROPERTY_UPDATE_NOT_ALLOWED = "N";
3739

38-
private String m_sName = null;
39-
private String m_iType = PROPERTY_TYPE_STRING;
40-
private String m_sMapParameter = null;
40+
private String name = null;
41+
private String type = PROPERTY_TYPE_STRING;
42+
private int maxLength = DEFAULT_MAX_LENGTH;
43+
private String mapParameter = null;
4144
private boolean usedToImport = false;
4245
private String redirectOU = null;
4346
private String redirectAttribute = null;
@@ -52,17 +55,18 @@ public DomainProperty() {
5255
public DomainProperty(ResourceLocator rs, String num) {
5356
String s;
5457

55-
m_sName = rs.getString("property_" + num + ".Name");
56-
m_iType = PROPERTY_TYPE_STRING;
58+
name = rs.getString("property_" + num + ".Name");
59+
type = PROPERTY_TYPE_STRING;
5760
s = rs.getString("property_" + num + ".Type");
5861
if ((s != null) && (s.length() > 0)) {
5962
if (s.equalsIgnoreCase("USERID")) {
60-
m_iType = PROPERTY_TYPE_USERID;
63+
type = PROPERTY_TYPE_USERID;
6164
} else if (s.equalsIgnoreCase("BOOLEAN")) {
62-
m_iType = PROPERTY_TYPE_BOOLEAN;
65+
type = PROPERTY_TYPE_BOOLEAN;
6366
}
6467
}
65-
m_sMapParameter = rs.getString("property_" + num + ".MapParameter");
68+
maxLength = rs.getInteger("property_" + num + ".MaxLength", DEFAULT_MAX_LENGTH);
69+
mapParameter = rs.getString("property_" + num + ".MapParameter");
6670
usedToImport = rs.getBoolean("property_" + num + ".UsedToImport", false);
6771
redirectOU = rs.getString("property_" + num + ".RedirectOU");
6872
redirectAttribute = rs.getString("property_" + num + ".RedirectAttribute");
@@ -71,27 +75,35 @@ public DomainProperty(ResourceLocator rs, String num) {
7175
}
7276

7377
public void setName(String propertyName) {
74-
m_sName = propertyName;
78+
name = propertyName;
7579
}
7680

7781
public String getName() {
78-
return m_sName;
82+
return name;
7983
}
8084

8185
public void setType(String propertyType) {
82-
m_iType = propertyType;
86+
type = propertyType;
8387
}
8488

8589
public String getType() {
86-
return m_iType;
90+
return type;
91+
}
92+
93+
public void setMaxLength(final int maxLength) {
94+
this.maxLength = maxLength;
95+
}
96+
97+
public int getMaxLength() {
98+
return maxLength;
8799
}
88100

89101
public void setMapParameter(String mapParameter) {
90-
m_sMapParameter = mapParameter;
102+
this.mapParameter = mapParameter;
91103
}
92104

93105
public String getMapParameter() {
94-
return m_sMapParameter;
106+
return mapParameter;
95107
}
96108

97109
public boolean isUsedToImport() {

lib-core/src/main/java/org/silverpeas/admin/domain/repository/SQLInternalDomainRepository.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424

2525
package org.silverpeas.admin.domain.repository;
2626

27+
import com.silverpeas.util.StringUtil;
2728
import com.stratelia.webactiv.beans.admin.Domain;
29+
import com.stratelia.webactiv.beans.admin.DomainProperty;
2830
import com.stratelia.webactiv.util.FileRepositoryManager;
2931
import org.apache.commons.io.IOUtils;
3032
import org.silverpeas.admin.domain.exception.SQLDomainDAOException;
@@ -116,8 +118,7 @@ private String generateGroupTableDropStatement(String domainName) {
116118
return dropStatement.toString();
117119
}
118120

119-
private String generateUserTableCreateStatement(String domainName) throws FileNotFoundException,
120-
IOException {
121+
private String generateUserTableCreateStatement(String domainName) throws IOException {
121122
Properties props = new Properties();
122123
FileInputStream fis = null;
123124
try {
@@ -142,15 +143,23 @@ private String generateUserTableCreateStatement(String domainName) throws FileNo
142143
// Domain specific columns
143144
String specificColumnName;
144145
String specificColumnType;
146+
int specificColumnMaxLength;
145147
for (int i = 1; i <= numberOfColumns; i++) {
146148
specificColumnType = props.getProperty("property_" + String.valueOf(i) + ".Type");
147149
specificColumnName = props.getProperty("property_" + String.valueOf(i) + ".MapParameter");
150+
String maxLengthPropertyValue =
151+
props.getProperty("property_" + String.valueOf(i) + ".MaxLength");
152+
if (StringUtil.isInteger(maxLengthPropertyValue)) {
153+
specificColumnMaxLength = Integer.parseInt(maxLengthPropertyValue);
154+
} else {
155+
specificColumnMaxLength = DomainProperty.DEFAULT_MAX_LENGTH;
156+
}
148157

149158
createStatement.append(specificColumnName);
150159
if ("BOOLEAN".equals(specificColumnType)) {
151160
createStatement.append(" int NOT NULL DEFAULT (0) ");
152161
} else {
153-
createStatement.append(" varchar(50) NULL ");
162+
createStatement.append(" varchar(").append(specificColumnMaxLength).append(") NULL ");
154163
}
155164

156165
if (i != numberOfColumns) {

lib-core/src/test/resources/org/silverpeas/admin/domain/expectedDomainPropertiesFile.properties

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# As a special exception to the terms and conditions of version 3.0 of
1010
# the GPL, you may redistribute this Program in connection with Free/Libre
1111
# Open Source Software ("FLOSS") applications as described in Silverpeas's
12-
# FLOSS exception. You should have recieved a copy of the text describing
12+
# FLOSS exception. You should have received a copy of the text describing
1313
# the FLOSS exception, and it is also available here:
1414
# "http://www.silverpeas.org/docs/core/legal/floss_exception.html"
1515
#
@@ -72,7 +72,7 @@ ExternalSynchroClass =
7272
# Property number : from 1 to N
7373

7474
property.Number = 9
75-
property.ResourceFile = com.stratelia.silverpeas.domains.multilang.templateDomainSQLBundle
75+
property.ResourceFile = org.silverpeas.domains.multilang.templateDomainSQLBundle
7676

7777
property_1.Name = title
7878
property_1.Type = STRING
@@ -81,33 +81,41 @@ property_1.MapParameter = title
8181
property_2.Name = company
8282
property_2.Type = STRING
8383
property_2.MapParameter = company
84+
property_2.MaxLength = 100
8485

8586
property_3.Name = position
8687
property_3.Type = STRING
8788
property_3.MapParameter = position
89+
property_3.MaxLength = 100
8890

8991
property_4.Name = boss
9092
property_4.Type = USERID
9193
property_4.MapParameter = boss
94+
property_4.MaxLength = 100
9295

9396
property_5.Name = phone
9497
property_5.Type = STRING
9598
property_5.MapParameter = phone
99+
property_5.MaxLength = 20
96100

97101
property_6.Name = homePhone
98102
property_6.Type = STRING
99103
property_6.MapParameter = homePhone
104+
property_6.MaxLength = 20
100105

101106
property_7.Name = fax
102107
property_7.Type = STRING
103108
property_7.MapParameter = fax
109+
property_7.MaxLength = 20
104110

105111
property_8.Name = cellularPhone
106112
property_8.Type = STRING
107113
property_8.MapParameter = cellPhone
114+
property_8.MaxLength = 20
108115

109116
property_9.Name = address
110117
property_9.Type = STRING
111118
property_9.MapParameter = address
119+
property_9.MaxLength = 500
112120

113121
property.Grouping =

0 commit comments

Comments
 (0)