[jboss-svn-commits] JBL Code SVN: r37394 - in labs/jbosstm/trunk/rest-tx/tx: src/main/java/org/jboss/jbossts/star/resource and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Aug 12 05:31:48 EDT 2011


Author: mmusgrov
Date: 2011-08-12 05:31:48 -0400 (Fri, 12 Aug 2011)
New Revision: 37394

Modified:
   labs/jbosstm/trunk/rest-tx/tx/pom.xml
   labs/jbosstm/trunk/rest-tx/tx/src/main/java/org/jboss/jbossts/star/resource/RESTRecord.java
   labs/jbosstm/trunk/rest-tx/tx/src/main/java/org/jboss/jbossts/star/service/Coordinator.java
Log:
[JBTM-747] Add java doc target to the REST-AT API module

Modified: labs/jbosstm/trunk/rest-tx/tx/pom.xml
===================================================================
--- labs/jbosstm/trunk/rest-tx/tx/pom.xml	2011-08-11 20:40:29 UTC (rev 37393)
+++ labs/jbosstm/trunk/rest-tx/tx/pom.xml	2011-08-12 09:31:48 UTC (rev 37394)
@@ -222,6 +222,22 @@
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>create_javadocs</id>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+            <phase>prepare-package</phase>
+          </execution>
+        </executions>
+        <configuration>
+          <detectOfflineLinks>false</detectOfflineLinks>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-jar-plugin</artifactId>
         <version>2.2</version>
         <executions>

Modified: labs/jbosstm/trunk/rest-tx/tx/src/main/java/org/jboss/jbossts/star/resource/RESTRecord.java
===================================================================
--- labs/jbosstm/trunk/rest-tx/tx/src/main/java/org/jboss/jbossts/star/resource/RESTRecord.java	2011-08-11 20:40:29 UTC (rev 37393)
+++ labs/jbosstm/trunk/rest-tx/tx/src/main/java/org/jboss/jbossts/star/resource/RESTRecord.java	2011-08-12 09:31:48 UTC (rev 37394)
@@ -30,9 +30,10 @@
 import org.jboss.jbossts.star.util.LinkHolder;
 import org.jboss.jbossts.star.provider.HttpResponseException;
 import org.jboss.jbossts.star.util.TxSupport;
-import org.jboss.resteasy.util.HttpResponseCodes;
 import org.jboss.logging.Logger;
 
+import java.net.HttpURLConnection;
+
 /**
  * Log record for driving participants through 2PC and recoverery
  */
@@ -50,6 +51,8 @@
     private boolean prepared;
     private String recoveryUrl;
 
