Author: sujen
Date: Sat Nov 14 03:41:32 2015
New Revision: 1714292

URL: http://svn.apache.org/viewvc?rev=1714292&view=rev
Log:
NUTCH-2157 Addressing Miredot REST API Warnings, this closes #84 (Sujen Shah)

Modified:
    nutch/trunk/CHANGES.txt
    nutch/trunk/src/java/org/apache/nutch/service/resources/AdminResource.java
    nutch/trunk/src/java/org/apache/nutch/service/resources/ConfigResource.java
    nutch/trunk/src/java/org/apache/nutch/service/resources/JobResource.java
    nutch/trunk/src/java/org/apache/nutch/service/resources/ReaderResouce.java
    nutch/trunk/src/java/org/apache/nutch/service/resources/SeedResource.java

Modified: nutch/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/nutch/trunk/CHANGES.txt?rev=1714292&r1=1714291&r2=1714292&view=diff
==============================================================================
--- nutch/trunk/CHANGES.txt (original)
+++ nutch/trunk/CHANGES.txt Sat Nov 14 03:41:32 2015
@@ -3,6 +3,8 @@ Nutch Change Log
 Nutch 1.11 Release 25/10/2015 (dd/mm/yyyy)
 Release Report: http://s.apache.org/nutch11
 
+* NUTCH-2157 Addressing Miredot REST API Warnings (Sujen Shah)
+
 * NUTCH-2165 FileDumper Util hard codes part-# folder name (joyce)
 
 * NUTCH-2167 Backport TableUtil from 2.x for URL reversing (joyce)

Modified: 
nutch/trunk/src/java/org/apache/nutch/service/resources/AdminResource.java
URL: 
http://svn.apache.org/viewvc/nutch/trunk/src/java/org/apache/nutch/service/resources/AdminResource.java?rev=1714292&r1=1714291&r2=1714292&view=diff
==============================================================================
--- nutch/trunk/src/java/org/apache/nutch/service/resources/AdminResource.java 
(original)
+++ nutch/trunk/src/java/org/apache/nutch/service/resources/AdminResource.java 
Sat Nov 14 03:41:32 2015
@@ -34,6 +34,10 @@ public class AdminResource extends Abstr
   private static final Logger LOG = LoggerFactory
       .getLogger(AdminResource.class);
 
+  /**
+   * To get the status of the Nutch Server 
+   * @return
+   */
   @GET
   @Path(value="/")
   public NutchServerInfo getServerStatus(){
@@ -45,6 +49,11 @@ public class AdminResource extends Abstr
     return serverInfo;
   }
 
+  /**
+   * Stop the Nutch server
+   * @param force If set to true, it will kill any running jobs
+   * @return
+   */
   @GET
   @Path(value="/stop")
   public String stopServer(@QueryParam("force") boolean force){

Modified: 
nutch/trunk/src/java/org/apache/nutch/service/resources/ConfigResource.java
URL: 
http://svn.apache.org/viewvc/nutch/trunk/src/java/org/apache/nutch/service/resources/ConfigResource.java?rev=1714292&r1=1714291&r2=1714292&view=diff
==============================================================================
--- nutch/trunk/src/java/org/apache/nutch/service/resources/ConfigResource.java 
(original)
+++ nutch/trunk/src/java/org/apache/nutch/service/resources/ConfigResource.java 
Sat Nov 14 03:41:32 2015
@@ -43,6 +43,10 @@ public class ConfigResource extends Abst
 
   public static final String DEFAULT = "default";
 
+  /**
+   * Returns a list of all configurations created.
+   * @return List of configurations
+   */
   @GET
   @Path("/")
        @JacksonFeatures(serializationEnable =  { 
SerializationFeature.INDENT_OUTPUT })
@@ -50,6 +54,11 @@ public class ConfigResource extends Abst
     return configManager.list();
   }
 
+  /** 
+   * Get configuration properties 
+   * @param configId The configuration ID to fetch
+   * @return HashMap of the properties set within the given configId
+   */
   @GET
   @Path("/{configId}")
        @JacksonFeatures(serializationEnable =  { 
SerializationFeature.INDENT_OUTPUT })
@@ -57,6 +66,12 @@ public class ConfigResource extends Abst
     return configManager.getAsMap(configId);
   }
 
