Slight refactor. ReferredMetadataService uses the registry to look up Referrals rather than the AdminService. Seems neater.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/classified_renditions@111772 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Neil McErlean
2015-09-09 09:26:02 +00:00
parent 10fdfcf078
commit c21cd5fac3
4 changed files with 32 additions and 6 deletions

View File

@@ -79,11 +79,29 @@ public class ReferralRegistry
*/
public MetadataReferral getReferralForAssociation(QName assocType)
{
for (MetadataReferral d : metadataReferrals)
for (MetadataReferral mr : metadataReferrals)
{
if (d.getAssocType().equals(assocType))
if (mr.getAssocType().equals(assocType))
{
return d;
return mr;
}
}
return null;
}
/**
* Gets the {@link MetadataReferral} which is defined to handle the specified aspect.
*
* @param aspectName the name of the aspect whose {@link MetadataReferral} is sought.
* @return the {@link MetadataReferral} handling the specified aspect if there is one, else {@code null}.
*/
public MetadataReferral getReferralForAspect(QName aspectName)
{
for (MetadataReferral mr : metadataReferrals)
{
if (mr.getAspects().contains(aspectName))
{
return mr;
}
}
return null;

View File

@@ -46,6 +46,7 @@ import java.util.Set;
public class ReferredMetadataServiceImpl implements ReferredMetadataService
{
private ReferralAdminService referralAdminService;
private ReferralRegistry referralRegistry;
private DictionaryService dictionaryService;
private NodeService nodeService;
@@ -54,6 +55,11 @@ public class ReferredMetadataServiceImpl implements ReferredMetadataService
this.referralAdminService = service;
}
public void setReferralRegistry(ReferralRegistry registry)
{
this.referralRegistry = registry;
}
public void setDictionaryService(DictionaryService service)
{
this.dictionaryService = service;
@@ -71,7 +77,7 @@ public class ReferredMetadataServiceImpl implements ReferredMetadataService
throw new InvalidNodeRefException(potentialReferrer);
}
final MetadataReferral metadataReferral = referralAdminService.getReferralFor(aspectName);
final MetadataReferral metadataReferral = referralRegistry.getReferralForAspect(aspectName);
if (metadataReferral == null)
{
@@ -91,7 +97,7 @@ public class ReferredMetadataServiceImpl implements ReferredMetadataService
throw new InvalidNodeRefException(referrer);
}
final MetadataReferral d = referralAdminService.getReferralFor(aspectName);
final MetadataReferral d = referralRegistry.getReferralForAspect(aspectName);
if (d == null)
{