2. Piergiorgio Lucidi
•
•
•
•
•
•
Open Source ECM Specialist at Sourcesense
Alfresco Trainer / Engineer / Wiki Gardener / Star
Alfresco Global Moderator of the italian forum
Author / Technical Reviewer at Packt Publishing
PMC Member / Mentor at Apache Software
Foundation
Project Leader in the JBoss Community
#SummitNow
#SummitNow
3. Overview
• Introducing portals
• Introducing standard portlets
• Implementing portlets
• Alfresco Web Services API
• Spring WebScripts
• OpenCMIS
• Spring Surf
#SummitNow
#SummitNow
4. Overview
• Introducing portals
• Introducing standard portlets
• Implementing portlets
• Alfresco Web Services API
• Spring WebScripts
• OpenCMIS
• Spring Surf
#SummitNow
#SummitNow
6. What is a portal?
A portal is a web application focused on
• Creating dynamic website
• Page-centric approach
• Aggregation of contents
• Enterprise Services
#SummitNow
#SummitNow
7. What is a portal?
A portal is a web application focused on
• Creating dynamic website
• user oriented and extremely dynamic fragments
• Page-centric approach
• Aggregation of contents
• Enterprise Services
#SummitNow
#SummitNow
8. What is a portal?
A portal is a web application focused on
• Creating dynamic website
• Page-centric approach
• Each page hosts presentation layer apps
• Portlets
• Apps (wrapping using bridge framework)
• Gadgets (based on XML and JavaScript)
• Aggregation of contents
• Enterprise Services
#SummitNow
#SummitNow
9. What is a portal?
A portal is a web application focused on
• Creating dynamic website
• Page-centric approach
• Aggregation of contents
• Enterprise Services
#SummitNow
#SummitNow
10. What is a portal?
A portal is a web application focused on
• Creating dynamic website
• Page-centric approach
• Aggregation of contents
• Enterprise Services
•
•
•
•
•
Authentication
Authorization
Personalization
Export / Import
APIs for integrations
#SummitNow
#SummitNow
12. What is a portal?
A portlet is an application that contains specific
business logic
• Provides a fragment of content
• The output depends on user permissions
• Potentially the fragment could be dynamic for each user
• A permission can be given for
• The entire portal
• Page
• Portlet
#SummitNow
#SummitNow
13. What is a portal?
An app is a wrapper of a portlet and it can be
implemented using
•
•
•
•
•
•
•
Pure Java
JSF
Spring MVC
Spring WebScripts
GWT
Struts
So on…
#SummitNow
#SummitNow
14. What is a portal? – User roles
#SummitNow
#SummitNow
15. What is a portlet container?
A portlet container is a runtime framework
• Manages the execution of portlet requests
• Provides user session mechanism
• Check permissions for different scope levels
• Portal
• Page
• Portlet
• Implements JSR-286 Java Portlet Specification 2.0
• Can be embedded in any JEE application
• Portlet requests can be executed against non-web contexts
• The web context is a detail!
#SummitNow
#SummitNow
16. What is a portlet container?
Portal A
Portal B
Portal C
• Portlet 1
• Portlet 2
• Portlet 3
• Portlet 4
• Portlet 5
• Portlet 6
#SummitNow
#SummitNow
17. Why use a portal?
You may want a portal for
• Creating custom and dynamic websites
• Providing personalized contents
• Providing features for personalizing sections
• Integrating different systems with a unique frontend
• Providing valuable services for your customers/users
• Private access
• Profiled informations
• E-commerce
• Advanced editing
• Enterprise Content Management (ECM)
#SummitNow
#SummitNow
18. Why use a portal with Alfresco
Portal aggregates corporate apps and contents
Agile development
Decoupling responsabilities
Fragments can be managed by Alfresco
• Records Management
• Content and Document Management
• Web Publishing
• BPM
The portal is responsible for presentation
• Portlets will present contents managed by Alfresco
Portlets are based on Enterprise Java
standards!!!
#SummitNow
#SummitNow
20. How a portal works
The portlet container (PC) retrieves the portlet deployment
descriptor (PDD) from all the applications deployed in the
Java container (JSE or JEE)
• web-app.war
• WEB-INF
• portlet.xml
• web.xml
• Deployment Descriptors (DD) are used in many
Enterprise Java components
#SummitNow
#SummitNow
21. Overview
• Introducing portals
• Developing standard portlets
• Implementing portlets
• Alfresco Web Services API
• Spring WebScripts
• OpenCMIS
• Spring Surf
#SummitNow
#SummitNow
23. Developing standard portlets
You can use the GenericPortlet abstract
class for overriding the following methods:
•
•
•
•
•
•
•
processAction
doView
doEdit
doHelp
doHeaders
init
destroy
#SummitNow
#SummitNow
29. Web Services API - Search
The only query language supported is Lucene
Notice that use have to use the RepositoryService to search contents:
there is no SearchService -> Query method
#SummitNow
#SummitNow
32. Overview
• Introducing portals
• Developing standard portlets
• Implementing portlets
• Alfresco Web Services API
• Spring WebScripts
• OpenCMIS
• Spring Surf
#SummitNow
#SummitNow
33. Portlets with Spring WebScripts
A quick tour about how to implement portlets
exposing your WebScripts in the portlet
descriptor of Alfresco
#SummitNow
#SummitNow
34. Spring WebScripts
Alfresco Web Scripts use
a lightweight Model View
Controller (MVC) style
framework.
#SummitNow
#SummitNow
35. Components of a WebScript
There are 3 main components of a web script:
• Descriptor
• Controller (optional if exists an FTL template)
• JavaScript server side (Mozilla Rhino)
• Subgroup of the Java API
• You can extend it!!!
• Template
• FTL (optional if request and response are managed
by Java)
• Java Action (AbstractWebScript)
#SummitNow
#SummitNow
36. WebScript Descriptor
The descriptor file uses the following naming convention
which provides additional information to Alfresco:
helloworld.get.desc.xml
The content of the descriptor file:
#SummitNow
#SummitNow
37. WebScript Controller
The controller script is an optional component
written in JavaScript or Java, which does the
actual work.
#SummitNow
#SummitNow
38. WebScript Template
The WebScript template is the output template for
displaying the content to user agents or
applications.
The output format can be based on many formats:
• HTML
• ATOM
• XML
• RSS
#SummitNow
#SummitNow
39. WebScriptPortlet
Wrapper for exposing a WebScript as a portlet, you need to
set these two parameters:
• scriptUrl
• The URL exposed by the involved WebScript
• Authenticator factory
• jsr168.webclient
• Based on cookie
• Jsr168
• Based on the portal session
#SummitNow
#SummitNow
41. WebScriptPortlet – Search
The search object is exposed for executing queries:
For XPath expression use ISO9075 to encode paths
var luceneQuery =
“PATH:”/app:company_home/cm:”+search.ISO9075(“Books
tore orders”)+”/*””;
var ordersResults =
search.luceneSearch(luceneQuery);
model.results = ordersResults;
#SummitNow
#SummitNow
42. WebScriptPortlet – Get details
var id = args.id;
if(id!=null && id!=“”){
var node = utils.getNodeFromString(id);
model.node = node;
} else {
status.code = 400;
status.message = “id must be not null";
status.redirect = true;
}
#SummitNow
#SummitNow
44. Overview
• Introducing portals
• Developing standard portlets
• Implementing portlets
• Alfresco Web Services API
• Spring WebScripts
• OpenCMIS
• Spring Surf
#SummitNow
#SummitNow
45. Portlets with OpenCMIS
A quick tour about how to implement portlets
using OpenCMIS
#SummitNow
#SummitNow
46. CMIS – Domain Model
Data Model
Repository
Object
CMIS Query
Associated services
Common elements
Repository services
Navigation services
Object Services
Multi-filing services
Discovery, versioning, relationship, policy and ACL services
#SummitNow
#SummitNow
47. OpenCMIS – Repository
• Contains set of data entities
• getRepositories() for given endpoint
• get repository capabilities
#SummitNow
#SummitNow
48. OpenCMIS – Object
• Used to model typed
objects
• Four base types:
• Document Object
• Folder Object
• Relationship object
• Policy object
• Object ID
• Object properties
• Version, ACL
• Content Stream
• Renditions
#SummitNow
#SummitNow
49. OpenCMIS – Services
Repository services: used to discover information about the
repository
Navigation services: used to traverse the CMIS repository folder
hierarchy
Objects services: used to manipulate the repository contents with a
CRUD interface
Discovery services: used to search for query-able objects within
repository
#SummitNow
#SummitNow
50. OpenCMIS Client API
• Client-side Java library that implements the
CMIS specification
• object-oriented way
• AtomPub or SOAP protocols
• Binding selected with getRepositories()
method on SessionFactory object
#SummitNow
#SummitNow
59. ProxyPortlet
• Allows to expose as a portlet any bits of Share
• scriptUrl
• Page
• Component / WebScript
• Each WebScript inside Share is a Presentation
WebScript that needs to invoke against the
repo:
• a Data WebScript
• CMIS AtomPub binding
#SummitNow
#SummitNow
60. ProxyPortlet – How it works
1.
2.
3.
4.
5.
6.
7.
8.
9.
The portal starts to render the portlet page
Share starts to render the Surf page (only 1 component)
Share starts to render the component
Share invokes Alfresco using REST calls
Share connector get the user session from
request.getRemoteUser() and set the user as authenticated in
Alfresco (external authentication)
Alfresco executes the WebScripts
The returned JSON will be parsed by Share to render the FTL
template for the portlet
Share ends to render the Surf page
The portal finishes to render the portlet
#SummitNow
#SummitNow