code: public static void validatePath(final Session session, final String path) {
  
          final NamespaceRegistry namespaceRegistry = getNamespaceRegistry(session);
          final String[] pathSegments = path.replaceAll("^/+", "").replaceAll("/+$", "").split("/");
          for (final String segment : pathSegments) {
              final int colonPosition = segment.indexOf(':');
              if (segment.length() > 0 && colonPosition > -1) {
                  final String prefix = segment.substring(0, colonPosition);
  
                  // Skip the fcr namespace registration check to avoid the FedoraInvalidNamespaceException,
                  // which will happen when it fails to retrieve the memento from Modeshape.
                  if (!prefix.equals("fedora") && !prefix.equals("fcr")) {
                      if (prefix.length() == 0) {
                          throw new FedoraInvalidNamespaceException("Empty namespace in " + segment);
                      }
                      try {
                          namespaceRegistry.getURI(prefix);
                      } catch (final NamespaceException e) {
                          throw new FedoraInvalidNamespaceException("Prefix " + prefix + " has not been registered", e);
                      } catch (final RepositoryException e) {
                          throw new RepositoryRuntimeException(e);
                      }
                  }
              }
          }
      }
docs: Validate resource path for unregistered namespace prefixes
  
  @param session the JCR session to use
  @param path the absolute path to the object
  @throws org.fcrepo.kernel.api.exception.FedoraInvalidNamespaceException on unregistered namespaces
  @throws org.fcrepo.kernel.api.exception.RepositoryRuntimeException if repository runtime exception occurred