Author: dulvac
Date: Wed Aug 10 11:38:38 2016
New Revision: 1755727

URL: http://svn.apache.org/viewvc?rev=1755727&view=rev
Log:
SLING-5880 Fixed service interface

Modified:
    sling/trunk/contrib/extensions/hapi/client/pom.xml
    
sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/Document.java
    
sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/HtmlClientService.java
    
sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/Item.java
    
sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/impl/HtmlClientServiceImpl.java

Modified: sling/trunk/contrib/extensions/hapi/client/pom.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/hapi/client/pom.xml?rev=1755727&r1=1755726&r2=1755727&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/hapi/client/pom.xml (original)
+++ sling/trunk/contrib/extensions/hapi/client/pom.xml Wed Aug 10 11:38:38 2016
@@ -61,6 +61,7 @@
                 <configuration>
                     <instructions>
                         <Bundle-Category>sling</Bundle-Category>
+                        
<Private-Package>org.apache.sling.hapi.client.forms</Private-Package>
                         
<Sling-Initial-Content>SLING-INF;overwrite=true</Sling-Initial-Content>
                         <Embed-Dependency>groupId=org.jsoup</Embed-Dependency>
                     </instructions>

Modified: 
sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/Document.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/Document.java?rev=1755727&r1=1755726&r2=1755727&view=diff
==============================================================================
--- 
sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/Document.java
 (original)
+++ 
sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/Document.java
 Wed Aug 10 11:38:38 2016
@@ -19,11 +19,39 @@
 package org.apache.sling.hapi.client;
 
 /**
- * An HTML document representation
+ * A hapi representation of an HTML document, backed by HTML markup.
+ * The Document provides a structure, accessible through the {@link 
#item(String)} and {@link #items()} methods
+ * and a way to use the hypermedia controls through the {@link #link(String)} 
and {@link #form(String)} methods
  */
 public interface Document {
+    /**
+     * Get all the {@link Document}'s link items. These Items should normally 
be backed by HTML <i>anchors</i> and <i>links</i>.
+     * @param rel An identifier that groups all the <i>link</i> Items for this 
Document
+     * @return all the link Items for this Document, that have the given 
relation
+     * @throws ClientException
+     */
     Items link(String rel) throws ClientException;
+
+    /**
+     * Get all the {@link Document}'s form items. These Items should normally 
be backed by the HTML <i>form</i> element
+     * @param rel An identifier that groups all the <i>form</i> Items for this 
Document
+     * @return all the form Items for this Document, that have the given 
relation
+     * @throws ClientException
+     */
     Items form(String rel) throws ClientException;
+
+    /**
+     * Get all the {@link Document}'s items. These Items are backed by any 
HTML element
+     * @param rel An identifier that groups all the Items for this Document
+     * @return all the Items for this Document, that have the given relation
+     * @throws ClientException
+     */
     Items item(String rel) throws ClientException;
+
+    /**
+     * Get all the {@link Document}'s items. These Items are backed by any 
HTML element
+     * @return all the Items for this Document
+     * @throws ClientException
+     */
     Items items() throws ClientException;
 }

Modified: 
sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/HtmlClientService.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/HtmlClientService.java?rev=1755727&r1=1755726&r2=1755727&view=diff
==============================================================================
--- 
sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/HtmlClientService.java
 (original)
+++ 
sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/HtmlClientService.java
 Wed Aug 10 11:38:38 2016
@@ -18,6 +18,32 @@
  
******************************************************************************/
 package org.apache.sling.hapi.client;
 
