Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to set correct datasource for Restful table

Hy Nguyen February 14, 2019

Hi all,

I'm developing a plugin for Jira 7.13 (AUI 7.9.9). I'm following the document of AUI's Restful Table and try to create a restful table without my own datasource. My rest resource provides a method to get every custom field from the system.

@Path("/customfield")
@Consumes ({ MediaType.APPLICATION_JSON })
@Produces ({ MediaType.APPLICATION_JSON })
public class CustomFieldResource {

@Autowired
private CustomFieldManager customFieldManager;

@GET
@AnonymousAllowed
@Path("/getCustomField")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Response getAll() {
final List<CustomField> allCustomFields = customFieldManager.getCustomFieldObjects();
List<CustomFieldDTO> customFieldDTOs = new ArrayList<>();
allCustomFields.forEach(cf -> customFieldDTOs.add(new CustomFieldDTO(cf.getId(), cf.getFieldName())));
return Response.ok(new Gson().toJson(customFieldDTOs)).build();
}

@GET
@Path("{id}")
public Response get(@PathParam("id") final String id) {
return Response.ok().build();
}

@PUT
@Path ("{id}")
public Response updateVersion(@PathParam ("id") final String id, final CustomFieldDTO bean)
{
return null;
}


@POST
public Response createVersion(final CustomFieldDTO bean)
{
return null;
}
}

In the documentation of Restful table, at the resources part:

resources: {
all: "rest/project/HSP/versions?expand=operations",
self: "rest/version"
},

I think the "all" is meant to be replaced "getAll" method by my custom resource, and the "self" should map to the endpoint of "get" method (or update?). so I made the configuration like this:

var baseUrl = AJS.params.baseURL;
var requestURL = baseUrl + "/rest/cfresource/1.0/customfield/getCustomField";
var selfURL = baseUrl + "/rest/cfresource/1.0/customfield";
resources: {
all: requestURL,
self: selfURL
},

Some how I can get the data from browser console. But what happen in UI is just "Loading" and "Loading".

loading.png

Could you please tell me what is the problem with my config and how to solve that? Any help would be appreciated

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events