if (JCR_PRIMARYTYPE.equals(prefix)) {
return;
}
if (namespaces.hasProperty(prefix)) {
throw new CommitFailedException(CommitFailedException.NAMESPACE, 1,
"Namespace mapping already registered: " + prefix);
} else if (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 (containsValue(namespaces, after.getValue(STRING))) {
throw modificationNotAllowed(prefix);
}
} else {
throw new CommitFailedException(CommitFailedException.NAMESPACE, 4,
"Not a valid namespace prefix: " + prefix);
}
modified = true;
}