Class GlobalNameMapper
- java.lang.Object
-
- org.apache.jackrabbit.oak.namepath.impl.GlobalNameMapper
-
- All Implemented Interfaces:
NameMapper
- Direct Known Subclasses:
LocalNameMapper
public class GlobalNameMapper extends Object implements NameMapper
Name mapper with no local prefix remappings. URI to prefix mappings are read from the repository when for transforming expanded JCR names to prefixed Oak names.Note that even though this class could be used to verify that all prefixed names have valid prefixes, we explicitly don't do that since this is a fairly performance-sensitive part of the codebase and since normally the NameValidator and other consistency checks already ensure that all names being committed or already in the repository should be valid. A separate consistency check can be used if needed to locate and fix any Oak names with invalid namespace prefixes.
-
-
Constructor Summary
Constructors Constructor Description GlobalNameMapper(Map<String,String> mappings)
GlobalNameMapper(Root root)
GlobalNameMapper(NodeState root)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull String
getExpandedJcrName(@NotNull String oakName)
Returns the JCR name in expanded form for the given Oak name.@NotNull String
getJcrName(@NotNull String oakName)
Returns the JCR name in qualified form for the given Oak name.protected String
getNamespacesProperty(String prefix)
@NotNull String
getOakName(@NotNull String jcrName)
Returns the Oak name for the specified JCR name.protected @Nullable String
getOakNameFromExpanded(String expandedName)
@Nullable String
getOakNameOrNull(@NotNull String jcrName)
Returns the Oak name for the given JCR name, ornull
if no such mapping exists because the given JCR name contains an unknown namespace URI or prefix, or is otherwise invalid.protected @Nullable String
getOakPrefixOrNull(String uri)
protected @Nullable String
getOakURIOrNull(String prefix)
protected Iterable<String>
getPrefixes()
@NotNull Map<String,String>
getSessionLocalMappings()
Returns the local namespace prefix mappings, or an empty map if there aren't any local mappings.protected static boolean
isExpandedName(String name)
protected static boolean
isHiddenName(String name)
void
onSessionRefresh()
-
-
-
Method Detail
-
isHiddenName
protected static boolean isHiddenName(String name)
-
isExpandedName
protected static boolean isExpandedName(String name)
-
getJcrName
@NotNull public @NotNull String getJcrName(@NotNull @NotNull String oakName)
Description copied from interface:NameMapper
Returns the JCR name in qualified form for the given Oak name. The given name is expected to have come from a valid Oak repository that contains only valid names with proper namespace mappings. If that's not the case, either a programming error or a repository corruption has occurred and an appropriate unchecked exception gets thrown.- Specified by:
getJcrName
in interfaceNameMapper
- Parameters:
oakName
- Oak name- Returns:
- JCR name in qualified form
- See Also:
- JCR 2.0, 3.2.5.2 Qualifed Form
-
getExpandedJcrName
@NotNull public @NotNull String getExpandedJcrName(@NotNull @NotNull String oakName)
Description copied from interface:NameMapper
Returns the JCR name in expanded form for the given Oak name. The given name is expected to have come from a valid Oak repository that contains only valid names with proper namespace mappings. If that's not the case, either a programming error or a repository corruption has occurred and an appropriate unchecked exception gets thrown.- Specified by:
getExpandedJcrName
in interfaceNameMapper
- Parameters:
oakName
- Oak name- Returns:
- JCR name in expanded form
- See Also:
- JCR 2.0, 3.2.5.1 Expanded Form
-
getOakNameOrNull
@Nullable public @Nullable String getOakNameOrNull(@NotNull @NotNull String jcrName)
Description copied from interface:NameMapper
Returns the Oak name for the given JCR name, ornull
if no such mapping exists because the given JCR name contains an unknown namespace URI or prefix, or is otherwise invalid.- Specified by:
getOakNameOrNull
in interfaceNameMapper
- Parameters:
jcrName
- JCR name- Returns:
- Oak name, or
null
-
getOakName
@NotNull public @NotNull String getOakName(@NotNull @NotNull String jcrName) throws RepositoryException
Description copied from interface:NameMapper
Returns the Oak name for the specified JCR name. In contrast toNameMapper.getOakNameOrNull(String)
this method will throw aRepositoryException
if the JCR name is invalid and cannot be resolved.- Specified by:
getOakName
in interfaceNameMapper
- Parameters:
jcrName
- The JCR name to be converted.- Returns:
- A valid Oak name.
- Throws:
RepositoryException
- If the JCR name cannot be resolved.
-
getSessionLocalMappings
@NotNull public @NotNull Map<String,String> getSessionLocalMappings()
Description copied from interface:NameMapper
Returns the local namespace prefix mappings, or an empty map if there aren't any local mappings.- Specified by:
getSessionLocalMappings
in interfaceNameMapper
- Returns:
- local namespace prefix to URI mappings
-
getOakNameFromExpanded
@Nullable protected @Nullable String getOakNameFromExpanded(String expandedName)
-
onSessionRefresh
public void onSessionRefresh()
-
-