add test cases after the kafka 11 upgrade changes
[dmaap/messagerouter/messageservice.git] / src / main / java / com / att / nsa / dmaap / service / TransactionRestService.java
index 1a870a1..784f7c5 100644 (file)
@@ -8,14 +8,14 @@
  *  you may not use this file except in compliance with the License.
  *  You may obtain a copy of the License at
  *        http://www.apache.org/licenses/LICENSE-2.0
- *  
+*  
  *  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.
  *  ============LICENSE_END=========================================================
- *
+ *  
  *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
  *  
  *******************************************************************************/
@@ -38,19 +38,19 @@ import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
 
 import com.att.aft.dme2.internal.jettison.json.JSONException;
-import com.att.nsa.cambria.CambriaApiException;
-import com.att.nsa.cambria.beans.DMaaPContext;
-import com.att.nsa.cambria.exception.DMaaPResponseCode;
-import com.att.nsa.cambria.exception.ErrorResponse;
-import com.att.nsa.cambria.service.TransactionService;
-import com.att.nsa.cambria.utils.ConfigurationReader;
+import com.att.dmf.mr.CambriaApiException;
+import com.att.dmf.mr.beans.DMaaPContext;
+import com.att.dmf.mr.exception.DMaaPResponseCode;
+import com.att.dmf.mr.exception.ErrorResponse;
+import com.att.dmf.mr.service.TransactionService;
+import com.att.dmf.mr.utils.ConfigurationReader;
 import com.att.nsa.configs.ConfigDbException;
 
 /**
- * This class is a CXF REST service which acts as gateway for DMaaP Transaction
- * Ids.
- * 
- * @author author
+ * This class is a CXF REST service 
+ * which acts as gateway for DMaaP
+ * Transaction Ids.
+ * @author rajashree.khare
  *
  */
 @Component
@@ -84,13 +84,10 @@ public class TransactionRestService {
        @Autowired
        private TransactionService transactionService;
 
-       private DMaaPContext dmaapContext = new DMaaPContext();
-
        /**
         * 
         * Returns a list of all the existing Transaction Ids
-        * 
-        * @throws CambriaApiException
+        * @throws CambriaApiException 
         * 
         * @throws IOException
         * @exception ConfigDbException
@@ -107,10 +104,11 @@ public class TransactionRestService {
 
                        LOGGER.info("Returning list of all transactions.");
                } catch (ConfigDbException | IOException e) {
-                       LOGGER.error("Error while retrieving list of all transactions: " + e.getMessage(), e);
-                       ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_EXPECTATION_FAILED,
-                                       DMaaPResponseCode.RETRIEVE_TRANSACTIONS.getResponseCode(),
-                                       "Error while retrieving list of all transactions:" + e.getMessage());
+                       LOGGER.error("Error while retrieving list of all transactions: "
+                                       + e.getMessage(), e);
+                       ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_EXPECTATION_FAILED, 
+                                       DMaaPResponseCode.RETRIEVE_TRANSACTIONS.getResponseCode(), 
+                                       "Error while retrieving list of all transactions:"+e.getMessage());
                        LOGGER.info(errRes.toString());
                        throw new CambriaApiException(errRes);
                }
@@ -123,7 +121,7 @@ public class TransactionRestService {
         * 
         * @param transactionId
         *            - id of transaction
-        * @throws CambriaApiException
+        * @throws CambriaApiException 
         * @throws IOException
         * @exception ConfigDbException
         * @exception IOException
@@ -133,18 +131,22 @@ public class TransactionRestService {
         */
        @GET
        @Path("/{transactionId}")
-       public void getTransactionObj(@PathParam("transactionId") String transactionId) throws CambriaApiException {
+       public void getTransactionObj(
+                       @PathParam("transactionId") String transactionId) throws CambriaApiException {
 
                LOGGER.info("Fetching details of Transaction ID : " + transactionId);
 
                try {
-                       transactionService.getTransactionObj(getDmaapContext(), transactionId);
+                       transactionService.getTransactionObj(getDmaapContext(),
+                                       transactionId);
                } catch (ConfigDbException | JSONException | IOException e) {
-                       LOGGER.error("Error while retrieving transaction details for id: " + transactionId, e);
-
-                       ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_EXPECTATION_FAILED,
-                                       DMaaPResponseCode.RETRIEVE_TRANSACTIONS_DETAILS.getResponseCode(),
-                                       "Error while retrieving transaction details for id: [" + transactionId + "]: " + e.getMessage());
+                       LOGGER.error("Error while retrieving transaction details for id: "
+                                       + transactionId, e);
+               
+                       ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_EXPECTATION_FAILED, 
+                                       DMaaPResponseCode.RETRIEVE_TRANSACTIONS_DETAILS.getResponseCode(), 
+                                       "Error while retrieving transaction details for id: ["
+                                                       + transactionId + "]: " + e.getMessage());
                        LOGGER.info(errRes.toString());
                        throw new CambriaApiException(errRes);
 
@@ -163,7 +165,8 @@ public class TransactionRestService {
         *         Object,HttpServlet Object
         * 
         */
-       public DMaaPContext getDmaapContext() {
+       private DMaaPContext getDmaapContext() {
+               DMaaPContext dmaapContext = new DMaaPContext();
                dmaapContext.setConfigReader(configReader);
                dmaapContext.setRequest(request);
                dmaapContext.setResponse(response);