Difference between revisions of "Lyo/TRSReferenceApplication"

From Eclipsepedia

< Lyo
Jump to: navigation, search
Line 25: Line 25:
 
#Go back to the Tracked Resource Set page and refresh if necessary. Notice an entry in the change log section of the Tracked Resource Set containing a Creation event. If you repeat the creation event more than 3 times, you'll notice the change log being segmented with a previous element containing a URI to return the previous segment of the change log.
 
#Go back to the Tracked Resource Set page and refresh if necessary. Notice an entry in the change log section of the Tracked Resource Set containing a Creation event. If you repeat the creation event more than 3 times, you'll notice the change log being segmented with a previous element containing a URI to return the previous segment of the change log.
  
== Examine how the TRS toolkit helps create a TRS provider, via generic Servlet ==
+
== Examine how the TRS toolkit helps create a TRS provider, via generic Servlet ==
  
 +
#Open the file org.eclipse.lyo.rio.trs\src\main\webapp\WEB-INF\web.xml. Notice the servlet mapping for the relative path /restx/trs/base/. This maps the Base resource RESTful endpoint to the servlet class com.ibm.team.integration.refapps.trs.servlet.BaseGeneric.
 +
#Open the file org.eclipse.lyo.rio.trs.servlet.BaseGeneric. It has an overridden doGet method, which implements the root of the RESTful service for the Base Resource.
 +
#In the reference application, the Base Resource is paged so that, according to the specification, a get on the base resources will do a redirect to the first page of base resources. If the path for the Get request contains the page number, it returns the response corresponding to the Base resource at the given page. In a simple servlet implementation, we serialize the Base resource to the response stream using OSLC4JMarshaller. The current implementation of the Base end point only handles RDF XML, but it could be extended to various other media types based on the HTTP request.
 +
#Similary, the file web.xml also contains the servlet mapping for two other endpoints for Tracked Resource Set and Change Log.
 +
#The servlet mapping for the relative path /restx/trs/ maps the Tracked Resource Set RESTful endpoint to the servlet class org.eclipse.lyo.rio.trs.servlet.TRSGeneric.
 +
#Open the file org.eclipse.lyo.rio.trs.servlet.TRSGeneric. It has an overridden doGet method, which implements the root of the RESTful service for the Tracked Resource Set.
 +
#The reference application is utilizing the segmented Changelog concept from the TRS Specification (sec 1.3.1.1). The method toGet() populates a TrackedResourceSet (a simple java bean provided by the toolkit for representing a tracked resource set) with the most recent segment of the changelog. It then serializes the TrackedResourceSet object to the response stream using OSLC4JMarshaller.
 +
#In a similar fashion, the Changelog endpoint, which is mapped to the the relative path /restx/trs/changelog/, is implemented in the class org.eclipse.lyo.rio.trs.servlet.ChangeLogGeneric.java.
  
  
#Open the file org.eclipse.lyo.rio.trs\src\main\webapp\WEB-INF\web.xml. Notice the servlet mapping for the relative path /restx/trs/base/. This maps the Base resource RESTful endpoint to the servlet class com.ibm.team.integration.refapps.trs.servlet.BaseGeneric.
+
 
#Open the file org.eclipse.lyo.rio.trs.servlet.BaseGeneric. It has an overridden doGet method, which implements the root of the RESTful service for the Base Resource.
+
=== Trying it out ===
#In the reference application, the Base Resource is paged so that, according to the specification, a get on the base resources will do a redirect to the first page of base resources. If the path for the Get request contains the page number, it returns the response corresponding to the Base resource at the given page. In a simple servlet implementation, we serialize the Base resource to the response stream using OSLC4JMarshaller. The current implementation of the Base end point only handles RDF XML, but it could be extended to various other media types based on the HTTP request.
+
 
