diff --git a/.gitignore b/.gitignore
index 92141b1..c9645b9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ target
.project
.settings
.classpath
+*.orig
diff --git a/core/pom.xml b/core/pom.xml
index dcbfa90..497b0fc 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -208,11 +208,11 @@
- org.wildfly
- wildfly-arquillian-container-remote
- 8.0.0.Final
- test
-
+ org.wildfly
+ wildfly-arquillian-container-remote
+ 8.0.0.Final
+ test
+
diff --git a/core/src/main/java/io/narayana/nta/persistence/DataAccessObject.java b/core/src/main/java/io/narayana/nta/persistence/DataAccessObject.java
index 2037d2f..bc6fd84 100644
--- a/core/src/main/java/io/narayana/nta/persistence/DataAccessObject.java
+++ b/core/src/main/java/io/narayana/nta/persistence/DataAccessObject.java
@@ -23,6 +23,7 @@
package io.narayana.nta.persistence;
import io.narayana.nta.interceptors.LoggingInterceptor;
+import io.narayana.nta.persistence.entities.Event;
import io.narayana.nta.persistence.entities.ParticipantRecord;
import io.narayana.nta.persistence.entities.ResourceManager;
import io.narayana.nta.persistence.entities.Transaction;
@@ -195,6 +196,32 @@ public Collection findAllResourceManagers() {
return em.createNamedQuery("ResourceManager.findAll", ResourceManager.class).getResultList();
}
+ public ResourceManager findResourceManagerByBranchId(String branchId)
+ {
+ try
+ {
+ return em.createNamedQuery("ResourceManager.findByBranchId", ResourceManager.class)
+ .setParameter("branchId", branchId).getSingleResult();
+ }
+ catch(NoResultException nre)
+ {
+ return null;
+ }
+ }
+
+ /*
+ * Method for retrieving objects of type Events
+ */
+
+ public Event findEvent(Long id) {
+
+ return em.find(Event.class, id);
+ }
+
+ public Collection findAllEvents(){
+
+ return em.createNamedQuery("Event.findAll", Event.class).getResultList();
+ }
/*
@AroundInvoke
diff --git a/core/src/main/java/io/narayana/nta/persistence/entities/Event.java b/core/src/main/java/io/narayana/nta/persistence/entities/Event.java
index 3c0b527..6737080 100644
--- a/core/src/main/java/io/narayana/nta/persistence/entities/Event.java
+++ b/core/src/main/java/io/narayana/nta/persistence/entities/Event.java
@@ -24,13 +24,7 @@
import io.narayana.nta.persistence.enums.EventType;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
+import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
@@ -40,6 +34,10 @@
* Time: 22:57
*/
@Entity
+@NamedQueries({
+ @NamedQuery(name = "Event.findAll",
+ query = "FROM Event e ORDER BY e.timestamp"
+ )})
public class Event implements Serializable, Comparable {
@Id
diff --git a/core/src/main/java/io/narayana/nta/persistence/entities/ResourceManager.java b/core/src/main/java/io/narayana/nta/persistence/entities/ResourceManager.java
index b304ee7..061e60c 100644
--- a/core/src/main/java/io/narayana/nta/persistence/entities/ResourceManager.java
+++ b/core/src/main/java/io/narayana/nta/persistence/entities/ResourceManager.java
@@ -42,6 +42,9 @@
@NamedQueries({
@NamedQuery(name = "ResourceManager.findAll",
query = "FROM ResourceManager r"
+ ),
+ @NamedQuery(name = "ResourceManager.findByBranchId",
+ query = "FROM ResourceManager r WHERE r.branchId=:branchId"
)
})
public class ResourceManager implements Serializable {
diff --git a/nta-dist/pom.xml b/nta-dist/pom.xml
index e7583aa..adb1e2f 100644
--- a/nta-dist/pom.xml
+++ b/nta-dist/pom.xml
@@ -46,6 +46,11 @@
webappwar
+
+ io.narayana.nta
+ restapi
+ war
+ io.narayana.ntacore
@@ -93,6 +98,11 @@
webapp/nta
+
+ io.narayana.nta
+ restapi
+ /nta/rest
+ no-version
diff --git a/pom.xml b/pom.xml
index ad6bf5f..8a4a4b1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -111,6 +111,7 @@
corepluginswebapp
+ restapinta-distnta-remote-distdemo
@@ -164,6 +165,15 @@
compile
+
+ io.narayana.nta
+ restapi
+ ${project.version}
+ war
+ compile
+
+
+
org.jboss.specjboss-javaee-6.0
diff --git a/restapi/pom.xml b/restapi/pom.xml
new file mode 100644
index 0000000..79be98f
--- /dev/null
+++ b/restapi/pom.xml
@@ -0,0 +1,233 @@
+
+
+
+ nta-all
+ io.narayana.nta
+ 1.0.0.Alpha3-SNAPSHOT
+
+ 4.0.0
+
+ restapi
+ Narayana Transaction Analyser REST API
+ Contains the REST API component of the tool
+ war
+
+
+
+
+ org.jboss.spec
+ jboss-javaee-7.0
+ 1.0.0.Final
+ pom
+ import
+
+
+ org.jboss.arquillian.extension
+ arquillian-warp-bom
+ 1.0.0.Alpha7
+ pom
+ import
+
+
+ org.jboss.arquillian
+ arquillian-bom
+ 1.1.5.Final
+ import
+ pom
+
+
+
+
+
+
+
+ io.narayana.nta
+ core
+ 1.0.0.Alpha3-SNAPSHOT
+ provided
+
+
+
+ org.jboss.spec.javax.servlet
+ jboss-servlet-api_3.1_spec
+ 1.0.0.Final
+
+
+
+ org.jboss.resteasy
+ resteasy-jaxrs
+ 3.0.2.Final
+ provided
+
+
+
+ org.jboss.resteasy
+ resteasy-cdi
+ 3.0.2.Final
+ provided
+
+
+
+ javax.enterprise
+ cdi-api
+ 1.0-SP4
+ provided
+
+
+
+ javax.validation
+ validation-api
+ 1.1.0.Final
+ provided
+
+
+
+ org.hibernate
+ hibernate-validator
+ 5.0.3.Final
+ provided
+
+
+
+ org.wildfly
+ wildfly-controller-client
+ 8.0.0.Final
+ provided
+
+
+
+ junit
+ junit
+ 4.11
+ test
+
+
+
+ org.jboss.resteasy
+ resteasy-client
+ 3.0.2.Final
+ test
+
+
+
+ org.jboss.arquillian.junit
+ arquillian-junit-container
+ test
+
+
+ org.jboss.shrinkwrap.resolver
+ shrinkwrap-resolver-impl-maven
+ test
+
+
+ org.wildfly
+ wildfly-arquillian-container-remote
+ 8.0.0.Final
+ test
+
+
+ org.jboss.resteasy
+ resteasy-client
+ 3.0.2.Final
+ test
+
+
+ org.jboss.arquillian.extension
+ arquillian-warp
+ 1.0.0.Alpha7
+ test
+ pom
+
+
+ org.jboss.arquillian.extension
+ arquillian-rest-warp-impl-jaxrs-2.0
+ 1.0.0.Alpha3
+ test
+
+
+
+
+ ${project.artifactId}
+
+
+ maven-war-plugin
+ ${version.war.plugin}
+
+ false
+
+
+
+
+ maven-compiler-plugin
+ ${version.compiler.plugin}
+
+ ${maven.compiler.source}
+ ${maven.compiler.target}
+
+
+
+
+ maven-surefire-plugin
+ ${version.maven.surefire}
+
+ false
+
+
+
+
+
+
+
+ wildfly-8-snapshot
+
+
+
+ maven-surefire-plugin
+ ${version.maven.surefire}
+
+ false
+
+
+
+
+
+
+ org.jboss.arquillian.junit
+ arquillian-junit-container
+ test
+
+
+ org.jboss.shrinkwrap.resolver
+ shrinkwrap-resolver-impl-maven
+ test
+
+
+ org.wildfly
+ wildfly-arquillian-container-remote
+ 8.0.0.Final
+ test
+
+
+ org.jboss.resteasy
+ resteasy-client
+ 3.0.2.Final
+ test
+
+
+ org.jboss.arquillian.extension
+ arquillian-warp
+ 1.0.0.Alpha7
+ test
+ pom
+
+
+ org.jboss.arquillian.extension
+ arquillian-rest-warp-impl-jaxrs-2.0
+ 1.0.0.Alpha3
+ test
+
+
+
+
+
\ No newline at end of file
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/apis/EventAPI.java b/restapi/src/main/java/io/narayana/nta/restapi/apis/EventAPI.java
new file mode 100644
index 0000000..76b9363
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/apis/EventAPI.java
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.apis;
+
+import io.narayana.nta.restapi.models.URIConstants;
+import io.narayana.nta.restapi.models.event.EventInfo;
+import io.narayana.nta.restapi.models.response.PayloadResponse;
+import io.narayana.nta.restapi.services.CommonService;
+
+import javax.inject.Inject;
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.Collection;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 8/1/2014
+ * Time: 11:35 PM
+ */
+@Path(URIConstants.EventURI)
+public class EventAPI {
+
+ @Inject
+ CommonService eventService;
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getEvents() {
+
+ Collection payload = eventService.get();
+
+ if ((payload == null) || (payload != null && payload.size() == 0)) {
+
+ return Response.noContent().build();
+ }
+
+ PayloadResponse payloadResponse = new PayloadResponse();
+ payloadResponse.setPayload(payload);
+ payloadResponse.setStatus(Response.Status.OK);
+
+ return Response.ok(payloadResponse).build();
+
+ }
+
+ @GET
+ @Path("/{eventId}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getEventById(
+ @PathParam("eventId")
+ @NotNull
+ long Id) {
+
+ EventInfo payload = eventService.getById(Id);
+
+ if (payload == null) {
+ return Response.status(Response.Status.BAD_REQUEST).build();
+ }
+
+ PayloadResponse payloadResponse = new PayloadResponse();
+ payloadResponse.setPayload(payload);
+ payloadResponse.setStatus(Response.Status.OK);
+
+ return Response.ok(payloadResponse).build();
+ }
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/apis/ParticipantRecordAPI.java b/restapi/src/main/java/io/narayana/nta/restapi/apis/ParticipantRecordAPI.java
new file mode 100644
index 0000000..d334a06
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/apis/ParticipantRecordAPI.java
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.apis;
+
+import io.narayana.nta.restapi.models.URIConstants;
+import io.narayana.nta.restapi.models.participantRecord.ParticipantRecordInfo;
+import io.narayana.nta.restapi.models.response.PayloadResponse;
+import io.narayana.nta.restapi.services.CommonService;
+
+import javax.inject.Inject;
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.UnsupportedEncodingException;
+import java.util.Collection;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 04/06/14
+ * Time: 12:01
+ */
+@Path(URIConstants.ParticipantRecordURI)
+public class ParticipantRecordAPI {
+
+ @Inject
+ CommonService participantRecordService;
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getParticipantRecords() throws UnsupportedEncodingException {
+
+ Collection participantRecords = participantRecordService.get();
+
+ if((participantRecords == null) || (participantRecords != null && participantRecords.size() == 0)){
+ return Response.noContent().build();
+ }
+
+ PayloadResponse payloadResponse = new PayloadResponse();
+ payloadResponse.setPayload(participantRecords);
+ payloadResponse.setStatus(Response.Status.OK);
+
+ return Response.ok(payloadResponse).build();
+ }
+
+ @GET
+ @Path("/{id}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getParticipantRecordById(
+ @PathParam("id")
+ @NotNull
+ Long id
+ ) throws UnsupportedEncodingException {
+
+ Object payload = participantRecordService.getById(id);
+
+ if(payload == null){
+ return Response.status(Response.Status.BAD_REQUEST).build();
+ }
+
+ PayloadResponse payloadResponse = new PayloadResponse();
+ payloadResponse.setPayload(payload);
+ payloadResponse.setStatus(Response.Status.OK);
+ return Response.ok(payloadResponse).build();
+ }
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/apis/ResourceManagerAPI.java b/restapi/src/main/java/io/narayana/nta/restapi/apis/ResourceManagerAPI.java
new file mode 100644
index 0000000..39c4145
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/apis/ResourceManagerAPI.java
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.apis;
+
+import io.narayana.nta.restapi.models.resourceManager.ResourceManagerInfo;
+import io.narayana.nta.restapi.models.response.PayloadResponse;
+import io.narayana.nta.restapi.models.URIConstants;
+import io.narayana.nta.restapi.services.ResourceManagerService;
+
+import javax.inject.Inject;
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.Collection;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 02/06/14
+ * Time: 05:14
+ */
+@Path(URIConstants.ResourceManagerURI)
+public class ResourceManagerAPI {
+ @Inject
+ ResourceManagerService resourceManagerService;
+
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getResourceManagers() {
+
+ Collection payload = resourceManagerService.get();
+
+ if ((payload == null) || (payload != null && payload.size() == 0)) {
+ return Response.noContent().build();
+ }
+
+ PayloadResponse payloadResponse = new PayloadResponse();
+ payloadResponse.setPayload(payload);
+ payloadResponse.setStatus(Response.Status.OK);
+
+ return Response.ok(payloadResponse).build();
+ }
+
+ @GET
+ @Path("/{branchId}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getResourceManagerByBranchId(
+ @PathParam("branchId")
+ @NotNull
+ String branchId
+ ) {
+ Object payload = resourceManagerService.getById(branchId);
+
+ if (payload == null) {
+ return Response.status(Response.Status.BAD_REQUEST).build();
+ }
+
+ PayloadResponse payloadResponse = new PayloadResponse();
+ payloadResponse.setPayload(payload);
+ payloadResponse.setStatus(Response.Status.OK);
+ return Response.ok(payloadResponse).build();
+ }
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/apis/Root.java b/restapi/src/main/java/io/narayana/nta/restapi/apis/Root.java
new file mode 100644
index 0000000..f2e1ee8
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/apis/Root.java
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.apis;
+
+import io.narayana.nta.restapi.models.URIConstants;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 04/05/14
+ * Time: 17:52
+ */
+@ApplicationPath(URIConstants.RootURI)
+public class Root extends Application {
+
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/apis/TracerAPI.java b/restapi/src/main/java/io/narayana/nta/restapi/apis/TracerAPI.java
new file mode 100644
index 0000000..d4c2b21
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/apis/TracerAPI.java
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.apis;
+
+import io.narayana.nta.restapi.models.response.BaseResponse;
+import io.narayana.nta.restapi.models.URIConstants;
+import io.narayana.nta.restapi.services.TraceLoggingService;
+
+import javax.inject.Inject;
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 14/05/14
+ * Time: 23:01
+ */
+@Path(URIConstants.TracerURI)
+public class TracerAPI {
+ @Inject
+ private TraceLoggingService traceLoggingService;
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getTraceStatus() {
+ boolean tracingStatus = traceLoggingService.getTraceLoggingEnable();
+
+ BaseResponse baseResponse = new BaseResponse();
+ baseResponse.setMessage(String.valueOf(tracingStatus));
+ baseResponse.setStatus(Response.Status.OK);
+ return Response.ok(baseResponse).build();
+ }
+
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response setTransactionStatus(@QueryParam("enable") boolean enable) {
+ traceLoggingService.setTraceLoggingEnable(enable);
+
+ String status = enable ? "Enabled" : "Disabled";
+ BaseResponse baseResponse = new BaseResponse();
+ baseResponse.setMessage("Trace logging has been " + status);
+ baseResponse.setStatus(Response.Status.OK);
+
+ return Response.ok(baseResponse).build();
+ }
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/apis/TransactionAPI.java b/restapi/src/main/java/io/narayana/nta/restapi/apis/TransactionAPI.java
new file mode 100644
index 0000000..cd5b3b1
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/apis/TransactionAPI.java
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.apis;
+
+import io.narayana.nta.restapi.models.URIConstants;
+
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 8/20/2014
+ * Time: 12:13 AM
+ */
+@Path(URIConstants.TransactionURI)
+public interface TransactionAPI {
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getTransactions(
+ @QueryParam("status")
+ String status);
+
+ @GET
+ @Path("/{id}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getTransactionById(
+ @PathParam("id")
+ @NotNull
+ Long id);
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/apis/TransactionAPIImpl.java b/restapi/src/main/java/io/narayana/nta/restapi/apis/TransactionAPIImpl.java
new file mode 100644
index 0000000..8ea7e19
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/apis/TransactionAPIImpl.java
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.apis;
+
+import io.narayana.nta.persistence.enums.Status;
+import io.narayana.nta.restapi.models.response.PayloadResponse;
+import io.narayana.nta.restapi.models.transaction.TransactionInfo;
+import io.narayana.nta.restapi.services.TransactionService;
+
+import javax.inject.Inject;
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.core.Response;
+import java.util.Collection;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 04/05/14
+ * Time: 17:52
+ */
+
+public class TransactionAPIImpl implements TransactionAPI{
+ @Inject
+ private TransactionService transactionService;
+
+ @Override
+ public Response getTransactions(String status) {
+ Collection payload;
+
+ if (status == null) {
+ payload = transactionService.get();
+ } else {
+ Status requestedTransactionStatus = Status.valueOf(status.toUpperCase());
+ payload = transactionService.getByStatus(requestedTransactionStatus);
+ }
+
+ if ((payload == null) || (payload != null && payload.size() == 0)) {
+ return Response.status(Response.Status.BAD_REQUEST).build();
+ }
+
+ PayloadResponse payloadResponse = new PayloadResponse();
+ payloadResponse.setStatus(Response.Status.OK);
+ payloadResponse.setPayload(payload);
+ return Response.ok(payloadResponse).build();
+ }
+
+ @Override
+ public Response getTransactionById(@NotNull Long id) {
+ Object payload = transactionService.getById(id);
+
+ if (payload == null) {
+ return Response.status(Response.Status.BAD_REQUEST).build();
+ }
+ PayloadResponse payloadResponse = new PayloadResponse();
+ payloadResponse.setStatus(Response.Status.OK);
+ payloadResponse.setPayload(payload);
+ return Response.ok(payloadResponse).build();
+ }
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/handlers/exceptions/ApplicationExceptionHandler.java b/restapi/src/main/java/io/narayana/nta/restapi/handlers/exceptions/ApplicationExceptionHandler.java
new file mode 100644
index 0000000..0dc2ce3
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/handlers/exceptions/ApplicationExceptionHandler.java
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.handlers.exceptions;
+
+import io.narayana.nta.restapi.models.response.ErrorResponse;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 27/05/14
+ * Time: 22:51
+ */
+@Provider
+public class ApplicationExceptionHandler implements ExceptionMapper {
+ @Override
+ public Response toResponse(Exception exception) {
+ ErrorResponse errorResponse = new ErrorResponse();
+ errorResponse.setMessage(exception.getMessage());
+ errorResponse.setExceptionClass(exception.getClass());
+ errorResponse.setException(exception);
+ if (exception.getCause() != null) {
+ errorResponse.setCause(exception.getCause().toString());
+ }
+
+ if (exception instanceof IllegalArgumentException) {
+ errorResponse.setStatus(Response.Status.BAD_REQUEST);
+ return BadRequestResponse(errorResponse);
+ }
+
+ if(exception instanceof UnsupportedEncodingException){
+ errorResponse.setStatus(Response.Status.BAD_REQUEST);
+ return BadRequestResponse(errorResponse);
+ }
+
+ errorResponse.setStatus(Response.Status.INTERNAL_SERVER_ERROR);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponse).type(MediaType.APPLICATION_JSON).build();
+ }
+
+ private Response BadRequestResponse(ErrorResponse errorResponse) {
+ return Response.status(Response.Status.BAD_REQUEST).entity(errorResponse).type(MediaType.APPLICATION_JSON).build();
+ }
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/handlers/exceptions/ValidationExceptionHandler.java b/restapi/src/main/java/io/narayana/nta/restapi/handlers/exceptions/ValidationExceptionHandler.java
new file mode 100644
index 0000000..35a0567
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/handlers/exceptions/ValidationExceptionHandler.java
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.handlers.exceptions;
+
+import io.narayana.nta.restapi.models.response.ErrorResponse;
+
+import javax.validation.ConstraintViolationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 27/05/14
+ * Time: 23:30
+ */
+public class ValidationExceptionHandler implements ExceptionMapper {
+ @Override
+ public Response toResponse(ConstraintViolationException exception) {
+ ErrorResponse errorResponse = new ErrorResponse();
+ errorResponse.setMessage(exception.getMessage());
+ errorResponse.setExceptionClass(exception.getClass());
+ errorResponse.setException(exception);
+ errorResponse.setViolations(exception.getConstraintViolations().toString());
+ if (exception.getCause() != null) {
+ errorResponse.setCause(exception.getCause().toString());
+ }
+ errorResponse.setStatus(Response.Status.BAD_REQUEST);
+
+ return Response.status(Response.Status.BAD_REQUEST).entity(errorResponse).type(MediaType.APPLICATION_JSON).build();
+ }
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/helpers/LinkGenerator.java b/restapi/src/main/java/io/narayana/nta/restapi/helpers/LinkGenerator.java
new file mode 100644
index 0000000..2c1a0c8
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/helpers/LinkGenerator.java
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.helpers;
+
+import io.narayana.nta.restapi.models.URIConstants;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 14/05/14
+ * Time: 00:14
+ */
+public final class LinkGenerator {
+ public static String participantRecordURI(Long id) {
+ return URIConstants.RootURI + URIConstants.ParticipantRecordURI + "/" + id;
+ }
+
+ public static String eventURI(Long id) {
+ return URIConstants.RootURI + URIConstants.EventURI + "/" + id;
+ }
+
+ public static String transactionURI(Long id) {
+ return URIConstants.RootURI + URIConstants.TransactionURI + "/" + id;
+ }
+
+ public static String resourceManagerURI(String branchId) {
+ try{
+ return URIConstants.RootURI + URIConstants.ResourceManagerURI + "/" + URLEncoder.encode(branchId,"UTF-8");
+ }
+ catch(UnsupportedEncodingException ex){
+ return "";
+ }
+
+ }
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/models/ResourceManager/ResourceManagerInfo.java b/restapi/src/main/java/io/narayana/nta/restapi/models/ResourceManager/ResourceManagerInfo.java
new file mode 100644
index 0000000..0c49b14
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/models/ResourceManager/ResourceManagerInfo.java
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.models.resourceManager;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 02/06/14
+ * Time: 05:20
+ */
+public class ResourceManagerInfo {
+ private String branchId;
+ private String jndiName;
+ private String productName;
+ private String productVersion;
+ private String eisName;
+ private Collection participantsRecords;
+
+ public ResourceManagerInfo() {
+ participantsRecords = new ArrayList<>();
+ }
+
+ public String getBranchId() {
+ return branchId;
+ }
+
+ public void setBranchId(String branchId) {
+ this.branchId = branchId;
+ }
+
+ public String getJndiName() {
+ return jndiName;
+ }
+
+ public void setJndiName(String jndiName) {
+ this.jndiName = jndiName;
+ }
+
+ public String getProductName() {
+ return productName;
+ }
+
+ public void setProductName(String productName) {
+ this.productName = productName;
+ }
+
+ public String getProductVersion() {
+ return productVersion;
+ }
+
+ public void setProductVersion(String productVersion) {
+ this.productVersion = productVersion;
+ }
+
+ public String getEisName() {
+ return eisName;
+ }
+
+ public void setEisName(String eisName) {
+ this.eisName = eisName;
+ }
+
+ public Collection getParticipantsRecords() {
+ return participantsRecords;
+ }
+
+ public void setParticipantsRecords(Collection participantsRecords) {
+ this.participantsRecords = participantsRecords;
+ }
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/models/Response/BaseResponse.java b/restapi/src/main/java/io/narayana/nta/restapi/models/Response/BaseResponse.java
new file mode 100644
index 0000000..9ae7fd5
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/models/Response/BaseResponse.java
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.models.response;
+
+import javax.ws.rs.core.Response;
+import java.util.Calendar;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 28/05/14
+ * Time: 20:35
+ */
+public class BaseResponse {
+ private String timeStamp;
+ private Response.Status status;
+ private String message;
+
+ public BaseResponse() {
+ this.timeStamp = Calendar.getInstance().getTime().toString();
+ }
+
+ public String getTimeStamp() {
+ return timeStamp;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public Response.Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Response.Status status) {
+ this.status = status;
+ }
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/models/Response/ErrorResponse.java b/restapi/src/main/java/io/narayana/nta/restapi/models/Response/ErrorResponse.java
new file mode 100644
index 0000000..43b2815
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/models/Response/ErrorResponse.java
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.models.response;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 28/05/14
+ * Time: 20:39
+ */
+public class ErrorResponse extends BaseResponse {
+ private Exception exception;
+ private String cause;
+ private Class exceptionClass;
+ private String violations;
+
+ public Exception getException() {
+ return exception;
+ }
+
+ public void setException(Exception exception) {
+ this.exception = exception;
+ }
+
+ public String getCause() {
+ return cause;
+ }
+
+ public void setCause(String cause) {
+ this.cause = cause;
+ }
+
+ public Class getExceptionClass() {
+ return exceptionClass;
+ }
+
+ public void setExceptionClass(Class exceptionClass) {
+ this.exceptionClass = exceptionClass;
+ }
+
+ public String getViolations() {
+ return violations;
+ }
+
+ public void setViolations(String violations) {
+ this.violations = violations;
+ }
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/models/Response/PayloadResponse.java b/restapi/src/main/java/io/narayana/nta/restapi/models/Response/PayloadResponse.java
new file mode 100644
index 0000000..9253095
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/models/Response/PayloadResponse.java
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.models.response;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 28/05/14
+ * Time: 20:42
+ */
+public class PayloadResponse extends BaseResponse {
+ private Object payload;
+
+ public Object getPayload() {
+ return payload;
+ }
+
+ public void setPayload(Object payload) {
+ this.payload = payload;
+ }
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/models/Transaction/TransactionInfo.java b/restapi/src/main/java/io/narayana/nta/restapi/models/Transaction/TransactionInfo.java
new file mode 100644
index 0000000..d1a7d08
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/models/Transaction/TransactionInfo.java
@@ -0,0 +1,133 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.models.transaction;
+
+import io.narayana.nta.persistence.enums.Status;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 10/05/14
+ * Time: 12:01
+ */
+public class TransactionInfo {
+ private Long id;
+ private String txuid;
+ private Status status;
+ private String nodeid;
+ private Long startTime;
+ private Long endTime;
+ private Collection participantRecords;
+ private Collection events;
+ private Collection subordinates;
+ private String parentTransaction;
+
+ public TransactionInfo() {
+ participantRecords = new ArrayList<>();
+ events = new ArrayList<>();
+ subordinates = new ArrayList<>();
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getTxuid() {
+ return txuid;
+ }
+
+ public void setTxuid(String txuid) {
+ this.txuid = txuid;
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+
+ public String getNodeid() {
+ return nodeid;
+ }
+
+ public void setNodeid(String nodeid) {
+ this.nodeid = nodeid;
+ }
+
+ public Long getStartTime() {
+ return startTime;
+ }
+
+ public void setStartTime(Long startTime) {
+ this.startTime = startTime;
+ }
+
+ public Long getEndTime() {
+ return endTime;
+ }
+
+ public void setEndTime(Long endTime) {
+ this.endTime = endTime;
+ }
+
+ public Collection getParticipantRecords() {
+ return participantRecords;
+ }
+
+ public void setParticipantRecords(Collection participantRecords) {
+ this.participantRecords = participantRecords;
+ }
+
+ public Collection getEvents() {
+ return events;
+ }
+
+ public void setEvents(Collection events) {
+ this.events = events;
+ }
+
+ public Collection getSubordinates() {
+ return subordinates;
+ }
+
+ public void setSubordinates(Collection subordinates) {
+ this.subordinates = subordinates;
+ }
+
+ public String getParent() {
+ return parentTransaction;
+ }
+
+ public void setParent(String parentTransaction) {
+ this.parentTransaction = parentTransaction;
+ }
+}
+
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/models/URIConstants.java b/restapi/src/main/java/io/narayana/nta/restapi/models/URIConstants.java
new file mode 100644
index 0000000..58a6af9
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/models/URIConstants.java
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.models;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 13/05/14
+ * Time: 23:58
+ */
+public final class URIConstants {
+ public static final String RootURI = "api/v1";
+ public static final String TransactionURI = "/transaction";
+ public static final String ParticipantRecordURI = "/participantRecord";
+ public static final String ResourceManagerURI = "/resourceManager";
+ public static final String EventURI = "/event";
+ public static final String TracerURI = "/tracer";
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/models/event/EventInfo.java b/restapi/src/main/java/io/narayana/nta/restapi/models/event/EventInfo.java
new file mode 100644
index 0000000..3382a6c
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/models/event/EventInfo.java
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.models.event;
+
+import io.narayana.nta.persistence.enums.EventType;
+
+import java.sql.Timestamp;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 6/22/2014
+ * Time: 12:02 PM
+ */
+public class EventInfo {
+
+ private Long Id;
+ private String transaction;
+ private Timestamp timestamp;
+ private EventType eventType;
+ private String eventEntity;
+
+ public Long getId() {
+ return Id;
+ }
+
+ public void setId(Long id) {
+ Id = id;
+ }
+
+ public String getTransaction() {
+ return transaction;
+ }
+
+ public void setTransaction(String transaction) {
+ this.transaction = transaction;
+ }
+
+ public Timestamp getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(Timestamp timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public EventType getEventType() {
+ return eventType;
+ }
+
+ public void setEventType(EventType eventType) {
+ this.eventType = eventType;
+ }
+
+ public String getEventEntity() {
+ return eventEntity;
+ }
+
+ public void setEventEntity(String eventEntity) {
+ this.eventEntity = eventEntity;
+ }
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/models/participantRecord/ParticipantRecordInfo.java b/restapi/src/main/java/io/narayana/nta/restapi/models/participantRecord/ParticipantRecordInfo.java
new file mode 100644
index 0000000..b89ce36
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/models/participantRecord/ParticipantRecordInfo.java
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.models.participantRecord;
+
+import io.narayana.nta.persistence.enums.Vote;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 04/06/14
+ * Time: 11:14
+ */
+public class ParticipantRecordInfo {
+
+ private Long id;
+ private String rmuid;
+ private String transaction;
+ private String resourceManager;
+ private String xaException;
+ private Vote vote;
+ private boolean prepareCalled;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getRmuid() {
+ return rmuid;
+ }
+
+ public void setRmuid(String rmuid) {
+ this.rmuid = rmuid;
+ }
+
+ public String getTransaction() {
+ return transaction;
+ }
+
+ public void setTransaction(String transaction) {
+ this.transaction = transaction;
+ }
+
+ public String getResourceManager() {
+ return resourceManager;
+ }
+
+ public void setResourceManager(String resourceManager) {
+ this.resourceManager = resourceManager;
+ }
+
+ public String getXaException() {
+ return xaException;
+ }
+
+ public void setXaException(String xaException) {
+ this.xaException = xaException;
+ }
+
+ public Vote getVote() {
+ return vote;
+ }
+
+ public void setVote(Vote vote) {
+ this.vote = vote;
+ }
+
+ public boolean isPrepareCalled() {
+ return prepareCalled;
+ }
+
+ public void setPrepareCalled(boolean prepareCalled) {
+ this.prepareCalled = prepareCalled;
+ }
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/services/CommonService.java b/restapi/src/main/java/io/narayana/nta/restapi/services/CommonService.java
new file mode 100644
index 0000000..99d9e98
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/services/CommonService.java
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.services;
+
+import java.util.Collection;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 7/31/2014
+ * Time: 9:44 PM
+ */
+public interface CommonService {
+
+ public Collection get();
+
+ public T getById(Long id);
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/services/EventServiceImpl.java b/restapi/src/main/java/io/narayana/nta/restapi/services/EventServiceImpl.java
new file mode 100644
index 0000000..a5d25f3
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/services/EventServiceImpl.java
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.services;
+
+import io.narayana.nta.persistence.DataAccessObject;
+import io.narayana.nta.persistence.entities.Event;
+import io.narayana.nta.restapi.helpers.LinkGenerator;
+import io.narayana.nta.restapi.models.event.EventInfo;
+
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 6/24/2014
+ * Time: 11:04 PM
+ */
+public class EventServiceImpl implements CommonService {
+
+ @Inject
+ DataAccessObject dao;
+
+ @Override
+ public Collection get() {
+ Collection events = dao.findAllEvents();
+
+ Collection eventInfos = processDaoEvents(events);
+
+ return eventInfos;
+ }
+
+ @Override
+ public EventInfo getById(Long id) {
+ if (id == null) {
+ throw new IllegalArgumentException("event id cannot be null.");
+ }
+
+ Event event = dao.findEvent(id);
+
+ return processDoaEvent(event);
+ }
+
+ private Collection processDaoEvents(Collection events) {
+
+ if (events != null) {
+
+ Collection eventInfos = new ArrayList();
+
+ for (Event event : events) {
+ eventInfos.add(processDoaEvent(event));
+ }
+ return eventInfos;
+ }
+
+ return null;
+ }
+
+ private EventInfo processDoaEvent(Event event) {
+
+ if(event != null){
+
+ EventInfo eventInfo = new EventInfo();
+ eventInfo.setId(event.getId());
+ eventInfo.setTimestamp(event.getTimestamp());
+ eventInfo.setEventType(event.getEventType());
+ eventInfo.setEventEntity(event.getEventEntity());
+ eventInfo.setTransaction(LinkGenerator.transactionURI(event.getTransaction().getId()));
+
+ return eventInfo;
+ }
+
+ return null;
+ }
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/services/ParticipantRecordServiceImpl.java b/restapi/src/main/java/io/narayana/nta/restapi/services/ParticipantRecordServiceImpl.java
new file mode 100644
index 0000000..38108ab
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/services/ParticipantRecordServiceImpl.java
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.services;
+
+import io.narayana.nta.persistence.DataAccessObject;
+import io.narayana.nta.persistence.entities.ParticipantRecord;
+import io.narayana.nta.restapi.helpers.LinkGenerator;
+import io.narayana.nta.restapi.models.participantRecord.ParticipantRecordInfo;
+
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 04/06/14
+ * Time: 12:14
+ */
+public class ParticipantRecordServiceImpl implements CommonService {
+
+ @Inject
+ DataAccessObject dao;
+
+ @Override
+ public Collection get() {
+
+ Collection participantRecords = dao.findAllParticipantRecords();
+
+ return processDaoParticipantRecords(participantRecords);
+ }
+
+ @Override
+ public ParticipantRecordInfo getById(Long id){
+
+ if (id == null) {
+ throw new IllegalArgumentException("The passed in parameter Id cannot be null.");
+ }
+ ParticipantRecord daoParticipantRecord = dao.findParticipantRecord(id);
+ return processDaoParticipantRecord(daoParticipantRecord);
+ }
+
+ private Collection processDaoParticipantRecords(Collection daoParticipantRecords) {
+ if (daoParticipantRecords != null) {
+ Collection participantRecords = new ArrayList<>();
+ for (ParticipantRecord participantRecord : daoParticipantRecords) {
+ participantRecords.add(processDaoParticipantRecord(participantRecord));
+ }
+
+ return participantRecords;
+ }
+ return null;
+ }
+
+ private ParticipantRecordInfo processDaoParticipantRecord(ParticipantRecord daoParticipantRecord) {
+ if (daoParticipantRecord != null) {
+
+ ParticipantRecordInfo participantRecordInfo = new ParticipantRecordInfo();
+ participantRecordInfo.setId(daoParticipantRecord.getId());
+ participantRecordInfo.setRmuid(daoParticipantRecord.getRmuid());
+ participantRecordInfo.setPrepareCalled(daoParticipantRecord.isPrepareCalled());
+ participantRecordInfo.setVote(daoParticipantRecord.getVote());
+ participantRecordInfo.setXaException(daoParticipantRecord.getXaException());
+ participantRecordInfo.setResourceManager(LinkGenerator.resourceManagerURI(daoParticipantRecord.getResourceManager().getBranchId()));
+ participantRecordInfo.setTransaction(LinkGenerator.transactionURI(daoParticipantRecord.getTransaction().getId()));
+
+ return participantRecordInfo;
+ }
+ return null;
+ }
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/services/ResourceManagerService.java b/restapi/src/main/java/io/narayana/nta/restapi/services/ResourceManagerService.java
new file mode 100644
index 0000000..2a04604
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/services/ResourceManagerService.java
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.services;
+
+import io.narayana.nta.restapi.models.resourceManager.ResourceManagerInfo;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 7/31/2014
+ * Time: 10:05 PM
+ */
+public interface ResourceManagerService extends CommonService {
+
+ public ResourceManagerInfo getById(String id);
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/services/ResourceManagerServiceImpl.java b/restapi/src/main/java/io/narayana/nta/restapi/services/ResourceManagerServiceImpl.java
new file mode 100644
index 0000000..3dd741e
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/services/ResourceManagerServiceImpl.java
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.services;
+
+import io.narayana.nta.persistence.DataAccessObject;
+import io.narayana.nta.persistence.entities.ParticipantRecord;
+import io.narayana.nta.persistence.entities.ResourceManager;
+import io.narayana.nta.restapi.helpers.LinkGenerator;
+import io.narayana.nta.restapi.models.resourceManager.ResourceManagerInfo;
+import sun.reflect.generics.reflectiveObjects.NotImplementedException;
+
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 02/06/14
+ * Time: 05:30
+ */
+public class ResourceManagerServiceImpl implements ResourceManagerService{
+ @Inject
+ DataAccessObject dao;
+
+ @Override
+ public Collection get() {
+ Collection resourceManagers = dao.findAllResourceManagers();
+
+ return processDaoResourceManagers(resourceManagers);
+ }
+
+ @Override
+ public ResourceManagerInfo getById(Long id) {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public ResourceManagerInfo getById(String branchId) {
+ if (branchId == null) {
+ throw new IllegalArgumentException("Branch Id cannot be null.");
+ }
+
+ ResourceManager resourceManager = dao.findResourceManagerByBranchId(branchId);
+
+ return processDaoResourceManager(resourceManager);
+ }
+
+ private Collection processDaoResourceManagers(Collection daoResourceManagers) {
+ if (daoResourceManagers != null) {
+ Collection resourceManagers = new ArrayList<>();
+ for (ResourceManager resourceManager : daoResourceManagers) {
+ resourceManagers.add(processDaoResourceManager(resourceManager));
+ }
+
+ return resourceManagers;
+ }
+ return null;
+ }
+
+ private ResourceManagerInfo processDaoResourceManager(ResourceManager daoResourceManager) {
+ if (daoResourceManager != null) {
+ Collection participantRecords = new ArrayList<>();
+
+ for (ParticipantRecord participantRecord : daoResourceManager.getParticipantRecords()) {
+ participantRecords.add(LinkGenerator.participantRecordURI(participantRecord.getId()));
+ }
+
+ ResourceManagerInfo resourceManagerInfo = new ResourceManagerInfo();
+ resourceManagerInfo.setBranchId(daoResourceManager.getBranchId());
+ resourceManagerInfo.setEisName(daoResourceManager.getEisName());
+ resourceManagerInfo.setJndiName(daoResourceManager.getJndiName());
+ resourceManagerInfo.setProductName(daoResourceManager.getProductName());
+ resourceManagerInfo.setProductVersion(daoResourceManager.getProductVersion());
+ resourceManagerInfo.setParticipantsRecords(participantRecords);
+
+ return resourceManagerInfo;
+ }
+ return null;
+ }
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/services/TraceLoggingService.java b/restapi/src/main/java/io/narayana/nta/restapi/services/TraceLoggingService.java
new file mode 100644
index 0000000..ecc86f7
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/services/TraceLoggingService.java
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.services;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 14/05/14
+ * Time: 23:08
+ */
+public interface TraceLoggingService {
+ public boolean getTraceLoggingEnable();
+
+ public void setTraceLoggingEnable(boolean enable);
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/services/TraceLoggingServiceImpl.java b/restapi/src/main/java/io/narayana/nta/restapi/services/TraceLoggingServiceImpl.java
new file mode 100644
index 0000000..7c30850
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/services/TraceLoggingServiceImpl.java
@@ -0,0 +1,132 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.services;
+
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.dmr.ModelNode;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Named;
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.InetAddress;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 14/05/14
+ * Time: 23:09
+ */
+@SessionScoped
+public class TraceLoggingServiceImpl implements TraceLoggingService, Serializable {
+ private boolean traceLoggingEnable = false;
+ private ModelControllerClient client = null;
+ private String rotatingFileLogging;
+ private String arjunaLogging;
+
+
+ @PostConstruct
+ public void init() {
+ try {
+ client = ModelControllerClient.Factory.create(InetAddress.getByName("localhost"), 9999);
+ ModelNode op = new ModelNode();
+ op.get("operation").set("read-attribute");
+ op.get("address").add("subsystem", "logging").add("periodic-rotating-file-handler", "FILE");
+ op.get("name").set("level");
+
+ ModelNode ret;
+ try {
+ ret = client.execute(op);
+ } catch (java.io.IOException e) {
+ client.close();
+ client = ModelControllerClient.Factory.create("http-remoting", InetAddress.getByName("localhost"), 9990);
+ ret = client.execute(op);
+ }
+ rotatingFileLogging = ret.get("result").toString().replaceAll("\"", "");
+
+ op = new ModelNode();
+ op.get("operation").set("read-attribute");
+ op.get("address").add("subsystem", "logging").add("logger", "com.arjuna");
+ op.get("name").set("level");
+
+ ret = client.execute(op);
+ arjunaLogging = ret.get("result").toString().replaceAll("\"", "");
+
+ traceLoggingEnable = rotatingFileLogging.equals("TRACE") && arjunaLogging.equals("TRACE");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @PreDestroy
+ public void destroy() {
+ if (client != null) {
+ try {
+ client.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Override
+ public boolean getTraceLoggingEnable() {
+ return traceLoggingEnable;
+ }
+
+ @Override
+ public void setTraceLoggingEnable(boolean enable) {
+ try {
+ setTraceLogging(enable);
+ traceLoggingEnable = enable;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void setTraceLogging(boolean enable) throws Exception {
+ ModelNode op = new ModelNode();
+
+ op.get("operation").set("write-attribute");
+ op.get("address").add("subsystem", "logging").add("periodic-rotating-file-handler", "FILE");
+ op.get("name").set("level");
+ if (!enable) {
+ op.get("value").set(rotatingFileLogging.equals("TRACE") ? "INFO" : rotatingFileLogging);
+ } else {
+ op.get("value").set("TRACE");
+ }
+ client.execute(op);
+
+ op = new ModelNode();
+ op.get("operation").set("write-attribute");
+ op.get("address").add("subsystem", "logging").add("logger", "com.arjuna");
+ op.get("name").set("level");
+ if (!enable) {
+ op.get("value").set(arjunaLogging.equals("TRACE") ? "INFO" : arjunaLogging);
+ } else {
+ op.get("value").set("TRACE");
+ }
+ client.execute(op);
+ }
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/services/TransactionService.java b/restapi/src/main/java/io/narayana/nta/restapi/services/TransactionService.java
new file mode 100644
index 0000000..7f2ace6
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/services/TransactionService.java
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.services;
+
+import io.narayana.nta.persistence.enums.Status;
+import io.narayana.nta.restapi.models.transaction.TransactionInfo;
+
+import java.util.Collection;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 10/05/14
+ * Time: 01:22
+ */
+public interface TransactionService extends CommonService {
+
+ public Collection getByStatus(Status status);
+
+}
diff --git a/restapi/src/main/java/io/narayana/nta/restapi/services/TransactionServiceImpl.java b/restapi/src/main/java/io/narayana/nta/restapi/services/TransactionServiceImpl.java
new file mode 100644
index 0000000..c8d0a5c
--- /dev/null
+++ b/restapi/src/main/java/io/narayana/nta/restapi/services/TransactionServiceImpl.java
@@ -0,0 +1,132 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.services;
+
+import io.narayana.nta.persistence.DataAccessObject;
+import io.narayana.nta.persistence.entities.Event;
+import io.narayana.nta.persistence.entities.ParticipantRecord;
+import io.narayana.nta.persistence.entities.Transaction;
+import io.narayana.nta.persistence.enums.Status;
+import io.narayana.nta.restapi.helpers.LinkGenerator;
+import io.narayana.nta.restapi.models.transaction.TransactionInfo;
+
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 13/05/14
+ * Time: 23:46
+ */
+public class TransactionServiceImpl implements TransactionService {
+ @Inject
+ DataAccessObject dao;
+
+ @Override
+ public Collection get() {
+ Collection transactions = dao.findAllTopLevelTransactions();
+
+ Collection transactionInfos = processDaoTransactions(transactions);
+
+ return transactionInfos;
+ }
+
+ @Override
+ public Collection getByStatus(Status status) {
+ if (status == null) {
+ throw new IllegalArgumentException("transaction status cannot be null.");
+ }
+
+ Collection transactions = dao.findAllTopLevelTransactionsWithStatus(status);
+
+ Collection transactionInfos = processDaoTransactions(transactions);
+
+ return transactionInfos;
+ }
+
+ @Override
+ public TransactionInfo getById(Long id) {
+ if (id == null) {
+ throw new IllegalArgumentException("transaction id cannot be null.");
+ }
+
+ Transaction transaction = dao.findTransaction(id);
+
+ return processDaoTransaction(transaction);
+ }
+
+
+ private TransactionInfo processDaoTransaction(Transaction daoTransaction) {
+ if (daoTransaction != null) {
+ Collection participantRecordLinks = new ArrayList<>();
+
+ for (ParticipantRecord participantRecord : daoTransaction.getParticipantRecords()) {
+ participantRecordLinks.add(LinkGenerator.participantRecordURI(participantRecord.getId()));
+ }
+
+ Collection eventLinks = new ArrayList<>();
+ for (Event event : daoTransaction.getEvents()) {
+ eventLinks.add(LinkGenerator.eventURI(event.getId()));
+ }
+
+ Collection subordinateLinks = new ArrayList<>();
+ for (Transaction subordinateTransaction : daoTransaction.getSubordinates()) {
+ subordinateLinks.add(LinkGenerator.transactionURI(subordinateTransaction.getId()));
+ }
+
+ TransactionInfo transactionInfo = new TransactionInfo();
+ transactionInfo.setId(daoTransaction.getId());
+ transactionInfo.setEndTime(daoTransaction.getEndTime().getTime());
+ transactionInfo.setNodeid(daoTransaction.getNodeid());
+ transactionInfo.setStartTime(daoTransaction.getStartTime().getTime());
+ transactionInfo.setTxuid(daoTransaction.getTxuid());
+ transactionInfo.setStatus(daoTransaction.getStatus());
+ transactionInfo.setEvents(eventLinks);
+ transactionInfo.setParticipantRecords(participantRecordLinks);
+ transactionInfo.setSubordinates(subordinateLinks);
+
+ if (daoTransaction.getParent() != null)
+ transactionInfo.setParent(LinkGenerator.transactionURI(daoTransaction.getParent().getId()));
+
+ return transactionInfo;
+ }
+
+ return null;
+ }
+
+ private Collection processDaoTransactions(Collection daoTransactions) {
+
+ if(daoTransactions != null){
+ Collection transactionInfos = new ArrayList<>();
+
+ for (Transaction transaction : daoTransactions) {
+ transactionInfos.add(processDaoTransaction(transaction));
+ }
+
+ return transactionInfos;
+ }
+
+ return null;
+ }
+}
diff --git a/restapi/src/main/resources/META-INF/MANIFEST.MF b/restapi/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..5da11e6
--- /dev/null
+++ b/restapi/src/main/resources/META-INF/MANIFEST.MF
@@ -0,0 +1 @@
+Dependencies: org.jboss.as.controller-client, org.jboss.dmr
diff --git a/restapi/src/main/webapp/WEB-INF/beans.xml b/restapi/src/main/webapp/WEB-INF/beans.xml
new file mode 100644
index 0000000..ab3f5c3
--- /dev/null
+++ b/restapi/src/main/webapp/WEB-INF/beans.xml
@@ -0,0 +1,4 @@
+
+
+
\ No newline at end of file
diff --git a/restapi/src/test/java/io/narayana/nta/restapi/test/integration/TransactionAPITest.java b/restapi/src/test/java/io/narayana/nta/restapi/test/integration/TransactionAPITest.java
new file mode 100644
index 0000000..bf93335
--- /dev/null
+++ b/restapi/src/test/java/io/narayana/nta/restapi/test/integration/TransactionAPITest.java
@@ -0,0 +1,136 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package io.narayana.nta.restapi.test.integration;
+
+
+import io.narayana.nta.restapi.apis.TransactionAPI;
+import io.narayana.nta.restapi.models.transaction.TransactionInfo;
+import junit.framework.Assert;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.container.test.api.RunAsClient;
+import org.jboss.arquillian.extension.rest.warp.api.RestContext;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.arquillian.warp.Activity;
+import org.jboss.arquillian.warp.Inspection;
+import org.jboss.arquillian.warp.Warp;
+import org.jboss.arquillian.warp.WarpTest;
+import org.jboss.arquillian.warp.servlet.AfterServlet;
+import org.jboss.resteasy.client.ProxyFactory;
+import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
+import org.jboss.resteasy.spi.ResteasyProviderFactory;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.asset.FileAsset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.core.Response;
+import java.io.File;
+import java.net.URL;
+import java.util.Collection;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 8/2/2014
+ * Time: 12:08 AM
+ */
+@WarpTest
+@RunWith(Arquillian.class)
+public class TransactionAPITest {
+
+ @ArquillianResource
+ private URL contextPath;
+
+ private TransactionAPI transactionAPI;
+
+ @Deployment
+ @OverProtocol("Servlet 3.0")
+ public static WebArchive createDeployment() {
+ String ManifestMF = "Manifest-Version: 1.0\n"
+ + "Dependencies: org.jboss.jts, org.jboss.as.controller-client, org.jboss.dmr\n";
+
+ return ShrinkWrap.create(WebArchive.class, "testapi.war")
+ .addPackages(true, "io.narayana.nta")
+ .addPackages(true, "io.narayana.nta.restapi")
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
+ .addAsWebInfResource(new FileAsset(new File("src/test/resources/persistence.xml")),
+ "classes/META-INF/persistence.xml")
+ .addAsManifestResource(new FileAsset(new File("src/test/resources/nta-test-ds.xml")), "nta-test-ds.xml")
+ .addAsLibraries(new File("D:/Projects/TransactionAnalyser/transaction-analyser/etc/lib/commons-io-2.5-SNAPSHOT.jar"))
+ .setManifest(new StringAsset(ManifestMF));
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+
+ // initializes the rest easy client framework
+ RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
+ }
+
+ @Before
+ public void setUp() {
+
+/* ResteasyClient client = new ResteasyClientBuilder().build();
+ ResteasyWebTarget target = client.target(contextPath + "rest");
+
+ transactionAPI = target.proxy(TransactionAPI.class);*/
+
+ transactionAPI = ProxyFactory.create(TransactionAPI.class, contextPath + "api/v1/transaction");
+ }
+
+ @Test
+ @RunAsClient
+ public void testTransactionGetByStatusWarp(){
+
+ Warp.initiate(new Activity(){
+
+ @Override
+ public void perform(){
+
+ Response response = transactionAPI.getTransactions("COMMIT");
+ Collection result = response.readEntity(Collection.class);
+ Assert.assertNotNull(result);
+ }
+
+ }).inspect(new Inspection() {
+
+ @ArquillianResource
+ private RestContext restContext;
+
+ @AfterServlet
+ public void testTransactionGetByStatus(){
+ Assert.assertEquals(HttpMethod.GET, restContext.getHttpRequest().getMethod());
+ }
+
+ });
+
+ }
+
+}
diff --git a/restapi/src/test/java/io/narayana/nta/restapi/test/unit/helpers/LinkGeneratorTest.java b/restapi/src/test/java/io/narayana/nta/restapi/test/unit/helpers/LinkGeneratorTest.java
new file mode 100644
index 0000000..d5efb89
--- /dev/null
+++ b/restapi/src/test/java/io/narayana/nta/restapi/test/unit/helpers/LinkGeneratorTest.java
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package io.narayana.nta.restapi.test.unit.helpers;
+
+import io.narayana.nta.restapi.helpers.LinkGenerator;
+import io.narayana.nta.restapi.models.URIConstants;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.UnsupportedEncodingException;
+
+/**
+ * @Author Palahepitiya Gamage Amila Prabandhika <amila_fiz@hotmail.com$gt;
+ * Date: 7/16/2014
+ * Time: 11:22 PM
+ */
+
+public class LinkGeneratorTest {
+
+ private static final String ASSERTURIFAILURE = "Failure - The URI's are not equal.";
+
+ @Test
+ public void testParticipantRecordURIGenerator() {
+
+ long id = 1;
+ String participantRecordURI = LinkGenerator.participantRecordURI(id);
+ String expectedURI = URIConstants.RootURI + URIConstants.ParticipantRecordURI + "/1";
+ Assert.assertEquals(ASSERTURIFAILURE, expectedURI, participantRecordURI);
+
+ }
+
+ @Test
+ public void testEventURIGenerator() {
+
+ long id = 1;
+ String eventURI = LinkGenerator.eventURI(id);
+ String expectedURI = URIConstants.RootURI + URIConstants.EventURI + "/1";
+ Assert.assertEquals(ASSERTURIFAILURE, expectedURI, eventURI);
+ }
+
+ @Test
+ public void testTransactionURIGenerator() {
+
+ long id = 1;
+ String transactionURI = LinkGenerator.transactionURI(id);
+ String expectedURI = URIConstants.RootURI + URIConstants.TransactionURI + "/1";
+ Assert.assertEquals(ASSERTURIFAILURE, expectedURI, transactionURI);
+ }
+
+ @Test
+ public void testResourceManagerURIGenerator() {
+
+ String branchId = "testBranch";
+ String resourceManagerURI = LinkGenerator.resourceManagerURI(branchId);
+ String expectedURI = URIConstants.RootURI + URIConstants.ResourceManagerURI + "/testBranch";
+ Assert.assertEquals(ASSERTURIFAILURE, expectedURI, resourceManagerURI);
+ }
+}
diff --git a/restapi/src/test/resources/arquillian.xml b/restapi/src/test/resources/arquillian.xml
new file mode 100644
index 0000000..d0ab343
--- /dev/null
+++ b/restapi/src/test/resources/arquillian.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/restapi/src/test/resources/nta-test-ds.xml b/restapi/src/test/resources/nta-test-ds.xml
new file mode 100644
index 0000000..130e5d1
--- /dev/null
+++ b/restapi/src/test/resources/nta-test-ds.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+ jdbc:h2:mem:ticket-monster;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1
+ h2
+
+ sa
+ sa
+
+
+
diff --git a/restapi/src/test/resources/persistence.xml b/restapi/src/test/resources/persistence.xml
new file mode 100644
index 0000000..330fece
--- /dev/null
+++ b/restapi/src/test/resources/persistence.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+ java:jboss/datasources/ntaTestDS
+ io.narayana.nta.persistence.entities.Transaction
+ io.narayana.nta.persistence.entities.ResourceManager
+ io.narayana.nta.persistence.entities.ParticipantRecord
+ io.narayana.nta.persistence.entities.Event
+ io.narayana.nta.persistence.entities.RequestRecord
+
+
+
+
+
+
+
+
+