Package com.itextpdf.xmp

Examples of com.itextpdf.xmp.XMPException


   */
  private static void verifySimpleXMLName(String name) throws XMPException
  {
    if (!Utils.isXMLName(name))
    {
      throw new XMPException("Bad XML name", XMPError.BADXPATH);
    }
  }
View Full Code Here


    // Do some basic checks on the URI and name. Try to lookup the URI. See if the name is
    // qualified.

    if (schemaNS == null || schemaNS.length() == 0)
    {
      throw new XMPException(
        "Schema namespace URI is required", XMPError.BADSCHEMA);
    }

    if ((rootProp.charAt(0) == '?') || (rootProp.charAt(0) == '@'))
    {
      throw new XMPException("Top level name must not be a qualifier", XMPError.BADXPATH);
    }

    if (rootProp.indexOf('/') >= 0 || rootProp.indexOf('[') >= 0)
    {
      throw new XMPException("Top level name must be simple", XMPError.BADXPATH);
    }

    String prefix = XMPMetaFactory.getSchemaRegistry().getNamespacePrefix(schemaNS);
    if (prefix == null)
    {
      throw new XMPException("Unregistered schema namespace URI", XMPError.BADSCHEMA);
    }

    // Verify the various URI and prefix combinations. Initialize the
    // expanded XMPPath.
    int colonPos = rootProp.indexOf(':');
    if (colonPos < 0)
    {
      // The propName is unqualified, use the schemaURI and associated
      // prefix.
      verifySimpleXMLName(rootProp); // Verify the part before any colon
      return prefix + rootProp;
    }
    else
    {
      // The propName is qualified. Make sure the prefix is legit. Use the associated URI and
      // qualified name.

      // Verify the part before any colon
      verifySimpleXMLName(rootProp.substring(0, colonPos));
      verifySimpleXMLName(rootProp.substring(colonPos));
     
      prefix = rootProp.substring(0, colonPos + 1);

      String regPrefix = XMPMetaFactory.getSchemaRegistry().getNamespacePrefix(schemaNS);
      if (regPrefix == null)
      {
        throw new XMPException("Unknown schema namespace prefix", XMPError.BADSCHEMA);
      }
      if (!prefix.equals(regPrefix))
      {
        throw new XMPException("Schema namespace URI and prefix mismatch",
            XMPError.BADSCHEMA);
      }

      return rootProp;
    }
View Full Code Here

        return value;
     
    }
    else
    {
      throw new XMPException(errorMsg, XMPError.BADVALUE);
    }
  }
View Full Code Here

  private void assertChildNotExisting(String childName) throws XMPException
  {
    if (!XMPConst.ARRAY_ITEM_NAME.equals(childName&&
      findChildByName(childName) != null)
    {
      throw new XMPException("Duplicate property or field node '" + childName + "'",
          XMPError.BADXMP);
    }
  }
View Full Code Here

  private void assertQualifierNotExisting(String qualifierName) throws XMPException
  {
    if (!XMPConst.ARRAY_ITEM_NAME.equals(qualifierName&&
      findQualifierByName(qualifierName) != null)
    {
      throw new XMPException("Duplicate '" + qualifierName + "' qualifier", XMPError.BADXMP);
    }
  }
View Full Code Here

    }
   
    if (!Utils.isXMLNameNS(suggestedPrefix.substring(0,
        suggestedPrefix.length() - 1)))
    {
      throw new XMPException("The prefix is a bad XML name", XMPError.BADXML);
    }
   
    String registeredPrefix = (String) namespaceToPrefixMap.get(namespaceURI);
    String registeredNS = (String) prefixToNamespaceMap.get(suggestedPrefix);
    if (registeredPrefix != null)
View Full Code Here

        aliasForm.toPropertyOptions(), null).getOptions()) :
      new AliasOptions();
 
    if (p.matcher(aliasProp).find()  ||  p.matcher(actualProp).find())
    {
      throw new XMPException("Alias and actual property names must be simple",
          XMPError.BADXPATH);
    }
   
    // check if both namespaces are registered
    final String aliasPrefix = getNamespacePrefix(aliasNS);
    final String actualPrefix = getNamespacePrefix(actualNS);
    if (aliasPrefix == null)
    {
      throw new XMPException("Alias namespace is not registered", XMPError.BADSCHEMA);
    }
    else if (actualPrefix == null)
    {
      throw new XMPException("Actual namespace is not registered",
        XMPError.BADSCHEMA);
    }
   
    String key = aliasPrefix + aliasProp;
   
    // check if alias is already existing
    if (aliasMap.containsKey(key))
    {
      throw new XMPException("Alias is already existing", XMPError.BADPARAM);
    }
    else if (aliasMap.containsKey(actualPrefix + actualProp))
    { 
      throw new XMPException(
          "Actual property is already an alias, use the base property",
          XMPError.BADPARAM);
    }
   
    XMPAliasInfo aliasInfo = new XMPAliasInfo()
View Full Code Here

          idNode.removeQualifiers();   
          tree.setName(null);
        }
        else
       
          throw new XMPException("Failure creating xmpMM:InstanceID",
              XMPError.INTERNALFAILURE);
       
      }
    }   
  }
View Full Code Here

  {
    if (baseArray.getOptions().isArrayAltText())
    {
      if (childNode.getOptions().getHasLanguage())
      {
        throw new XMPException("Alias to x-default already has a language qualifier",
            XMPError.BADXMP);
      }
     
      XMPNode langQual = new XMPNode(XMPConst.XML_LANG, XMPConst.X_DEFAULT, null);
      childNode.addQualifier(langQual);
View Full Code Here

      boolean outerCall) throws XMPException
  {
    if (!aliasNode.getValue().equals(baseNode.getValue())  ||
      aliasNode.getChildrenLength() != baseNode.getChildrenLength())
    {
      throw new XMPException("Mismatch between alias and base nodes", XMPError.BADXMP);
    }
   
    if (
        !outerCall  &&
        (!aliasNode.getName().equals(baseNode.getName())  ||
         !aliasNode.getOptions().equals(baseNode.getOptions())  ||
         aliasNode.getQualifierLength() != baseNode.getQualifierLength())
       )
      {
      throw new XMPException("Mismatch between alias and base nodes",
        XMPError.BADXMP);
    }
   
    for (Iterator an = aliasNode.iterateChildren(),
            bn = baseNode.iterateChildren();
View Full Code Here

TOP

Related Classes of com.itextpdf.xmp.XMPException

Copyright © 2018 www.massapicom. 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.