Sharepoint API for Java - java

Steps that I am trying to perform the following steps through Java:
1) Connect to a sharepoint site with a given URL.
2) Get the list of files listed on that page
3) Filter the files using Modified date
4) Perform some more checks using Create Date and Modified Date
5) And finally save that file(s) into the Unix box.
As of now, I am able to access a particular file and read through it.
However I need to get hold of file's metadata before reading it.
Is there an API or a way to do all these in Java.
Thanks

With SharePoint 2013, the REST services will make your life easier. In previous versions, you could use the good old SOAP web services.
For instance, you could connect to a list with this query on the REST API:
http://server/site/_api/lists/getbytitle('listname')/items
This will give you all items from that list. With OData you can do additional stuff like filtering:
$filter=StartDate ge datetime'2015-05-21T00%3a00%3a00'
Additionally, you can provide CAML queries to these services, allowing you to define detailed queries. Here's an example in Javascript:
var re = new SP.RequestExecutor(webUrl);
re.executeAsync({
url: "http://server/site/_api/web/lists/getbytitle('listname')/GetItems",
method: 'POST',
headers: {
"Accept": "application/json; odata=verbose",
"Content-Type": "application/json; odata=verbose"
},
body: {
"query" : {
"__metadata": {
"type": "SP.CamlQuery"
},
"ViewXml": "<View>" +
"<Query>" + query + "</Query>" +
"</View>"
}
},
success: successHandler,
error: errorHandler
});
If all of this doesn't provide enough flexibility, you might as well take these list items in memory and do additional work in your (server side) code.

I have developed a Sharepoint Rest API java wrapper that allows you to use most common operations of the rest API.
https://github.com/kikovalle/PLGSharepointRestAPI-java

Related

Load testing on jmeter to compare request and response

I am trying to test my Springboot App using jMeter. I want to send multiple request with some JSON payload to receive the response concurrently (via threading).
While doing this, in order to check validity of response, I want to keep a log where it can show the request-response pair (side-by-side or even in separate files, they should just be identifiable which request gave which response).
This is to test if one request is not tampering other request's response (data validation).
I have already tried Simple Writer tool where we can log request and response (I think jmeter have used some different terminology in menu) on configure menu. But it doesn't seem to be working when I run the results.
So my main concern is how can we store the JSON request data and response data pair somewhere after test iteration have completed. I have never used jmeter before so a little bit of detailing will help.
Thanks!
You can use Flexible File Writer which gives you the full freedom with regards to what and where to store.
For example if you configure the Flexible File Writer as:
I'll provide textual form of the sample template:
---------REQUEST----------------------\r\n|requestData|\r\n---------RESPONSE--------------------\r\n|responseData|\r\n-------------------------------------
You will get results file looking like:
---------REQUEST----------------------
POST https://jsonplaceholder.typicode.com/posts
POST data:
{
"title": "foo",
"body": "bar",
"userId": 1
}
[no cookies]
---------RESPONSE--------------------
{
"id": 101
}
-------------------------------------
You can install Flexible File Writer plugin using JMeter Plugins Manager
Check out the JMeter docs on configuring the Results Tree. It will show you the results and you can configure how much to keep and where.
https://jmeter.apache.org/usermanual/component_reference.html#View_Results_Tree
In particular you might benefit from this:
https://jmeter.apache.org/usermanual/component_reference.html#Save_Responses_to_a_file

Changing PHP developed backend to Java spring boot

I am not sure if this question gonna be considered as duplicated or not, but I wasn't able to find my answer even by googling or through out the QA suggested topics on the SOF. So here I go asking my question:
I have developed a website with Javascript, PHP , AJAX that's using JSON to talk to eachother. And now the client is asking me to change all PHP backend to Spring Boot. That means I gonna talk to the HTML and Javascript and MySql using Java EE Spring Boot and I am not sure how I gonna do it. My main problems are:
1- Is it possible to parse data from Java to the jQuery using JSON ? I mean I retrive data from the MySql and then send it back to the .php file.
The PHP example would be:
$myJSON = json_encode($myObj);
echo $myJSON;
2- Is it possible to get the parsed the respons from the JAVA through the jQuery :
jQuery.ajax({
type:"post",
dataType:"json",
url: myAjax.ajaxurl,
data: {action: 'submit_data', info: info},
success: function(getParsedVAL) {
// the variable getParsedVAL is comming from the JAVA file
successmessage = 'Data was succesfully captured';
$("label#successmessage").text(successmessage);
},
error: function(getParsedVAL) {
// the variable getParsedVAL is comming from the JAVA file
successmessage = 'Error';
$("label#successmessage").text(successmessage);
},
});
success: function(getParsedVAL) {
// the variable getParsedVAL is comming from the JAVA file
successmessage = 'Data was succesfully captured';
}
I’m actually transitioning to spring boot from php. Spring boot actually encodes the java object to json automatically. If you developed the back end with some lightweight framework with routing and model controller structure you can easily convert it to spring boost

