org.apache.jackrabbit.util.Text.getNamespacePrefix()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中org.apache.jackrabbit.util.Text.getNamespacePrefix()方法的一些代码示例,展示了Text.getNamespacePrefix()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Text.getNamespacePrefix()方法的具体详情如下:
包路径:org.apache.jackrabbit.util.Text
类名称:Text
方法名:getNamespacePrefix

Text.getNamespacePrefix介绍

[英]Returns the namespace prefix of the given qname. If the prefix is missing, an empty string is returned. Please note, that this method does not validate the name or prefix.

The qname has the format: qname := [prefix ':'] local;
[中]返回给定qname的命名空间前缀。如果缺少前缀,则返回空字符串。请注意,此方法不会验证名称或前缀。
qname的格式为:qname:=[前缀]:']local;

代码示例

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

private static boolean isRestrictionProperty(String propertyName) {
    return !AccessControlConstants.ACE_PROPERTY_NAMES.contains(propertyName) &&
        !NamespaceRegistry.PREFIX_JCR.equals(Text.getNamespacePrefix(propertyName));
  }
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-core

/**
 * Returns {@code false} if the specified attribute name doesn't have
 * a 'jcr' or 'rep' namespace prefix; {@code true} otherwise. This is
 * a lazy evaluation in order to avoid testing the defining node type of
 * the associated jcr property.
 *
 * @param attributeName The attribute name.
 * @return {@code true} if the specified property name doesn't seem
 *         to represent repository internal information.
 */
static  boolean isInfoAttribute(String attributeName) {
  String prefix = Text.getNamespacePrefix(attributeName);
  return !RESERVED_PREFIXES.contains(prefix);
}

代码示例来源:origin: apache/jackrabbit

/**
 * Returns {@code false} if the specified attribute name doesn't have
 * a 'jcr' or 'rep' namespace prefix; {@code true} otherwise. This is
 * a lazy evaluation in order to avoid testing the defining node type of
 * the associated jcr property.
 *
 * @param attributeName The attribute name.
 * @return {@code true} if the specified property name doesn't seem
 *         to represent repository internal information.
 */
static  boolean isInfoAttribute(String attributeName) {
  String prefix = Text.getNamespacePrefix(attributeName);
  return !RESERVED_PREFIXES.contains(prefix);
}

代码示例来源:origin: apache/jackrabbit-oak

private static boolean isRestrictionProperty(String propertyName) {
    return !AccessControlConstants.ACE_PROPERTY_NAMES.contains(propertyName) &&
        !NamespaceRegistry.PREFIX_JCR.equals(Text.getNamespacePrefix(propertyName));
  }
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-core

/**
 * Returns <code>false</code> if the specified attribute name doesn't have
 * a 'jcr' or 'rep' namespace prefix; <code>true</code> otherwise. This is
 * a lazy evaluation in order to avoid testing the defining node type of
 * the associated jcr property.
 *
 * @param propertyName
 * @return <code>true</code> if the specified property name doesn't seem
 * to represent repository internal information.
 */
private static boolean isInfoAttribute(String propertyName) {
  String prefix = Text.getNamespacePrefix(propertyName);
  return !Name.NS_JCR_PREFIX.equals(prefix) && !Name.NS_REP_PREFIX.equals(prefix);
}

代码示例来源:origin: apache/jackrabbit

/**
 * Returns <code>false</code> if the specified attribute name doesn't have
 * a 'jcr' or 'rep' namespace prefix; <code>true</code> otherwise. This is
 * a lazy evaluation in order to avoid testing the defining node type of
 * the associated jcr property.
 *
 * @param propertyName
 * @return <code>true</code> if the specified property name doesn't seem
 * to represent repository internal information.
 */
private static boolean isInfoAttribute(String propertyName) {
  String prefix = Text.getNamespacePrefix(propertyName);
  return !Name.NS_JCR_PREFIX.equals(prefix) && !Name.NS_REP_PREFIX.equals(prefix);
}

代码示例来源:origin: org.apache.jackrabbit/oak-core

/**
   * Returns {@code false} if the specified attribute name doesn't have
   * a 'jcr' or 'rep' namespace prefix; {@code true} otherwise. This is
   * a lazy evaluation in order to avoid testing the defining node type of
   * the associated jcr property.
   *
   * @param attributeName The attribute name.
   * @return {@code true} if the specified property name doesn't seem
   *         to represent repository internal information.
   */
  private boolean isInfoAttribute(@NotNull String attributeName) {
    String prefix = Text.getNamespacePrefix(attributeName);
    return !NamespaceConstants.RESERVED_PREFIXES.contains(prefix);
  }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

