// ignore jcr:primaryType
if (prefix.equals("jcr:primaryType")) {
return;
}
if (map.containsKey(prefix)) {
throw new CommitFailedException(
CommitFailedException.NAMESPACE, 1,
"Namespace mapping already registered: " + prefix);
} else if (Namespaces.isValidPrefix(prefix)) {
if (after.isArray() || !STRING.equals(after.getType())) {
throw new CommitFailedException(
CommitFailedException.NAMESPACE, 2,
"Invalid namespace mapping: " + prefix);
} else if (prefix.toLowerCase(Locale.ENGLISH).startsWith("xml")) {
throw new CommitFailedException(
CommitFailedException.NAMESPACE, 3,
"XML prefixes are reserved: " + prefix);
} else if (map.containsValue(after.getValue(STRING))) {
throw modificationNotAllowed(prefix);
}
} else {
throw new CommitFailedException(
CommitFailedException.NAMESPACE, 4,
"Not a valid namespace prefix: " + prefix);
}
}