protected String getResourceTypeForNode()

in src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResource.java [120:140]


    protected String getResourceTypeForNode(final @NotNull Node node) throws RepositoryException {
        String result = null;

        Property property = NodeUtil.getPropertyOrNull(node, JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY);
        if (property != null) {
            result = property.getString();
        }

        if (result == null || result.length() == 0) {
            // Do not load the relatively expensive NodeType object unless necessary. See OAK-2441 for the reason why it
            // cannot only use getProperty here.
            property = NodeUtil.getPropertyOrNull(node, Property.JCR_PRIMARY_TYPE);
            if (property != null) {
                result = property.getString();
            } else {
                result = node.getPrimaryNodeType().getName();
            }
        }

        return result;
    }