+    public RESTRecord() {}
+
     public RESTRecord(String coordinatorUrl, String participantUrl, String terminateUrl, String txId)
     {
         super(new Uid());
@@ -176,7 +179,7 @@
             log.trace("forgetting heuristic for " + terminateUrl);
 
         try {
-            new TxSupport().httpRequest(new int[] {HttpResponseCodes.SC_OK, HttpResponseCodes.SC_NO_CONTENT},
+            new TxSupport().httpRequest(new int[] {HttpURLConnection.HTTP_OK, HttpURLConnection.HTTP_NO_CONTENT},
                     this.participantUrl, "DELETE", null, null, null);
             status = "";
         } catch (HttpResponseException e) {
@@ -202,7 +205,7 @@
 
         try
         {
-            status = TxSupport.getStatus(new TxSupport().httpRequest(new int[] {HttpResponseCodes.SC_OK}, this.terminateUrl, "PUT",
+            status = TxSupport.getStatus(new TxSupport().httpRequest(new int[] {HttpURLConnection.HTTP_OK}, this.terminateUrl, "PUT",
                     TxSupport.STATUS_MEDIA_TYPE, TxSupport.toStatusContent(TxSupport.PREPARED), null));
 
             prepared = true;
@@ -237,7 +240,7 @@
             return TwoPhaseOutcome.FINISH_ERROR;
 
         try {
-            status = TxSupport.getStatus(new TxSupport().httpRequest(new int[] {HttpResponseCodes.SC_OK}, this.terminateUrl, "PUT", TxSupport.STATUS_MEDIA_TYPE,
+            status = TxSupport.getStatus(new TxSupport().httpRequest(new int[] {HttpURLConnection.HTTP_OK}, this.terminateUrl, "PUT", TxSupport.STATUS_MEDIA_TYPE,
                     TxSupport.toStatusContent(TxSupport.ABORTED), null));
         } catch (HttpResponseException e) {
 
@@ -287,7 +290,7 @@
                 log.trace("committing " + this.terminateUrl);
             
             if (!TxSupport.isReadOnly(status))
-                status = TxSupport.getStatus(new TxSupport().httpRequest(new int[] {HttpResponseCodes.SC_OK}, this.terminateUrl, "PUT", TxSupport.STATUS_MEDIA_TYPE,
+                status = TxSupport.getStatus(new TxSupport().httpRequest(new int[] {HttpURLConnection.HTTP_OK}, this.terminateUrl, "PUT", TxSupport.STATUS_MEDIA_TYPE,
                         TxSupport.toStatusContent(TxSupport.COMMITTED), null));   // ONE_PHASE_COMMIT_CONTENT
             else
                 status = TxSupport.COMMITTED;
@@ -305,7 +308,7 @@
 
     private boolean checkFinishError(int expected, boolean commit) throws HttpResponseException
     {
-        if (expected == HttpResponseCodes.SC_NOT_FOUND)
+        if (expected == HttpURLConnection.HTTP_NOT_FOUND)
         {
             // the participant may have moved so check the coordinator terminateUrl
             if (hasParticipantMoved())
@@ -315,7 +318,7 @@
 
                 try
                 {
-                    TxSupport.getStatus(new TxSupport().httpRequest(new int[] {HttpResponseCodes.SC_OK}, this.terminateUrl, "PUT", TxSupport.STATUS_MEDIA_TYPE,
+                    TxSupport.getStatus(new TxSupport().httpRequest(new int[] {HttpURLConnection.HTTP_OK}, this.terminateUrl, "PUT", TxSupport.STATUS_MEDIA_TYPE,
                         TxSupport.toStatusContent(commit ? TxSupport.COMMITTED : TxSupport.ABORTED), null));
                     if (log.isDebugEnabled())
                         log.debug("Finish OK at new terminateUrl: " + this.terminateUrl);
@@ -357,7 +360,7 @@
                     return false;
 
             // get the latest participant terminateUrl by probing the recovery terminateUrl:
-            String content = new TxSupport().httpRequest(new int[] {HttpResponseCodes.SC_OK}, recoveryUrl, "GET", TxSupport.PLAIN_MEDIA_TYPE, null, null);
+            String content = new TxSupport().httpRequest(new int[] {HttpURLConnection.HTTP_OK}, recoveryUrl, "GET", TxSupport.PLAIN_MEDIA_TYPE, null, null);
             String terminator = new LinkHolder(content).get(TxSupport.TERMINATOR_LINK);
             String participant = new LinkHolder(content).get(TxSupport.PARTICIPANT_LINK);
 

Modified: labs/jbosstm/trunk/rest-tx/tx/src/main/java/org/jboss/jbossts/star/service/Coordinator.java
===================================================================
--- labs/jbosstm/trunk/rest-tx/tx/src/main/java/org/jboss/jbossts/star/service/Coordinator.java	2011-08-11 20:40:29 UTC (rev 37393)
+++ labs/jbosstm/trunk/rest-tx/tx/src/main/java/org/jboss/jbossts/star/service/Coordinator.java	2011-08-12 09:31:48 UTC (rev 37394)
@@ -29,8 +29,6 @@
 import javax.ws.rs.*;
 import javax.ws.rs.core.*;
 
-import org.jboss.resteasy.util.HttpResponseCodes;
-
 import java.net.HttpURLConnection;
 import java.net.URI;
 import java.util.*;
@@ -53,7 +51,9 @@
      * Performing a GET on the transaction-manager returns a list of all transaction URIs
      * known to the coordinator (active and in recovery) separated by
      * the @see TxSupport.URI_SEPARATOR character
-    */
+     * @param info http context of the request
+     * @return JSON representation of active transactions and HTTP status code
+     */
     @GET
     @Path(TxSupport.TX_SEGMENT)
     @Produces(TxSupport.PLAIN_MEDIA_TYPE)
@@ -77,7 +77,8 @@
          * getTransactions(recoveringFilter); or
          * getTransactions(activeTxFilter);
          */
-
+        Response.ResponseBuilder builder = Response.ok(txns.toString());
+        builder.header("Content-Length", txns.length());
         return Response.ok(txns.toString()).build();
     }
 
@@ -97,7 +98,7 @@
         Transaction txn = transactions.get(id);
 
         if (txn == null)
-            return Response.status(HttpResponseCodes.SC_NOT_FOUND).build();
+            return Response.status(HttpURLConnection.HTTP_NOT_FOUND).build();
 
         return Response.ok(TxSupport.toStatusContent(txn.getStatus())).build();
     }
@@ -111,30 +112,30 @@
     @Path(TxSupport.TX_SEGMENT + "/{id}")
     public Response deleteTransaction(@PathParam("id") String id)
     {
-        return Response.status(HttpResponseCodes.SC_FORBIDDEN).build();
+        return Response.status(HttpURLConnection.HTTP_FORBIDDEN).build();
     }
 
     // Performing HEAD, GET, POST, DELETE and OPTIONS on the transaction
     // url generates a 400 status code
     @HEAD @Path(TxSupport.TX_SEGMENT + "/{TxId}/terminate")
     public Response tt1(@PathParam("TxId")String txId) {
-        return Response.status(HttpResponseCodes.SC_BAD_REQUEST).build();
+        return Response.status(HttpURLConnection.HTTP_BAD_REQUEST).build();
     }
     @GET @Path(TxSupport.TX_SEGMENT + "/{TxId}/terminate")
     public Response tt2(@PathParam("TxId")String txId) {
-        return Response.status(HttpResponseCodes.SC_BAD_REQUEST).build();
+        return Response.status(HttpURLConnection.HTTP_BAD_REQUEST).build();
     }
     @POST @Path(TxSupport.TX_SEGMENT + "/{TxId}/terminate")
     public Response tt3(@PathParam("TxId")String txId) {
-        return Response.status(HttpResponseCodes.SC_BAD_REQUEST).build();
+        return Response.status(HttpURLConnection.HTTP_BAD_REQUEST).build();
     }
     @DELETE @Path(TxSupport.TX_SEGMENT + "/{TxId}/terminate")
     public Response tt4(@PathParam("TxId")String txId) {
-        return Response.status(HttpResponseCodes.SC_BAD_REQUEST).build();
+        return Response.status(HttpURLConnection.HTTP_BAD_REQUEST).build();
     }
     @OPTIONS @Path(TxSupport.TX_SEGMENT + "/{TxId}/terminate")
     public Response tt5(@PathParam("TxId")String txId) {
-        return Response.status(HttpResponseCodes.SC_BAD_REQUEST).build();
+        return Response.status(HttpURLConnection.HTTP_BAD_REQUEST).build();
     }
 
     /**
@@ -219,7 +220,7 @@
         Transaction tx = getTransaction(id);
 
         if (tx == null)
-            return Response.status(HttpResponseCodes.SC_GONE).build();
+            return Response.status(HttpURLConnection.HTTP_GONE).build();
 
         Response.ResponseBuilder builder = Response.ok();
 
@@ -267,7 +268,7 @@
         else if (TxSupport.ABORTED.equals(how))
             commit = false;
         else
-            return Response.status(HttpResponseCodes.SC_BAD_REQUEST).build();
+            return Response.status(HttpURLConnection.HTTP_BAD_REQUEST).build();
 
         tx.setFault(fault);
         AtomicAction.resume(tx);
@@ -292,9 +293,9 @@
         }
 
         if (status.length() == 0)
-            scRes = HttpResponseCodes.SC_INTERNAL_SERVER_ERROR;
+            scRes = HttpURLConnection.HTTP_INTERNAL_ERROR;
         else
-            scRes = HttpResponseCodes.SC_OK;
+            scRes = HttpURLConnection.HTTP_OK;
 
         return Response.status(scRes).entity(TxSupport.toStatusContent(status)).build();
     }
@@ -310,9 +311,11 @@
     @Path(TxSupport.TX_SEGMENT + "/{TxId}")
     public Response enlistParticipant(@Context UriInfo info, @PathParam("TxId")String txId, String content)
     {
+        log.trace("enlistParticipant request uri " + info.getRequestUri() + " txid: " + txId + " content: " + content);
+        System.out.println("enlistParticipant request uri " + info.getRequestUri() + " txid: " + txId + " content: " + content);
         Transaction tx = getTransaction(txId);
         if (tx == null)
-            return Response.status(HttpResponseCodes.SC_GONE).build();
+            return Response.status(HttpURLConnection.HTTP_GONE).build();
 
         LinkHolder links = new LinkHolder(content);
         String txURI = TxSupport.buildURI(info.getBaseUriBuilder(), info.getPathSegments().get(0).getPath(), info.getPathSegments().get(1).getPath());
@@ -331,7 +334,7 @@
         String coordinatorId = tx.enlistParticipant(txURI, links.get(TxSupport.PARTICIPANT_LINK), terminatorUrl, recoveryUrlBase);
 
         if (coordinatorId == null) // the request was rejected (2PC processing must have started or already registerd)
-            return Response.status(HttpResponseCodes.SC_FORBIDDEN).build();
+            return Response.status(HttpURLConnection.HTTP_FORBIDDEN).build();
 
         links.put("txid", txId);
         participants.put(coordinatorId, links);
@@ -357,7 +360,7 @@
         LinkHolder p = participants.get(enlistmentId);
 
         if (p == null)
-            return Response.status(HttpResponseCodes.SC_NOT_FOUND).build();
+            return Response.status(HttpURLConnection.HTTP_NOT_FOUND).build();
 
         String pContent = TxSupport.getParticipantUrls(p.get(TxSupport.TERMINATOR_LINK), p.get(TxSupport.PARTICIPANT_LINK));
 
@@ -382,11 +385,11 @@
 
         log.trace("coordinator: replace: recovery-coordinator/" + enlistmentId + "?URL=" + terminator);
         if (terminator == null)
-            return Response.status(HttpResponseCodes.SC_BAD_REQUEST).build();
+            return Response.status(HttpURLConnection.HTTP_BAD_REQUEST).build();
 
         participants.put(enlistmentId, links);
 
-        return Response.status(HttpResponseCodes.SC_OK).build();
+        return Response.status(HttpURLConnection.HTTP_OK).build();
     }
 
     @POST
@@ -394,7 +397,7 @@
     public Response postParticipant(@PathParam("RecCoordId")String enlistmentId)
     {
         log.trace("coordinator: replace via Post: recovery-coordinator/" + enlistmentId);
-        return Response.status(HttpResponseCodes.SC_UNAUTHORIZED).build();
+        return Response.status(HttpURLConnection.HTTP_UNAUTHORIZED).build();
     }
 
     @DELETE
@@ -406,12 +409,12 @@
         Transaction txn;
 
         if (p == null || (txn = transactions.get(p.get("txid"))) == null)
-            return Response.status(HttpResponseCodes.SC_NOT_FOUND).build();
+            return Response.status(HttpURLConnection.HTTP_NOT_FOUND).build();
 
         if (txn.forgetParticipant(p.get(TxSupport.TERMINATOR_LINK)))
-            return Response.status(HttpResponseCodes.SC_OK).build();
+            return Response.status(HttpURLConnection.HTTP_OK).build();
         
-        return Response.status(HttpResponseCodes.SC_CONFLICT).build();
+        return Response.status(HttpURLConnection.HTTP_CONFLICT).build();
     }
 
     private Transaction getTransaction(String txId)



More information about the jboss-svn-commits mailing list