jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java
author joehw
Wed, 11 Jan 2017 13:06:04 -0800
changeset 43121 e73af7b6ce47
parent 40582 1dddef49982c
child 43358 9e2d943b5b66
permissions -rw-r--r--
8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar Reviewed-by: rriggs, dfuchs, lancea, alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     1
/*
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
     2
 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     4
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    10
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    15
 * accompanied this code).
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    16
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    20
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    23
 * questions.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    24
 */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    25
package javax.xml.catalog;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    26
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
    27
import java.io.File;
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    28
import java.io.IOException;
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
    29
import java.net.MalformedURLException;
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
    30
import java.net.URI;
38497
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    31
import java.util.Iterator;
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    32
import java.util.jar.JarEntry;
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    33
import java.util.jar.JarFile;
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    34
import static javax.xml.catalog.CatalogFeatures.DEFER_FALSE;
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    35
import static javax.xml.catalog.CatalogFeatures.DEFER_TRUE;
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    36
import javax.xml.catalog.CatalogFeatures.Feature;
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    37
import static javax.xml.catalog.CatalogFeatures.PREFER_PUBLIC;
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    38
import static javax.xml.catalog.CatalogFeatures.PREFER_SYSTEM;
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    39
import static javax.xml.catalog.CatalogFeatures.RESOLVE_CONTINUE;
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    40
import static javax.xml.catalog.CatalogFeatures.RESOLVE_IGNORE;
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    41
import static javax.xml.catalog.CatalogFeatures.RESOLVE_STRICT;
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    42
import jdk.xml.internal.SecuritySupport;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    43
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    44
/**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    45
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    46
 * @since 9
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    47
 */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    48
