cancel
Showing results for 
Search instead for 
Did you mean: 

Help required in java based webscript

abhashree
Champ in-the-making
Champ in-the-making
Hi All,

I want to write one java based webscript for searching the content with its type and aspect value.
I don't want to give any hard coded value in luecene query.
My intention is to pass the parameters for search as json object and converting the object into the hashmap.
I am not sure about the logic of the webscript.
Please guide me for implementing the webscript.



Thanks in advance
Abhashree
5 REPLIES 5

mitpatoliya
Star Collaborator
Star Collaborator
You can refer this link
http://wiki.alfresco.com/wiki/Java-backed_Web_Scripts_Samples
to get idea about the webscripts.
And rather then creating json object and all that just pass the criterias in your URL as parameters.
and then generate the query dynamically based on that passed parameters.
This should server your purpose.

abhashree
Champ in-the-making
Champ in-the-making
Hi Mitapatoliya,

Thanks a lot for your response.
I have gone through the wiki.
It will really helpful to me if you will give an example of this scenario as I am not getting the logic properly.
Please guide me.

Thanks,
Abhashree

mitpatoliya
Star Collaborator
Star Collaborator
Here is the case:

I want to search the documents of particular type which are created between certain time.
In my webscript there I will pass three parameters.

YourscriptURL/type={Type}&from_date={from_date}&todate={to_date}
Type,from date and to date.
Then in script I get all those values and will create query on the fly with all those values.

get values inside webscript bean from request object.
String type=req.getparameter("type");
Similarly you have all the values passed from the URL the you can generate query with those values.
as follow:
TYPE:type AND @test\:date:[from_date TO todate]

then search with that query via searchparameter object.

abhashree
Champ in-the-making
Champ in-the-making
Hi Mitapatoliya,

Thanks a lot for your reply.
This is meeting my requirement.
I have some new queries like in case if I want to pass the request parameter as json object and then converting that object into hashmap.
After converting I will build the query according to keys in the map.
Please guide me .

Thanks
Abhashree

mitpatoliya
Star Collaborator
Star Collaborator
You can go either way.

1) Get Webscript where you have to pass everything as a parameter of URL itself.
2) POST Webscript incase you want to pass the object or xml file in the request.
  As you want to use the JSON object you have to go for the POST Webscript.