cancel
Showing results for 
Search instead for 
Did you mean: 

RESTful SPECIFICATIONS, Webservices

gfiacchi
Champ in-the-making
Champ in-the-making
Hi all i'm totally new to Alfresco, or better i've read thousands of articles, but still i've problems in doing what i need.

My situation is: i'm trying to use Alfresco as a CMS to store my contents and posts that i will use in my application.

I'm developing a Flex application and the main features i need are:
- Retrieve the posts and related comments contents.
- Beeing able to insert custom content (both posts and comments)
- Search through all the "blog" contents

Since now i've tried both RESTful and WebService API.

I've tried the first way using the FLEX-SDK provided by the Alfresco project with some changes, but what i'm actually able to do is just make GET calls. I think i can get both posts.
private function searchPosts():void{
            // Create the web script object
            var url:String = "http://localhost:28080/alfresco/service/api/blog/site/first-site/blog/posts";
            var webScript:WebScriptService = new WebScriptService(url, WebScriptService.GET, onSearchSuccess, onLoginFailure, true);
            webScript.ticket = this._ticket;
            webScript.resultFormat = "text";
            // Execute the web script
            webScript.execute();
         }
Then i tried to make POST calls but there a couldn't figure out which parameters i have to pass: for example if i want to make a new post this is the code i'm using:
var url:String = "http://localhost:28080/alfresco/service/api/blog/site/first-site/blog/posts";
            var webScript:WebScriptService = new WebScriptService(url, WebScriptService.POST, onSearchSuccess, onLoginFailure, true);

but obviously to execute the call i need to pass the parameters, i think at least title, content, description, name…
But i couldn't find a sort of code reference where this parameters are defined.
Could you tell me if is there something like this?
I also downloaded the FlexSpaces project but it actually uses custom webscripts.

Then i tried with the WebServices API using Java. I figured out how to search for my contents and actually i could retrieve the posts and using the PARENT seach also the comments. But the resultsets that the call returned do not include the real content of the posts and blogs. They provide a sort of link to the content (also a simple html/plain):
row 0: {http://www.alfresco.org/model/content/1.0}content = contentUrl=store://2012/2/6/10/28/6e54d336-f1b8-4d3e-bb02-bf80d161a234.bin|mimetype=text/html|size=23|encoding=UTF-8|locale=it_

Is there a way to get the bytes of the content?

Thanks in advance.
I will appreciate every kind of suggetion!!!
6 REPLIES 6

pmonks
Star Contributor
Star Contributor
Have you considered using CMIS, perhaps with a pre-built CMIS client for Flex (such as [1])?

Cheers,
Peter

[1] http://code.google.com/p/flex-cmis-client/

gfiacchi
Champ in-the-making
Champ in-the-making
Thank you Peter for your reply, i've to investigate better what CMIS is about. I've read something about, but i'm not sure on how to use it.

Thanks,
Giacomo

stevereiner
Champ in-the-making
Champ in-the-making
You can use FlexSpaces code which is now has an app and library piece
( some library apis will change on switch from cairngorm to fully using Spring ActionScript / DI )
http://code.google.com/p/flexspaces/

For CMIS and Flex
You can use CMIS Spaces code which now split into app and library parts (soap and atompub rest)
http://code.google.com/p/cmisspaces/

If you want some Flex UI code for blog post updating, etc. you could use some stuff from FlexibleShare
(uses the Share backend apis / data model for blogs, discussions, wikis)
http://code.google.com/p/flexibleshare/

The "flex-cmis-client"
Doesn't have full functionality, is atompub only,  is AIR only (not Flex/Flash in a browser), and isn't being maintained.
Does have nice aspect of using service names and model names that mirror cmis terms. And there is only a small amount of code and its easy to understand.

gfiacchi
Champ in-the-making
Champ in-the-making
Thank you Steve, too.
I've been investigating on FlexSpaces to see if i could use something and actually i did.

What i also need to know is if the alfresco bundled webscript can be used instead of defining new ones.
I mean, to manage the inset of a new post i found the webscript /api/blog/site/{site}/{container}/posts and due to the errors i get when trying to call this one i understood that the problem is that in the java class BlogPostsPost.java:95 the json object is null, and so it returns a nullpointerexception.


{
    "status" :
  {
    "code" : 500,
    "name" : "Internal Error",
    "description" : "An error inside the HTTP server which prevented it from fulfilling the request."
  }, 
 
  "message" : "03110002 Wrapped Exception (with status template): null", 
  "exception" : "org.springframework.extensions.webscripts.WebScriptException - 03110002 Wrapped Exception (with status template): null",
 
  "callstack" :
  [
       ""      ,"java.lang.NullPointerException"
      ,"org.alfresco.repo.web.scripts.blogs.posts.BlogPostsPost.parsePostParams(BlogPostsPost.java:95)"
      ,"org.alfresco.repo.web.scripts.blogs.posts.BlogPostsPost.executeImpl(BlogPostsPost.java:72)"
      ,"org.alfresco.repo.web.scripts.blogs.AbstractBlogWebScript.executeImpl(AbstractBlogWebScript.java:294)"
      ,"org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:64)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:400)"
      ,"org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:388)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:462)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:500)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:316)"
      ,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:372)"
      ,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)"
      ,"org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)"
      ,"javax.servlet.http.HttpServlet.service(HttpServlet.java:717)"
      ,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)"
      ,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)"
      ,"org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:58)"
      ,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)"
      ,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)"
      ,"org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)"
      ,"org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)"
      ,"org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)"
      ,"org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)"
      ,"org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)"
      ,"org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)"
      ,"org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)"
      ,"org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)"
      ,"org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)"
      ,"org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)"
      ,"java.lang.Thread.run(Thread.java:662)"
      ,"org.springframework.extensions.webscripts.WebScriptException: 03110002 Wrapped Exception (with status template): null"
      ,"org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:971)"

  ],
 
  "server" : "Community v4.0.0 (3979) schema 5.025",
  "time" : "11-apr-2012 11.20.37"
}

The fact is that i use the same utility class to make the call. So i do not understand where is the problem.

Thanks again

stevereiner
Champ in-the-making
Champ in-the-making
FlexibleShare has simple code that uses the blog rest api you are calling
http://code.google.com/p/flexibleshare/source/browse/trunk/FlexibleShare/src/org/integratedsemantics...
This just uses regular Flex HTTPService

It also uses as3corelib json util (in newer flex 4.5/4.6? JSON class will conflict with json apis added flash 11 and you can change to use them instead like in
http://code.google.com/p/flexspaces/source/browse/trunk/flexspaces-lib/src/org/integratedsemantics/f...

Using the alfresco WebScriptService instead just HTTPService
I ran into problems using WebScriptService and modified it in
http://code.google.com/p/flexspaces/source/browse/trunk/flexspaces-lib/src/org/integratedsemantics/f...

gfiacchi
Champ in-the-making
Champ in-the-making
Hi Steve!!!!

FlexibleShare WAS EXACTLY WHAT I WAS LOOKING FOR!!!

Thanks to all!

But now i'm facing a new problem, but i think i will open a new thread –> Deploying Alfresco on JBOSS 6.