|
13 | 13 | import java.util.List;
|
14 | 14 | import java.util.Map;
|
15 | 15 | import java.util.Set;
|
| 16 | +import java.util.regex.Pattern; |
16 | 17 |
|
17 | 18 | import javax.annotation.PostConstruct;
|
18 | 19 | import javax.annotation.Resource;
|
|
371 | 372 | @TransactionManagement(TransactionManagementType.CONTAINER)
|
372 | 373 | @TransactionAttribute(TransactionAttributeType.REQUIRED)
|
373 | 374 | public class ProjectServiceBean implements ProjectServiceLocal, ProjectServiceRemote {
|
| 375 | + /** |
| 376 | + * Represents the pattern for project name |
| 377 | + * |
| 378 | + * @since 2.4 |
| 379 | + */ |
| 380 | + private static final String NAME_PATTERN = "[a-zA-Z0-9\\$\\!\\(\\)\\[\\]'\\\"\\-\\.\\,\\/\\+ ]+"; |
| 381 | + |
374 | 382 | /**
|
375 | 383 | * Represents the field names to be audit.
|
376 | 384 | *
|
@@ -1988,6 +1996,17 @@ private void checkProjectData(ProjectData projectData, boolean isCreate) throws
|
1988 | 1996 | throw logException(new IllegalArgumentFault("The name attribute of the project data can not be null."));
|
1989 | 1997 | } else if (name.trim().length() == 0) {
|
1990 | 1998 | throw logException(new IllegalArgumentFault("The name attribute of the project data can not be empty."));
|
| 1999 | + } else if (!Pattern.matches(NAME_PATTERN, name)) { |
| 2000 | + throw logException(new IllegalArgumentFault("The name attribute of the project data is not following pattern as - " + NAME_PATTERN)); |
| 2001 | + } |
| 2002 | + |
| 2003 | + String description = projectData.getDescription(); |
| 2004 | + if (null == description) { |
| 2005 | + throw logException(new IllegalArgumentFault("The description attribute of the project data can not be null.")); |
| 2006 | + } else if (description.trim().length() == 0) { |
| 2007 | + throw logException(new IllegalArgumentFault("The description attribute of the project data can not be empty.")); |
| 2008 | + } else if (!Pattern.matches(NAME_PATTERN, description)) { |
| 2009 | + throw logException(new IllegalArgumentFault("The description attribute of the project data is not following pattern as - " + NAME_PATTERN)); |
1991 | 2010 | }
|
1992 | 2011 |
|
1993 | 2012 | //added in version 2.2
|
|
0 commit comments