Cordova passbook from restful response

I am building a cordova application using the cordova-plugin-passbook plugin, which can be seen here: https://github.com/passslot/cordova-plugin-passbook.
I am trying to consume a pkpass from our java server that is returning the file as expected if we directly hit our service from a browser, but the problem is that we need to use an auth token and go through our oAuth server first. So I must request the pass via ajax in my front end using Angular.
The data I get back is an octet-stream and somehow I need to parse it and get it to work with the plugin above. The plugin is configured to look for a url ending in ".pkpass", I am wondering if it can be configured to look for the parsed data instead of a url.
Can anyone see in the src of the plugin if there is a possible way to do that? I am not very familiar with objective c, but just trying to think of options.
Thanks
Using cordova fileTransfer plugin, I got this working:
fileTransfer.download(
uri,
fileURL,
function(entry) {
Passbook.downloadPass(fileURL);
},
function(error) {
alert('Error retrieving pass, please try again in a little while.');
},
true,
{
headers: {
"Authorization": "Bearer " + LS.get( 'user_token' )
}
}
);

Make Call to Back-end, Multiple Path Variables, Ext Js

I've got a RESTful call that I'd like to make to the back end of my application. The front end is written in Ext JS (JavaScript) the back-end in JAVA utilizing Hibernate. The application utilizes the MVC design pattern.
On the back end, I've got a GET request endpoint with a "mapping" akin to: thing/{thingOne}/otherThing/{thingTwo}.
Ext JS provides a number of functions on their stores for hitting a back end through a model's proxy: .load(), .save(), .remove(). Each of these is able to take multiple arguments for their [options] parameter; however, I am attempting to find documentation that shows me how to make a multi-parametered request to a back-end GET endpoint and have found none, so far.
My assumption is that the call would be structured like: .load("param1", "param2") based upon the documentation for .save() and .remove(). Here's the doc. for save, for remove, and load.
So, how do I make a GET call to the back end with multiple parameters? Am I even in the correct ballpark?
You can use "extraparams" on proxy.
sencha api 4.2.2 - extraparams on store
var formOperation = [];
var example = {"city":"Manchester"};
Ext.Object.merge(formOperacion,example);
store.getProxy().extraParams = formOperation;
store.load();
Another solution:
Sencha api - store - Dynamic Loading
store.load({
params: {
group: 3,
type: 'user'
},
callback: function(records, operation, success) {
// do something after the load finishes
},
scope: this
});
Build the request's URL as a concatenated string, including the arguments:
var requestUrl = 'thingOne/' + thingOneVar + '/otherThing/' + otherThingVar;
Note that whether your "built" string should be prefixed with a / depends upon how your model's proxy is configured. Essentially, you are aiming for a legitimate request url.
And make a request via the proxy (here, I'm using AJAX):
Ext.Ajax.request({
url : requestUrl,
// ....
});
The then needs to be handled by a callback or as a promise.

Json based webservice in java and client in javascript

I am new in web service development. Currently I am developing an application (in html5 using javascript and jquery) in which I wanted to send data to web service in Json format.
My question are: 1) How to send(post) data to web service using javascript ? 2) How to retrieve json data at server side ? 3) How to get data from the web service in json format ? 4) How to retrieve json data at client side ?
Cast you json to string than send to server. In the server side cast it json again.
JSON is just a way to encapsulate data.
You should have parses on both sides that parse the json into data you can work with. On your Java serve you can use e.g. https://code.google.com/p/json-simple/
Easiest would be to use jquery ajax() function.
$.ajax({
type: 'post',
dataType: 'json',
data: { "var1": value1, "var2": value2 },
url: 'www.example.com' })
.success( function() {
console.log( 'success' );
});
This depends on what backend do you use on server, I can reccomend node.js with express.
The same as p1, the only difference that you will have to parse data you have received in success() function.
I am not sure if I understand correctly what you mean.

Categories

Resources