class Util {
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    49
38497
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    50
    final static String URN = "urn:publicid:";
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    51
    final static String PUBLICID_PREFIX = "-//";
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    52
    final static String PUBLICID_PREFIX_ALT = "+//";
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    53
    final static String SCHEME_FILE = "file";
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    54
    final static String SCHEME_JAR = "jar";
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    55
    final static String SCHEME_JARFILE = "jar:file:";
38497
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    56
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    57
    /**
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    58
     * Finds an entry in the catalog that matches with the publicId or systemId.
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    59
     *
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    60
     * The resolution follows the following rules determined by the prefer
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    61
     * setting:
38497
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    62
     *
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    63
     * prefer "system": attempts to resolve with a system entry; attempts to
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    64
     * resolve with a public entry when only publicId is specified.
38497
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    65
     *
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    66
     * prefer "public": attempts to resolve with a system entry; attempts to
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    67
     * resolve with a public entry if no matching system entry is found.
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 38497
diff changeset
    68
     *
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 38497
diff changeset
    69
     * If no match is found, continue searching uri entries
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 38497
diff changeset
    70
     *
38497
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    71
     * @param catalog the catalog
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    72
     * @param publicId the publicId
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    73
     * @param systemId the systemId
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    74
     * @return the resolved systemId if a match is found, null otherwise
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    75
     */
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    76
    static String resolve(CatalogImpl catalog, String publicId, String systemId) {
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    77
        String resolvedSystemId = null;
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    78
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    79
        //search the current catalog
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    80
        catalog.reset();
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    81
        if (systemId != null) {
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    82
            /*
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    83
             If a system identifier is specified, it is used no matter how
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    84
             prefer is set.
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
    85
             */
38497
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    86
            resolvedSystemId = catalog.matchSystem(systemId);
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    87
        }
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    88
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    89
        if (resolvedSystemId == null && publicId != null) {
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    90
            resolvedSystemId = catalog.matchPublic(publicId);
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    91
        }
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    92
40582
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 38497
diff changeset
    93
        if (resolvedSystemId == null && systemId != null) {
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 38497
diff changeset
    94
            resolvedSystemId = catalog.matchURI(systemId);
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 38497
diff changeset
    95
        }
1dddef49982c 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents: 38497
diff changeset
    96
38497
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    97
        //mark the catalog as having been searched before trying alternatives
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    98
        catalog.markAsSearched();
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
    99
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
   100
        //search alternative catalogs
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
   101
        if (resolvedSystemId == null) {
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
   102
            Iterator<Catalog> iter = catalog.catalogs().iterator();
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
   103
            while (iter.hasNext()) {
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   104
                resolvedSystemId = resolve((CatalogImpl) iter.next(), publicId, systemId);
38497
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
   105
                if (resolvedSystemId != null) {
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
   106
                    break;
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
   107
                }
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
   108
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
   109
            }
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
   110
        }
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
   111
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
   112
        return resolvedSystemId;
06b1977d0f4f 8156845: Uri is getting incorrectly unwrapped
joehw
parents: 37382
diff changeset
   113
    }
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   114
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   115
    static void validateUrisSyntax(URI... uris) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   116
        for (URI uri : uris) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   117
            validateUriSyntax(uri);
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   118
        }
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   119
    }
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   120
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   121
    static void validateUrisSyntax(String... uris) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   122
        for (String uri : uris) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   123
            validateUriSyntax(URI.create(uri));
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   124
        }
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   125
    }
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   126
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   127
    /**
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   128
     * Validate that the URI must be absolute and a valid URL.
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   129
     *
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   130
     * Note that this method does not verify the existence of the resource. The
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   131
     * Catalog standard requires that such resources be ignored.
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   132
     *
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   133
     * @param uri
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   134
     * @throws IllegalArgumentException if the uri is not absolute and a valid
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   135
     * URL
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   136
     */
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   137
    static void validateUriSyntax(URI uri) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   138
        CatalogMessages.reportNPEOnNull("URI input", uri);
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   139
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   140
        if (!uri.isAbsolute()) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   141
            CatalogMessages.reportIAE(CatalogMessages.ERR_URI_NOTABSOLUTE,
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   142
                    new Object[]{uri}, null);
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   143
        }
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   144
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   145
        try {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   146
            // check if the scheme was valid
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   147
            uri.toURL();
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   148
        } catch (MalformedURLException ex) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   149
            CatalogMessages.reportIAE(CatalogMessages.ERR_URI_NOTVALIDURL,
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   150
                    new Object[]{uri}, null);
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   151
        }
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   152
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   153
        // verify the resource exists where possible
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   154
        if (isFileUri(uri)) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   155
            if (!isFileUriExist(uri, false)) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   156
                CatalogMessages.reportIAE(CatalogMessages.ERR_URI_NOTVALIDURL,
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   157
                        new Object[]{uri}, null);
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   158
            }
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   159
        }
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   160
    }
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   161
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   162
    /**
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   163
     * Checks whether the URI is a file URI, including JAR file.
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   164
     *
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   165
     * @param uri the specified URI.
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   166
     * @return true if it is a file or JAR file URI, false otherwise
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   167
     */
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   168
    static boolean isFileUri(URI uri) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   169
        if (SCHEME_FILE.equals(uri.getScheme())
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   170
                || SCHEME_JAR.equals(uri.getScheme())) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   171
            return true;
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   172
        }
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   173
        return false;
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   174
    }
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   175
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   176
    /**
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   177
     * Verifies whether the file resource exists.
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   178
     *
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   179
     * @param uri the URI to locate the resource
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   180
     * @param openJarFile a flag to indicate whether a JAR file should be
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   181
     * opened. This operation may be expensive.
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   182
     * @return true if the resource exists, false otherwise.
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   183
     */
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   184
    static boolean isFileUriExist(URI uri, boolean openJarFile) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   185
        if (uri != null && uri.isAbsolute()) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   186
            if (null != uri.getScheme()) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   187
                switch (uri.getScheme()) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   188
                    case SCHEME_FILE:
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   189
                        String path = uri.getPath();
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   190
                        File f1 = new File(path);
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   191
                        if (f1.isFile()) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   192
                            return true;
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   193
                        }
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   194
                        break;
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   195
                    case SCHEME_JAR:
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   196
                        String tempUri = uri.toString();
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   197
                        int pos = tempUri.indexOf("!");
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   198
                        if (pos < 0) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   199
                            return false;
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   200
                        }
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   201
                        if (openJarFile) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   202
                            String jarFile = tempUri.substring(SCHEME_JARFILE.length(), pos);
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   203
                            String entryName = tempUri.substring(pos + 2);
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   204
                            try {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   205
                                JarFile jf = new JarFile(jarFile);
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   206
                                JarEntry je = jf.getJarEntry(entryName);
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   207
                                if (je != null) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   208
                                    return true;
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   209
                                }
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   210
                            } catch (IOException ex) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   211
                                return false;
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   212
                            }
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   213
                        } else {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   214
                            return true;
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   215
                        }
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   216
                        break;
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   217
                }
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   218
            }
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   219
        }
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   220
        return false;
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   221
    }
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   222
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   223
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   224
     * Find catalog file paths by reading the system property, and then
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   225
     * jaxp.properties if the system property is not specified.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   226
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   227
     * @param sysPropertyName the name of system property
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   228
     * @return the catalog file paths, or null if not found.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   229
     */
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   230
    static String[] getCatalogFiles(String sysPropertyName) {
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   231
        String value = SecuritySupport.getJAXPSystemProperty(sysPropertyName);
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   232
        if (value != null && !value.equals("")) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   233
            return value.split(";");
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   234
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   235
        return null;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   236
    }
