diff options
author | Harald Musum <musum@oath.com> | 2018-07-12 08:52:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-12 08:52:20 +0200 |
commit | ef5ac16e81ddfbb2e5553769aac53c268944e8b9 (patch) | |
tree | 2ab512c304adece0a9126add4b3e7b8f5f9bd588 | |
parent | e243642ab09dc3aed3a10c7fc1634e80b4f23a57 (diff) |
Revert "Adding handler and binding when services.xml has <search>-field"
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | application/pom.xml | 5 | ||||
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/container/search/GUIHandler.java | 27 | ||||
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java | 11 | ||||
-rw-r--r-- | config-model/src/test/java/com/yahoo/vespa/model/container/xml/SearchBuilderTest.java | 27 | ||||
-rw-r--r-- | container-disc/pom.xml | 1 | ||||
-rw-r--r-- | container-integration-test/.gitignore | 31 | ||||
-rw-r--r-- | container-integration-test/OWNERS | 1 | ||||
-rw-r--r-- | container-integration-test/README | 1 | ||||
-rw-r--r-- | container-integration-test/pom.xml | 44 | ||||
-rw-r--r-- | container-search-gui/CMakeLists.txt | 2 | ||||
-rw-r--r-- | container-search-gui/pom.xml | 91 | ||||
-rw-r--r-- | container-search-gui/src/main/java/com/yahoo/search/query/gui/GUIHandler.java | 70 | ||||
-rw-r--r-- | container-search-gui/src/test/java/com/yahoo/search/query/gui/GUIHandlerTest.java (renamed from container-integration-test/src/test/java/com/yahoo/search/query/gui/GUIHandlerTest.java) | 11 | ||||
-rw-r--r-- | pom.xml | 1 |
15 files changed, 80 insertions, 244 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c557179750..23dcef6d96d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,6 @@ add_subdirectory(container-disc) add_subdirectory(container-jersey2) add_subdirectory(container-messagebus) add_subdirectory(container-search) -add_subdirectory(container-search-gui) add_subdirectory(container-search-and-docproc) add_subdirectory(clustercontroller-apps) add_subdirectory(clustercontroller-apputil) diff --git a/application/pom.xml b/application/pom.xml index 0808f2be58e..db298451a8b 100644 --- a/application/pom.xml +++ b/application/pom.xml @@ -46,11 +46,6 @@ </dependency> <dependency> <groupId>com.yahoo.vespa</groupId> - <artifactId>container-search-gui</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> <artifactId>zkfacade</artifactId> <version>${project.version}</version> </dependency> diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/GUIHandler.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/GUIHandler.java deleted file mode 100644 index 025075be8fd..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/GUIHandler.java +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.container.search; - -import com.yahoo.config.model.producer.AbstractConfigProducer; -import com.yahoo.container.bundle.BundleInstantiationSpecification; -import com.yahoo.osgi.provider.model.ComponentModel; -import com.yahoo.vespa.model.container.component.Handler; - - -/** - * @author Henrik Høiness - */ - -public class GUIHandler extends Handler<AbstractConfigProducer<?>> { - public static final String BUNDLE = "container-search-gui"; - public static final String CLASS = "com.yahoo.search.query.gui.GUIHandler"; - public static final String BINDING = "*/querybuilder/*"; - - public GUIHandler() { - super(new ComponentModel(bundleSpec(CLASS, BUNDLE))); - } - - public static BundleInstantiationSpecification bundleSpec(String className, String bundle) { - return BundleInstantiationSpecification.getFromStrings(className, className, bundle); - } - -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java index d81026c54d1..a007c4765c0 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java @@ -23,7 +23,6 @@ import com.yahoo.config.provision.NodeType; import com.yahoo.config.provision.Rotation; import com.yahoo.config.provision.Zone; import com.yahoo.container.jdisc.config.MetricDefaultsConfig; -import com.yahoo.osgi.provider.model.ComponentModel; import com.yahoo.search.rendering.RendererRegistry; import com.yahoo.text.XML; import com.yahoo.vespa.defaults.Defaults; @@ -48,7 +47,6 @@ import com.yahoo.vespa.model.container.IdentityProvider; import com.yahoo.vespa.model.container.SecretStore; import com.yahoo.vespa.model.container.component.Component; import com.yahoo.vespa.model.container.component.FileStatusHandlerComponent; -import com.yahoo.vespa.model.container.component.Handler; import com.yahoo.vespa.model.container.component.chain.ProcessingHandler; import com.yahoo.vespa.model.container.docproc.ContainerDocproc; import com.yahoo.vespa.model.container.docproc.DocprocChains; @@ -57,7 +55,6 @@ import com.yahoo.vespa.model.container.http.xml.HttpBuilder; import com.yahoo.vespa.model.container.jersey.xml.RestApiBuilder; import com.yahoo.vespa.model.container.processing.ProcessingChains; import com.yahoo.vespa.model.container.search.ContainerSearch; -import com.yahoo.vespa.model.container.search.GUIHandler; import com.yahoo.vespa.model.container.search.PageTemplates; import com.yahoo.vespa.model.container.search.QueryProfiles; import com.yahoo.vespa.model.container.search.SemanticRules; @@ -381,7 +378,6 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { cluster.setSearch(buildSearch(cluster, searchElement, queryProfiles, semanticRules)); addSearchHandler(cluster, searchElement); - addGUIHandler(cluster); validateAndAddConfiguredComponents(cluster, searchElement, "renderer", ContainerModelBuilder::validateRendererElement); } } @@ -674,13 +670,6 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { cluster.addComponent(searchHandler); } - private void addGUIHandler(ContainerCluster cluster) { - Handler<?> guiHandler = new GUIHandler(); - guiHandler.addServerBindings("http://"+GUIHandler.BINDING, "https://"+GUIHandler.BINDING); - cluster.addComponent(guiHandler); - } - - private String[] serverBindings(Element searchElement, String... defaultBindings) { List<Element> bindings = XML.getChildren(searchElement, "binding"); if (bindings.isEmpty()) diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/SearchBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/SearchBuilderTest.java index 30f1df6a394..cc8733fc9e2 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/SearchBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/SearchBuilderTest.java @@ -8,8 +8,6 @@ import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.model.VespaModel; import com.yahoo.vespa.model.container.Container; import com.yahoo.vespa.model.container.ContainerCluster; -import com.yahoo.vespa.model.container.component.Handler; -import com.yahoo.vespa.model.container.search.GUIHandler; import com.yahoo.vespa.model.test.utils.ApplicationPackageUtils; import com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg; import org.junit.Test; @@ -34,31 +32,6 @@ public class SearchBuilderTest extends ContainerModelBuilderTestBase { return root.getConfig(ChainsConfig.class, "default/component/com.yahoo.search.handler.SearchHandler"); } - @Test - public void gui_search_handler_is_always_included_when_search_is_specified() throws Exception{ - Element clusterElem = DomBuilderTest.parse( - "<jdisc id='default' version='1.0'>", - " <search />", - nodesXml, - "</jdisc>"); - - createModel(root, clusterElem); - - String discBindingsConfig = root.getConfig(JdiscBindingsConfig.class, "default").toString(); - assertThat(discBindingsConfig, containsString(GUIHandler.BINDING)); - - ContainerCluster cluster = (ContainerCluster)root.getChildren().get("default"); - - GUIHandler guiHandler = null; - for (Handler<?> handler : cluster.getHandlers()) { - if (handler instanceof GUIHandler) { - guiHandler = (GUIHandler) handler; - } - } - if (guiHandler == null) fail(); - } - - @Test public void search_handler_bindings_can_be_overridden() throws Exception { diff --git a/container-disc/pom.xml b/container-disc/pom.xml index ea3425d302d..c112466bbd4 100644 --- a/container-disc/pom.xml +++ b/container-disc/pom.xml @@ -169,7 +169,6 @@ configdefinitions-jar-with-dependencies.jar, container-jersey2-jar-with-dependencies.jar, container-search-and-docproc-jar-with-dependencies.jar, - container-search-gui-jar-with-dependencies.jar, docprocs-jar-with-dependencies.jar, jdisc-security-filters-jar-with-dependencies.jar, jdisc_http_service-jar-with-dependencies.jar, diff --git a/container-integration-test/.gitignore b/container-integration-test/.gitignore deleted file mode 100644 index 7f4ebc3a7c6..00000000000 --- a/container-integration-test/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -.classpath -.project -.settings -/.cache -/.classpath -/.emacs.desktop -/.nbintdb -/.project -/.settings -/.version -/QueryAccessLog* -/accessLog.log -/build -/bundles -/libexec -/nbproject -/pom.xml.build -/prelude.iml -/prelude.ipr -/prelude.iws -/staging -/target -/temp -/testLogFileG.txt -/testLogs -/test_yapache_access_log -/testlogsG -/testng.out.log -/tmp -null.log -tmp diff --git a/container-integration-test/OWNERS b/container-integration-test/OWNERS deleted file mode 100644 index 6faef1015fb..00000000000 --- a/container-integration-test/OWNERS +++ /dev/null @@ -1 +0,0 @@ -gjoranv
\ No newline at end of file diff --git a/container-integration-test/README b/container-integration-test/README deleted file mode 100644 index c10341c3d8e..00000000000 --- a/container-integration-test/README +++ /dev/null @@ -1 +0,0 @@ -Test for JDisc-components diff --git a/container-integration-test/pom.xml b/container-integration-test/pom.xml deleted file mode 100644 index 4b4d5de21eb..00000000000 --- a/container-integration-test/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0"?> -<!-- Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 - http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>com.yahoo.vespa</groupId> - <artifactId>parent</artifactId> - <version>6-SNAPSHOT</version> - <relativePath>../parent/pom.xml</relativePath> - </parent> - <artifactId>container-integration-test</artifactId> - <packaging>jar</packaging> - <version>6-SNAPSHOT</version> - <dependencies> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>container-search-gui</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>application</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - </plugin> - </plugins> - </build> -</project>
\ No newline at end of file diff --git a/container-search-gui/CMakeLists.txt b/container-search-gui/CMakeLists.txt deleted file mode 100644 index 95476154443..00000000000 --- a/container-search-gui/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -# Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -install_fat_java_artifact(container-search-gui)
\ No newline at end of file diff --git a/container-search-gui/pom.xml b/container-search-gui/pom.xml index f598758e1de..f2ca70dd1f3 100644 --- a/container-search-gui/pom.xml +++ b/container-search-gui/pom.xml @@ -4,55 +4,46 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>com.yahoo.vespa</groupId> - <artifactId>parent</artifactId> - <version>6-SNAPSHOT</version> - <relativePath>../parent/pom.xml</relativePath> - </parent> - <artifactId>container-search-gui</artifactId> - <packaging>container-plugin</packaging> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>com.yahoo.vespa</groupId> + <artifactId>parent</artifactId> <version>6-SNAPSHOT</version> - <dependencies> - <dependency> - <groupId>com.google.inject</groupId> - <artifactId>guice</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>yolean</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>jdisc_http_service</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>jdisc_core</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>container-core</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>com.yahoo.vespa</groupId> - <artifactId>bundle-plugin</artifactId> - <extensions>true</extensions> - </plugin> - </plugins> - </build> - + <relativePath>../parent/pom.xml</relativePath> + </parent> + <artifactId>container-search-gui</artifactId> + <packaging>jar</packaging> + <version>6-SNAPSHOT</version> + <dependencies> + <dependency> + <groupId>com.yahoo.vespa</groupId> + <artifactId>application</artifactId> + <version>6-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <compilerArgs> + <arg>-Xlint:all</arg> + <arg>-Xlint:-rawtypes</arg> + <arg>-Xlint:-unchecked</arg> + <arg>-Xlint:-serial</arg> + <arg>-Xlint:-deprecation</arg> + <arg>-Xlint:-dep-ann</arg> + <arg>-Xlint:-cast</arg> + <arg>-Werror</arg> + </compilerArgs> + </configuration> + </plugin> + </plugins> + </build> </project>
\ No newline at end of file diff --git a/container-search-gui/src/main/java/com/yahoo/search/query/gui/GUIHandler.java b/container-search-gui/src/main/java/com/yahoo/search/query/gui/GUIHandler.java index 95adbbea3fc..0f4eebd7fd7 100644 --- a/container-search-gui/src/main/java/com/yahoo/search/query/gui/GUIHandler.java +++ b/container-search-gui/src/main/java/com/yahoo/search/query/gui/GUIHandler.java @@ -5,13 +5,17 @@ import com.google.inject.Inject; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.container.jdisc.LoggingRequestHandler; + + import com.yahoo.search.query.restapi.ErrorResponse; import com.yahoo.yolean.Exceptions; - +import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.logging.Level; /** @@ -43,83 +47,75 @@ public class GUIHandler extends LoggingRequestHandler { } private HttpResponse handleGET(HttpRequest request) { - com.yahoo.restapi.Path path = new com.yahoo.restapi.Path(request.getUri().getPath()); + com.yahoo.restapi.Path path = new com.yahoo.restapi.Path(request.getUri().getPath()); if (path.matches("/querybuilder/")) { return new FileResponse("_includes/index.html"); } if (!path.matches("/querybuilder/{*}") ) { - return ErrorResponse.notFoundError("Nothing at path:" + path); + return ErrorResponse.notFoundError("Nothing at " + path); } String filepath = path.getRest(); - if (!isValidPath(filepath)){ - return ErrorResponse.notFoundError("Nothing at path:" + filepath); + if (!isValidPath(GUIHandler.class.getClassLoader().getResource("gui").getFile()+"/"+filepath)){ + return ErrorResponse.notFoundError("Nothing at " + path); } return new FileResponse(filepath); } private static boolean isValidPath(String path) { - InputStream in = GUIHandler.class.getClassLoader().getResourceAsStream("gui/"+path); - boolean isValid = (in != null); - if(isValid){ - try { in.close(); } catch (IOException e) {/* Problem with closing inputstream */} - } - - return isValid; + File file = new File(path); + return file.exists(); } private static class FileResponse extends HttpResponse { - private final String path; + private final Path path; public FileResponse(String relativePath) { super(200); - this.path = relativePath; + this.path = Paths.get(GUIHandler.class.getClassLoader().getResource("gui").getFile(), relativePath); } @Override public void render(OutputStream out) throws IOException { - InputStream is = GUIHandler.class.getClassLoader().getResourceAsStream("gui/"+this.path); - byte[] buf = new byte[1024]; - int numRead; - while ( (numRead = is.read(buf) ) >= 0) { - out.write(buf, 0, numRead); - } + byte[] data = Files.readAllBytes(path); + out.write(data); } @Override public String getContentType() { - if (path.endsWith(".css")) { + if (path.toString().endsWith(".css")) { return "text/css"; - } else if (path.endsWith(".js")) { + } else if (path.toString().endsWith(".js")) { return "application/javascript"; - } else if (path.endsWith(".html")) { + } else if (path.toString().endsWith(".html")) { return "text/html"; - } else if (path.endsWith(".php")) { + }else if (path.toString().endsWith(".php")) { return "text/php"; - } else if (path.endsWith(".svg")) { + }else if (path.toString().endsWith(".svg")) { return "image/svg+xml"; - } else if (path.endsWith(".eot")) { + }else if (path.toString().endsWith(".eot")) { return "application/vnd.ms-fontobject"; - } else if (path.endsWith(".ttf")) { + }else if (path.toString().endsWith(".ttf")) { return "font/ttf"; - } else if (path.endsWith(".woff")) { + }else if (path.toString().endsWith(".woff")) { return "font/woff"; - } else if (path.endsWith(".woff2")) { + }else if (path.toString().endsWith(".woff2")) { return "font/woff2"; - } else if (path.endsWith(".otf")) { + }else if (path.toString().endsWith(".otf")) { return "font/otf"; - } else if (path.endsWith(".png")) { + }else if (path.toString().endsWith(".png")) { return "image/png"; - } else if (path.endsWith(".xml")) { + }else if (path.toString().endsWith(".xml")) { return "application/xml"; - } else if (path.endsWith(".ico")) { + }else if (path.toString().endsWith(".ico")) { return "image/x-icon"; - } else if (path.endsWith(".json")) { + }else if (path.toString().endsWith(".json")) { return "application/json"; - } else if (path.endsWith(".ttf")) { + }else if (path.toString().endsWith(".ttf")) { return "font/ttf"; } return "text/html"; } } -}
\ No newline at end of file + +} diff --git a/container-integration-test/src/test/java/com/yahoo/search/query/gui/GUIHandlerTest.java b/container-search-gui/src/test/java/com/yahoo/search/query/gui/GUIHandlerTest.java index 5fd73afe800..ec515a1bf4a 100644 --- a/container-integration-test/src/test/java/com/yahoo/search/query/gui/GUIHandlerTest.java +++ b/container-search-gui/src/test/java/com/yahoo/search/query/gui/GUIHandlerTest.java @@ -5,12 +5,13 @@ import com.yahoo.application.Networking; import com.yahoo.application.container.JDisc; import com.yahoo.application.container.handler.Request; import com.yahoo.application.container.handler.Response; - import org.junit.After; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; + import java.io.IOException; -import static org.junit.Assert.assertEquals; + import static org.junit.Assert.assertTrue; @@ -24,7 +25,7 @@ public class GUIHandlerTest { @Before public void startContainer() { - container = JDisc.fromServicesXml(servicesXml(), Networking.disable); + container = JDisc.fromServicesXml(servicesXml(), Networking.enable); } @After @@ -63,8 +64,8 @@ public class GUIHandlerTest { private void assertResponse(Request.Method method, String path, String expectedStartString, String expectedContentType, int expectedStatusCode) throws IOException { Response response = container.handleRequest(new Request("http://localhost:8080" + path, new byte[0], method)); - assertEquals("Status code", expectedStatusCode, response.getStatus()); - assertEquals(expectedContentType, response.getHeaders().getFirst("Content-Type")); + Assert.assertEquals("Status code", expectedStatusCode, response.getStatus()); + Assert.assertEquals(expectedContentType, response.getHeaders().getFirst("Content-Type")); if(expectedStartString != null){ assertTrue(response.getBodyAsString().startsWith(expectedStartString)); } @@ -56,7 +56,6 @@ <module>container-dev</module> <module>container-di</module> <module>container-disc</module> - <module>container-integration-test</module> <module>container-jersey2</module> <module>container-messagebus</module> <module>container-search-and-docproc</module> |