Search in sources :

Example 21 with Server

use of com.reprezen.kaizen.oasparser.model3.Server in project webtools.servertools by eclipse.

the class XmlTestCase method getXml32Server.

private org.eclipse.jst.server.tomcat.core.internal.xml.server32.Server getXml32Server(String testId) {
    Factory factory = new Factory();
    factory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server32");
    try {
        return (org.eclipse.jst.server.tomcat.core.internal.xml.server32.Server) factory.loadDocument(getXmlInputStream(testId));
    } catch (Exception e) {
        fail("Exception occurred loading " + testId + " XML: " + e.getMessage());
        return null;
    }
}
Also used : Server(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server) Factory(org.eclipse.jst.server.tomcat.core.internal.xml.Factory)

Example 22 with Server

use of com.reprezen.kaizen.oasparser.model3.Server in project ets-ogcapi-edr10 by opengeospatial.

the class OpenApiUtils method identifyServerUrls.

/**
 * A.4.3.2. Identify Server URIs:
 *
 * a) Purpose: To identify all server URIs applicable to an OpenAPI Operation
 * Object
 *
 * b) Pre-conditions:
 *
 * Server Objects from the root level of the OpenAPI document have been obtained
 *
 * A Path Item Object has been retrieved
 *
 * An Operation Object has been retrieved
 *
 * The Operation Object is associated with the Path Item Object
 *
 * A list of URLs for the servers to be included in the compliance test has been
 * provided
 *
 * c) Method:
 *
 * 1) Identify the Server Objects which are in-scope for this operationObject
 *
 * IF Server Objects are defined at the Operation level, then those and only
 * those Server Objects apply to that Operation.
 *
 * IF Server Objects are defined at the Path Item level, then those and only
 * those Server Objects apply to that Path Item.
 *
 * IF Server Objects are not defined at the Operation level, then the Server
 * Objects defined for the parent Path Item apply to that Operation.
 *
 * IF Server Objects are not defined at the Path Item level, then the Server
 * Objects defined for the root level apply to that Path.
 *
 * IF no Server Objects are defined at the root level, then the default server
 * object is assumed as described in the OpenAPI specification.
 *
 * 2) Process each Server Object using A.4.3.3.
 *
 * 3) Delete any Server URI which does not reference a server on the list of
 * servers to test.
 *
 * d) References: None
 *
 * @param apiModel        never <code>null</code>
 * @param iut             never <code>null</code>
 * @param pathItemObjects never <code>null</code>
 */
private static List<PathItemAndServer> identifyServerUrls(OpenApi3 apiModel, URI iut, List<Path> pathItemObjects) {
    List<PathItemAndServer> pathItemAndServers = new ArrayList<>();
    for (Path pathItemObject : pathItemObjects) {
        Map<String, Operation> operationObjects = pathItemObject.getOperations();
        for (Operation operationObject : operationObjects.values()) {
            List<String> serverUrls = identifyServerObjects(apiModel, pathItemObject, operationObject);
            for (String serverUrl : serverUrls) {
                if (DEFAULT_SERVER_URL.equalsIgnoreCase(serverUrl)) {
                    serverUrl = iut.toString();
                } else if (serverUrl.startsWith("/")) {
                    URI resolvedUri = iut.resolve(serverUrl);
                    serverUrl = resolvedUri.toString();
                }
                PathItemAndServer pathItemAndServer = new PathItemAndServer(pathItemObject, operationObject, serverUrl);
                pathItemAndServers.add(pathItemAndServer);
            }
        }
    }
    return pathItemAndServers;
}
Also used : Path(com.reprezen.kaizen.oasparser.model3.Path) ArrayList(java.util.ArrayList) Operation(com.reprezen.kaizen.oasparser.model3.Operation) URI(java.net.URI)

Example 23 with Server

use of com.reprezen.kaizen.oasparser.model3.Server in project ets-ogcapi-features10 by opengeospatial.

the class OpenApiUtils method identifyServerUrls.

/**
 * A.4.3.2. Identify Server URIs:
 *
 * a) Purpose: To identify all server URIs applicable to an OpenAPI Operation Object
 *
 * b) Pre-conditions:
 *
 * Server Objects from the root level of the OpenAPI document have been obtained
 *
 * A Path Item Object has been retrieved
 *
 * An Operation Object has been retrieved
 *
 * The Operation Object is associated with the Path Item Object
 *
 * A list of URLs for the servers to be included in the compliance test has been provided
 *
 * c) Method:
 *
 * 1) Identify the Server Objects which are in-scope for this operationObject
 *
 * IF Server Objects are defined at the Operation level, then those and only those Server Objects apply to that
 * Operation.
 *
 * IF Server Objects are defined at the Path Item level, then those and only those Server Objects apply to that Path
 * Item.
 *
 * IF Server Objects are not defined at the Operation level, then the Server Objects defined for the parent Path
 * Item apply to that Operation.
 *
 * IF Server Objects are not defined at the Path Item level, then the Server Objects defined for the root level
 * apply to that Path.
 *
 * IF no Server Objects are defined at the root level, then the default server object is assumed as described in the
 * OpenAPI specification.
 *
 * 2) Process each Server Object using A.4.3.3.
 *
 * 3) Delete any Server URI which does not reference a server on the list of servers to test.
 *
 * d) References: None
 *
 * @param apiModel
 *            never <code>null</code>
 * @param iut
 *            never <code>null</code>
 * @param pathItemObjects
 *            never <code>null</code>
 */
private static List<PathItemAndServer> identifyServerUrls(OpenApi3 apiModel, URI iut, List<Path> pathItemObjects) {
    List<PathItemAndServer> pathItemAndServers = new ArrayList<>();
    for (Path pathItemObject : pathItemObjects) {
        Map<String, Operation> operationObjects = pathItemObject.getOperations();
        for (Operation operationObject : operationObjects.values()) {
            List<String> serverUrls = identifyServerObjects(apiModel, pathItemObject, operationObject);
            for (String serverUrl : serverUrls) {
                if (DEFAULT_SERVER_URL.equalsIgnoreCase(serverUrl)) {
                    serverUrl = iut.toString();
                } else if (serverUrl.startsWith("/")) {
                    URI resolvedUri = iut.resolve(serverUrl);
                    serverUrl = resolvedUri.toString();
                }
                PathItemAndServer pathItemAndServer = new PathItemAndServer(pathItemObject, operationObject, serverUrl);
                pathItemAndServers.add(pathItemAndServer);
            }
        }
    }
    return pathItemAndServers;
}
Also used : Path(com.reprezen.kaizen.oasparser.model3.Path) ArrayList(java.util.ArrayList) Operation(com.reprezen.kaizen.oasparser.model3.Operation) URI(java.net.URI)

Aggregations

Server (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server)15 ServerInstance (org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance)10 Context (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context)9 Factory (org.eclipse.jst.server.tomcat.core.internal.xml.Factory)8 IPath (org.eclipse.core.runtime.IPath)6 Host (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Host)6 FileInputStream (java.io.FileInputStream)5 IStatus (org.eclipse.core.runtime.IStatus)5 MultiStatus (org.eclipse.core.runtime.MultiStatus)5 Status (org.eclipse.core.runtime.Status)5 ArrayList (java.util.ArrayList)4 Connector (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector)4 Engine (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Engine)4 Listener (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Listener)4 Service (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service)4 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 SAXException (org.xml.sax.SAXException)3 Operation (com.reprezen.kaizen.oasparser.model3.Operation)2