37382
c7d898d8da12 8151162: Public entries not searched when prefer='system'
joehw
parents: 36700
diff changeset
   237
c7d898d8da12 8151162: Public entries not searched when prefer='system'
joehw
parents: 36700
diff changeset
   238
    /**
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   239
     * Checks whether the specified string is null or empty, returns the
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   240
     * original string with leading and trailing spaces removed if not.
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   241
     *
37382
c7d898d8da12 8151162: Public entries not searched when prefer='system'
joehw
parents: 36700
diff changeset
   242
     * @param test the string to be tested
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   243
     * @return the original string with leading and trailing spaces removed, or
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   244
     * null if it is null or empty
37382
c7d898d8da12 8151162: Public entries not searched when prefer='system'
joehw
parents: 36700
diff changeset
   245
     *
c7d898d8da12 8151162: Public entries not searched when prefer='system'
joehw
parents: 36700
diff changeset
   246
     */
c7d898d8da12 8151162: Public entries not searched when prefer='system'
joehw
parents: 36700
diff changeset
   247
    static String getNotNullOrEmpty(String test) {
c7d898d8da12 8151162: Public entries not searched when prefer='system'
joehw
parents: 36700
diff changeset
   248
        if (test == null) {
c7d898d8da12 8151162: Public entries not searched when prefer='system'
joehw
parents: 36700
diff changeset
   249
            return test;
c7d898d8da12 8151162: Public entries not searched when prefer='system'
joehw
parents: 36700
diff changeset
   250
        } else {
c7d898d8da12 8151162: Public entries not searched when prefer='system'
joehw
parents: 36700
diff changeset
   251
            String temp = test.trim();
c7d898d8da12 8151162: Public entries not searched when prefer='system'
joehw
parents: 36700
diff changeset
   252
            if (temp.length() == 0) {
c7d898d8da12 8151162: Public entries not searched when prefer='system'
joehw
parents: 36700
diff changeset
   253
                return null;
c7d898d8da12 8151162: Public entries not searched when prefer='system'
joehw
parents: 36700
diff changeset
   254
            } else {
c7d898d8da12 8151162: Public entries not searched when prefer='system'
joehw
parents: 36700
diff changeset
   255
                return temp;
c7d898d8da12 8151162: Public entries not searched when prefer='system'
joehw
parents: 36700
diff changeset
   256
            }
c7d898d8da12 8151162: Public entries not searched when prefer='system'
joehw
parents: 36700
diff changeset
   257
        }
c7d898d8da12 8151162: Public entries not searched when prefer='system'
joehw
parents: 36700
diff changeset
   258
    }
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   259
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   260
    /**
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   261
     * Validates the input for features.
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   262
     *
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   263
     * @param f the feature
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   264
     * @param value the value
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   265
     * @throws IllegalArgumentException if the value is invalid for the feature
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   266
     */
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   267
    static void validateFeatureInput(Feature f, String value) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   268
        CatalogMessages.reportNPEOnNull(f.name(), value);
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   269
        if (value.length() == 0) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   270
            CatalogMessages.reportIAE(CatalogMessages.ERR_INVALID_ARGUMENT,
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   271
                    new Object[]{value, f.name()}, null);
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   272
        }
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   273
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   274
        if (f == Feature.PREFER) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   275
            if (!value.equals(PREFER_SYSTEM) && !value.equals(PREFER_PUBLIC)) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   276
                CatalogMessages.reportIAE(CatalogMessages.ERR_INVALID_ARGUMENT,
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   277
                        new Object[]{value, Feature.PREFER.name()}, null);
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   278
            }
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   279
        } else if (f == Feature.DEFER) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   280
            if (!value.equals(DEFER_TRUE) && !value.equals(DEFER_FALSE)) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   281
                CatalogMessages.reportIAE(CatalogMessages.ERR_INVALID_ARGUMENT,
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   282
                        new Object[]{value, Feature.DEFER.name()}, null);
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   283
            }
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   284
        } else if (f == Feature.RESOLVE) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   285
            if (!value.equals(RESOLVE_STRICT) && !value.equals(RESOLVE_CONTINUE)
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   286
                    && !value.equals(RESOLVE_IGNORE)) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   287
                CatalogMessages.reportIAE(CatalogMessages.ERR_INVALID_ARGUMENT,
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   288
                        new Object[]{value, Feature.RESOLVE.name()}, null);
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   289
            }
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   290
        } else if (f == Feature.FILES) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   291
            Util.validateUrisSyntax(value.split(";"));
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   292
        }
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 40582
diff changeset
   293
    }
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   294
}