Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Lyo/OSLC4JAnnotations"

< Lyo
 
Line 19: Line 19:
 
     )
 
     )
 
     @GET
 
     @GET
     @Produces({OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML,
+
     @Produces({"application/rdf+xml", "application/xml", "application/json", "text/turtle"})
      OslcMediaType.APPLICATION_JSON, OslcMediaType.TEXT_TURTLE})
+
 
     public ChangeRequest[] getChangeRequests(@QueryParam("oslc.where") final String where)
 
     public ChangeRequest[] getChangeRequests(@QueryParam("oslc.where") final String where)
 
     {
 
     {
Line 34: Line 33:
 
         title = "Change Request Creation Factory",
 
         title = "Change Request Creation Factory",
 
         label = "Change Request Creation",
 
         label = "Change Request Creation",
         resourceShapes = {OslcConstants.PATH_RESOURCE_SHAPES + "/" + Constants.PATH_CHANGE_REQUEST},
+
         resourceShape = "shapes/changeRequest",
         resourceTypes = {Constants.TYPE_CHANGE_REQUEST},
+
         resourceTypes = {"http://open-services.net/ns/cm#ChangeRequest"},
         usages = {OslcConstants.OSLC_USAGE_DEFAULT}
+
         usages = {"http://open-services.net/ns/core#default"}
 
     )
 
     )
 
     @POST
 
     @POST
     @Consumes({OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML,
+
     @Consumes({"application/rdf+xml", "application/xml", "application/json", "text/turtle"})
          OslcMediaType.APPLICATION_JSON, OslcMediaType.TEXT_TURTLE})
+
     @Produces({"application/rdf+xml", "application/xml", "application/json", "text/turtle"})
     @Produces({OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML,
+
          OslcMediaType.APPLICATION_JSON, OslcMediaType.TEXT_TURTLE})
+
 
     public Response addChangeRequest(ChangeRequest changeRequest)
 
     public Response addChangeRequest(ChangeRequest changeRequest)
 
     {
 
     {

Latest revision as of 13:33, 8 March 2014

Service Description Documents

OSLC4J will generate an OSLC service description document for you if you've properly annotated your code. You should have an @OslcService annotation on every JAX-RS resource you want to use with OSLC4J, even if you only have one service description document.

Query Capabilities and Creation Factories

To use @OslcQueryCapability and @OslcCreationFactory, simply add those annotations to the @GET and @POST methods for each resource that handles those requests. The URIs are added to the service description document calculated from the JAX-RS @Path annotation.

Here is an example @OslcQueryCapability:

   @OslcQueryCapability
   (
       title = "Change Request Query Capability",
       label = "Change Request Catalog Query",
       resourceShape = "shapes/changeRequest",
       resourceTypes = {"http://open-services.net/ns/cm#ChangeRequest"},
       usages = {"http://open-services.net/ns/core#default"}
   )
   @GET
   @Produces({"application/rdf+xml", "application/xml", "application/json", "text/turtle"})
   public ChangeRequest[] getChangeRequests(@QueryParam("oslc.where") final String where)
   {
      // ... implementation here ...
   }

Here is an example @OslcCreationFactory:

   @OslcCreationFactory
   (
        title = "Change Request Creation Factory",
        label = "Change Request Creation",
        resourceShape = "shapes/changeRequest",
        resourceTypes = {"http://open-services.net/ns/cm#ChangeRequest"},
        usages = {"http://open-services.net/ns/core#default"}
   )
   @POST
   @Consumes({"application/rdf+xml", "application/xml", "application/json", "text/turtle"})
   @Produces({"application/rdf+xml", "application/xml", "application/json", "text/turtle"})
   public Response addChangeRequest(ChangeRequest changeRequest)
   {
      // ... implementation here ...
   }

Dialogs

  • For selection dialogs, the @OslcDialogs or @OslcDialog annotation has to be on a @GET method, usually the query capability.
  • For creation dialogs, the annotation has to be on an @POST method, usually the creation factory.

The @OslcDialog "uri" determines the URI for the dialog, and you can use path parameters. For instance, the Bugzilla adapter has this selection dialog:

       @OslcDialog
       (
            title = "Change Request Selection Dialog",
            label = "Change Request Selection Dialog",
            uri = "/{productId}/changeRequests/selector",
            hintWidth = "525px",
            hintHeight = "325px",
            resourceTypes = {Constants.TYPE_CHANGE_REQUEST},
            usages = {OslcConstants.OSLC_USAGE_DEFAULT}
       )

Creating the ServiceProvider

To create the ServiceProvider, call org.eclipse.lyo.oslc4j.core.model.ServiceProviderFactory.createServiceProvider(). You might need to set a few properties manually, such as the details URI and prefix definitions.

Back to the top