String mixinTypesField = locationFactory.createJCRName(Constants.JCR_MIXINTYPES).getAsString();
String primaryTypeField = locationFactory.createJCRName(Constants.JCR_PRIMARYTYPE).getAsString();
// ExtendedNodeTypeManager ntMgr =
// session.getWorkspace().getNodeTypeManager();
NodeTypeData base = findNodeType(nodeType);
if (base.isMixin())
{
// search for nodes where jcr:mixinTypes is set to this mixin
Term t =
new Term(FieldNames.PROPERTIES, FieldNames.createNamedValue(mixinTypesField, locationFactory
.createJCRName(nodeType).getAsString()));
terms.add(t);
}
else
{
// search for nodes where jcr:primaryType is set to this type
Term t =
new Term(FieldNames.PROPERTIES, FieldNames.createNamedValue(primaryTypeField, locationFactory
.createJCRName(nodeType).getAsString()));
terms.add(t);
}
// now search for all node types that are derived from base
Set<InternalQName> allTypes = getSubtypes(nodeType);
for (InternalQName descendantNt : allTypes)
{
String ntName = locationFactory.createJCRName(descendantNt).getAsString();
NodeTypeData nt = findNodeType(descendantNt);
Term t;
if (nt.isMixin())
{
// search on jcr:mixinTypes
t = new Term(FieldNames.PROPERTIES, FieldNames.createNamedValue(mixinTypesField, ntName));
}
else