/**
  * Map query specific node types.
  *
  * @param queryCriteria the query criteria
  * @param queryBuilder the query builder
  * @param nodeTypeManager the node type manager
  * @throws Exception the exception
  */
 private void mapQuerySpecificNodeTypes(
     final QueryCriteria queryCriteria,
     final SQLQueryBuilder queryBuilder,
     final NodeTypeManager nodeTypeManager)
     throws Exception {
   String[] contentTypes = queryCriteria.getContentTypes();
   NodeType fistType = nodeTypeManager.getNodeType(contentTypes[0]);
   queryBuilder.openGroup(LOGICAL.AND);
   if (fistType.isMixin()) {
     queryBuilder.like("jcr:mixinTypes", contentTypes[0], LOGICAL.NULL);
   } else {
     queryBuilder.equal("jcr:primaryType", contentTypes[0], LOGICAL.NULL);
   }
   if (contentTypes.length > 1) {
     for (int i = 1; i < contentTypes.length; i++) {
       String type = contentTypes[i];
       NodeType nodetype = nodeTypeManager.getNodeType(type);
       if (nodetype.isMixin()) {
         queryBuilder.like("jcr:mixinTypes", type, LOGICAL.OR);
       } else {
         queryBuilder.equal("jcr:primaryType", type, LOGICAL.OR);
       }
     }
   }
   queryBuilder.closeGroup();
   // Remove some specific mimtype
   queryBuilder.openGroup(LOGICAL.AND_NOT);
   queryBuilder.like("jcr:mixinTypes", "exo:cssFile", LOGICAL.NULL);
   queryBuilder.like("jcr:mixinTypes", "exo:jsFile", LOGICAL.OR);
   queryBuilder.closeGroup();
 }
 /**
  * Map query types.
  *
  * @param queryCriteria the query criteria
  * @param queryBuilder the query builder
  * @throws Exception the exception
  */
 private void mapQueryTypes(final QueryCriteria queryCriteria, final SQLQueryBuilder queryBuilder)
     throws Exception {
   queryBuilder.selectTypes(null);
   // Searh on nt:base
   queryBuilder.fromNodeTypes(queryCriteria.getNodeTypes());
   ManageableRepository currentRepository = repositoryService.getCurrentRepository();
   NodeTypeManager manager = currentRepository.getNodeTypeManager();
   // Query all documents for specific content types
   String[] contentTypes = queryCriteria.getContentTypes();
   if ((contentTypes != null && contentTypes.length > 0 && queryCriteria.getKeyword() == null)
       || queryCriteria.isSearchWebpage()) {
     mapQuerySpecificNodeTypes(queryCriteria, queryBuilder, manager);
     return;
   }
   List<String> selectedNodeTypes = templateService.getDocumentTemplates();
   queryBuilder.openGroup(LOGICAL.AND);
   queryBuilder.equal("jcr:primaryType", "nt:resource", LOGICAL.NULL);
   // query on exo:rss-enable nodetypes for title, summary field
   queryBuilder.equal("jcr:mixinTypes", "exo:rss-enable", LOGICAL.OR);
   // query on metadata nodetype
   List<String> publicatioTypes = new ArrayList<String>(4);
   for (NodeTypeIterator iterator = manager.getAllNodeTypes(); iterator.hasNext(); ) {
     NodeType nodeType = iterator.nextNodeType();
     if (nodeType.isNodeType("publication:webpagesPublication")) {
       publicatioTypes.add(nodeType.getName());
       continue;
     }
     if (!nodeType.isNodeType("exo:metadata")) continue;
     if (nodeType.isMixin()) {
       queryBuilder.equal("jcr:mixinTypes", nodeType.getName(), LOGICAL.OR);
     } else {
       queryBuilder.equal("jcr:primaryType", nodeType.getName(), LOGICAL.OR);
     }
   }
   for (String type : selectedNodeTypes) {
     NodeType nodetype = manager.getNodeType(type);
     if (nodetype.isMixin()) {
       queryBuilder.like("jcr:mixinTypes", type, LOGICAL.OR);
     } else {
       queryBuilder.equal("jcr:primaryType", type, LOGICAL.OR);
     }
   }
   queryBuilder.closeGroup();
   // unwanted document types: exo:cssFile, exo:jsFile
   if (excludeMimeTypes.size() < 1) return;
   queryBuilder.openGroup(LOGICAL.AND_NOT);
   String[] mimetypes = excludeMimeTypes.toArray(new String[] {});
   queryBuilder.equal("jcr:mimeType", mimetypes[0], LOGICAL.NULL);
   for (int i = 1; i < mimetypes.length; i++) {
     queryBuilder.equal("jcr:mimeType", mimetypes[i], LOGICAL.OR);
   }
   queryBuilder.closeGroup();
   // Unwanted document by mixin nodetypes
   queryBuilder.openGroup(LOGICAL.AND_NOT);
   queryBuilder.like("jcr:mixinTypes", "exo:cssFile", LOGICAL.NULL);
   queryBuilder.like("jcr:mixinTypes", "exo:jsFile", LOGICAL.OR);
   queryBuilder.closeGroup();
 }
