Hi Ghania,
I think the problem lies with the JSON you're sending.
It needs to look something like this:
{attributes: {left: "something", right: "something-else"}, tags: {}}
If this is not the case, could you show me the JSON you're sending?
Perhaps you could validate the JSON somewhere online aswell.
Good luck,
Mike van Dongen.
> Date: Tue, 10 Sep 2013 12:06:20 -0700
> From: [email protected]
> Subject: Re: How to query the distributions/targets with the Client Rest API?
> To: [email protected]
>
> Hi every one,
>
> Thank you very much Igor for your response.
> I found that tool very very useful. I tried a post on client/work to get the
> ID and a query to get the targets and the distributions which worked.
> But, when I post on client/work/rest-25/distribution2target, I am still
> getting that exception with this tool(see below the details of the
> exception).
>
> Just for your information, I have installed Apache Ace in my machine and on 2
> other servers. While doing the post for the association distribution2target,
> with google Chrom Advanced REST client, I tried all combinations. I mean I
> used left/right keys and then leftEndpoint/rightEndpoint keys. Then, in the
> left I put a value I got from the distribution query, and in the right I put
> a value I got from the target query.
>
> I’m wondering if I installed the right version, or what I’m missing here?
> Please if someone could help with this issue and thank you so much in advance
> for your response,
> Best Regards,
> Ghania Ferrag
>
>
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
> <title>Error 500 INTERNAL_SERVER_ERROR</title>
> </head>
> <body><h2>HTTP ERROR 500</h2>
> <p>Problem accessing /client/work/rest-3/distribution2target. Reason:
> <pre> INTERNAL_SERVER_ERROR</pre></p><h3>Caused
> by:</h3><pre>java.lang.NullPointerException
> at
> org.apache.ace.client.rest.RESTClientServlet.createRepositoryObject(RESTClientServlet.java:413)
> at
> org.apache.ace.client.rest.RESTClientServlet.doPost(RESTClientServlet.java:354)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
> at
> org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
> at
> org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
> at
> org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
> at
> org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
> at
> org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
> at
> org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:48)
> at
> org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:39)
> at
> org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
> at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
> at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
> at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
> at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
> at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
> at org.mortbay.jetty.Server.handle(Server.java:326)
> at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
> at
> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926)
> at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
> at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
> at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
> at
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
> at
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
> </pre>
>
>
>
> ________________________________
> De : "Passchier, I. (Igor)" <[email protected]>
> À : ghania ferrag <[email protected]>; "[email protected]"
> <[email protected]>
> Envoyé le : lundi 9 Septembre 2013 14h30
> Objet : Re: How to query the distributions/targets with the Client Rest API?
>
>
> Hi Ghania,
>
> To debug any rest interface, you could use the rest api plugin for chrome.
> This enables you to query any rest api on the fly, without programming the
> client side yourself. Probably something similar is also available for
> Firefox, but I never tried to find that.
>
> if you understand the details of the api in this way, you can implement it in
> your code afterwards.
>
> Regards,
>
> Igor Passchier
>
> ----- Reply message -----
> Van: "ghania ferrag" <[email protected]>
> Aan: "[email protected]" <[email protected]>
> Onderwerp: How to query the distributions/targets with the Client Rest API?
> Datum: ma, sep. 9, 2013 18:09
>
> Hi Mike and Thank you very much for your response :)
>
> I tried "left" and "right" instead of "leftEndpoint" and "rightEndpoint", as
> parameters in the form, but it is still not working with the same error
> message.
> I even created an other java client ( not using jersey) to communicate with
> REST API of ACE, no luck..
> Is there a more suitable Client REST API than Jersey ? A sample of code will
> really help.
> Thank you again for your response,
> My best Regards,
> Ghania
>
>
>
> ________________________________
> De : Mike van Dongen <[email protected]>
> À : "[email protected]" <[email protected]>
> Envoyé le : dimanche 8 Septembre 2013 16h24
> Objet : RE: How to query the distributions/targets with the Client Rest API?
>
>
> Hi Ghania!
> I ran into the same problems when I started using ACE 1 or 2 months ago.
>
> > Hi every one,
> >
> > Thank you Mike, Elmar for your response.
> >
> > I’m having an exception when doing a post to
> > client/work/rest-ID/distrubution2target with setting a form with the form
> > parameters : leftEndpoint, rightEndpoint, leftCardinality, rightCardinality
> >
> > The exception is <p>Problem accessing
> > /client/work/rest-1/distribution2target. Reason:
> > <pre> Unable to parse repository object!</pre></p><h3>Caused
> > by:</h3><pre>java.io.IOException: Unable to parse repository object!
> > at
> > org.apache.ace.client.rest.RESTClientServlet.getRepositoryValueObject(RESTClientServlet.java:486)
> > at
> > org.apache.ace.client.rest.RESTClientServlet.doPost(RESTClientServlet.java:353)
> > …..Caused by: com.google.gson.JsonParseException: Expecting object found:
> > "leftEndpoint"
>
> If I recall correctly, you should use the parameters 'left' and 'right'.The
> values of those parameters need to be the definitions of the distribution and
> target respectively.
>
> > Also when I do I post to Client/work, I’m getting this with no sessionID :
> > ["artifact", "feature", "distribution", "target", "artifact2feature",
> > "feature2distribution", "distribution2target"]
> > How to get the new Workspace with the sessionID, what I’m missing in my
> > post?
> > Any idea how to fix this error?
> Once a new workspace is created, the client will be redirected to this
> workspace.The URL you're being redirected to is "client/work/rest-ID", where
> rest-ID is the ID of your workspace.In my case I was able to retrieve the URL
> that was last used and set it as the base URI.
> I'm unfamiliar with Jersey but this might
> help:https://jersey.java.net/nonav/apidocs/1.1.1-ea/jersey/com/sun/jersey/api/client/WebResource.html#getURI()
>
> Good luck!Mike.
> > Thank you again for your response,
> > My Best Regards,
> > Ghania
> >
> >
> >
> > ________________________________
> > De : Elmar Zeeb <[email protected]>
> > À : [email protected]
> > Envoyé le : vendredi 6 Septembre 2013 3h15
> > Objet : Re: How to query the distributions/targets with the Client Rest API?
> >
> >
> > Hi Ghania,
> >
> > Am 05.09.2013 19:04, schrieb ghania ferrag:
> > > Hi all,
> > >
> > > I’m working on new web UI ( I used Vaadin for this UI) to allow our users
> > > to send distributions to specific targets.
> > > In our UI we have just to display all existing distributions and I wonder
> > > how to query the distributions with the Client Rest API?
> > > I read the following link:
> > > https://cwiki.apache.org/confluence/display/ACE/Client+REST+API
> > >
> > >
> > >
> > > Some one can tell me what is wrong with this REST-client code (I used
> > > Jersey):
> > > 1) I suspect the path is wrong: "ace/workspaceID/distribution" ?
> > > 2) or may be REST-server is not set ?
> > >
> > > import javax.ws.rs.core.UriBuilder;
> > > import com.sun.jersey.api.client.Client;
> > > import com.sun.jersey.api.client.WebResource;
> > > import com.sun.jersey.api.client.config.ClientConfig;
> > > import com.sun.jersey.api.client.config.DefaultClientConfig;
> > > public class ClientTest{
> > > public static void main(String[] args) {
> > > getDistributions();
> > > }
> > >
> > > public static void getDistributions() {
> > > ClientConfig config = new DefaultClientConfig();
> > > Client client = Client.create(config);
> > > WebResource service = client.resource(getBaseURI());
> > > // Get JSONfor application
> > >
> > > System.out.println(service.path("workspaceID").path("distribution").accept(MediaType.APPLICATION_JSON).get(String.class));
> > > // Get XML for application
> > >
> > > System.out.println(service.path("workspaceID").path("distribution").accept(MediaType.APPLICATION_XML).get(String.class));
> > > }
> > > private static URI getBaseURI() {
> > > return UriBuilder.fromUri("http://localhost:8080/ace").build();
> > > }
> > >
> > > Thanks and Regards,
> > > Ghania
> > You should create a association between a distribution and a target,
> > this is called distribution2target and is a resource that can be created
> > with a post to ace/workspaceID/distribution2target (see
> > http://ace.apache.org/user-doc/restapi.html).
> >
> > Regards,
> > Elmar