#Similary, the file web.xml also contains the servlet mapping for two other endpoints for Tracked Resource Set and Change Log.
+
#Ensure that the reference application is running. If it is not, in the Project Explorer view, in the org.eclipse.lyo.rio.trs project, right-click Launch TRS Reference App.launch and click Run As -&gt; Launch TRS Reference App.
#The servlet mapping for the relative path /restx/trs/ maps the Tracked Resource Set RESTful endpoint to the servlet class org.eclipse.lyo.rio.trs.servlet.TRSGeneric.
+
#The TRS Reference Application includes an index.html file that contains links to the various capabilities provided by the application. To open the page, point your browser at http://&lt;hostname&gt;:8082/org.eclipse.lyo.rio.trs (e.g. http://localhost:8082/org.eclipse.lyo.rio.trs)
#Open the file org.eclipse.lyo.rio.trs.servlet.TRSGeneric. It has an overridden doGet method, which implements the root of the RESTful service for the Tracked Resource Set.
+
#The first section of the page provides link "Generic Base Resources" to the Base and "Generic Tracked Resource Set" to Tracked Resource Set as implemented by the BaseGeneric and TRSGeneric classes we observed earlier. Navigate to the Generic Base Resources link. You'll see the Base Resources document in XML form.
#The reference application is utilizing the segmented Changelog concept from the TRS Specification (sec 1.3.1.1). The method toGet() populates a TrackedResourceSet (a simple java bean provided by the toolkit for representing a tracked resource set) with the most recent segment of the changelog. It then serializes the TrackedResourceSet object to the response stream using OSLC4JMarshaller.
+
#Navigate to the Generic Tracked Resource Set link. The change log contained in the Tracked Resource Set should contain an rdf:nil entry to represent no changes have been made to the resources.
#In a similar fashion, the Changelog endpoint, which is mapped to the the relative path /restx/trs/changelog/, is implemented in the class org.eclipse.lyo.rio.trs.servlet.ChangeLogGeneric.java.
+
#Return to the index page and click Create Change Request.
 +
#Type in a title and a description, and then click Submit Bug. Make note of the change request number.
 +
#Go back to the Tracked Resource Set page and refresh if necessary. Notice an entry in the change log section of the Tracked Resource Set containing a Creation event. If you repeat the creation event more than 3 times, you'll notice the change log being segmented with a previous element containing a URI to return the previous segment of the change log.

Revision as of 15:38, 8 March 2013

 The Guided Tour walks you through the following tasks:


Contents

Examine how the TRS toolkit, can help you create a TRS provider, using JAX-RS

  1. Open the file org.eclipse.lyo.rio.trs.resources.BaseResource.java. Notice @Path("/trs/"+TRSConstants.TRS_TERM_BASE) at the top of the class.
  2. This is a JAX-RS annotation that assigns a relative path (from the jax-rs servlet context) for the Base Resource RESTful endpoint. There are various constants and vocabularies defined in the toolkit to abstract the terms and namespaces from TRS provider implementers.
  3. In the reference application, the Base Resource is paged so that, according to the specification, a get on the base resources will do a redirect to the first page of base resources. This is what happens in the getBase() endpoint.
  4. The other method, getBasePage(page), returns the Base resource at the given page. The class org.eclipse.lyo.core.trs.Base is provided by the TRS toolkit. It is basically a simple java bean that has been annotated with various OSLC4J annotations to allow the OSLC4J marshalling to create the proper RDF document for the JAX-RS configured serialization.
  5. Both methods have additional annotations such as @GET, which identifies the type of HTTP traffic it can handle, as well as an @Produces that identifies the return type the method can handle. In all cases, the REST endpoints can return RDF XML, XML, or JSON. JAX-RS dynamically returns the correct format based on the HTTP request that is received.
  6. Open the file org.eclipse.lyo.rio.trs.resources.TRSResource.java
  7. In similar fashion it also has an @Path annotation that identifies the root of the RESTful service for the Tracked Resource Set.
  8. The reference application is utilizing the segmented Changelog concept from the TRS Specification (sec 1.3.1.1). The method getTrackedResourceSet() returns a tracked resource set with the most recent segment of the changelog.
  9. The other method in this class, getChangeLog(page), returns the segmented portion of the change as requested by the HTTP request