/**
   * Returns {@code false} if the specified attribute name doesn't have
   * a 'jcr' or 'rep' namespace prefix; {@code true} otherwise. This is
   * a lazy evaluation in order to avoid testing the defining node type of
   * the associated jcr property.
   *
   * @param attributeName The attribute name.
   * @return {@code true} if the specified property name doesn't seem
   *         to represent repository internal information.
   */
  private boolean isInfoAttribute(@Nonnull String attributeName) {
    String prefix = Text.getNamespacePrefix(attributeName);
    return !NamespaceConstants.RESERVED_PREFIXES.contains(prefix);
  }
}

代码示例来源:origin: apache/jackrabbit-oak

/**
   * Returns {@code false} if the specified attribute name doesn't have
   * a 'jcr' or 'rep' namespace prefix; {@code true} otherwise. This is
   * a lazy evaluation in order to avoid testing the defining node type of
   * the associated jcr property.
   *
   * @param attributeName The attribute name.
   * @return {@code true} if the specified property name doesn't seem
   *         to represent repository internal information.
   */
  private boolean isInfoAttribute(@NotNull String attributeName) {
    String prefix = Text.getNamespacePrefix(attributeName);
    return !NamespaceConstants.RESERVED_PREFIXES.contains(prefix);
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Override
public boolean matches(@NotNull Tree tree, @Nullable PropertyState property) {
  String name = (property != null) ? property.getName() : tree.getName();
  String prefix = Text.getNamespacePrefix(name);
  if (!prefix.isEmpty()) {
    for (String p : prefixes) {
      if (prefix.equals(p)) {
        return true;
      }
    }
  }
  return false;
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi-commons

private Name getName(String jcrName, Map<String,String> namespaces) {
  String prefix = Text.getNamespacePrefix(jcrName);
  String uri = (Name.NS_EMPTY_PREFIX.equals(prefix)) ? Name.NS_DEFAULT_URI : namespaces.get(prefix);
  return NAME_FACTORY.create(uri, Text.getLocalName(jcrName));
}

代码示例来源:origin: apache/jackrabbit

private Name getName(String jcrName, Map<String,String> namespaces) {
  String prefix = Text.getNamespacePrefix(jcrName);
  String uri = (Name.NS_EMPTY_PREFIX.equals(prefix)) ? Name.NS_DEFAULT_URI : namespaces.get(prefix);
  return NAME_FACTORY.create(uri, Text.getLocalName(jcrName));
}

代码示例来源:origin: org.apache.jackrabbit/oak-core

@Override
public boolean matches(@NotNull Tree tree, @Nullable PropertyState property) {
  String name = (property != null) ? property.getName() : tree.getName();
  String prefix = Text.getNamespacePrefix(name);
  if (!prefix.isEmpty()) {
    for (String p : prefixes) {
      if (prefix.equals(p)) {
        return true;
      }
    }
  }
  return false;
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

@Override
public boolean matches(@Nonnull Tree tree, @Nullable PropertyState property) {
  String name = (property != null) ? property.getName() : tree.getName();
  String prefix = Text.getNamespacePrefix(name);
  if (!prefix.isEmpty()) {
    for (String p : prefixes) {
      if (prefix.equals(p)) {
        return true;
      }
    }
  }
  return false;
}

代码示例来源:origin: apache/jackrabbit

public CurrentUserPrivilegeSetProperty asDavProperty() throws RepositoryException {
    List<Privilege> davPrivs = new ArrayList<Privilege>();
    for (javax.jcr.security.Privilege privilege : session.getAccessControlManager().getPrivileges(absPath)) {
      String privilegeName = privilege.getName();

      String prefix = Text.getNamespacePrefix(privilegeName);
      Namespace ns = (prefix.isEmpty()) ? Namespace.EMPTY_NAMESPACE : Namespace.getNamespace(prefix, session.getNamespaceURI(prefix));
      davPrivs.add(Privilege.getPrivilege(Text.getLocalName(privilegeName), ns));
    }

    return new CurrentUserPrivilegeSetProperty(davPrivs.toArray(new Privilege[davPrivs.size()]));
  }
}

代码示例来源:origin: apache/jackrabbit

private SupportedPrivilege createSupportedPrivilege(Privilege privilege) throws RepositoryException {
  String privilegeName = privilege.getName();
  String localName = Text.getLocalName(privilegeName);
  String prefix = Text.getNamespacePrefix(privilegeName);
  Namespace ns = (prefix.isEmpty()) ? Namespace.EMPTY_NAMESPACE : Namespace.getNamespace(prefix, session.getNamespaceURI(prefix));
  org.apache.jackrabbit.webdav.security.Privilege davPrivilege = org.apache.jackrabbit.webdav.security.Privilege.getPrivilege(localName, ns);
  SupportedPrivilege[] aggregates = (privilege.isAggregate()) ? getDeclaredAggregates(privilege) : null;
  SupportedPrivilege sp = new SupportedPrivilege(davPrivilege, null, null, privilege.isAbstract(), aggregates);
  if (!aggregated.contains(privilegeName)) {
    supportedPrivileges.put(privilegeName, sp);
  }
  return sp;
}

代码示例来源:origin: org.apache.jackrabbit/oak-core

@Override
public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException {
  if (isPrivilegeDefinition(after)) {
    // make sure privileges have been initialized before
    Tree parent = getPrivilegesTree(rootBefore);
    // the following characteristics are expected to be validated elsewhere:
    // - permission to allow privilege registration -> permission validator.
    // - name collisions (-> delegated to NodeTypeValidator since sms are not allowed)
    // - name must be valid (-> delegated to NameValidator)
    // name may not contain reserved namespace prefix
    if (NamespaceConstants.RESERVED_PREFIXES.contains(Text.getNamespacePrefix(name))) {
      String msg = "Failed to register custom privilege: Definition uses reserved namespace: " + name;
      throw new CommitFailedException("Privilege", 1, msg);
    }
    // validate the definition
    Tree tree = treeProvider.createReadOnlyTree(parent, name, after);
    validateDefinition(tree);
  }
  // privilege definitions may not have child nodes (or another type of nodes
  // that is not handled by this validator anyway).
  return null;
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

@Override
public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException {
  if (isPrivilegeDefinition(after)) {
    // make sure privileges have been initialized before
    getPrivilegesTree(rootBefore);
    // the following characteristics are expected to be validated elsewhere:
    // - permission to allow privilege registration -> permission validator.
    // - name collisions (-> delegated to NodeTypeValidator since sms are not allowed)
    // - name must be valid (-> delegated to NameValidator)
    // name may not contain reserved namespace prefix
    if (NamespaceConstants.RESERVED_PREFIXES.contains(Text.getNamespacePrefix(name))) {
      String msg = "Failed to register custom privilege: Definition uses reserved namespace: " + name;
      throw new CommitFailedException("Privilege", 1, msg);
    }
    // validate the definition
    Tree tree = new ImmutableTree(ImmutableTree.ParentProvider.UNSUPPORTED, name, after);
    validateDefinition(tree);
  }
  // privilege definitions may not have child nodes (or another type of nodes
  // that is not handled by this validator anyway).
  return null;
}

代码示例来源:origin: apache/jackrabbit-oak

@Override
public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException {
  if (isPrivilegeDefinition(after)) {
    // make sure privileges have been initialized before
    Tree parent = getPrivilegesTree(rootBefore);
    // the following characteristics are expected to be validated elsewhere:
    // - permission to allow privilege registration -> permission validator.
    // - name collisions (-> delegated to NodeTypeValidator since sms are not allowed)
    // - name must be valid (-> delegated to NameValidator)
    // name may not contain reserved namespace prefix
    if (NamespaceConstants.RESERVED_PREFIXES.contains(Text.getNamespacePrefix(name))) {
      String msg = "Failed to register custom privilege: Definition uses reserved namespace: " + name;
      throw new CommitFailedException("Privilege", 1, msg);
    }
    // validate the definition
    Tree tree = treeProvider.createReadOnlyTree(parent, name, after);
    validateDefinition(tree);
  }
  // privilege definitions may not have child nodes (or another type of nodes
  // that is not handled by this validator anyway).
  return null;
}

代码示例来源:origin: apache/jackrabbit

/**
 * Builds a webdav property name from the given jcrName. In case the jcrName
 * contains a namespace prefix that would conflict with any of the predefined
 * webdav namespaces a new prefix is assigned.<br>
 * Please note, that the local part of the jcrName is checked for XML
 * compatibility by calling {@link ISO9075#encode(String)}
 *
 * @param jcrName name of the jcr property
 * @param session session
 * @return a <code>DavPropertyName</code> for the given jcr name.
 * @throws RepositoryException if an error during repository access occurs.
 */
private DavPropertyName getDavName(String jcrName, Session session) throws RepositoryException {
  // make sure the local name is xml compliant
  String localName = ISO9075.encode(Text.getLocalName(jcrName));
  String prefix = Text.getNamespacePrefix(jcrName);
  String uri = session.getNamespaceURI(prefix);
  Namespace namespace = Namespace.getNamespace(prefix, uri);
  DavPropertyName name = DavPropertyName.create(localName, namespace);
  return name;
}

相关文章