Exemple #1
0
  @Override
  public IAfSysObject moveTo(String specific, String newName) throws AfException {

    if (isNew()) {
      throw new AfException("this object is new, you can not move it");
    }

    NodeService nodeService = ServiceHelper.getNodeService(afSession);

    NodeRef newParent = getSpecifiedNode(specific);
    if (newParent == null || !(nodeService.exists(newParent))) {
      throw new AfException("the folder " + specific + " you specified does not exist");
    }

    IAfType folderType = AFCHelper.getNodeType(afSession, newParent);
    if (!(folderType.isSubTypeOf("cm:folder") || folderType.getName().equals("cm:folder"))) {
      // parent is a doc
      throw new AfException("you can not move object into a document");
    }

    String objName = (newName == null) ? getObjectName() : newName;
    QName nodeName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, objName);
    ChildAssociationRef child = nodeService.moveNode(nodeRef, newParent, getAssType(), nodeName);

    IAfSysObject doc = (IAfSysObject) afSession.getObject(new AfID(child.getChildRef().getId()));

    doc.setObjectName(objName);
    doc.save();

    return doc;
  }
  public NodeRef validateNode(NodeRef nodeRef) {
    if (!nodeService.exists(nodeRef)) {
      throw new EntityNotFoundException(nodeRef.getId());
    }

    return nodeRef;
  }
  @Test
  public void cloud928() {
    final NodeRef node =
        testNodes.createNodeWithTextContent(
            userHome,
            "CLOUD-928 Test Node",
            ContentModel.TYPE_CONTENT,
            user1.getUsername(),
            "Quick Share Test Node Content");

    QuickShareDTO dto = share(node, user1.getUsername());

    attributeService.removeAttribute(QuickShareServiceImpl.ATTR_KEY_SHAREDIDS_ROOT, dto.getId());

    AuthenticationUtil.runAs(
        new RunAsWork<Object>() {

          @Override
          public Object doWork() throws Exception {
            nodeService.deleteNode(node);
            return null;
          }
        },
        user1.getUsername());

    AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
    Assert.assertFalse(nodeService.exists(node));
  }
