I'm sure this is somewhat easy, but I couldn't figure it with my limited Java knowledge, and couldn't find an answer.
I have a plugin that implements some REST. I can currently get static information by going to this url:
http://my.server.com:7990/rest/my_plugin/1.0/settings
Which spits out the static info I've put in nicely.
What I want to be able to do is pass in some info, and have the plugin mutate the REST Call based on paramaters recieved, as such:
http://my.server.com:7990/rest/my_plugin/1.0/settings?repo=myrepo&project=project1
Where it will then use project and repo as variables at the Java level.
(This is specifically for Stash, but I presume the method is the same regardless)
Community moderators have prevented the ability to post new answers.
Hi Justin,
Yep, we just use normal Jersey annotations, and they should work across all Atlassian products.
Off topic slightly, if you want to use those two parameters to load a repository from the RepositoryService, you can do the following to save you work:
@Path(ResourcePatterns.REPOSITORY_URI + "/settings") public class SomethingResource { @GET public Response getMesssage(@Context Repository repository) {...} }
This will end up as:
/rest/my_plugin/1.0/projects/project1/repos/myrepo/settings
Just a convention we use to make things easier. The "magic" is that you must use REPOSITORY_URI somewhere in the path, otherwise @Context won't work. Using query parameters is fine too though. :)
Charles
Incase anyone else has the same question:
@GET @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response getMessage(@QueryParam("repo") String repo, @QueryParam("project") String project)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.