+  /**
+   * Get property 
+   * @param configId The ID of the configuration
+   * @param propertyId The name(key) of the property
+   * @return value of the specified property in the provided configId.
+   */
   @GET
   @Path("/{configId}/{propertyId}")
   @Produces(MediaType.TEXT_PLAIN)
@@ -66,12 +81,21 @@ public class ConfigResource extends Abst
     return configManager.getAsMap(configId).get(propertyId);
   }
 
+  /**
+   * Removes the configuration from the list of known configurations. 
+   * @param configId The ID of the configuration to delete
+   */
   @DELETE
   @Path("/{configId}")
   public void deleteConfig(@PathParam("configId") String configId) {
     configManager.delete(configId);
   }
 
+  /**
+   * Create new configuration.
+   * @param newConfig 
+   * @return The name of the new configuration created
+   */
   @POST
   @Path("/create")
   @Consumes(MediaType.APPLICATION_JSON)
@@ -90,6 +114,14 @@ public class ConfigResource extends Abst
     return Response.ok(newConfig.getConfigId()).build();
   }
   
+  /**
+   * Adds/Updates a particular property value in the configuration
+   * @param confId Configuration ID whose property needs to be updated. Make 
sure that the given
+   *               confId exists to prevent errors. 
+   * @param propertyKey Name of the property
+   * @param value Value as a simple text 
+   * @return Success code
+   */
   @PUT
   @Path("/{configId}/{propertyId}")
   @Consumes(MediaType.TEXT_PLAIN)

Modified: 
nutch/trunk/src/java/org/apache/nutch/service/resources/JobResource.java
URL: 
http://svn.apache.org/viewvc/nutch/trunk/src/java/org/apache/nutch/service/resources/JobResource.java?rev=1714292&r1=1714291&r2=1714292&view=diff
==============================================================================
--- nutch/trunk/src/java/org/apache/nutch/service/resources/JobResource.java 
(original)
+++ nutch/trunk/src/java/org/apache/nutch/service/resources/JobResource.java 
Sat Nov 14 03:41:32 2015
@@ -35,6 +35,11 @@ import org.apache.nutch.service.model.re
 @Path(value = "/job")
 public class JobResource extends AbstractResource {
 
+  /**
+   * Get job history
+   * @param crawlId
+   * @return A nested JSON object of all the jobs created
+   */
   @GET
   @Path(value = "/")
   @JacksonFeatures(serializationEnable =  { SerializationFeature.INDENT_OUTPUT 
})
@@ -42,6 +47,12 @@ public class JobResource extends Abstrac
     return jobManager.list(crawlId, State.ANY);
   }
 
+  /**
+   * Get job info
+   * @param id Job ID
+   * @param crawlId Crawl ID
+   * @return A JSON object of job parameters
+   */
   @GET
   @Path(value = "/{id}")
   @JacksonFeatures(serializationEnable =  { SerializationFeature.INDENT_OUTPUT 
})
@@ -50,6 +61,12 @@ public class JobResource extends Abstrac
     return jobManager.get(crawlId, id);
   }
 
+  /**
+   * Stop Job
+   * @param id Job ID
+   * @param crawlId
+   * @return
+   */
   @GET
   @Path(value = "/{id}/stop")
   public boolean stop(@PathParam("id") String id,
@@ -57,6 +74,7 @@ public class JobResource extends Abstrac
     return jobManager.stop(crawlId, id);
   }
 
+  
   @GET
   @Path(value = "/{id}/abort")
   public boolean abort(@PathParam("id") String id,
@@ -64,6 +82,11 @@ public class JobResource extends Abstrac
     return jobManager.abort(crawlId, id);
   }
 
+  /**
+   * Create a new job
+   * @param config The parameters of the job to create
+   * @return A JSON object of the job created with its details
+   */
   @POST
   @Path(value = "/create")
   @Consumes(MediaType.APPLICATION_JSON)

Modified: 
nutch/trunk/src/java/org/apache/nutch/service/resources/ReaderResouce.java
URL: 
http://svn.apache.org/viewvc/nutch/trunk/src/java/org/apache/nutch/service/resources/ReaderResouce.java?rev=1714292&r1=1714291&r2=1714292&view=diff
==============================================================================
--- nutch/trunk/src/java/org/apache/nutch/service/resources/ReaderResouce.java 
(original)
+++ nutch/trunk/src/java/org/apache/nutch/service/resources/ReaderResouce.java 
Sat Nov 14 03:41:32 2015
@@ -18,10 +18,12 @@ package org.apache.nutch.service.resourc
 
 import java.util.HashMap;
 