Exemple #4
0
  @Override
  public IAfSysObject copyTo(String specific, String newName) throws AfException {
    if (isNew()) {
      throw new AfException("this object is new, you can not do copy action");
    }

    NodeService nodeService = ServiceHelper.getNodeService(afSession);
    NodeRef parent = getSpecifiedNode(specific);

    if (parent == null || !nodeService.exists(parent)) {
      throw new AfException("the folder " + specific + " you specified not exist");
    }

    IAfType folderType = AFCHelper.getNodeType(afSession, parent);
    if (!(folderType.isSubTypeOf("cm:folder") || folderType.getName().equals("cm:folder"))) {
      // parent is a doc
      throw new AfException("you can not copy object into a document");
    }

    CopyService copyService = ServiceHelper.getCopyService(afSession);

    String objName = (newName == null) ? getObjectName() : newName;
    QName nodeName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, objName);
    NodeRef ref = copyService.copyAndRename(nodeRef, parent, getAssType(), nodeName, true);

    IAfSysObject object = (IAfSysObject) afSession.getObject(new AfID(ref.getId()));

    object.setObjectName(objName);
    object.save();

    return object;
  }
  public boolean nodeMatches(NodeRef nodeRef, Set<QName> expectedTypes, Set<QName> excludedTypes) {
    if (!nodeService.exists(nodeRef)) {
      throw new EntityNotFoundException(nodeRef.getId());
    }

    QName type = nodeService.getType(nodeRef);

    Set<QName> allExpectedTypes = new HashSet<QName>();
    if (expectedTypes != null) {
      for (QName expectedType : expectedTypes) {
        allExpectedTypes.addAll(dictionaryService.getSubTypes(expectedType, true));
      }
    }

    Set<QName> allExcludedTypes = new HashSet<QName>();
    if (excludedTypes != null) {
      for (QName excludedType : excludedTypes) {
        allExcludedTypes.addAll(dictionaryService.getSubTypes(excludedType, true));
      }
    }

    boolean inExpected = allExpectedTypes.contains(type);
    boolean excluded = allExcludedTypes.contains(type);
    return (inExpected && !excluded);
  }
  /**
   * @param storeValue
   * @param rootPath
   * @param context
   * @param nodeService
   * @param searchService
   * @param namespaceService
   * @param tenantService
   * @param m_transactionService
   */
  private void initializeRootNode(
      String storeValue,
      String rootPath,
      WebApplicationContext context,
      NodeService nodeService,
      SearchService searchService,
      NamespaceService namespaceService,
      TenantService tenantService,
      TransactionService m_transactionService) {

    // Use the system user as the authenticated context for the filesystem initialization

    AuthenticationContext authComponent =
        (AuthenticationContext) context.getBean("authenticationContext");
    authComponent.setSystemUserAsCurrentUser();

    // Wrap the initialization in a transaction

    UserTransaction tx = m_transactionService.getUserTransaction(true);

    try {
      // Start the transaction

      if (tx != null) tx.begin();

      StoreRef storeRef = new StoreRef(storeValue);

      if (nodeService.exists(storeRef) == false) {
        throw new RuntimeException("No store for path: " + storeRef);
      }

      NodeRef storeRootNodeRef = nodeService.getRootNode(storeRef);

      List<NodeRef> nodeRefs =
          searchService.selectNodes(storeRootNodeRef, rootPath, null, namespaceService, false);

      if (nodeRefs.size() > 1) {
        throw new RuntimeException(
            "Multiple possible children for : \n"
                + "   path: "
                + rootPath
                + "\n"
                + "   results: "
                + nodeRefs);
      } else if (nodeRefs.size() == 0) {
        throw new RuntimeException("Node is not found for : \n" + "   root path: " + rootPath);
      }

      defaultRootNode = nodeRefs.get(0);

      // Commit the transaction
      if (tx != null) tx.commit();
    } catch (Exception ex) {
      logger.error(ex);
    } finally {
      // Clear the current system user

      authComponent.clearCurrentSecurityContext();
    }
  }
    public NodeRef doWork() throws Exception {
      // Get company home / root for the tenant domain
      // Do this as the System user in case the tenant user does not have permission

      // Connect to the repo and ensure that the store exists
      if (!nodeService.exists(storeRef)) {
        throw new AlfrescoRuntimeException(
            "Store not created prior to application startup: " + storeRef);
      }
      NodeRef storeRootNodeRef = nodeService.getRootNode(storeRef);

      // Find the root node for this device
      List<NodeRef> nodeRefs =
          searchService.selectNodes(storeRootNodeRef, rootPath, null, namespaceService, false);

      if (nodeRefs.size() > 1) {
        throw new AlfrescoRuntimeException(
            "Multiple possible roots for device: \n"
                + "   root path: "
                + rootPath
                + "\n"
                + "   results: "
                + nodeRefs);
      } else if (nodeRefs.size() == 0) {
        // nothing found
        throw new AlfrescoRuntimeException(
            "No root found for device: \n" + "   root path: " + rootPath);
      } else {
        // we found a node
        rootNodeRef = nodeRefs.get(0);
      }

      return rootNodeRef;
    }
 /**
  * Returns human readable path for node. To improve performance may return simple toString()
  * method of the path.
  *
  * @param nodeRef
  * @return Human readable path for node
  */
 private String getNodePath(NodeRef nodeRef) {
   String result = null;
   if (nodeService.exists(nodeRef)) {
     Path path = nodeService.getPath(nodeRef);
     return path.toPrefixString(namespacePrefixResolver);
   }
   return result;
 }
 @Override
 public Set<NodeRef> findFrom(NodeRef thisNode) {
   Set<NodeRef> result = Collections.emptySet();
   if (nodeService.exists(thisNode)
       && (WebSiteModel.TYPE_INDEX_PAGE.equals(nodeService.getType(thisNode)))) {
     result = new HashSet<NodeRef>();
     result.add(nodeService.getPrimaryParent(thisNode).getParentRef());
   }
   return result;
 }
