This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git
commit 73280b07682b665fdaf942eb2ae4ceb1ae74019d Author: Andrei Dulvac <[email protected]> AuthorDate: Tue Aug 9 07:47:02 2016 +0000 SLING-5880 [hapi client] Make org.apache.sling.hapi.client into a bundle git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1755563 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 33 +++++++-- ...odataHtmlClient.java => HtmlClientService.java} | 31 ++------ .../package-info.java} | 31 ++------ .../hapi/client/impl/HtmlClientServiceImpl.java | 82 ++++++++++++++++++++++ .../{ => impl}/microdata/MicrodataDocument.java | 2 +- .../{ => impl}/microdata/MicrodataHtmlClient.java | 2 +- .../MicrodataHtmlClient.java => package-info.java} | 31 ++------ .../apache/sling/hapi/client/test/FormTest.java | 2 +- .../apache/sling/hapi/client/test/GetPostTest.java | 2 +- .../apache/sling/hapi/client/test/ItemsTest.java | 2 +- 10 files changed, 131 insertions(+), 87 deletions(-) diff --git a/pom.xml b/pom.xml index 249f1ac..c4e0735 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,8 @@ </parent> <artifactId>org.apache.sling.hapi.client</artifactId> - <version>1.0.1-SNAPSHOT</version> + <version>1.0.0-SNAPSHOT</version> + <packaging>bundle</packaging> <name>HApi - Sling Hypermedia API client-side tools</name> <description>Sling client-side tools for HApi</description> @@ -43,6 +44,30 @@ <sling.java.version>6</sling.java.version> </properties> + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-scr-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.sling</groupId> + <artifactId>maven-sling-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Bundle-Category>sling</Bundle-Category> + <Sling-Initial-Content>SLING-INF;overwrite=true</Sling-Initial-Content> + <Embed-Dependency>groupId=org.jsoup</Embed-Dependency> + </instructions> + </configuration> + </plugin> + </plugins> + </build> <dependencies> <dependency> @@ -68,12 +93,12 @@ <dependency> <groupId>org.jsoup</groupId> <artifactId>jsoup</artifactId> - <version>1.8.3</version> + <version>1.9.2</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> - <version>1.7.12</version> + <version>1.7.21</version> </dependency> <!-- test scope --> <dependency> @@ -86,7 +111,7 @@ <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> - <version>1.7.12</version> + <version>1.7.21</version> <scope>test</scope> </dependency> <dependency> diff --git a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java b/src/main/java/org/apache/sling/hapi/client/HtmlClientService.java similarity index 53% copy from src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java copy to src/main/java/org/apache/sling/hapi/client/HtmlClientService.java index 807067a..bedf01d 100644 --- a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java +++ b/src/main/java/org/apache/sling/hapi/client/HtmlClientService.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * <p> + * <p/> * http://www.apache.org/licenses/LICENSE-2.0 - * <p> + * <p/> * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -16,29 +16,8 @@ * specific language governing permissions and limitations * under the License. ******************************************************************************/ -package org.apache.sling.hapi.client.microdata; +package org.apache.sling.hapi.client; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.sling.hapi.client.impl.AbstractHtmlClientImpl; +public interface HtmlClientService { -import java.net.URISyntaxException; - -public class MicrodataHtmlClient extends AbstractHtmlClientImpl { - - public MicrodataHtmlClient(CloseableHttpClient client, String baseUrl) throws URISyntaxException { - super(client, baseUrl); - } - - public MicrodataHtmlClient(String baseUrl) throws URISyntaxException { - super(baseUrl); - } - - public MicrodataHtmlClient(String baseUrl, String user, String password) throws URISyntaxException { - super(baseUrl, user, password); - } - - @Override - public MicrodataDocument newDocument(String html) { - return new MicrodataDocument(html, this, this.baseUrl.toString()); - } -} +} \ No newline at end of file diff --git a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java b/src/main/java/org/apache/sling/hapi/client/forms/package-info.java similarity index 53% copy from src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java copy to src/main/java/org/apache/sling/hapi/client/forms/package-info.java index 807067a..8003994 100644 --- a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java +++ b/src/main/java/org/apache/sling/hapi/client/forms/package-info.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * <p> + * * http://www.apache.org/licenses/LICENSE-2.0 - * <p> + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -16,29 +16,8 @@ * specific language governing permissions and limitations * under the License. ******************************************************************************/ -package org.apache.sling.hapi.client.microdata; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.sling.hapi.client.impl.AbstractHtmlClientImpl; +@Version("1.0.0") +package org.apache.sling.hapi.client.forms; -import java.net.URISyntaxException; - -public class MicrodataHtmlClient extends AbstractHtmlClientImpl { - - public MicrodataHtmlClient(CloseableHttpClient client, String baseUrl) throws URISyntaxException { - super(client, baseUrl); - } - - public MicrodataHtmlClient(String baseUrl) throws URISyntaxException { - super(baseUrl); - } - - public MicrodataHtmlClient(String baseUrl, String user, String password) throws URISyntaxException { - super(baseUrl, user, password); - } - - @Override - public MicrodataDocument newDocument(String html) { - return new MicrodataDocument(html, this, this.baseUrl.toString()); - } -} +import aQute.bnd.annotation.Version; diff --git a/src/main/java/org/apache/sling/hapi/client/impl/HtmlClientServiceImpl.java b/src/main/java/org/apache/sling/hapi/client/impl/HtmlClientServiceImpl.java new file mode 100644 index 0000000..a684d1d --- /dev/null +++ b/src/main/java/org/apache/sling/hapi/client/impl/HtmlClientServiceImpl.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + ******************************************************************************/ +package org.apache.sling.hapi.client.impl; + +import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.Service; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.sling.hapi.client.HtmlClient; +import org.apache.sling.hapi.client.HtmlClientService; +import org.apache.sling.hapi.client.impl.microdata.MicrodataHtmlClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.URISyntaxException; + +@Component(metatype = false) +@Service(value = HtmlClientService.class) +public class HtmlClientServiceImpl implements HtmlClientService { + + private final Logger LOG = LoggerFactory.getLogger(HtmlClientService.class); + + /** + * Get the HtmlClient + * @param client The inner http client + * @param baseUrl the base URL as String + * @return the HtmlClient or null if there was an error + */ + public HtmlClient getClient(CloseableHttpClient client, String baseUrl) { + try { + return new MicrodataHtmlClient(client, baseUrl); + } catch (URISyntaxException e) { + LOG.error("Cannot instantiate client", e); + return null; + } + } + + /** + * {@see HtmlClient} + * @param baseUrl the base URL as String + * @return the HtmlClient or null if there was an error + */ + public HtmlClient getClient(String baseUrl) { + try { + return new MicrodataHtmlClient(baseUrl); + } catch (URISyntaxException e) { + LOG.error("Cannot instantiate client", e); + return null; + } + } + + /** + * {@see HtmlClient} + * @param baseUrl the base URL as String + * @param user the username to be used for basic auth + * @param password the password to be used for basic auth + * @return the HtmlClient or null if there was an error + */ + public HtmlClient getClient(String baseUrl, String user, String password) { + try { + return new MicrodataHtmlClient(baseUrl, user, password); + } catch (URISyntaxException e) { + LOG.error("Cannot instantiate client", e); + return null; + } + } +} diff --git a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java b/src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataDocument.java similarity index 99% rename from src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java rename to src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataDocument.java index 22539df..248887d 100644 --- a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java +++ b/src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataDocument.java @@ -17,7 +17,7 @@ * under the License. ******************************************************************************/ -package org.apache.sling.hapi.client.microdata; +package org.apache.sling.hapi.client.impl.microdata; import org.apache.http.NameValuePair; import org.apache.sling.hapi.client.*; diff --git a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java b/src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataHtmlClient.java similarity index 97% copy from src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java copy to src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataHtmlClient.java index 807067a..c09eb3e 100644 --- a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java +++ b/src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataHtmlClient.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. ******************************************************************************/ -package org.apache.sling.hapi.client.microdata; +package org.apache.sling.hapi.client.impl.microdata; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.sling.hapi.client.impl.AbstractHtmlClientImpl; diff --git a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java b/src/main/java/org/apache/sling/hapi/client/package-info.java similarity index 53% rename from src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java rename to src/main/java/org/apache/sling/hapi/client/package-info.java index 807067a..c15121e 100644 --- a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java +++ b/src/main/java/org/apache/sling/hapi/client/package-info.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * <p> + * * http://www.apache.org/licenses/LICENSE-2.0 - * <p> + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -16,29 +16,8 @@ * specific language governing permissions and limitations * under the License. ******************************************************************************/ -package org.apache.sling.hapi.client.microdata; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.sling.hapi.client.impl.AbstractHtmlClientImpl; +@Version("1.0.0") +package org.apache.sling.hapi.client; -import java.net.URISyntaxException; - -public class MicrodataHtmlClient extends AbstractHtmlClientImpl { - - public MicrodataHtmlClient(CloseableHttpClient client, String baseUrl) throws URISyntaxException { - super(client, baseUrl); - } - - public MicrodataHtmlClient(String baseUrl) throws URISyntaxException { - super(baseUrl); - } - - public MicrodataHtmlClient(String baseUrl, String user, String password) throws URISyntaxException { - super(baseUrl, user, password); - } - - @Override - public MicrodataDocument newDocument(String html) { - return new MicrodataDocument(html, this, this.baseUrl.toString()); - } -} +import aQute.bnd.annotation.Version; diff --git a/src/test/java/org/apache/sling/hapi/client/test/FormTest.java b/src/test/java/org/apache/sling/hapi/client/test/FormTest.java index 5d9b675..9cfc73b 100644 --- a/src/test/java/org/apache/sling/hapi/client/test/FormTest.java +++ b/src/test/java/org/apache/sling/hapi/client/test/FormTest.java @@ -39,7 +39,7 @@ import org.apache.http.protocol.HttpRequestHandler; import org.apache.sling.hapi.client.ClientException; import org.apache.sling.hapi.client.Document; import org.apache.sling.hapi.client.Items; -import org.apache.sling.hapi.client.microdata.MicrodataHtmlClient; +import org.apache.sling.hapi.client.impl.microdata.MicrodataHtmlClient; import org.apache.sling.hapi.client.test.util.HttpServerRule; import org.junit.Assert; import org.junit.ClassRule; diff --git a/src/test/java/org/apache/sling/hapi/client/test/GetPostTest.java b/src/test/java/org/apache/sling/hapi/client/test/GetPostTest.java index 4e9b158..3f457c4 100644 --- a/src/test/java/org/apache/sling/hapi/client/test/GetPostTest.java +++ b/src/test/java/org/apache/sling/hapi/client/test/GetPostTest.java @@ -35,7 +35,7 @@ import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpRequestHandler; import org.apache.sling.hapi.client.ClientException; import org.apache.sling.hapi.client.Document; -import org.apache.sling.hapi.client.microdata.MicrodataHtmlClient; +import org.apache.sling.hapi.client.impl.microdata.MicrodataHtmlClient; import org.apache.sling.hapi.client.test.util.HttpServerRule; import org.hamcrest.core.StringContains; import org.junit.Assert; diff --git a/src/test/java/org/apache/sling/hapi/client/test/ItemsTest.java b/src/test/java/org/apache/sling/hapi/client/test/ItemsTest.java index 66561db..e43394e 100644 --- a/src/test/java/org/apache/sling/hapi/client/test/ItemsTest.java +++ b/src/test/java/org/apache/sling/hapi/client/test/ItemsTest.java @@ -35,7 +35,7 @@ import org.apache.http.protocol.HttpRequestHandler; import org.apache.sling.hapi.client.ClientException; import org.apache.sling.hapi.client.Document; import org.apache.sling.hapi.client.Items; -import org.apache.sling.hapi.client.microdata.MicrodataHtmlClient; +import org.apache.sling.hapi.client.impl.microdata.MicrodataHtmlClient; import org.apache.sling.hapi.client.test.util.HttpServerRule; import org.junit.Assert; import org.junit.ClassRule; -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