Trying it out

  1. Ensure that the reference application is running. If it is not, in the Project Explorer view, in the org.eclipse.lyo.rio.trs project, right-click Launch TRS Reference App.launch and click Run As -> Launch TRS Reference App.
  2. The TRS Reference Application includes an index.html file that contains links to the various capabilities provided by the application. To open the page, point your browser at http://<hostname>:8082/org.eclipse.lyo.rio.trs (e.g. http://localhost:8082/org.eclipse.lyo.rio.trs)
  3. The first section of the page provides links to the Base and Tracked Resource Set as implemented by the BaseResource and TRSResource classes we observed earlier. Navigate to the Base Resources link. You'll see the Base Resources document in XML form. The format and syntax has been handled by the TRS toolkit's annotated beans and the OSLC4J serializers.
  4. Navigate to the Tracked Resource Set link. The change log contained in the Tracked Resource Set should contain a rdf:nil to represent no changes have been made to the resources.
  5. Return to the index page and click Create Change Request.
  6. Type in a title and a description, and then click Submit Bug. Make note of the change request number.
  7. Go back to the Tracked Resource Set page and refresh if necessary. Notice an entry in the change log section of the Tracked Resource Set containing a Creation event. If you repeat the creation event more than 3 times, you'll notice the change log being segmented with a previous element containing a URI to return the previous segment of the change log.

Examine how the TRS toolkit helps create a TRS provider, via generic Servlet

  1. Open the file org.eclipse.lyo.rio.trs\src\main\webapp\WEB-INF\web.xml. Notice the servlet mapping for the relative path /restx/trs/base/. This maps the Base resource RESTful endpoint to the servlet class com.ibm.team.integration.refapps.trs.servlet.BaseGeneric.
  2. Open the file org.eclipse.lyo.rio.trs.servlet.BaseGeneric. It has an overridden doGet method, which implements the root of the RESTful service for the Base Resource.
  3. In the reference application, the Base Resource is paged so that, according to the specification, a get on the base resources will do a redirect to the first page of base resources. If the path for the Get request contains the page number, it returns the response corresponding to the Base resource at the given page. In a simple servlet implementation, we serialize the Base resource to the response stream using OSLC4JMarshaller. The current implementation of the Base end point only handles RDF XML, but it could be extended to various other media types based on the HTTP request.
  4. Similary, the file web.xml also contains the servlet mapping for two other endpoints for Tracked Resource Set and Change Log.
  5. The servlet mapping for the relative path /restx/trs/ maps the Tracked Resource Set RESTful endpoint to the servlet class org.eclipse.lyo.rio.trs.servlet.TRSGeneric.
  6. Open the file org.eclipse.lyo.rio.trs.servlet.TRSGeneric. It has an overridden doGet method, which implements the root of the RESTful service for the Tracked Resource Set.
  7. The reference application is utilizing the segmented Changelog concept from the TRS Specification (sec 1.3.1.1). The method toGet() populates a TrackedResourceSet (a simple java bean provided by the toolkit for representing a tracked resource set) with the most recent segment of the changelog. It then serializes the TrackedResourceSet object to the response stream using OSLC4JMarshaller.
  8. In a similar fashion, the Changelog endpoint, which is mapped to the the relative path /restx/trs/changelog/, is implemented in the class org.eclipse.lyo.rio.trs.servlet.ChangeLogGeneric.java.


Trying it out

  1. Ensure that the reference application is running. If it is not, in the Project Explorer view, in the org.eclipse.lyo.rio.trs project, right-click Launch TRS Reference App.launch and click Run As -> Launch TRS Reference App.
  2. The TRS Reference Application includes an index.html file that contains links to the various capabilities provided by the application. To open the page, point your browser at http://<hostname>:8082/org.eclipse.lyo.rio.trs (e.g. http://localhost:8082/org.eclipse.lyo.rio.trs)
  3. The first section of the page provides link "Generic Base Resources" to the Base and "Generic Tracked Resource Set" to Tracked Resource Set as implemented by the BaseGeneric and TRSGeneric classes we observed earlier. Navigate to the Generic Base Resources link. You'll see the Base Resources document in XML form.
  4. Navigate to the Generic Tracked Resource Set link. The change log contained in the Tracked Resource Set should contain an rdf:nil entry to represent no changes have been made to the resources.
  5. Return to the index page and click Create Change Request.
  6. Type in a title and a description, and then click Submit Bug. Make note of the change request number.
  7. Go back to the Tracked Resource Set page and refresh if necessary. Notice an entry in the change log section of the Tracked Resource Set containing a Creation event. If you repeat the creation event more than 3 times, you'll notice the change log being segmented with a previous element containing a URI to return the previous segment of the change log.