+import org.apache.http.impl.client.CloseableHttpClient;
+
 public interface HtmlClientService {
 
+    /**
+     * Get an HtmlClient that internally uses a CloseableHttpClient
+     * @param client the inner {@link CloseableHttpClient}. The client should 
take care of any timeouts, authentication, pre/post
+     *               processing, etc.
+     * @param baseUrl The address prefix to all the http requests (e.g. 
http://localhost:8080/myapp/)
+     * @return
+     */
+    HtmlClient getClient(CloseableHttpClient client, String baseUrl);
+
+    /**
+     * Get an HtmlClient.
+     * @param baseUrl The address prefix to all the http requests (e.g. 
http://localhost:8080/myapp/)
+     * @return
+     */
+    HtmlClient getClient(String baseUrl);
+
+    /**
+     * Get an HtmlClient that uses BasicAuth for all requests
+     * @param baseUrl The address prefix to all the http requests (e.g. 
http://localhost:8080/myapp/)
+     * @param user The username for BasicAuth
+     * @param password The password for BasicAuth
+     * @return
+     */
+    HtmlClient getClient(String baseUrl, String user, String password);
 }
\ No newline at end of file

Modified: 
sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/Item.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/Item.java?rev=1755727&r1=1755726&r2=1755727&view=diff
==============================================================================
--- 
sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/Item.java
 (original)
+++ 
sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/Item.java
 Wed Aug 10 11:38:38 2016
@@ -20,21 +20,22 @@ package org.apache.sling.hapi.client;
  
******************************************************************************/
 
 import org.apache.http.NameValuePair;
-
-import java.util.List;
 import java.util.Set;
 
 /**
- *
+ * An HTML item representation. This maps to an html element and contains all 
the child elements.
+ * The child <i>semantic</i> elements (properties, links, forms) and the 
Item's metadata (src, href, value)
+ * are accessible through the dedicated methods
  */
 public interface Item {
     /**
-     * Returns the property of the item having the given name.
+     * Returns the property of the item having the given name. The property is 
a child Item.
      */
     Items prop(String name) throws ClientException;
 
     /**
-     * Return a List of all the properties of this item
+     * Return a List of all the properties of this item.
+     * The returned Strings are names that can be used for {@link 
#prop(String)}
      */
     Set<String> props() throws ClientException;
 
@@ -81,12 +82,12 @@ public interface Item {
     String src();
 
     /**
-     * Follow a hyperlink and get a new {@see Document} representation
+     * Follow a hyperlink and get a new {@link Document} representation
      */
     Document follow() throws ClientException;
 
     /**
-     * Submits this form item and returns a new {@see Document} representation
+     * Submits this form item and returns a new {@link Document} representation
      */
     Document submit(Iterable<NameValuePair> data) throws ClientException;
 }

Modified: 
sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/impl/HtmlClientServiceImpl.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/impl/HtmlClientServiceImpl.java?rev=1755727&r1=1755726&r2=1755727&view=diff
==============================================================================
--- 
sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/impl/HtmlClientServiceImpl.java
 (original)
+++ 
sling/trunk/contrib/extensions/hapi/client/src/main/java/org/apache/sling/hapi/client/impl/HtmlClientServiceImpl.java
 Wed Aug 10 11:38:38 2016
@@ -32,7 +32,6 @@ import java.net.URISyntaxException;
 @Component(metatype = false)
 @Service(value = HtmlClientService.class)
 public class HtmlClientServiceImpl implements HtmlClientService {
-
     private final Logger LOG = 
LoggerFactory.getLogger(HtmlClientService.class);
 
     /**
@@ -41,6 +40,7 @@ public class HtmlClientServiceImpl imple
      * @param baseUrl the base URL as String
      * @return the HtmlClient or null if there was an error
      */
+    @Override
     public HtmlClient getClient(CloseableHttpClient client, String baseUrl) {
         try {
             return new MicrodataHtmlClient(client, baseUrl);
@@ -55,6 +55,7 @@ public class HtmlClientServiceImpl imple
      * @param baseUrl the base URL as String
      * @return the HtmlClient or null if there was an error
      */
+    @Override
     public HtmlClient getClient(String baseUrl) {
         try {
             return new MicrodataHtmlClient(baseUrl);
@@ -71,6 +72,7 @@ public class HtmlClientServiceImpl imple
      * @param password the password to be used for basic auth
      * @return the HtmlClient or null if there was an error
      */
+    @Override
     public HtmlClient getClient(String baseUrl, String user, String password) {
         try {
             return new MicrodataHtmlClient(baseUrl, user, password);


Reply via email to