mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-17 14:21:39 +00:00
.externalToolBuilders
config
source
cpp
java
org
alfresco
email
filesys
jcr
linkvalidation
model
repo
action
admin
attributes
audit
avm
cache
clt
coci
config
configuration
content
copy
deploy
descriptor
dictionary
domain
exporter
forum
i18n
importer
jscript
lock
model
module
node
archive
db
index
integrity
AbstractIntegrityEvent.java
AspectsIntegrityEvent.java
AssocSourceMultiplicityIntegrityEvent.java
AssocSourceTypeIntegrityEvent.java
AssocTargetMultiplicityIntegrityEvent.java
AssocTargetRoleIntegrityEvent.java
AssocTargetTypeIntegrityEvent.java
IncompleteNodeTagger.java
IncompleteNodeTaggerTest.java
IntegrityChecker.java
IntegrityEvent.java
IntegrityEventTest.java
IntegrityException.java
IntegrityRecord.java
IntegrityTest.java
IntegrityTest_model.xml
PropertiesIntegrityEvent.java
AbstractNodeServiceImpl.java
BaseNodeServiceTest.java
BaseNodeServiceTest_model.xml
ConcurrentNodeServiceSearchTest.java
ConcurrentNodeServiceTest.java
FullNodeServiceTest.java
MLPropertyInterceptor.java
NodeRefPropertyMethodInterceptor.java
NodeRefPropertyMethodInterceptorTest.java
NodeRefTestModel.xml
NodeServicePolicies.java
PerformanceNodeServiceTest.java
ReferenceableAspect.java
StoreArchiveMap.java
TemporaryAspect.java
ownable
policy
processor
remote
rule
search
security
service
template
tenant
transaction
usage
version
workflow
sandbox
service
tools
util
apache
queryRegister.dtd
meta-inf
test-resources
web
.classpath
.project
build.xml
5448: (From V1.4) 5281 (V1.4): Patches not executed in read-only mode 5284 (V1.4): Integrity messages 5308 (V1.4): Category selector performance 5331 (V1.4): Category performance 5402 (V1.4): AR-1315 5410 (V1.4): 5417 (V1.4): Upgrade script performance 5435 (V1.4): Lucene test text encoding git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5482 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
115 lines
4.5 KiB
Java
115 lines
4.5 KiB
Java
/*
|
|
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* As a special exception to the terms and conditions of version 2.0 of
|
|
* the GPL, you may redistribute this Program in connection with Free/Libre
|
|
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
|
* FLOSS exception. You should have recieved a copy of the text describing
|
|
* the FLOSS exception, and it is also available here:
|
|
* http://www.alfresco.com/legal/licensing"
|
|
*/
|
|
package org.alfresco.repo.node.integrity;
|
|
|
|
import java.util.List;
|
|
|
|
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
|
import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition;
|
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
|
import org.alfresco.service.cmr.repository.NodeRef;
|
|
import org.alfresco.service.cmr.repository.NodeService;
|
|
import org.alfresco.service.namespace.QName;
|
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
|
|
|
/**
|
|
* Event to check the association target role name
|
|
*
|
|
* @author Derek Hulley
|
|
*/
|
|
public class AssocTargetRoleIntegrityEvent extends AbstractIntegrityEvent
|
|
{
|
|
public AssocTargetRoleIntegrityEvent(
|
|
NodeService nodeService,
|
|
DictionaryService dictionaryService,
|
|
NodeRef sourceNodeRef,
|
|
QName assocTypeQName,
|
|
QName assocName)
|
|
{
|
|
super(nodeService, dictionaryService, sourceNodeRef, assocTypeQName, assocName);
|
|
}
|
|
|
|
public void checkIntegrity(List<IntegrityRecord> eventResults)
|
|
{
|
|
QName assocTypeQName = getTypeQName();
|
|
QName assocQName = getQName();
|
|
NodeRef sourceNodeRef = getNodeRef();
|
|
|
|
// get the association def
|
|
AssociationDefinition assocDef = getAssocDef(eventResults, assocTypeQName);
|
|
// the association definition must exist
|
|
if (assocDef == null)
|
|
{
|
|
IntegrityRecord result = new IntegrityRecord(
|
|
"Association type does not exist: \n" +
|
|
" Association Type: " + assocTypeQName);
|
|
eventResults.add(result);
|
|
return;
|
|
}
|
|
|
|
// check that we are dealing with child associations
|
|
if (assocQName == null)
|
|
{
|
|
throw new IllegalArgumentException("The association qualified name must be supplied");
|
|
}
|
|
if (!assocDef.isChild())
|
|
{
|
|
throw new UnsupportedOperationException("This operation is only relevant to child associations");
|
|
}
|
|
ChildAssociationDefinition childAssocDef = (ChildAssociationDefinition) assocDef;
|
|
|
|
// perform required checks
|
|
checkAssocQNameRegex(eventResults, childAssocDef, assocQName, sourceNodeRef);
|
|
}
|
|
|
|
/**
|
|
* Checks that the association name matches the constraints imposed by the model.
|
|
*/
|
|
protected void checkAssocQNameRegex(
|
|
List<IntegrityRecord> eventResults,
|
|
ChildAssociationDefinition assocDef,
|
|
QName assocQName,
|
|
NodeRef sourceNodeRef)
|
|
{
|
|
// check the association name
|
|
QName assocRoleQName = assocDef.getTargetRoleName();
|
|
if (assocRoleQName != null)
|
|
{
|
|
// the assoc defines a role name - check it
|
|
RegexQNamePattern rolePattern = new RegexQNamePattern(assocRoleQName.toString());
|
|
if (!rolePattern.isMatch(assocQName))
|
|
{
|
|
IntegrityRecord result = new IntegrityRecord(
|
|
"The association name does not match the allowed role names: \n" +
|
|
" Source Node: " + sourceNodeRef + "\n" +
|
|
" Association: " + assocDef + "\n" +
|
|
" Allowed roles: " + rolePattern + "\n" +
|
|
" Name assigned: " + assocRoleQName);
|
|
eventResults.add(result);
|
|
}
|
|
}
|
|
}
|
|
}
|