03-26-2014 04:58 PM
../node/
APIs vs ../path/
apis?paradigm shift
having skipped a generation of CMS.03-27-2014 05:18 AM
03-27-2014 11:14 AM
03-27-2014 08:38 PM
GET /alfresco/service/api/node/content{property}/{store_type}/{store_id}/{id}?a={attach?}&streamId={streamId?}
GET /alfresco/service/api/path/content{property}/{store_type}/{store_id}/{nodepath}?a={attach?}&streamId={streamId?}
GET /alfresco/service/api/node/content{property}/{store_type}/{store_id}/{id}?a={attach?}
GET /alfresco/service/api/path/content{property}/{store_type}/{store_id}/{id}?a={attach?}
/alfresco/service/api/node
you should provider {id} paramter.if the front part of url is /alfresco/service/api/path
you should provide the {nodepath} parameter.
public String login() {
String ticket = null;
HttpClient client = new HttpClient();
String apiurl = "http://localhost:8080/alfresco/service/api/login";
PostMethod post = new PostMethod(apiurl);
try {
JSONObject login = new JSONObject();
login.put("username", "admin");
login.put("password", "admin");
//System.out.println(login.toString());
post.setDoAuthentication(true);
post.setRequestHeader("Content-Type", "application/json");
post.setRequestEntity(new StringRequestEntity(login.toString(),
"application/json", "UTF-8"));
int status = client.executeMethod(post);
if (status != HttpStatus.SC_OK) {
System.err.println("Method failed: " + post.getStatusLine());
}
String responseData = post.getResponseBodyAsString();
System.out.println(responseData);
JSONObject response = new JSONObject(responseData);
ticket = response.getJSONObject("data").getString("ticket");
} catch (Exception e) {
e.printStackTrace();
} finally {
post.releaseConnection();
}
return ticket;
}
public void getContent(String ticket){
HttpClient client = new HttpClient();
String uid = "e7d585dd-16f1-4b31-9cd5-a9f8e2869a17";
String apiurl = "http://localhost:8080/alfresco/service/api/node/content;cm:content/workspace/SpacesStore/"
+ uid + "?alf_ticket="+ticket;
GetMethod get = new GetMethod(apiurl);
try {
get.setDoAuthentication(true);
get.setRequestHeader("Content-Type", "application/json");
int status = client.executeMethod(get);
if (status != HttpStatus.SC_OK) {
System.err.println("Method failed: " + get.getStatusLine());
}
String resultString = get.getResponseBodyAsString();
System.out.println(resultString);
} catch (Exception e) {
e.printStackTrace();
} finally {
get.releaseConnection();
}
}
public static void main(String[] args) {
LoginAddGetContentTest t = new LoginAddGetContentTest();
String ticket = t.login();
System.out.println(ticket);
t.getContent(ticket);
}
03-28-2014 11:35 AM
03-28-2014 09:56 AM
03-28-2014 10:17 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.