+import javax.ws.rs.Consumes;
 import javax.ws.rs.DefaultValue;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -42,8 +44,19 @@ import org.apache.nutch.service.model.re
 @Path("/reader")
 public class ReaderResouce {
 
+  /**
+   * Read a sequence file
+   * @param readerConf 
+   * @param nrows Number of rows to read. If not specified all rows will be 
read
+   * @param start Specify a starting line number to read the file from
+   * @param end The line number to read the file till
+   * @param count Boolean value. If true, this endpoint will return the number 
of lines in the line
+   * @return Appropriate HTTP response based on the query
+   */
   @Path("/sequence/read")
   @POST
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
   public Response seqRead(ReaderConfig readerConf, 
       @DefaultValue("-1")@QueryParam("nrows") int nrows, 
       @DefaultValue("-1")@QueryParam("start") int start, 
@@ -54,8 +67,13 @@ public class ReaderResouce {
     return performRead(reader, path, nrows, start, end, count);
   }
 
+  /**
+   * Get Link Reader response schema 
+   * @return JSON object specifying the schema of the responses returned by 
the Link Reader
+   */
   @Path("/link")
   @GET
+  @Produces(MediaType.APPLICATION_JSON)
   public Response linkRead() {
     HashMap<String, String> schema = new HashMap<>();
     schema.put("key_url","string");
@@ -67,8 +85,19 @@ public class ReaderResouce {
     return Response.ok(schema).type(MediaType.APPLICATION_JSON).build();
   }
 
+  /**
+   * Read link object 
+   * @param readerConf
+   * @param nrows
+   * @param start
+   * @param end
+   * @param count
+   * @return
+   */
   @Path("/link/read")
   @POST
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
   public Response linkRead(ReaderConfig readerConf, 
       @DefaultValue("-1")@QueryParam("nrows") int nrows, 
       @DefaultValue("-1")@QueryParam("start") int start, 
@@ -79,8 +108,13 @@ public class ReaderResouce {
     return performRead(reader, path, nrows, start, end, count);
   }
 
+  /**
+   * Get schema of the Node object
+   * @return
+   */
   @Path("/node")
   @GET
+  @Produces(MediaType.APPLICATION_JSON)
   public Response nodeRead() {
     HashMap<String, String> schema = new HashMap<>();
     schema.put("key_url","string");
@@ -93,8 +127,19 @@ public class ReaderResouce {
   }
 
 
+  /**
+   * Read Node object as stored in the Nutch Webgraph
+   * @param readerConf
+   * @param nrows
+   * @param start
+   * @param end
+   * @param count
+   * @return
+   */
   @Path("/node/read")
   @POST
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
   public Response nodeRead(ReaderConfig readerConf, 
       @DefaultValue("-1")@QueryParam("nrows") int nrows, 
       @DefaultValue("-1")@QueryParam("start") int start, 

Modified: 
nutch/trunk/src/java/org/apache/nutch/service/resources/SeedResource.java
URL: 
http://svn.apache.org/viewvc/nutch/trunk/src/java/org/apache/nutch/service/resources/SeedResource.java?rev=1714292&r1=1714291&r2=1714292&view=diff
==============================================================================
--- nutch/trunk/src/java/org/apache/nutch/service/resources/SeedResource.java 
(original)
+++ nutch/trunk/src/java/org/apache/nutch/service/resources/SeedResource.java 
Sat Nov 14 03:41:32 2015
@@ -47,15 +47,15 @@ public class SeedResource extends Abstra
   private static final Logger log = LoggerFactory
       .getLogger(AdminResource.class);
 
-  @POST
-  @Path("/create")
-  @Consumes(MediaType.APPLICATION_JSON)
-  @Produces(MediaType.TEXT_PLAIN)
   /**
-   * Method creates seed list file and returns temorary directory path
+   * Method creates seed list file and returns temporary directory path
    * @param seedList
    * @return
    */
+  @POST
+  @Path("/create")
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.TEXT_PLAIN)
   public Response createSeedFile(SeedList seedList) {
     if (seedList == null) {
       return Response.status(Status.BAD_REQUEST)


Reply via email to