Exemple #10
0
  @Override
  public void unLink(String specific) throws AfException {

    if (isNew()) {
      throw new AfException("this object is new, you can not unlink it");
    }

    NodeService nodeService = ServiceHelper.getNodeService(afSession);

    NodeRef parent = getSpecifiedNode(specific);
    if (parent == null || !(nodeService.exists(parent))) {
      return;
    }

    List<ChildAssociationRef> parents = nodeService.getParentAssocs(nodeRef);

    for (ChildAssociationRef ref : parents) {

      if (ref.getParentRef().getId().equals(parent.getId())) {

        if (!ref.isPrimary()) {
          // not primary,delete
          nodeService.removeChildAssociation(ref);
          return;
        } else {
          // primary, it's not a good coding.f**k it!
          String rootId = AFCHelper.getNodeRefByPath(afSession, "/").getId();
          if (parents.size() <= 1) {
            if (rootId.equals(ref.getParentRef().getId())) {
              return;
            } else {
              moveTo("/", null);
              nodeService.removeChildAssociation(ref);
              return;
            }

          } else {
            // set the 2nd as the primary.moveTo
            for (ChildAssociationRef anotherP : parents) {
              if (!anotherP.equals(ref)) {
                String scndPId = anotherP.getParentRef().getId();

                nodeService.removeChildAssociation(anotherP);

                moveTo(scndPId, null);
                nodeService.removeChildAssociation(ref);
                return;
              }
            }
          }
        }
      }
    }
  }
  /*
   * Extract favourite nodes of the given type from the comma-separated list in "nodes".
   */
  private Map<PersonFavouriteKey, PersonFavourite> extractFavouriteNodes(
      String userName, Type type, String nodes) {
    PrefKeys prefKeys = getPrefKeys(type);
    Map<PersonFavouriteKey, PersonFavourite> favouriteNodes =
        new HashMap<PersonFavouriteKey, PersonFavourite>();

    StringTokenizer st = new StringTokenizer(nodes, ",");
    while (st.hasMoreTokens()) {
      String nodeRefStr = st.nextToken();
      nodeRefStr = nodeRefStr.trim();
      if (!NodeRef.isNodeRef((String) nodeRefStr)) {
        continue;
      }

      NodeRef nodeRef = new NodeRef((String) nodeRefStr);

      if (!nodeService.exists(nodeRef)) {
        continue;
      }

      if (permissionService.hasPermission(nodeRef, PermissionService.READ_PROPERTIES)
          == AccessStatus.DENIED) {
        continue;
      }

      // get createdAt for this favourited node
      // use ISO8601
      StringBuilder builder = new StringBuilder(prefKeys.getAlfrescoPrefKey());
      builder.append(nodeRef.toString());
      builder.append(".createdAt");
      String prefKey = builder.toString();
      String createdAtStr = (String) preferenceService.getPreference(userName, prefKey);
      Date createdAt = (createdAtStr != null ? ISO8601DateFormat.parse(createdAtStr) : null);

      String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);

      PersonFavourite personFavourite =
          new PersonFavourite(userName, nodeRef, type, name, createdAt);
      PersonFavouriteKey key = personFavourite.getKey();
      favouriteNodes.put(key, personFavourite);
    }

    return favouriteNodes;
  }
  // note: active or inactive
  public List<NodeRef> getModelRefs() {
    List<NodeRef> modelRefs = new ArrayList<NodeRef>();

    for (RepositoryLocation repositoryLocation : this.repositoryModelsLocations) {
      StoreRef storeRef = repositoryLocation.getStoreRef();

      if (!nodeService.exists(storeRef)) {
        logger.info("StoreRef '" + storeRef + "' does not exist");
        continue; // skip this location
      }

      if (repositoryLocation.getQueryLanguage().equals(RepositoryLocation.LANGUAGE_PATH)) {
        List<NodeRef> nodeRefs =
            getNodes(storeRef, repositoryLocation, ContentModel.TYPE_DICTIONARY_MODEL);

        if (nodeRefs.size() > 0) {
          for (NodeRef dictionaryModel : nodeRefs) {
            try {
              // Ignore if the node is a working copy or archived
              if (!(nodeService.hasAspect(dictionaryModel, ContentModel.ASPECT_WORKING_COPY)
                  || nodeService.hasAspect(dictionaryModel, ContentModel.ASPECT_ARCHIVED))) {
                modelRefs.add(dictionaryModel);
              }
            } catch (InvalidNodeRefException inre) {
              // ignore - model no longer exists
              if (logger.isDebugEnabled()) {
                logger.debug("getModelRefs: " + inre + " (assume concurrently deleted)");
              }

              continue;
            }
          }
        }
      } else {
        logger.error(
            "Unsupported query language for models location: "
                + repositoryLocation.getQueryLanguage());
      }
    }

    return modelRefs;
  }
  protected List<NodeRef> getNodes(
      StoreRef storeRef, RepositoryLocation repositoryLocation, QName nodeType) {
    List<NodeRef> nodeRefs = new ArrayList<NodeRef>();

    NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
    if (nodeService.exists(rootNodeRef) == false) {
      // Tenant is deleted. But cache refresh was called to inform another cluster nodes
      // Should be reworked when MNT-11638 will be implemented
      return nodeRefs;
    }

    if (repositoryLocation instanceof DynamicCreateRepositoryLocation) {
      ((DynamicCreateRepositoryLocation) repositoryLocation).checkAndCreate(rootNodeRef);
    }

    String[] pathElements = repositoryLocation.getPathElements();

    NodeRef folderNodeRef = rootNodeRef;
    if (pathElements.length > 0) {
      folderNodeRef = resolveQNamePath(rootNodeRef, pathElements);
    }

    if (folderNodeRef != null) {
      Set<QName> types = new HashSet<QName>(1);
      types.add(nodeType);
      List<ChildAssociationRef> childAssocRefs = nodeService.getChildAssocs(folderNodeRef, types);

      if (childAssocRefs.size() > 0) {
        nodeRefs = new ArrayList<NodeRef>(childAssocRefs.size());
        for (ChildAssociationRef childAssocRef : childAssocRefs) {
          nodeRefs.add(childAssocRef.getChildRef());
        }
      }
    }

    return nodeRefs;
  }
  public void initMessages() {
    if (this.repositoryMessagesLocations != null) {
      // Register the messages found in the repository
      for (RepositoryLocation repositoryLocation : this.repositoryMessagesLocations) {
        StoreRef storeRef = repositoryLocation.getStoreRef();

        if (!nodeService.exists(storeRef)) {
          logger.info("StoreRef '" + storeRef + "' does not exist");
          continue; // skip this location
        }

        if (repositoryLocation.getQueryLanguage().equals(RepositoryLocation.LANGUAGE_PATH)) {
          List<NodeRef> nodeRefs =
              getNodes(storeRef, repositoryLocation, ContentModel.TYPE_CONTENT);

          if (nodeRefs.size() > 0) {
            List<String> resourceBundleBaseNames = new ArrayList<String>();

            for (NodeRef messageResource : nodeRefs) {
              String resourceName =
                  (String) nodeService.getProperty(messageResource, ContentModel.PROP_NAME);

              String bundleBaseName = messageService.getBaseBundleName(resourceName);

              if (!resourceBundleBaseNames.contains(bundleBaseName)) {
                resourceBundleBaseNames.add(bundleBaseName);
              }
            }
          }
        } else {
          logger.error(
              "Unsupported query language for messages location: "
                  + repositoryLocation.getQueryLanguage());
        }
      }
    }
  }