Exemple #3
0
 public static List<String> getListAllowedFileType(
     Node currentNode, TemplateService templateService) throws Exception {
   List<String> nodeTypes = new ArrayList<String>();
   NodeTypeManager ntManager = currentNode.getSession().getWorkspace().getNodeTypeManager();
   NodeType currentNodeType = currentNode.getPrimaryNodeType();
   NodeDefinition[] childDefs = currentNodeType.getChildNodeDefinitions();
   List<String> templates = templateService.getDocumentTemplates();
   try {
     for (int i = 0; i < templates.size(); i++) {
       String nodeTypeName = templates.get(i).toString();
       NodeType nodeType = ntManager.getNodeType(nodeTypeName);
       NodeType[] superTypes = nodeType.getSupertypes();
       boolean isCanCreateDocument = false;
       for (NodeDefinition childDef : childDefs) {
         NodeType[] requiredChilds = childDef.getRequiredPrimaryTypes();
         for (NodeType requiredChild : requiredChilds) {
           if (nodeTypeName.equals(requiredChild.getName())) {
             isCanCreateDocument = true;
             break;
           }
         }
         if (nodeTypeName.equals(childDef.getName()) || isCanCreateDocument) {
           if (!nodeTypes.contains(nodeTypeName)) nodeTypes.add(nodeTypeName);
           isCanCreateDocument = true;
         }
       }
       if (!isCanCreateDocument) {
         for (NodeType superType : superTypes) {
           for (NodeDefinition childDef : childDefs) {
             for (NodeType requiredType : childDef.getRequiredPrimaryTypes()) {
               if (superType.getName().equals(requiredType.getName())) {
                 if (!nodeTypes.contains(nodeTypeName)) nodeTypes.add(nodeTypeName);
                 isCanCreateDocument = true;
                 break;
               }
             }
             if (isCanCreateDocument) break;
           }
           if (isCanCreateDocument) break;
         }
       }
     }
   } catch (Exception e) {
     if (LOG.isErrorEnabled()) {
       LOG.error("Unexpected error", e);
     }
   }
   return nodeTypes;
 }
  /**
   * Tests if <code>NodeType.canAddChildNode(String childNodeName, String nodeTypeName)</code>
   * returns false if <code>nodeTypeName</code> represents an abstract node type.
   */
  public void testCanAddAbstractType() throws NotExecutableException, RepositoryException {

    NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, false, false, false);

    if (nodeDef == null) {
      throw new NotExecutableException("No testable node type found.");
    }

    NodeType nodeType = nodeDef.getDeclaringNodeType();
    String childNodeName = nodeDef.getName();
    String abstractName = null;
    NodeTypeIterator it = manager.getPrimaryNodeTypes();
    while (it.hasNext() && abstractName == null) {
      NodeType nt = it.nextNodeType();
      if (nt.isAbstract()) {
        abstractName = nt.getName();
      }
    }
    if (abstractName == null) {
      throw new NotExecutableException("No abstract type found.");
    }

    assertFalse(
        "NodeType.canAddChildNode(String childNodeName, String nodeTypeName) "
            + "must return false if nodeTypeName represents an abstract node type.",
        nodeType.canAddChildNode(childNodeName, abstractName));
  }
 @Override
 public String[] getMixinTypes(boolean allowAbstract) throws RemoteException {
   ArrayList<String> list = new ArrayList();
   try {
     NodeTypeManager mgr = session().getWorkspace().getNodeTypeManager();
     NodeTypeIterator it = mgr.getMixinNodeTypes();
     while (it.hasNext()) {
       NodeType nodeType = it.nextNodeType();
       if (!nodeType.isAbstract() || allowAbstract) {
         list.add(nodeType.getName());
       }
     }
     String[] res = new String[list.size()];
     list.toArray(res);
     return res;
   } catch (RepositoryException e) {
     throw new RemoteException(e.getMessage());
   }
 }
