1717import java .util .Arrays ;
1818import java .util .HashSet ;
1919import java .util .List ;
20- import org .slf4j .MDC ;
2120import org .springframework .http .MediaType ;
2221
22+ /**
23+ * The Constants class contains various constants used throughout the
24+ * application. These constants include regular expression patterns,
25+ * configuration related to security, date and time formats, and other specific
26+ * data type names.
27+ */
2328public final class Constants {
29+
30+ /**
31+ * Regular expression pattern for validating names.
32+ */
2433 public static final String NAME_PATTERN =
25- "^[a-zA-ZàáãạảăắằẳẵặâấầẩẫậèéẹẻẽêềếểễệđìíĩỉịòóõọỏôốồổỗộơớờởỡợùúũụủưứừửữựỳỵỷỹýÀÁÃẠẢĂẮẰẲẴẶÂẤẦẨẪẬÈÉẸẺẼÊỀẾỂỄỆĐÌÍĨỈỊÒÓÕỌỎÔỐỒỔỖỘƠỚỜỞỠỢÙÚŨỤỦƯỨỪỬỮỰỲỴỶỸÝ\\ s]+$" ;
34+ "^[a-zA-ZàáãạảăắằẳẵặâấầẩẫậèéẹẻẽêềếểễệđìíĩỉịòóõọỏôốồổỗộơớờởỡợùúũụủưứừửữựỳỵỷỹýÀÁÃẠẢĂẮẰẲẴẶÂẤẦẨẪẬÈÉẸẺẼÊỀẾỂỄỆĐÌÍĨỈỊÒÓÕỌọÔỐỒỔỖỘƠỚỜỞỠỢÙÚŨỤỦƯỨỪỬỮỰỲỴỶỸÝ\\ s]+$" ;
35+
36+ /**
37+ * Regular expression pattern for validating email addresses.
38+ */
2639 public static final String EMAIL_PATTERN = "^[\\ w-_\\ .+]*[\\ w-_\\ .]\\ @([\\ w]+\\ .)+[\\ w]+[\\ w]$" ;
40+
41+ /**
42+ * Regular expression pattern for validating dates in the format dd/MM/yyyy.
43+ */
2744 public static final String DATE_PATTERN = "\\ d{2}[/]\\ d{2}[/]\\ d{4}" ;
28- public static final String ID_NO_PATTERN = "^[0-9\\ -]+$" ;
45+
46+ /**
47+ * Regular expression pattern for validating numbers.
48+ */
2949 public static final String NUMBER_PATTERN = "^[0-9]+$" ;
50+
51+ /**
52+ * Regular expression pattern for validating usernames, allowing alphanumeric
53+ * characters, dashes, and underscores.
54+ */
3055 public static final String USERNAME_PATTERN = "^[A-Za-z0-9_-]+$" ;
56+
57+ /**
58+ * List of supported image file extensions.
59+ */
3160 public static final List <String > IMAGE_EXTENSION_LIST =
3261 Arrays .asList ("jpg" , "jpeg" , "png" , "gif" , "bmp" , "tiff" , "tif" , "svg" , "raw" , "psd" , "ai" , "eps" );
33- public static final int MAX_FILE_SIZE_MB = 3 ;
34- public static final int EMPLOYEE_CODE_LENGTH = 6 ;
35- public static final String EMPLOYEE_CODE_MIN = "000001" ;
3662
63+ /**
64+ * List of media types that are visible.
65+ */
3766 public static final List <MediaType > VISIBLE_TYPES = Arrays .asList (
3867 MediaType .TEXT_XML ,
3968 MediaType .APPLICATION_XML ,
@@ -42,44 +71,41 @@ public final class Constants {
4271 MediaType .TEXT_PLAIN ,
4372 MediaType .TEXT_XML ,
4473 MediaType .MULTIPART_FORM_DATA );
74+
75+ /**
76+ * List of sensitive HTTP headers.
77+ */
4578 private static final List <String > SENSITIVE_HEADERS = Arrays .asList ("authorization" , "proxy-authorization" );
4679
47- // for prevent sonar issues
80+ /**
81+ * For preventing Sonar issues related to sensitive headers.
82+ *
83+ * @return List of sensitive headers.
84+ */
4885 public static List <String > getSensitiveHeaders () {
4986 return SENSITIVE_HEADERS ;
5087 }
5188
52- public interface SoapHeaderConstant {
53- String X_B3_TRACEID = "X-B3-TRACEID" ;
54- String X_B3_TRACEID_VALUE_SOAP = MDC .get ("X-B3-TraceId" );
55- String TYPE_XML_CHARSET_UTF8 = "text/xml; charset=utf-8" ;
56- String TYPE_XML = "text/xml" ;
57- String XYZ = "xyz" ;
58- }
59-
89+ /**
90+ * Constants for common HTTP headers.
91+ */
6092 public interface HeaderType {
6193 String CONTENT_TYPE = "Content-Type" ;
6294 String X_API_KEY = "x-api-key" ;
6395 }
6496
65- public interface DateTimePattern {
66- String DMY = "dd/MM/yyyy" ;
67- String DMY_HMS = "dd/MM/yyyy HH:mm:ss" ;
68- String LOCAL_DATE_TIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss" ;
69- String YYYYMMDD = "yyyy-MM-dd" ;
70- }
71-
72- public static final class Activation {
73- public static final Integer ACTIVE = 1 ;
74- public static final Integer INACTIVE = 0 ;
75- }
76-
97+ /**
98+ * Security-related constants.
99+ */
77100 public static final class Security {
78101 public static final String AUTHORIZATION = "Authorization" ;
79102 public static final String BEARER = "Bearer" ;
80103 public static final String DEFAULT_REGISTRATION_ID = "oidc" ;
81104 }
82105
106+ /**
107+ * Token-related properties.
108+ */
83109 public static final class TokenProperties {
84110 public static final String USERNAME = "preferred_username" ;
85111 public static final String ID = "sub" ;
@@ -89,12 +115,18 @@ public static final class TokenProperties {
89115 public static final String ORGANIZATION_ID = "organization_id" ;
90116 }
91117
118+ /**
119+ * Keycloak error codes.
120+ */
92121 public static final class KeyCloakError {
93122 public static final String INVALID_GRANT = "INVALID_GRANT" ;
94123 public static final String DISABLED = "DISABLED" ;
95124 public static final String INVALID = "INVALID" ;
96125 }
97126
127+ /**
128+ * Constants related to XML.
129+ */
98130 public static final class XmlConst {
99131 public static final String TAG_OPEN_RETURN = "<return>" ;
100132 public static final String TAG_CLOSE_RETURN = "</return>" ;
@@ -104,6 +136,9 @@ public static final class XmlConst {
104136 public static final String GT_CHARACTER = ">" ;
105137 }
106138
139+ /**
140+ * Logging related titles and sizes.
141+ */
107142 public static final class LoggingTitle {
108143 public static final String REQUEST = "\n -- REQUEST --\n " ;
109144 public static final String REQUEST_HEADER = "\n -- REQUEST HEADER --\n " ;
@@ -115,21 +150,9 @@ public static final class LoggingTitle {
115150 public static final Integer BODY_SIZE_RESPONSE_MAX = 1000 ;
116151 }
117152
118- public static final class Otp {
119- public static final String REGISTER = "REGISTER" ;
120- public static final String FORGOT_PASSWORD = "FORGOT_PASSWORD" ;
121- public static final String FORGOT_PASSWORD_CONTENT = "OTP for forgot password user" ;
122- public static final String REGISTER_CONTENT = "OTP for register user" ;
123- public static final Integer EXP_MINUTE = 2 ;
124- public static final Integer EXP_OTP_AM_MINUTE = 5 ;
125- }
126-
127- public static final class RoleName {
128- public static final String SYSTEM = "system" ;
129- public static final String ADMIN = "admin" ;
130- public static final String USER = "user" ;
131- }
132-
153+ /**
154+ * Sorting related constants.
155+ */
133156 public static final class Sorting {
134157 public static final String SPLIT_OPERATOR = "," ;
135158 public static final String MINUS_OPERATOR = "-" ;
@@ -139,144 +162,11 @@ public static final class Sorting {
139162 public static final String FILED_DISPLAY = "$1_$2" ;
140163 }
141164
142- public static final class ArrayLimit {
143- public static final Integer COMMON = 100 ;
144- }
145-
146- public static class TemplateMail {
147- public static final String FORGOT_PASSWORD = "FORGOT_PASSWORD" ;
148- public static final String SIGN_UP = "SIGN_UP" ;
149- public static final String CUSTOMER_ACTIVE_SUCCESS = "CUSTOMER_ACTIVE_SUCCESS" ;
150- public static final String CUSTOMER_REGISTER_SUCCESS = "CUSTOMER_REGISTER_SUCCESS" ;
151- public static final String EMPLOYEE_REGISTER_SUCCESS = "EMPLOYEE_REGISTER_SUCCESS" ;
152- public static final String ACCOUNT_ACTIVE = "ACCOUNT_ACTIVE" ;
153- public static final String SIGN_UP_PASSWORD = "SIGN_UP_PASSWORD" ;
154- public static final String VERIFY_ACCOUNT_SUCESS = "VERIFY_ACCOUNT_SUCESS" ;
155- public static final String NOTI_VERIFY_ACCOUNT = "NOTI_VERIFY_ACCOUNT" ;
156- }
157-
158- public static class ActionUser {
159- public static final String SYSTEM = "system" ;
160- }
161-
162- public interface MINIO_BUCKET_MARKET_INFO {
163- String URL_IMAGE = "market-info" ;
164- }
165-
166- public interface MINIO_BUCKET_MARKET_SECTION {
167- String MARKET_SECTION = "market-section" ;
168- }
169-
170- public static final String NULL_IMAGE_SRC = null ;
171-
172- public static final class COMMON {
173- public static final Integer STATUS_ACTIVE = 1 ;
174- public static final Integer STATUS_INACTIVE = 0 ;
175- public static final Integer STATUS_INVALID = -1 ;
176- public static final Integer STATUS_NULL = -2 ;
177- public static final String STR_STATUS_INACTIVE = "0" ;
178- }
179-
180- public static class ORGANIZATION_STATUS {
181- public static final Integer ACTIVE = 1 ;
182- public static final Integer INACTIVE = 0 ;
183- }
184-
185- public static class STATUS {
186- public static final Integer ACTIVE = 1 ;
187- public static final Integer INACTIVE = 0 ;
188- public static final Integer DELETE = -1 ;
189- }
190-
191- public static class STATE {
192- public static final Integer ACTIVE = 1 ;
193- public static final Integer INACTIVE = 0 ;
194- public static final Integer DELETE = 3 ;
195- }
196-
197- public static class IDENTIFY {
198- public static final String MST = "MST" ;
199- public static final String GPKD = "DKKD" ;
200- public static final Integer DELETE = 3 ;
201- }
202-
203- public static final class PERMISSION_TYPE {
204- public static final String ROLE = "ROLE" ;
205- public static final String GROUP = "GROUP" ;
206- }
207-
208165 public static final HashSet <String > EXCLUDE_LOGGING_ENDPOINTS = new HashSet <>(List .of ("/actuator/health" ));
209166
210167 public static final int MAX_BYTE = 4096 ;
211168
212169 public static class POOL {
213170 public static final String REST_CLIENT_POLL = "Rest-client-Pool" ; // name of Rest client poll for https proxy
214171 }
215-
216- public static final class TEMPLATE_PATH {
217- public static final String ADD_EMPLOYEE_TEMPLATE = "/template/employee/ADD_EMPLOYEE_TEMPLATE.xlsx" ;
218- public static final String ADD_ROLE_TEMPLATE = "/template/employee/ADD_ROLE_TEMPLATE.xlsx" ;
219- public static final String ADD_UNIT_TEMPLATE = "/template/employee/ADD_UNIT_ORGANIZATION_TEMPLATE.xlsx" ;
220-
221- public static final String ADD_EMPLOYEE_TEMPLATE_RESULT =
222- "/template/employee/ADD_EMPLOYEE_TEMPLATE_RESULT.xlsx" ;
223- public static final String ADD_ROLE_TEMPLATE_RESULT = "/template/employee/ADD_ROLE_TEMPLATE_RESULT.xlsx" ;
224- }
225-
226- public static final class TEMPLATE_FILE_NAME {
227- public static final String ADD_EMPLOYEE_FILE_NAME = "ADD_EMPLOYEE_TEMPLATE.xlsx" ;
228- public static final String ADD_ROLE_FILE_NAME = "ADD_ROLE_TEMPLATE.xlsx" ;
229- public static final String ADD_UNIT_FILE_NAME = "ADD_UNIT_TEMPLATE.xlsx" ;
230- public static final String ADD_EMPLOYEE_RESULT_FILE_NAME = "ADD_EMPLOYEE_TEMPLATE_RESULT.xlsx" ;
231- public static final String ADD_ROLE_RESULT_FILE_NAME = "ADD_ROLE_TEMPLATE_RESULT.xlsx" ;
232- }
233-
234- public static final class Role {
235- public static final String ENTERPRISE_STAFF = "ENTERPRISE_STAFF" ;
236- public static final String ENTERPRISE_ADMIN = "ENTERPRISE_ADMIN" ;
237- public static final String ENTERPRISE_ADMIN_NEW = "admin" ;
238- public static final String ENTERPRISE_STAFF_NEW = "staff" ;
239- public static final String ENTERPRISE_USER_NEW = "user" ;
240- public static final String SHORT_ENTERPRISE_STAFF = "S" ;
241- public static final String SHORT_ENTERPRISE_ADMIN = "A" ;
242- public static final String SHORT_ENTERPRISE_USER = "U" ;
243- }
244-
245- public static final class Gender {
246- public static final String SHORT_MALE = "M" ;
247- public static final String SHORT_FEMALE = "F" ;
248- public static final String FULL_MALE = "male" ;
249- public static final String FULL_FEMALE = "female" ;
250- }
251-
252- public static final class ROW_TEMPLAE_NAME {
253- public static final String FIRST_NAME = "first.name" ;
254- public static final String LAST_NAME = "last.name" ;
255- public static final String FULL_MALE = "full.name" ;
256- public static final String PHONE = "contact.phone" ;
257- public static final String EMAIL = "contact.email" ;
258- public static final String DATE_OF_BIRTH = "individual.date.of.birth" ;
259- public static final String SEX = "gender" ;
260- public static final String WORKING_STATUS = "working.status.row.name" ;
261- public static final String ADDRESS = "employee.address" ;
262- public static final String USERNAME = "login.account" ;
263- public static final String EMPLOYEE_CODE = "employee.code" ;
264- public static final String ACCOUNT_EMAIL = "email.account" ;
265- public static final String CODE = "employee.code" ;
266- public static final String SEX_DESCRIPTION = "sex.des" ;
267-
268- public static final String ORGANIZATION = "organization" ;
269- public static final String POSITION = "working.position" ;
270- public static final String DIRECT_MANAGER = "direct.manage" ;
271- public static final String ONBOARD = "intern.day.template" ;
272- public static final String ONBOARD_DAY = "start.working.day.template" ;
273- public static final String APPLICATION = "application.chose" ;
274- public static final String ROLE_GROUP = "role.group" ;
275- public static final String ROLE = "role.row.des" ;
276- public static final String OBLIGATORY = "(*)" ;
277- }
278-
279- public static final class OptionSetCode {
280- public static final String SUB_TITLE_MAIL = "SUB_TITLE_MAIL" ; // Cau hinh thong tin truyen vao mail
281- }
282172}
0 commit comments