I have investiagted Alfresco media-viewers project and also read a lot of documentation on WebScripts.
My idea is to create a Java-backed viewer for the Alfresco Share.
The underlying Java code will be a bit complicated - it has to handle additional URLs to load own resources form the bundle to use them.
The ideal solution is to integrate Java code as Spring Controller and handle URL mapping with #RequestMapping annotation (or through servlet-mapping xml node).
If someone know how Programming with Surf can be used in this case it also would be very helpful.
Have you considered using CMIS to access the Alfresco resource? If your Java runtime will run in a separate process than the Alfresco installation (or on a separate machine) then the CMIS interface would let you do that.
You would write your Spring controller inside a Java web application and then access the documents and metadata using CMIS.
Take a look at Apache Chemistry. which is the CMIS client reference implementation.
Related
Can you provide any sample code available to access out-of-box web scripts( provided by Alfresco) from web application
(login to alfresco, create folders, upload documents)
Web-Scripts is new for me. I am used to code using plain java API (Example Filenet API). Does Alfresco provide JAR files containing JAVA API which I can use for all repository operations like login,create folder,upload/download documents etc……..
My requirement is to create folders(spaces) in Alfresco through custom web application and upload documents to those spaces.
You can access out-of-the-box web scripts using the following URL (use your own host and port).
http://localhost:8080/alfresco/s/index
You can refer docs.alfresco.com for more Java, JavaScript APIs and all about Alfresco development.
Thanks
Can you provide any sample code available to access out-of-box web scripts( provided by Alfresco) from web application
As #Kintu said you can access the list of the Alfresco's out of the box webscripts using this URL:
/alfresco/service/index/all
And to make you own web script This tutorial is a good way to get started.
From your web application you can consume them like any other plain old REST API.
Does Alfresco provide JAR files containing JAVA API
Alfresco provides a rich set of services that you can use in your web scripts.
My requirement is to create folders(spaces) in Alfresco through custom web application and upload documents to those spaces
- To create a folder you can use this endpoint:
POST /alfresco/service/api/site/folder/{site}/{container}/{path}
The minimum request body is of the form:
{ "name": "NewNodeName" }
The full set of parameters accepted in the request is of the form:
{
"name": "NewNodeName",
"title": "New Node Title",
"description": "A shiny new node",
"type": "cm:folder"
}
- To upload files you can use this endpoint (HTML form data):
POST /alfresco/service/api/upload
Check the docs for more informations about this endpoint.
I suggest starting with API Explorer, later on you can always use something not documented as nicely as this is.
https://api-explorer.alfresco.com/api-explorer/
As someone who is already familiar with Filenet maybe you are already familiar with CMIS? That is probably the easiest way to create folders and documents in Alfresco. There are a number of CMIS clients available at Apache Chemistry, including OpenCMIS, which is a Java client.
You can find a bunch of code samples at the Apache Chemistry web site as well.
One advantage of using CMIS to do this is that CMIS works on a variety of repositories, not just Alfresco. Why go to the trouble of learning an Alfresco-specific REST API when there is already an industry standard? Learn it once and use it often.
i am working in a IT Company and i need to learn Alfresco. Using Apache CMIS i am able to all operations like Creating Folder, Creating Document, Creating Link of Folder and Document and blah blah.
Now I need to do all the operation using alfresco own web service.
I did google a lot but not able to get a single link over that.
Can any body suggest link or contents from where i can do all the operations using Alfresco own webservice. Document is good but i have less time and i cannot go through the whole document.
It will be helpful if i can get an example build on maven(java)
If you are asking how to use Alfresco via a SOAP-based web service, that no longer exists.
If you are asking how to use Alfresco's native REST API, then you could start by looking at https://api-explorer.alfresco.com/api-explorer/.
If you need to write your own RESTful endpoints in Alfresco that you will then call remotely, you can read my tutorial on Web Scripts: http://ecmarchitect.com/alfresco-developer-series-tutorials/webscripts/tutorial/tutorial.html.
I have an existing Java Web application which uses alfresco as its content repository.
Now I want my application to have a content repository interface to interact not only with alfresco but also with any JCR compliant repositories(Even to a local file system). According to my application architecture we can Inject JCR Implementation of any content repositories. I googled a lot and couldnt find any useful step by step walk guide to implement JCR Interface and Injecting an implementation. Please provide some links or something with which i can establish this easily. Atleast I want to use JCR alfresco Implementation.
Take a look at CMIS + Apache Chemistry and do the switch!
Well with JCR 2.0 the RepositoryFactory should be able to provide you with the repository you want. After that it is just how to pass the configuration in your code to create and access the repository.
You can look into Silverpeas code or Crash's code to see that.
If you have ever worked on alfresco, you must know the web script layer in it, my question is how does alfresco implement this ? What framework does it use?
If you don't know alfresco, then my question is : how can I implement a script layer to expose my service layer as a JavaScript style object?
With the layer, I can write the following code :
Var test = person.createPerson(556687);
Test......
Thanks in advance!
The webscript layer used in the Alfresco server was developed by Alfresco itself and is now part of Spring. The current version can be found in the Spring Surf project as Spring Surf Webscripts.
To expose your own Java class as Javascript object you have to extend the BaseProcessorExtension class and register it with the following spring bean configuration:
<bean id="yourJavascriptBean" parent="baseJavaScriptExtension" class="com.example.MyJavaService">
<property name="extensionName" value="customobject" />
</bean>
This will register your service as the object customobject. An example for registering the Alfresco serviceRegistry can be found in Alfresco wiki. You might also want to check out the source code for existing Alfresco services like the Javascript People API.
Keep in mind that this registers the object globally in the javascript engine which might alter the behavior of the existing javascript code.
Alfresco uses Mozzila Rhino that provides the Java Script engine that exposes Java Objects through Java Script.
You can use Direct Web Remoting (DWR). From their site:
DWR is a Java library that enables
Java on the server and JavaScript in a
browser to interact and call each
other as simply as possible.
I have a POJO which is being deployed as a webservice in Axis2 - Tomcat combo. What is the best way to supply runtime configurations to the service? All servcie related config parameters are in XML file -
What's the best location to keep this config file? Note I want the service to be completely self contained.
How do I get the physical location of the service home i.e. Tomcat 6.0\webapps\axis2\WEB-INF\services\MyService?
How good is Axis2 i.e. is it a good choice to select Axis2 as webservice platform? The project is with aggressive timelines (what's new? :)) so really do not wish to dive into the Contract First etc stuff. Need a quick solution where I can drop in POJO and use it as webservice.
As always, Your help is very much appreciated!
I used JNDI to control the runtime configuration options for simple web services. How to configure JNDI depends on the container you are using, Jetty/Tomcat etc.
More complicated projects I embed spring and manage both configuration and other persistent objects.
Axis2 is a good platform for developing stand-alone web services. I'd still recommend having a look at contract first stuff. It is of course more complicated but gives more control over the XML messages exchanged between client and server. The neat thing about Axis2 is that you can start with POJOs and get more complicated later.
Note I want the service to be completely self contained.
Do u mean u would like to move this modules on other container ... which do not support TOMCAT based dir structure...... bit difficult
If Axis hosting concern is of TOMCAT alone then the best way to use the configurations is via an Property /XML file stored at the root of the Java package and haven a Startup servlet with load on startup 1 to read the property file using
context.getRealPath("") + "/WEB-INF/classes/abcd.xml" or
context.getRealPath("") + "/WEB-INF/classes/abcd.propertyfile
Store the same in a key /value based Hashtable ...further store the Hash table in Servletcontext.
On any where required fetch the Valu by passing the Key to the Hash table and use the same.
However the startup servlet should run Once only only by using Load on startup tag in web-xml ...
hope this helps