Exemple #6
0
  /**
   * Get allowed folder types in current path.
   *
   * @param currentNode
   * @param currentDrive
   * @return List<String> of node types
   * @throws Exception
   */
  public static List<String> getAllowedFolderTypesInCurrentPath(
      Node currentNode, DriveData currentDrive) throws Exception {
    List<String> allowedTypes = new ArrayList<String>();
    NodeTypeImpl currentNodeType = (NodeTypeImpl) currentNode.getPrimaryNodeType();
    String[] arrFoldertypes = currentDrive.getAllowCreateFolders().split(",");
    NodeTypeManager ntManager = currentNode.getSession().getWorkspace().getNodeTypeManager();

    for (String strFolderType : arrFoldertypes) {
      if (strFolderType.isEmpty()) continue;
      NodeType folderType = ntManager.getNodeType(strFolderType);
      if ((currentNodeType)
          .isChildNodePrimaryTypeAllowed(
              Constants.JCR_ANY_NAME, ((NodeTypeImpl) folderType).getQName())) {
        allowedTypes.add(strFolderType);
      }
    }

    return allowedTypes;
  }
  @Override
  public Collection<JcrNodeType> nodeTypes() throws RemoteException {
    ArrayList<JcrNodeType> list = new ArrayList();
    try {
      NodeTypeManager mgr = session().getWorkspace().getNodeTypeManager();

      NodeTypeIterator it = mgr.getAllNodeTypes();
      while (it.hasNext()) {
        NodeType type = it.nextNodeType();
        JcrNodeType jcrType = new JcrNodeType();
        jcrType.setName(type.getName());
        jcrType.setAbstract(type.isAbstract());
        jcrType.setPrimary(!type.isMixin());
        jcrType.setMixin(type.isMixin());
        list.add(jcrType);
      }
    } catch (Exception e) {
      throw new RemoteException(e.getMessage());
    }
    return list;
  }
 /**
  * Create a new JCR node definition from the given <code>QNodeDefinition</code>.
  *
  * @param qNd A node definition.
  * @return The corresponding JCR node definition.
  * @throws RepositoryException if an error occurs.
  */
 public NodeDefinition create(QNodeDefinition qNd) throws RepositoryException {
   NodeDefinitionTemplate nt = ntMgr.createNodeDefinitionTemplate();
   nt.setName(getJCRName(qNd.getName()));
   nt.setAutoCreated(qNd.isAutoCreated());
   nt.setMandatory(qNd.isMandatory());
   nt.setOnParentVersion(qNd.getOnParentVersion());
   nt.setProtected(qNd.isProtected());
   nt.setSameNameSiblings(qNd.allowsSameNameSiblings());
   nt.setDefaultPrimaryTypeName(getJCRName(qNd.getDefaultPrimaryType()));
   nt.setRequiredPrimaryTypeNames(getJCRNames(qNd.getRequiredPrimaryTypes()));
   return nt;
 }
 /**
  * Create a new JCR property definition from the given <code>QPropertyDefinition</code>.
  *
  * @param qPd A SPI property definition.
  * @return the corresponding JCR property definition.
  * @throws RepositoryException if an error occurs.
  */
 public PropertyDefinition create(QPropertyDefinition qPd) throws RepositoryException {
   PropertyDefinitionTemplate pt = ntMgr.createPropertyDefinitionTemplate();
   pt.setName(getJCRName(qPd.getName()));
   pt.setAutoCreated(qPd.isAutoCreated());
   pt.setMandatory(qPd.isMandatory());
   pt.setOnParentVersion(qPd.getOnParentVersion());
   pt.setProtected(qPd.isProtected());
   pt.setRequiredType(qPd.getRequiredType());
   pt.setMultiple(qPd.isMultiple());
   pt.setFullTextSearchable(qPd.isFullTextSearchable());
   pt.setValueConstraints(
       createValueConstraints(qPd.getRequiredType(), qPd.getValueConstraints()));
   pt.setAvailableQueryOperators(qPd.getAvailableQueryOperators());
   pt.setQueryOrderable(qPd.isQueryOrderable());
   pt.setDefaultValues(createValues(qPd.getDefaultValues()));
   return pt;
 }
 /**
  * Create a new JCR node type definition from the given <code>QNodeTypeDefinition</code>.
  *
  * @param qNtd A SPI node type definition.
  * @return the corresponding JCR node type definition.
  * @throws RepositoryException if an error occurs.
  */
 @SuppressWarnings("unchecked")
 public NodeTypeDefinition create(QNodeTypeDefinition qNtd) throws RepositoryException {
   NodeTypeTemplate nt = ntMgr.createNodeTypeTemplate();
   nt.setName(getJCRName(qNtd.getName()));
   nt.setDeclaredSuperTypeNames(getJCRNames(qNtd.getSupertypes()));
   nt.setAbstract(qNtd.isAbstract());
   nt.setMixin(qNtd.isMixin());
   nt.setOrderableChildNodes(qNtd.hasOrderableChildNodes());
   nt.setPrimaryItemName(getJCRName(qNtd.getPrimaryItemName()));
   nt.setQueryable(qNtd.isQueryable());
   List nodeDefs = nt.getNodeDefinitionTemplates();
   for (QNodeDefinition qNd : qNtd.getChildNodeDefs()) {
     nodeDefs.add(create(qNd));
   }
   List propDefs = nt.getPropertyDefinitionTemplates();
   for (QPropertyDefinition qPd : qNtd.getPropertyDefs()) {
     propDefs.add(create(qPd));
   }
   return nt;
 }
  /**
   * Tests if <code>NodeType.canAddChildNode(String childNodeName, String nodeTypeName)</code>
   * returns false if <code>nodeTypeName</code> represents a mixin.
   */
  public void testCanAddMixinType() throws NotExecutableException, RepositoryException {

    NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, false, false, false);

    if (nodeDef == null) {
      throw new NotExecutableException("No testable node type found.");
    }

    NodeType nodeType = nodeDef.getDeclaringNodeType();
    String childNodeName = nodeDef.getName();
    String mixinName;
    NodeTypeIterator it = manager.getMixinNodeTypes();
    if (it.hasNext()) {
      mixinName = it.nextNodeType().getName();
    } else {
      throw new NotExecutableException("No mixin type found.");
    }

    assertFalse(
        "NodeType.canAddChildNode(String childNodeName, String nodeTypeName) "
            + "must return false if nodeTypeName represents a mixin type.",
        nodeType.canAddChildNode(childNodeName, mixinName));
  }
  @Test
  public void shouldAddNodeTypesAndNamespaces() throws Exception {
    File file = new File("src/test/resources/config/configRepository.xml");
    assertThat(file.exists(), is(true));
    assertThat(file.canRead(), is(true));
    assertThat(file.isFile(), is(true));

    configuration.loadFrom("src/test/resources/config/configRepository.xml");
    // Verify that the configration was loaded correctly ...
    assertThat(configuration.repository("Car Repository").getSource(), is("Cars"));
    // ModeShapeConfiguration.ConfigurationDefinition content1 =
    // configuration.getConfigurationDefinition();
    // Subgraph subgraph1 = content1.graph().getSubgraphOfDepth(6).at("/");

    // Load the node types from the CND file, and save the configuration ...
    InputStream nodeTypes = getClass().getResourceAsStream("/tck/tck_test_types.cnd");
    configuration.repository("Car Repository").addNodeTypes(nodeTypes);
    configuration.save();
    // ModeShapeConfiguration.ConfigurationDefinition content2 =
    // configuration.getConfigurationDefinition();
    // Subgraph subgraph2 = content2.graph().getSubgraphOfDepth(6).at("/");

    // Verify there were no problems loading the CND file ...
    assertThat(configuration.getProblems().isEmpty(), is(true));
    assertThat(
        configuration
            .getConfigurationDefinition()
            .getContext()
            .getNamespaceRegistry()
            .isRegisteredNamespaceUri("http://www.modeshape.org/test/1.0"),
        is(true));

    // Verify that the graph has been updated correctly ...
    ModeShapeConfiguration.ConfigurationDefinition content =
        configuration.getConfigurationDefinition();
    Subgraph subgraph = content.graph().getSubgraphOfDepth(6).at("/");

    assertThat(
        subgraph.getNode("/mode:repositories").getChildren(), hasChild(segment("Car Repository")));
    assertThat(subgraph.getNode("/mode:repositories/Car Repository"), is(notNullValue()));
    assertThat(
        subgraph.getNode("/mode:repositories/Car Repository"),
        hasProperty(ModeShapeLexicon.SOURCE_NAME, "Cars"));
    assertThat(
        subgraph.getNode("/mode:repositories/Car Repository").getChildren(),
        hasChild(segment("mode:options")));
    assertThat(
        subgraph.getNode("/mode:repositories/Car Repository/jcr:nodeTypes"), is(notNullValue()));
    // for (Location child : subgraph.getNode("/mode:repositories/Car
    // Repository/mode:nodeTypes").getChildren()) {
    // System.out.println(child.getPath().getLastSegment().getString(context().getNamespaceRegistry()));
    // }
    assertThat(
        subgraph.getNode("/mode:repositories/Car Repository/jcr:nodeTypes").getChildren(),
        hasChildren(
            segment("modetest:noSameNameSibs"),
            segment("modetest:referenceableUnstructured"),
            segment("modetest:nodeWithMandatoryProperty"),
            segment("modetest:nodeWithMandatoryChild"),
            segment("modetest:unorderableUnstructured")));
    assertThat(
        subgraph.getNode("/mode:repositories/Car Repository/mode:namespaces"), is(notNullValue()));

    // Check that the namespace in the CND file was persisted correctly ...
    assertThat(
        subgraph.getNode("/mode:repositories/Car Repository/mode:namespaces").getChildren(),
        hasChild(segment("modetest")));
    assertThat(
        subgraph.getNode("/mode:repositories/Car Repository/mode:namespaces/modetest"),
        hasProperty(ModeShapeLexicon.URI, "http://www.modeshape.org/test/1.0"));

    // Initialize IDTrust and a policy file (which defines the "modeshape-jcr" login config name)
    JaasTestUtil.initJaas("security/jaas.conf.xml");

    // Create and start the engine ...
    engine = configuration.build();
    engine.start();
    Repository repository = engine.getRepository("Car Repository");
    assertThat(repository, is(notNullValue()));

    // Create a session, authenticating using one of the usernames defined by our JAAS policy
    // file(s) ...
    Session session = null;
    try {
      session = repository.login(new SimpleCredentials("superuser", "superuser".toCharArray()));

      // Check that the namespace showed up ...
      assertThat(session.getNamespacePrefix("http://www.modeshape.org/test/1.0"), is("modetest"));

      // Check that some of the node types showed up ...
      NodeTypeManager ntm = session.getWorkspace().getNodeTypeManager();
      assertThat(
          ntm.getNodeType("modetest:noSameNameSibs"), is(notNullValue())); // throws exception
      assertThat(
          ntm.getNodeType("modetest:referenceableUnstructured"),
          is(notNullValue())); // throws exception
      assertThat(
          ntm.getNodeType("modetest:nodeWithMandatoryProperty"),
          is(notNullValue())); // throws exception
      assertThat(
          ntm.getNodeType("modetest:nodeWithMandatoryChild"),
          is(notNullValue())); // throws exception
      assertThat(
          ntm.getNodeType("modetest:unorderableUnstructured"),
          is(notNullValue())); // throws exception
    } finally {
      if (session != null) session.logout();
    }
  }
  @Test
  public void testAggregateIndex()
      throws IOException, RepositoryException, InterruptedException, ClientPoolException,
          StorageClientException, AccessDeniedException, ClassNotFoundException {
    RepositoryBase repositoryBase = RepositoryBaseTest.getRepositoryBase();
    Repository repository = repositoryBase.getRepository();
    Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
    NodeTypeManager ntm = session.getWorkspace().getNodeTypeManager();

    NodeTypeTemplate ntt = ntm.createNodeTypeTemplate();
    ntt.setDeclaredSuperTypeNames(new String[] {"nt:unstructured"});
    ntt.setName("sakai:user-home");

    ntm.registerNodeType(ntt, true);

    Node rootNode = session.getRootNode();
    Node homeNode = rootNode.addNode("iebhome", "sakai:user-home");
    homeNode.setProperty("sling:resourceType", "sakai/user-home");
    Node publicNode = homeNode.addNode("public", "nt:unstructured");
    Node publicSub = publicNode.addNode("sub", "nt:unstructured");
    publicSub.setProperty("test", "The brown fox");
    Node publicSub2 = publicNode.addNode("sub2", "nt:unstructured");
    publicSub2.setProperty("test", "The brown fox");
    Node childFileNode = publicSub.addNode("childNode", "nt:file");
    Node resourceNode = childFileNode.addNode("jcr:content", "nt:resource");
    ValueFactory valueFactory = session.getValueFactory();
    InputStream fileStream = new ByteArrayInputStream(FILE_CONTENT.getBytes("UTF-8"));
    Binary binary = valueFactory.createBinary(fileStream);
    resourceNode.setProperty("jcr:data", binary);
    session.save();
    session.logout();

    Thread.sleep(100);

    session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
    Node n = session.getNode("/iebhome/public/sub");
    Assert.assertEquals("The brown fox", n.getProperty("test").getString());

    QueryManager qm = session.getWorkspace().getQueryManager();
    {
      Query q =
          qm.createQuery(
              "//*[@sling:resourceType = 'sakai/user-home' and jcr:contains(.,'brown')]",
              Query.XPATH);
      QueryResult qr = q.execute();
      NodeIterator nodeIterator = qr.getNodes();
      Assert.assertTrue(nodeIterator.hasNext());
      Assert.assertEquals("/iebhome", nodeIterator.nextNode().getPath());
      Assert.assertFalse(nodeIterator.hasNext());
    }
    {
      Query q = qm.createQuery("//*[@sling:resourceType = 'sakai/user-home']", Query.XPATH);
      QueryResult qr = q.execute();
      NodeIterator nodeIterator = qr.getNodes();
      Assert.assertTrue(nodeIterator.hasNext());
      Assert.assertEquals("/iebhome", nodeIterator.nextNode().getPath());
      Assert.assertFalse(nodeIterator.hasNext());
    }
    {
      Query q = qm.createQuery("//*[jcr:contains(.,'brown')]", Query.XPATH);
      QueryResult qr = q.execute();
      NodeIterator nodeIterator = qr.getNodes();
      List<String> paths = new ArrayList<String>();
      while (nodeIterator.hasNext()) {
        paths.add(nodeIterator.nextNode().getPath());
      }

      Assert.assertTrue(paths.contains("/iebhome"));
      Assert.assertTrue(paths.contains("/iebhome/public/sub"));
      Assert.assertTrue(paths.contains("/iebhome/public/sub2"));
    }
    session.logout();
  }
