Exemplo n.º 1
0
 protected String getResourceProperty(TxSupport txn, String pUrl, String pid, String name) {
   return txn.httpRequest(
       new int[] {HttpURLConnection.HTTP_OK, HttpURLConnection.HTTP_NO_CONTENT},
       getResourceUpdateUrl(pUrl, pid, name, null).toString(),
       "GET",
       TxMediaType.PLAIN_MEDIA_TYPE);
 }
Exemplo n.º 2
0
 /**
  * Modify a transactional participant
  *
  * @param txn the transaction
  * @param pUrl the transactional participant
  * @param pid an id
  * @param name name of a property to update
  * @param value the new value of the property
  * @return the response body
  */
 protected String modifyResource(
     TxSupport txn, String pUrl, String pid, String name, String value) {
   // tell the resource to modify some data and pass the transaction enlistment url along with the
   // request
   return txn.httpRequest(
       new int[] {HttpURLConnection.HTTP_OK},
       getResourceUpdateUrl(pUrl, pid, name, value).toString(),
       "GET",
       TxMediaType.PLAIN_MEDIA_TYPE);
 }
Exemplo n.º 3
0
    private String moveParticipant(
        Work work, String nid, String register, boolean twoPhaseAware, boolean isVolatile) {
      TxSupport txn = new TxSupport();

      faults.remove(work.id);
      work =
          makeWork(
              txn,
              PURL,
              nid,
              work.tid,
              work.enlistUrl,
              twoPhaseAware,
              isVolatile,
              work.recoveryUrl,
              work.fault);
      faults.put(nid, work);
      // if register is true then tell the transaction manager about the new location - otherwise
      // the old
      // URIs will be used for transaction termination. This is used to test that the coordinator
      // uses
      // the recovery URI correctly
      if ("true".equals(register)) {
        Map<String, String> reqHeaders = new HashMap<String, String>();

        reqHeaders.put("Link", work.pLinks);
        txn.httpRequest(
            new int[] {HttpURLConnection.HTTP_OK},
            work.recoveryUrl,
            "PUT",
            TxMediaType.POST_MEDIA_TYPE,
            null,
            null,
            reqHeaders);
      }

      return nid;
    }