Examples of NamespaceException


Examples of javax.jcr.NamespaceException

   public void unregisterNamespace(String prefix) throws NamespaceException, RepositoryException
   {

      if (namespaces.get(prefix) == null)
      {
         throw new NamespaceException("Prefix " + prefix + " is not registered");
      }

      if (PROTECTED_NAMESPACES.contains(prefix))
      {
         throw new NamespaceException("Prefix " + prefix + " is protected");
      }
      String uri = getURI(prefix);
      if (indexSearcherHolder != null)
      {
         final Set<String> nodes = indexSearcherHolder.getNodesByUri(uri);
         if (nodes.size() > 0)
         {
            StringBuilder builder = new StringBuilder();
            builder.append("Fail to unregister namespace '");
            builder.append(prefix);
            builder.append("' because of following nodes:  ");

            for (String uuid : nodes)
            {
               ItemData item = dataManager.getItemData(uuid);
               if (item != null && item.isNode())
               {
                  builder.append(" - ");
                  builder.append(item.getQPath().getAsString());
                  builder.append("\r\n");
               }
            }
            builder.append(" uses this prefix.");
            throw new NamespaceException(builder.toString());
         }
      }
      prefixes.remove(uri);
      namespaces.remove(prefix);
      if (persister != null)
View Full Code Here

Examples of javax.jcr.NamespaceException

      if (PROTECTED_NAMESPACES.contains(prefix))
      {
         if (uri == null)
         {
            throw new NamespaceException("Can not remove built-in namespace " + prefix);
         }
         throw new NamespaceException("Can not change built-in namespace " + prefix);
      }
      if (prefix.toLowerCase().startsWith("xml"))
      {
         throw new NamespaceException("Can not re-assign prefix that start with 'xml'");
      }
      if (uri == null)
      {
         throw new NamespaceException("Can not register NULL URI!");
      }
   }
View Full Code Here

Examples of javax.jcr.NamespaceException

   {
      checkLive();
      NamespaceRegistryImpl nrg = (NamespaceRegistryImpl)workspace.getNamespaceRegistry();
      if (!nrg.isUriRegistered(uri))
      {
         throw new NamespaceException("The specified uri:" + uri + " is not among "
            + "those registered in the NamespaceRegistry");
      }
      if (nrg.isPrefixMaped(prefix))
      {
         throw new NamespaceException("A prefix '" + prefix + "' is currently already mapped to " + nrg.getURI(prefix)
            + " URI persistently in the repository NamespaceRegistry "
            + "and cannot be remapped to a new URI using this method, since this would make any "
            + "content stored using the old URI unreadable.");
      }
      if (namespaces.containsKey(prefix))
      {
         throw new NamespaceException("A prefix '" + prefix + "' is currently already mapped to "
            + namespaces.get(prefix) + " URI transiently within this Session and cannot be "
            + "remapped to a new URI using this method, since this would make any "
            + "content stored using the old URI unreadable.");
      }
      nrg.validateNamespace(prefix, uri);
View Full Code Here

Examples of javax.jcr.NamespaceException

   {
      checkLive();
      NamespaceRegistryImpl nrg = (NamespaceRegistryImpl)workspace.getNamespaceRegistry();
      if (!nrg.isUriRegistered(uri))
      {
         throw new NamespaceException("The specified uri:" + uri + " is not among "
            + "those registered in the NamespaceRegistry");
      }
      if (nrg.isPrefixMaped(prefix))
      {
         throw new NamespaceException("A prefix '" + prefix + "' is currently already mapped to " + nrg.getURI(prefix)
            + " URI persistently in the repository NamespaceRegistry "
            + "and cannot be remapped to a new URI using this method, since this would make any "
            + "content stored using the old URI unreadable.");
      }
      if (namespaces.containsKey(prefix))
      {
         throw new NamespaceException("A prefix '" + prefix + "' is currently already mapped to "
            + namespaces.get(prefix) + " URI transiently within this Session and cannot be "
            + "remapped to a new URI using this method, since this would make any "
            + "content stored using the old URI unreadable.");
      }
      nrg.validateNamespace(prefix, uri);
View Full Code Here

Examples of javax.jcr.NamespaceException

        try {
            Tree root = getReadTree();
            Map<String, String> map = Namespaces.getNamespaceMap(root);
            String uri = map.get(prefix);
            if (uri == null) {
                throw new NamespaceException(
                        "No namespace registered for prefix " + prefix);
            }
            return uri;
        } catch (RuntimeException e) {
            throw new RepositoryException(
View Full Code Here

Examples of javax.jcr.NamespaceException

            for (Map.Entry<String, String> entry : map.entrySet()) {
                if (entry.getValue().equals(uri)) {
                    return entry.getKey();
                }
            }
            throw new NamespaceException(
                        "No namespace prefix registered for URI " + uri);
        } catch (RuntimeException e) {
            throw new RepositoryException(
                    "Failed to retrieve the namespace prefix for URI "
                    + uri, e);
View Full Code Here

Examples of javax.jcr.NamespaceException

        try {
            return getNamespacePrefix(uri);
        } catch (NamespaceException e) {
            throw e;
        } catch (RepositoryException e) {
            throw new NamespaceException("Namespace not found: " + uri, e);
        }
    }
View Full Code Here

Examples of javax.jcr.NamespaceException

        try {
            return getNamespaceURI(prefix);
        } catch (NamespaceException e) {
            throw e;
        } catch (RepositoryException e) {
            throw new NamespaceException("Namespace not found: " + prefix, e);
        }
    }
View Full Code Here

Examples of javax.jcr.NamespaceException

            if (Name.NS_EMPTY_PREFIX.equals(prefix)) {
                return Name.NS_DEFAULT_URI;
            } else if ("a".equals(prefix)) {
                return "http://jackrabbit.apache.org";
            } else {
                throw new NamespaceException("Unknown namespace prefix " + prefix);
            }
        }
View Full Code Here

Examples of javax.jcr.NamespaceException

            if (Name.NS_DEFAULT_URI.equals(uri)) {
                return Name.NS_EMPTY_PREFIX;
            } else if ("http://jackrabbit.apache.org".equals(uri)) {
                return "a";
            } else {
                throw new NamespaceException("Unknown namespace prefix " + uri);
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.