Buggy code:
@ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public void removeACLFromDocumentRevision ( DocumentRevisionKey documentRevisionKey ) throws AccessRightException , DocumentRevisionNotFoundException , UserNotActiveException , UserNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public void removeACLFromDocumentMasterTemplate ( String pWorkspaceId , String documentTemplateId ) throws AccessRightException , DocumentMasterTemplateNotFoundException , UserNotActiveException , UserNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public DocumentRevision [ ] getAllDocumentsInWorkspace ( String workspaceId ) throws UserNotActiveException , UserNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public DocumentRevision [ ] getAllDocumentsInWorkspace ( String workspaceId , int start , int pMaxResults ) throws UserNotActiveException , UserNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public int getDocumentsInWorkspaceCount ( String workspaceId ) throws UserNotActiveException , UserNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( { UserGroupMapping . REGULAR_USER_ROLE_ID , UserGroupMapping . ADMIN_ROLE_ID } ) @ Override public int getTotalNumberOfDocuments ( String pWorkspaceId ) throws AccessRightException , AccountNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public DocumentRevision [ ] getCheckedOutDocumentRevisions ( String pWorkspaceId ) throws UserNotActiveException , UserNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public Task [ ] getTasks ( String pWorkspaceId ) throws UserNotActiveException , UserNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public DocumentRevisionKey [ ] getIterationChangeEventSubscriptions ( String pWorkspaceId ) throws UserNotActiveException , UserNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( { UserGroupMapping . REGULAR_USER_ROLE_ID } ) @ Override public DocumentRevisionKey [ ] getStateChangeEventSubscriptions ( String pWorkspaceId ) throws UserNotActiveException , UserNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public boolean isUserStateChangeEventSubscribedForGivenDocument ( String pWorkspaceId , DocumentRevision docR ) throws UserNotActiveException , UserNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public boolean isUserIterationChangeEventSubscribedForGivenDocument ( String pWorkspaceId , DocumentRevision docR ) throws UserNotActiveException , UserNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public DocumentRevision [ ] getDocumentRevisionsWithReferenceOrTitle ( String pWorkspaceId , String search , int maxResults ) throws UserNotActiveException , UserNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public String generateId ( String pWorkspaceId , String pDocMTemplateId ) throws DocumentMasterTemplateNotFoundException , UserNotActiveException , UserNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public DocumentRevision [ ] searchDocumentRevisions ( DocumentSearchQuery pQuery ) throws ESServerException , UserNotActiveException , UserNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public DocumentMasterTemplate [ ] getDocumentMasterTemplates ( String pWorkspaceId ) throws UserNotActiveException , UserNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public DocumentMasterTemplate getDocumentMasterTemplate ( DocumentMasterTemplateKey pKey ) throws DocumentMasterTemplateNotFoundException , UserNotActiveException , UserNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public DocumentMasterTemplate updateDocumentMasterTemplate ( DocumentMasterTemplateKey pKey , String pDocumentType , String pWorkflowModelId , String pMask , InstanceAttributeTemplate [ ] pAttributeTemplates , String [ ] lovNames , boolean idGenerated , boolean attributesLocked ) throws AccessRightException , DocumentMasterTemplateNotFoundException , ListOfValuesNotFoundException , UserNotActiveException , UserNotFoundException , WorkflowModelNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public void deleteTag ( TagKey pKey ) throws AccessRightException , TagNotFoundException , UserNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public void createTag ( String pWorkspaceId , String pLabel ) throws AccessRightException , CreationException , TagAlreadyExistsException , UserNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public DocumentRevision createDocumentMaster ( String pParentFolder , String pDocMId , String pTitle , String pDescription , String pDocMTemplateId , String pWorkflowModelId , ACLUserEntry [ ] pACLUserEntries , ACLUserGroupEntry [ ] pACLUserGroupEntries , Map < String , String > roleMappings ) throws AccessRightException , CreationException , DocumentMasterAlreadyExistsException , DocumentMasterTemplateNotFoundException , DocumentRevisionAlreadyExistsException , FileAlreadyExistsException , FolderNotFoundException , NotAllowedException , RoleNotFoundException , UserNotFoundException , WorkflowModelNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( { UserGroupMapping . REGULAR_USER_ROLE_ID , UserGroupMapping . ADMIN_ROLE_ID } ) @ Override public DocumentRevision [ ] getAllCheckedOutDocumentRevisions ( String pWorkspaceId ) throws AccessRightException , AccountNotFoundException , WorkspaceNotFoundException { } @ RolesAllowed ( UserGroupMapping . REGULAR_USER_ROLE_ID ) @ Override public DocumentMasterTemplate createDocumentMasterTemplate ( String pWorkspaceId , String pId , String pDocumentType , String pWorkflowModelId , String pMask , InstanceAttributeTemplate [ ] pAttributeTemplates , String [ ] lovNames , boolean idGenerated , boolean attributesLocked ) throws AccessRightException , CreationException , DocumentMasterTemplateAlreadyExistsException , ListOfValuesNotFoundException , NotAllowedException , UserNotFoundException , WorkflowModelNotFoundException , WorkspaceNotFoundException { User user = userManager . checkWorkspaceWriteAccess ( pWorkspaceId ) ; Locale locale = new Locale ( user . getLanguage ( ) ) ; checkNameValidity ( pId , locale ) ; <START_BUG> if ( ! ( NamingConvention . correctNameMask ( pMask ) ) ) { <END_BUG> throw new NotAllowedException ( locale , "DocumentMasterTemplateMaskCreationException" ) ; } DocumentMasterTemplate template = new DocumentMasterTemplate ( user . getWorkspace ( ) , pId , user , pDocumentType , pMask ) ; Date now = new Date ( ) ; template . setCreationDate ( now ) ; template . setIdGenerated ( idGenerated ) ; template . setAttributesLocked ( attributesLocked ) ; LOVDAO lovDAO = new LOVDAO ( locale , em ) ; List < InstanceAttributeTemplate > attrs = new ArrayList < > ( ) ; for ( int i = 0 ; i < ( pAttributeTemplates . length ) ; i ++ ) { attrs . add ( pAttributeTemplates [ i ] ) ; if ( ( pAttributeTemplates [ i ] ) instanceof ListOfValuesAttributeTemplate ) { ListOfValuesAttributeTemplate lovAttr = ( ( ListOfValuesAttributeTemplate ) ( pAttributeTemplates [ i ] ) ) ; ListOfValuesKey lovKey = new ListOfValuesKey ( user . getWorkspaceId ( ) , lovNames [ i ] ) ;

Fix:
if ( ( ( pMask != null ) && ( ! ( pMask . isEmpty ( ) ) ) ) && ( ! ( NamingConvention . correctNameMask ( pMask ) ) ) ) {