Exemple #15
0
  @SuppressWarnings("unchecked")
  @Override
  public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
    String reqContentAsString;
    try {
      reqContentAsString = req.getContent().getContent();
    } catch (IOException iox) {
      throw new WebScriptException(
          Status.STATUS_BAD_REQUEST, "Could not read content from req.", iox);
    }

    String actionName = null;
    List<NodeRef> targetNodeRefs = null;
    Map<String, Serializable> actionParams = new HashMap<String, Serializable>(3);

    try {
      JSONObject jsonObj = new JSONObject(new JSONTokener(reqContentAsString));

      // Get the action name
      if (jsonObj.has(PARAM_NAME) == true) {
        actionName = jsonObj.getString(PARAM_NAME);
      }

      // Get the target references
      if (jsonObj.has(PARAM_NODE_REF) == true) {
        NodeRef nodeRef = new NodeRef(jsonObj.getString(PARAM_NODE_REF));
        targetNodeRefs = new ArrayList<NodeRef>(1);
        targetNodeRefs.add(nodeRef);
      }
      if (jsonObj.has(PARAM_NODE_REFS) == true) {
        JSONArray jsonArray = jsonObj.getJSONArray(PARAM_NODE_REFS);
        if (jsonArray.length() != 0) {
          targetNodeRefs = new ArrayList<NodeRef>(jsonArray.length());
          for (int i = 0; i < jsonArray.length(); i++) {
            NodeRef nodeRef = new NodeRef(jsonArray.getString(i));
            targetNodeRefs.add(nodeRef);
          }
        }
      }

      // params are optional.
      if (jsonObj.has(PARAM_PARAMS)) {
        JSONObject paramsObj = jsonObj.getJSONObject(PARAM_PARAMS);
        for (Iterator iter = paramsObj.keys(); iter.hasNext(); ) {
          Object nextKey = iter.next();
          String nextKeyString = (String) nextKey;
          Object nextValue = paramsObj.get(nextKeyString);

          // Check for date values
          if (nextValue instanceof JSONObject) {
            if (((JSONObject) nextValue).has("iso8601") == true) {
              String dateStringValue = ((JSONObject) nextValue).getString("iso8601");
              nextValue = ISO8601DateFormat.parse(dateStringValue);
            }
          }

          actionParams.put(nextKeyString, (Serializable) nextValue);
        }
      }
    } catch (JSONException exception) {
      throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Unable to parse request JSON.");
    }

    // validate input: check for mandatory params.
    // Some RM actions can be posted without a nodeRef.
    if (actionName == null) {
      throw new WebScriptException(
          Status.STATUS_BAD_REQUEST, "A mandatory parameter has not been provided in URL");
    }

    // Check that all the nodes provided exist and build report string
    StringBuffer targetNodeRefsString = new StringBuffer(30);
    boolean firstTime = true;
    for (NodeRef targetNodeRef : targetNodeRefs) {
      if (nodeService.exists(targetNodeRef) == false) {
        throw new WebScriptException(
            Status.STATUS_NOT_FOUND,
            "The targetNode does not exist (" + targetNodeRef.toString() + ")");
      }

      // Build the string
      if (firstTime == true) {
        firstTime = false;
      } else {
        targetNodeRefsString.append(", ");
      }
      targetNodeRefsString.append(targetNodeRef.toString());
    }

    // Proceed to execute the specified action on the specified node.
    if (logger.isDebugEnabled()) {
      StringBuilder msg = new StringBuilder();
      msg.append("Executing Record Action ")
          .append(actionName)
          .append(", (")
          .append(targetNodeRefsString.toString())
          .append("), ")
          .append(actionParams);
      logger.debug(msg.toString());
    }

    Map<String, Object> model = new HashMap<String, Object>();
    if (targetNodeRefs.isEmpty()) {
      RecordsManagementActionResult result =
          this.rmActionService.executeRecordsManagementAction(actionName, actionParams);
      if (result.getValue() != null) {
        model.put("result", result.getValue().toString());
      }
    } else {
      Map<NodeRef, RecordsManagementActionResult> resultMap =
          this.rmActionService.executeRecordsManagementAction(
              targetNodeRefs, actionName, actionParams);
      Map<String, String> results = new HashMap<String, String>(resultMap.size());
      for (NodeRef nodeRef : resultMap.keySet()) {
        Object value = resultMap.get(nodeRef).getValue();
        if (value != null) {
          results.put(nodeRef.toString(), resultMap.get(nodeRef).getValue().toString());
        }
      }
      model.put("results", results);
    }

    model.put(
        "message",
        "Successfully queued action [" + actionName + "] on " + targetNodeRefsString.toString());

    return model;
  }
  /**
   * Return relative path between from and to references within export root
   *
   * @param fromRef from reference
   * @param toRef to reference
   * @return path
   */
  private Path createPath(NodeRef rootRef, NodeRef fromRef, NodeRef toRef) {
    // Check that item exists first
    if (!nodeService.exists(toRef)) {
      // return null path
      return null;
    }

    // Check whether item is the root node of the store
    // If so, always return absolute path
    if (toRef.equals(nodeService.getRootNode(toRef.getStoreRef()))) {
      return nodeService.getPath(toRef);
    }

    // construct relative path
    Path rootPath = createIndexedPath(rootRef, nodeService.getPath(rootRef));
    Path fromPath = createIndexedPath(fromRef, nodeService.getPath(fromRef));
    Path toPath = createIndexedPath(toRef, nodeService.getPath(toRef));
    Path relativePath = null;

    try {
      // Determine if 'to path' is a category
      // TODO: This needs to be resolved in a more appropriate manner - special support is
      //       required for categories.
      for (int i = 0; i < toPath.size(); i++) {
        Path.Element pathElement = toPath.get(i);
        if (pathElement.getPrefixedString(namespaceService).equals("cm:categoryRoot")) {
          Path.ChildAssocElement childPath = (Path.ChildAssocElement) pathElement;
          relativePath = new Path();
          relativePath.append(
              new Path.ChildAssocElement(
                  new ChildAssociationRef(null, null, null, childPath.getRef().getParentRef())));
          relativePath.append(toPath.subPath(i + 1, toPath.size() - 1));
          break;
        }
      }

      if (relativePath == null) {
        // Determine if from node is relative to export tree
        int i = 0;
        while (i < rootPath.size()
            && i < fromPath.size()
            && rootPath.get(i).equals(fromPath.get(i))) {
          i++;
        }
        if (i == rootPath.size()) {
          // Determine if to node is relative to export tree
          i = 0;
          while (i < rootPath.size()
              && i < toPath.size()
              && rootPath.get(i).equals(toPath.get(i))) {
            i++;
          }
          if (i == rootPath.size()) {
            // build relative path between from and to
            relativePath = new Path();
            for (int p = 0; p < fromPath.size() - i; p++) {
              relativePath.append(new Path.ParentElement());
            }
            if (i < toPath.size()) {
              relativePath.append(toPath.subPath(i, toPath.size() - 1));
            }
          }
        }
      }

      if (relativePath == null) {
        // default to absolute path
        relativePath = toPath;
      }
    } catch (Throwable e) {
      String msg =
          "Failed to determine relative path: root path="
              + rootPath
              + "; from path="
              + fromPath
              + "; to path="
              + toPath;
      throw new ExporterException(msg, e);
    }

    return relativePath;
  }
  /** Perform the actual repository access, checking for the existence of a valid transaction */
  private void onDictionaryInitInTxn() {
    if (AlfrescoTransactionSupport.getTransactionReadState() == TxnReadState.TXN_NONE) {
      throw new IllegalStateException(
          "The Repository-based dictionary initialization has to be done in the context of a transaction.");
    }

    long startTime = System.currentTimeMillis();

    if (logger.isTraceEnabled()) {
      String tenantDomain = tenantAdminService.getCurrentUserDomain();
      logger.trace(
          "onDictionaryInit: ["
              + Thread.currentThread()
              + "]"
              + (tenantDomain.equals(TenantService.DEFAULT_DOMAIN)
                  ? ""
                  : " (Tenant: " + tenantDomain + ")"));
    }

    Collection<QName> modelsBefore = dictionaryDAO.getModels(true); // note: re-entrant
    int modelsBeforeCnt = (modelsBefore != null ? modelsBefore.size() : 0);

    List<String> loadedModels = new ArrayList<String>();

    if (this.repositoryModelsLocations != null) {
      // URI to model map
      Map<String, DynamicModelInfo> modelMap = new HashMap<String, DynamicModelInfo>();

      if (logger.isTraceEnabled()) {
        logger.trace("onDictionaryInit: locations=" + this.repositoryModelsLocations);
      }

      // Register the models found in the repository

      for (RepositoryLocation repositoryLocation : this.repositoryModelsLocations) {
        StoreRef storeRef = repositoryLocation.getStoreRef();

        if (!nodeService.exists(storeRef)) {
          logger.info("StoreRef '" + storeRef + "' does not exist");
          continue; // skip this location
        }

        List<NodeRef> nodeRefs = null;

        if (repositoryLocation.getQueryLanguage().equals(RepositoryLocation.LANGUAGE_PATH)) {
          nodeRefs = getNodes(storeRef, repositoryLocation, ContentModel.TYPE_DICTIONARY_MODEL);

          if (nodeRefs.size() > 0) {
            for (NodeRef dictionaryModel : nodeRefs) {
              try {
                // Ignore if the node is a working copy or archived, or if its inactive
                if (!(nodeService.hasAspect(dictionaryModel, ContentModel.ASPECT_WORKING_COPY)
                    || nodeService.hasAspect(dictionaryModel, ContentModel.ASPECT_ARCHIVED))) {
                  Boolean isActive =
                      (Boolean)
                          nodeService.getProperty(dictionaryModel, ContentModel.PROP_MODEL_ACTIVE);

                  if ((isActive != null) && (isActive.booleanValue() == true)) {
                    M2Model model = createM2Model(dictionaryModel);
                    if (model != null) {
                      if (logger.isTraceEnabled()) {
                        logger.trace(
                            "onDictionaryInit: " + model.getName() + " (" + dictionaryModel + ")");
                      }

                      for (M2Namespace namespace : model.getNamespaces()) {
                        modelMap.put(
                            namespace.getUri(),
                            new DynamicModelInfo(repositoryLocation, model, dictionaryModel));
                      }
                    }
                  }
                }
              } catch (InvalidNodeRefException inre) {
                // ignore - model no longer exists
                if (logger.isDebugEnabled()) {
                  logger.debug("onDictionaryInit: " + inre + " (assume concurrently deleted)");
                }

                continue;
              }
            }
          }
        } else {
          logger.error(
              "Unsupported query language for models location: "
                  + repositoryLocation.getQueryLanguage());
        }
      }

      // Load the models ensuring that they are loaded in the correct order
      for (Map.Entry<String, DynamicModelInfo> entry : modelMap.entrySet()) {
        RepositoryLocation importedLocation = entry.getValue().location;
        M2Model importedModel = entry.getValue().model;
        loadModel(modelMap, loadedModels, importedModel, importedLocation);
        notifyDynamicModelLoaded(entry.getValue());
      }
    }

    Collection<QName> modelsAfter = dictionaryDAO.getModels(true);
    int modelsAfterCnt = (modelsAfter != null ? modelsAfter.size() : 0);

    if (logger.isDebugEnabled()) {
      String tenantDomain = tenantAdminService.getCurrentUserDomain();
      logger.debug(
          "Model count: before="
              + modelsBeforeCnt
              + ", load/update="
              + loadedModels.size()
              + ", after="
              + modelsAfterCnt
              + " in "
              + (System.currentTimeMillis() - startTime)
              + " msecs ["
              + Thread.currentThread()
              + "] "
              + (tenantDomain.equals(TenantService.DEFAULT_DOMAIN)
                  ? ""
                  : " (Tenant: " + tenantDomain + ")"));
    }
  }
 @Override
 public boolean accept(NodeRef thisNode) {
   return (nodeService.exists(thisNode));
 }