/** * Throws an exception if the specified URI is absolute. * * @param partUri * The URI to check. * @throws InvalidFormatException * Throws if the specified URI is absolute. */ private static void throwExceptionIfAbsoluteUri(URI partUri) throws InvalidFormatException { if (partUri.isAbsolute()) { log.error( "" ); throw new InvalidFormatException("Absolute URI forbidden: " + partUri); } }
/** * Throws an exception if the specified URI is empty. [M1.1] * * @param partURI * Part URI to check. * @throws InvalidFormatException * If the specified URI is empty. */ private static void throwExceptionIfEmptyURI(URI partURI) throws InvalidFormatException { if (partURI == null) { throw new IllegalArgumentException("partURI"); } String uriPath = partURI.getPath(); if (uriPath.length() == 0 || ((uriPath.length() == 1) && (uriPath.charAt(0) == URIHelper.FORWARD_SLASH_CHAR))) { throw new InvalidFormatException( "A part name shall not be empty [M1.1]: " + partURI.getPath()); } }
/** * Throws an exception if the specified part name doesn't start with a * forward slash character '/'. [M1.4] * * @param partUri * The part name to check. * @throws InvalidFormatException * If the specified part name doesn't start with a forward slash * character '/'. */ private static void throwExceptionIfPartNameNotStartsWithForwardSlashChar( URI partUri) throws InvalidFormatException { String uriPath = partUri.getPath(); if (uriPath.length() > 0 && uriPath.charAt(0) != URIHelper.FORWARD_SLASH_CHAR) { log.error( "" ); throw new InvalidFormatException( "A part name shall start with a forward slash ('/') character [M1.4]: " + partUri.getPath()); } }
/** * Throws an exception if the specified part name ends with a forward slash * character '/'. [M1.5] * * @param partUri * The part name to check. * @throws InvalidFormatException * If the specified part name ends with a forwar slash character * '/'. */ private static void throwExceptionIfPartNameEndsWithForwardSlashChar( URI partUri) throws InvalidFormatException { String uriPath = partUri.getPath(); if (uriPath.length() > 0 && uriPath.charAt(uriPath.length() - 1) == URIHelper.FORWARD_SLASH_CHAR) { log.error( "" ); throw new InvalidFormatException( "A part name shall not have a forward slash as the last character [M1.5]: " + partUri.getPath()); } }
/** * Create an OPC compliant part name by throwing an exception if the * specified name is not valid. * * @param partName * The part name to validate. * @return The correspondant part name if valid, else <code>null</code>. * @throws InvalidFormatException * Throws if the specified part name is not OPC compliant. * @see #createPartName(URI) */ public static PartName createPartName(String partName) throws InvalidFormatException { URI partNameURI; try { partNameURI = new URI(partName); } catch (URISyntaxException e) { throw new InvalidFormatException(e.getMessage()); } return createPartName(partNameURI); }
if (segments.length <= 1 || !segments[0].equals("")) { log.error( "" ); throw new InvalidFormatException( "A part name shall not have empty segments [M1.3]: " + partUri.getPath()); if (seg == null || "".equals(seg)) { log.error( "" ); throw new InvalidFormatException( "A part name shall not have empty segments [M1.3]: " + partUri.getPath()); throw new InvalidFormatException( "A segment shall not end with a dot ('.') character [M1.9]: " + partUri.getPath()); throw new InvalidFormatException( "A segment shall include at least one non-dot character. [M1.10]: " + partUri.getPath());
throw new InvalidFormatException("The segment " + segment + " contain invalid encoded character !"); throw new InvalidFormatException( "A segment shall not contain percent-encoded forward slash ('/'), or backward slash ('\') characters. [M1.7]"); throw new InvalidFormatException( "A segment shall not contain percent-encoded unreserved characters. [M1.8]"); throw new InvalidFormatException( "A segment shall not hold any characters other than pchar characters. [M1.6]");
throw new InvalidFormatException("Bad [Content_Types].xml", e);
throw new InvalidFormatException("Package not set; if you are adding part2 to part1, make sure part1 is added first."); throw new InvalidFormatException("You should add your part to the target part, not the target part's relationships part.");
throw new InvalidFormatException(e.getMessage(), e);
throw new InvalidFormatException("Couldn't create package", e);
throw new InvalidFormatException("Found existing rel, and yet constructed part name should be globally unique!");
throw new InvalidFormatException("Couldn't create package", e);
/** * Throws an exception if the specified URI is absolute. * * @param partUri * The URI to check. * @throws InvalidFormatException * Throws if the specified URI is absolute. */ private static void throwExceptionIfAbsoluteUri(URI partUri) throws InvalidFormatException { if (partUri.isAbsolute()) { log.error( "" ); throw new InvalidFormatException("Absolute URI forbidden: " + partUri); } }
/** * Throws an exception if the specified part name ends with a forward slash * character '/'. [M1.5] * * @param partUri * The part name to check. * @throws InvalidFormatException * If the specified part name ends with a forwar slash character * '/'. */ private static void throwExceptionIfPartNameEndsWithForwardSlashChar( URI partUri) throws InvalidFormatException { String uriPath = partUri.getPath(); if (uriPath.length() > 0 && uriPath.charAt(uriPath.length() - 1) == URIHelper.FORWARD_SLASH_CHAR) { log.error( "" ); throw new InvalidFormatException( "A part name shall not have a forward slash as the last character [M1.5]: " + partUri.getPath()); } }
/** * Throws an exception if the specified URI is empty. [M1.1] * * @param partURI * Part URI to check. * @throws InvalidFormatException * If the specified URI is empty. */ private static void throwExceptionIfEmptyURI(URI partURI) throws InvalidFormatException { if (partURI == null) { throw new IllegalArgumentException("partURI"); } String uriPath = partURI.getPath(); if (uriPath.length() == 0 || ((uriPath.length() == 1) && (uriPath.charAt(0) == URIHelper.FORWARD_SLASH_CHAR))) { throw new InvalidFormatException( "A part name shall not be empty [M1.1]: " + partURI.getPath()); } }
/** * Throws an exception if the specified part name doesn't start with a * forward slash character '/'. [M1.4] * * @param partUri * The part name to check. * @throws InvalidFormatException * If the specified part name doesn't start with a forward slash * character '/'. */ private static void throwExceptionIfPartNameNotStartsWithForwardSlashChar( URI partUri) throws InvalidFormatException { String uriPath = partUri.getPath(); if (uriPath.length() > 0 && uriPath.charAt(0) != URIHelper.FORWARD_SLASH_CHAR) { log.error( "" ); throw new InvalidFormatException( "A part name shall start with a forward slash ('/') character [M1.4]: " + partUri.getPath()); } }
/** * Create an OPC compliant part name by throwing an exception if the * specified name is not valid. * * @param partName * The part name to validate. * @return The correspondant part name if valid, else <code>null</code>. * @throws InvalidFormatException * Throws if the specified part name is not OPC compliant. * @see #createPartName(URI) */ public static PartName createPartName(String partName) throws InvalidFormatException { URI partNameURI; try { partNameURI = new URI(partName); } catch (URISyntaxException e) { throw new InvalidFormatException(e.getMessage()); } return createPartName(partNameURI); }
throw new InvalidFormatException("Package not set; if you are adding part2 to part1, make sure part1 is added first."); throw new InvalidFormatException("You should add your part to the target part, not the target part's relationships part.");
throw new InvalidFormatException("Couldn't create package", e);