Exemple #14
0
 /**
  * Map query types.
  *
  * @param queryCriteria the query criteria
  * @param queryBuilder the query builder
  * @throws Exception the exception
  */
 private void mapQueryTypes(final QueryCriteria queryCriteria, final SQLQueryBuilder queryBuilder)
     throws Exception {
   queryBuilder.selectTypes(null);
   // Searh on nt:base
   queryBuilder.fromNodeTypes(queryCriteria.getNodeTypes());
   ManageableRepository currentRepository = repositoryService.getCurrentRepository();
   NodeTypeManager manager = currentRepository.getNodeTypeManager();
   // Query all documents for specific content types
   String[] contentTypes = queryCriteria.getContentTypes();
   if ((contentTypes != null && contentTypes.length > 0 && queryCriteria.getKeyword() == null)
       || queryCriteria.isSearchWebpage()) {
     mapQuerySpecificNodeTypes(queryCriteria, queryBuilder, manager);
     return;
   }
   List<String> selectedNodeTypes =
       (contentTypes != null && contentTypes.length > 0)
           ? Arrays.asList(contentTypes)
           : templateService.getDocumentTemplates();
   queryBuilder.openGroup(LOGICAL.AND);
   if (selectedNodeTypes.contains("nt:file")) {
     queryBuilder.equal("jcr:primaryType", "nt:resource", LOGICAL.NULL);
   } else {
     // searching only document, not file. In this case, search nt:resource with
     // exo:webContentChild mixin
     queryBuilder.openGroup(null);
     queryBuilder.equal(
         NodetypeConstant.JCR_PRIMARY_TYPE, NodetypeConstant.NT_RESOURCE, LOGICAL.NULL);
     queryBuilder.equal(
         NodetypeConstant.JCR_MIXIN_TYPES, NodetypeConstant.EXO_WEBCONTENT_CHILD, LOGICAL.AND);
     queryBuilder.closeGroup();
   }
   // query on exo:rss-enable nodetypes for title, summary field
   queryBuilder.equal("jcr:mixinTypes", "exo:rss-enable", LOGICAL.OR);
   for (String type : selectedNodeTypes) {
     NodeType nodetype = manager.getNodeType(type);
     if (nodetype.isMixin()) {
       if (selectedNodeTypes.contains("nt:file")
           || !NodetypeConstant.EXO_CSS_FILE.equals(type)
               && !NodetypeConstant.EXO_JS_FILE.equals(type)
               && !NodetypeConstant.EXO_HTML_FILE.equals(type)) {
         queryBuilder.like("jcr:mixinTypes", type, LOGICAL.OR);
       } else {
         // searching only document, not file. In this case, search nt:resource with
         // exo:webContentChild mixin
         queryBuilder.openGroup(LOGICAL.OR);
         queryBuilder.equal(NodetypeConstant.JCR_MIXIN_TYPES, type, LOGICAL.NULL);
         queryBuilder.equal(
             NodetypeConstant.JCR_MIXIN_TYPES, NodetypeConstant.EXO_WEBCONTENT_CHILD, LOGICAL.AND);
         queryBuilder.closeGroup();
       }
     } else {
       queryBuilder.equal("jcr:primaryType", type, LOGICAL.OR);
     }
   }
   queryBuilder.closeGroup();
   // unwanted document types: exo:cssFile, exo:jsFile
   if (excludeMimeTypes.size() < 1) return;
   queryBuilder.openGroup(LOGICAL.AND_NOT);
   String[] mimetypes = excludeMimeTypes.toArray(new String[] {});
   queryBuilder.equal("jcr:mimeType", mimetypes[0], LOGICAL.NULL);
   for (int i = 1; i < mimetypes.length; i++) {
     queryBuilder.equal("jcr:mimeType", mimetypes[i], LOGICAL.OR);
   }
   queryBuilder.closeGroup();
   // Unwanted document by mixin nodetypes
   queryBuilder.openGroup(LOGICAL.AND_NOT);
   queryBuilder.like("jcr:mixinTypes", "exo:cssFile", LOGICAL.NULL);
   queryBuilder.like("jcr:mixinTypes", "exo:jsFile", LOGICAL.OR);
   queryBuilder.closeGroup();
 }