SlideShare una empresa de Scribd logo
1 de 34
Descargar para leer sin conexión
Spring Surf & Web Scripts!
Dave Draper – UI Engineer - @_DaveDraper!
History lesson...
2007
  • Alfresco 2.0 introduces first REST API (early WebScripts concepts)!
  • Alfresco 2.1 introduces WebScripts!
     • REST framework, JSR-311 (Jax-RS) URI Index!
     • Scriptable controllers (or backed by Spring Java Beans)!
     • FreeMarker template output (or Java output stream)!
2008
  • Alfresco Web Framework demo-ware (model objects, JSP, FTL)!
  • Alfresco Page Render (WebScripts as components on a page)!
  • Combined, productised and renamed to Surf!
  • Alfresco Share 3.0, 3.1 – Alfresco collaboration and DM – modern
   XHTML and Ajax based interface!
History lesson (cont)...
Early 2009
  • Alfresco Share 3.2!
  • First contact between Alfresco and Spring Source!
Late 2009
  • Alfresco Surf and WebScripts integrated with Spring MVC!
  • Alfresco Surf and WebScripts contributed as Spring Extension –
   Spring WebScripts and Spring Surf!
  • Alfresco Share 3.3 – refactored onto Spring WebScripts and Spring
   Surf!!
2010
  • 3 Milestones and RC1 release!
  • Alfresco Share 3.4 – using SpringSurf RC1!
History lesson (cont)...
2011
 • Alfresco Team!
 • New extensibility capabilities added!
 • Version 1.0.0 releases!
 • Alfresco Share 4.0!
What Are WebScripts?
• Services bound to a URIs which respond to
 HTTP methods such as GET, POST, PUT and
 DELETE!
• Support multiple formats (HTML, JSON & XML)!
• A framework for creating a REST API!
• Made up of descriptor, controller, properties,
 configuration and presentation files!
WebScripts!
• Descriptor (XML)
• Controller (JavaScript/Java Spring Bean)
• Response Formats (FreeMarker)
• I18N properties (Text)
• Configuration (XML)
Response Formats!
•  Available formats
 • HTML!
 • Text!
 • XML!
 • ATOM!
 • RSS!
 • JSON!
•  Set default in Descriptor (if more than one available)
•  Request by:
 • Extension (e.g. /script1.html, /script1.json, etc)!
 • Format request parameter (e.g. /script1?format=xml)!
Why Use Web Scripts?
•    Rapid development (no server restarts)
•    Separation of concerns (MVC)
•    Localization
•    Extensibility
•    FreeMarker and JavaScript
But What Is Spring Surf ?
•  An extension to Spring MVC
•  A set of controllers, resolvers and views
•  A way of breaking an HTML page into re-
   usable composite parts
•  An interface to the Alfresco Repository
•  The framework that underpins Alfresco
   Share
Example Spring Surf Objects
•    Pages
•    Template Instances
•    Regions
•    Chrome
•    Components
•    Sub-Components
Sub-­‐
  Component	
  
   Component	
  
     Region	
  
 Region-­‐Chrome	
  
  Components	
  
    Chrome	
  


Template-­‐Instance	
  
      Page	
  
Mistakes were made…
•    Chrome
•    Scopes
•    No Component nesting
•    1-1 Region/Component binding
•    Spring Roo
•    Tools
•    Difficult to match output to source
…but there is lots of good stuff !
•     Themes
•     Model Object stores (file system, classpath, remote,
      etc)
•     Presets / object creation
•     URI templates
•     Remote connections
•     Authentication
•     Extensibility
•     Endlessly configurable
What can you do with it?
• Rapid web-tier view composition – Spring MVC
 View Resolver!
• FreeMarker, JSP, Groovy, PHP pages!
• WebScript, FTL, JSP, Groovy, PHP components!
• Simple JavaScript, Groovy controllers!
• Remote API – REST request/response
 processing!
• WebScripts – standalone REST API tier!
• Portlets!
What you SHOULD do with it?!

 • Customize Alfresco Share!
 • Use WebScripts and FreeMarker!
 • Use JavaScript controllers!
 • Use Endpoints to contact an Alfresco Repository
  in standalone applications!
SOME USEFUL INFORMATION!
WebScript and Surf Object lookup!
Authentication (WebScripts & Surf Pages)!

•  Use <authentication> element
•  Available types:
 • “none”!
 • “guest”!
 • “user”!
 • “admin”!
•  Authenticates against Alfresco Repository
•  Can use “runas” property with WebScripts only
URI Templates (WebScripts)!

•  Use tokens in URL
 • e.g. “/x/{token1}/y/{token2}/z”!
•  Can define multiple URLs in single descriptor
•  Use “url.templateArgs” to access
 • ${url.templateArgs.token1}!
URI Templates (Surf Pages)!

•  Define “uri-template” in <alfresco-config> (e.g. “share-config-
   custom.xml)
  • Include {pageid} token for Page mapping!
  • Or ensure Page exists (e.g. Created through Preset)!
•  Use page.url.templateArgs to access tokens
  • e.g. ${page.url.templateArgs.token1}!
Surf Configuration!

•  Configuration object
   • Site home page!
   • Site theme!
•  Surf.xml
   • Object type implementations (e.g. AdvancedComponent)!
   • User factories!
   • Site configuration!
   • Chrome!
   • Page type (e.g. Login)!
   • Module Deployment!
•  Spring Application Context
   • Services (configuration loading, user factories, persistence, remote access, etc)!
   • Controllers (login controllers, etc)!
   • Interceptors!
Custom Home Page!

•  From:
   http://blogs.alfresco.com/wp/ddraper/2011/11/01/advanced-
   share-customization-part-1/
•  Optionally override <site-configuration> in “surf.xml”
  • Default is “slingshot.site.configuration”!
•  Set <root-page> property in Configuration object
Custom Login Page!
•  From:
   http://blogs.alfresco.com/wp/ddraper/2011/11/03/advanced-
   share-customization-part-2/
•  Create Page and Template-Instance objects for custom
   login page
•  Define new default “login” Page-Type object
Regions and Components
•         Regions define location into which Components can
          be bound
•         Binding done through region-id, source-id and
          scope
     o      Forced 1-1 bindings
     o      Flawed concept for Component switching
•         Sub-Components introduced as a workaround
•         Components SHOULD use ComponentType or
          Processor but are “optimized” to use WebScript
          URL
Remote API
• Connectors & Authenticators!
• XML configure access to “endpoints” – obtained
 by id!
• Access HTTP methods through JavaScript
 controller or Ajax via proxy controller!
• Endpoints hide the URL stem from scripts –
 authentication encapsulated by connectors and
 authenticators!
• Connect to multiple REST sources; alfresco,
 wiki, search!
Remote API – Example!
var conn = remote.connect("alfresco");
var json = conn.get("/api/products/" + args.filter);
if (json.status == 200)
{
   // Create JavaScript objects from the response
   var obj = eval('(' + json + ')');
   if (obj)
   {
      // Perform processing on the js objects
      // set results into the model for the template
      model.results = somearray;
   }
}
Model Object Stores
• Persisters – read model object definitions from
 classpath, WEB-INF, JARs!
• Alfresco legacy locations and Spring “friendly”
 locations!
  o Migration of Alfresco Surf 3.2 apps!
  o New locations require less files, folders!
• Read and write to remote location and local file
 system!
• Example - Alfresco Share stores pages and
 components for dynamic dashboards in the
 repository!
Component .head.ftl template!

•      Allow WebScripts to add JavaScript and CSS dependencies into
       HTML <head>
•      Use ${head} in Template Instance to output dependencies into
       <head>
•      Use <@script> to automatically switch between .js and –min.js



     <link rel="stylesheet" type="text/css" href="${page.url.context}/
       products/products.css" />
     <script src="${page.url.context}/products/products.js"></script>
Useful Runtime Tools
•  /service/index
 o    Browse WebScripts

 o    WebScript refresh

 o    SurfBug toggle
Roadmap!

•  Forking from Spring back into Alfresco
•  Continued development (more extensibility
   features, performance improvements)
•  Continued use in Alfresco projects
•  More blogging, forums and documentation
How do I use it?!

 • You CAN SVN checkout, maven build:
  https://src.springframework.org/svn/se-surf/trunk!
 • You SHOULD use Alfresco Community JARs
  when available!
Learn More!

•  Blog posts:
 • http://blogs.alfresco.com/wp/ewinlof/!
 • http://blogs.alfresco.com/wp/kevinr/!
 • http://blogs.alfresco.com/wp/ddraper/!
 • http://mindthegab.com/!
•  Alfresco Forum: “Surf Development”
Questions?!
PLAT-7 Spring Web Scripts and Spring Surf

Más contenido relacionado

La actualidad más candente

Web Application Frameworks (WAF)
Web Application Frameworks (WAF)Web Application Frameworks (WAF)
Web Application Frameworks (WAF)
Ako Kaman
 

La actualidad más candente (19)

RESTful Services
RESTful ServicesRESTful Services
RESTful Services
 
WCM-7 Surfing with CMIS
WCM-7 Surfing with CMISWCM-7 Surfing with CMIS
WCM-7 Surfing with CMIS
 
An Intense Overview of the React Ecosystem
An Intense Overview of the React EcosystemAn Intense Overview of the React Ecosystem
An Intense Overview of the React Ecosystem
 
Node and Azure
Node and AzureNode and Azure
Node and Azure
 
Introduction to Monsoon PHP framework
Introduction to Monsoon PHP frameworkIntroduction to Monsoon PHP framework
Introduction to Monsoon PHP framework
 
RESTful Rails2
RESTful Rails2RESTful Rails2
RESTful Rails2
 
CUST-10 Customizing the Upload File(s) dialog in Alfresco Share
CUST-10 Customizing the Upload File(s) dialog in Alfresco ShareCUST-10 Customizing the Upload File(s) dialog in Alfresco Share
CUST-10 Customizing the Upload File(s) dialog in Alfresco Share
 
An Introduction to the Laravel Framework (AFUP Forum PHP 2014)
An Introduction to the Laravel Framework (AFUP Forum PHP 2014)An Introduction to the Laravel Framework (AFUP Forum PHP 2014)
An Introduction to the Laravel Framework (AFUP Forum PHP 2014)
 
Agile sites2
Agile sites2Agile sites2
Agile sites2
 
Agile sites @ telmore
Agile sites @ telmore Agile sites @ telmore
Agile sites @ telmore
 
Building a spa_in_30min
Building a spa_in_30minBuilding a spa_in_30min
Building a spa_in_30min
 
Oracle APEX Nitro
Oracle APEX NitroOracle APEX Nitro
Oracle APEX Nitro
 
Oak, the architecture of Apache Jackrabbit 3
Oak, the architecture of Apache Jackrabbit 3Oak, the architecture of Apache Jackrabbit 3
Oak, the architecture of Apache Jackrabbit 3
 
SilverStripe From a Developer's Perspective
SilverStripe From a Developer's PerspectiveSilverStripe From a Developer's Perspective
SilverStripe From a Developer's Perspective
 
LatJUG. JSF2.0 - The JavaEE6 Standard
LatJUG. JSF2.0 - The JavaEE6 StandardLatJUG. JSF2.0 - The JavaEE6 Standard
LatJUG. JSF2.0 - The JavaEE6 Standard
 
A Day of REST
A Day of RESTA Day of REST
A Day of REST
 
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friendWebcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
 
Laravel Meetup
Laravel MeetupLaravel Meetup
Laravel Meetup
 
Web Application Frameworks (WAF)
Web Application Frameworks (WAF)Web Application Frameworks (WAF)
Web Application Frameworks (WAF)
 

Similar a PLAT-7 Spring Web Scripts and Spring Surf

Rapid API Development ArangoDB Foxx
Rapid API Development ArangoDB FoxxRapid API Development ArangoDB Foxx
Rapid API Development ArangoDB Foxx
Michael Hackstein
 
WebNetConf 2012 - Single Page Apps
WebNetConf 2012 - Single Page AppsWebNetConf 2012 - Single Page Apps
WebNetConf 2012 - Single Page Apps
Pop Apps
 
Web Technologies in Java EE 7
Web Technologies in Java EE 7Web Technologies in Java EE 7
Web Technologies in Java EE 7
Lukáš Fryč
 

Similar a PLAT-7 Spring Web Scripts and Spring Surf (20)

Developer’s intro to the alfresco platform
Developer’s intro to the alfresco platformDeveloper’s intro to the alfresco platform
Developer’s intro to the alfresco platform
 
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
 
BP-9 Share Customization Best Practices
BP-9 Share Customization Best PracticesBP-9 Share Customization Best Practices
BP-9 Share Customization Best Practices
 
BP-7 Share Customization Best Practices
BP-7 Share Customization Best PracticesBP-7 Share Customization Best Practices
BP-7 Share Customization Best Practices
 
Rapid API Development ArangoDB Foxx
Rapid API Development ArangoDB FoxxRapid API Development ArangoDB Foxx
Rapid API Development ArangoDB Foxx
 
Alfresco overview EDM
Alfresco overview EDMAlfresco overview EDM
Alfresco overview EDM
 
Spring 3 - An Introduction
Spring 3 - An IntroductionSpring 3 - An Introduction
Spring 3 - An Introduction
 
Share point development 101
Share point development 101Share point development 101
Share point development 101
 
Advanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojoAdvanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojo
 
Introduction to Flask Micro Framework
Introduction to Flask Micro FrameworkIntroduction to Flask Micro Framework
Introduction to Flask Micro Framework
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
Laravel 4 presentation
Laravel 4 presentationLaravel 4 presentation
Laravel 4 presentation
 
PLAT-16 Using Enterprise Content in Grails
PLAT-16 Using Enterprise Content in GrailsPLAT-16 Using Enterprise Content in Grails
PLAT-16 Using Enterprise Content in Grails
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 
Alfresco Coding mit dem Alfresco SDK (auf Englisch) - Julien Bruinaud, Techni...
Alfresco Coding mit dem Alfresco SDK (auf Englisch) - Julien Bruinaud, Techni...Alfresco Coding mit dem Alfresco SDK (auf Englisch) - Julien Bruinaud, Techni...
Alfresco Coding mit dem Alfresco SDK (auf Englisch) - Julien Bruinaud, Techni...
 
Integrating Alfresco with Portals
Integrating Alfresco with PortalsIntegrating Alfresco with Portals
Integrating Alfresco with Portals
 
WebNetConf 2012 - Single Page Apps
WebNetConf 2012 - Single Page AppsWebNetConf 2012 - Single Page Apps
WebNetConf 2012 - Single Page Apps
 
Web Technologies in Java EE 7
Web Technologies in Java EE 7Web Technologies in Java EE 7
Web Technologies in Java EE 7
 
CUST-2 New Client Configuration & Extension Points in Share
CUST-2 New Client Configuration & Extension Points in ShareCUST-2 New Client Configuration & Extension Points in Share
CUST-2 New Client Configuration & Extension Points in Share
 
Progressive Web Apps and React
Progressive Web Apps and ReactProgressive Web Apps and React
Progressive Web Apps and React
 

Más de Alfresco Software

Más de Alfresco Software (20)

Alfresco Day Benelux Inholland studentendossier
Alfresco Day Benelux Inholland studentendossierAlfresco Day Benelux Inholland studentendossier
Alfresco Day Benelux Inholland studentendossier
 
Alfresco Day Benelux Hogeschool Inholland Records Management application
Alfresco Day Benelux Hogeschool Inholland Records Management applicationAlfresco Day Benelux Hogeschool Inholland Records Management application
Alfresco Day Benelux Hogeschool Inholland Records Management application
 
Alfresco Day BeNelux: Customer Success Showcase - Saxion Hogescholen
Alfresco Day BeNelux: Customer Success Showcase - Saxion HogescholenAlfresco Day BeNelux: Customer Success Showcase - Saxion Hogescholen
Alfresco Day BeNelux: Customer Success Showcase - Saxion Hogescholen
 
Alfresco Day BeNelux: Customer Success Showcase - Gemeente Amsterdam
Alfresco Day BeNelux: Customer Success Showcase - Gemeente AmsterdamAlfresco Day BeNelux: Customer Success Showcase - Gemeente Amsterdam
Alfresco Day BeNelux: Customer Success Showcase - Gemeente Amsterdam
 
Alfresco Day BeNelux: The success of Alfresco
Alfresco Day BeNelux: The success of AlfrescoAlfresco Day BeNelux: The success of Alfresco
Alfresco Day BeNelux: The success of Alfresco
 
Alfresco Day BeNelux: Customer Success Showcase - Credendo Group
Alfresco Day BeNelux: Customer Success Showcase - Credendo GroupAlfresco Day BeNelux: Customer Success Showcase - Credendo Group
Alfresco Day BeNelux: Customer Success Showcase - Credendo Group
 
Alfresco Day BeNelux: Digital Transformation - It's All About Flow
Alfresco Day BeNelux: Digital Transformation - It's All About FlowAlfresco Day BeNelux: Digital Transformation - It's All About Flow
Alfresco Day BeNelux: Digital Transformation - It's All About Flow
 
Alfresco Day Vienna 2016: Activiti – ein Katalysator für die DMS-Strategie be...
Alfresco Day Vienna 2016: Activiti – ein Katalysator für die DMS-Strategie be...Alfresco Day Vienna 2016: Activiti – ein Katalysator für die DMS-Strategie be...
Alfresco Day Vienna 2016: Activiti – ein Katalysator für die DMS-Strategie be...
 
Alfresco Day Vienna 2016: Elektronische Geschäftsprozesse auf Basis von Alfre...
Alfresco Day Vienna 2016: Elektronische Geschäftsprozesse auf Basis von Alfre...Alfresco Day Vienna 2016: Elektronische Geschäftsprozesse auf Basis von Alfre...
Alfresco Day Vienna 2016: Elektronische Geschäftsprozesse auf Basis von Alfre...
 
Alfresco Day Vienna 2016: Alfrescos neue Rest API
Alfresco Day Vienna 2016: Alfrescos neue Rest APIAlfresco Day Vienna 2016: Alfrescos neue Rest API
Alfresco Day Vienna 2016: Alfrescos neue Rest API
 
Alfresco Day Vienna 2016: Support Tools für die Admin-Konsole
Alfresco Day Vienna 2016: Support Tools für die Admin-KonsoleAlfresco Day Vienna 2016: Support Tools für die Admin-Konsole
Alfresco Day Vienna 2016: Support Tools für die Admin-Konsole
 
Alfresco Day Vienna 2016: Entwickeln mit Alfresco
Alfresco Day Vienna 2016: Entwickeln mit AlfrescoAlfresco Day Vienna 2016: Entwickeln mit Alfresco
Alfresco Day Vienna 2016: Entwickeln mit Alfresco
 
Alfresco Day Vienna 2016: Activiti goes enterprise: Die Evolution der BPM Sui...
Alfresco Day Vienna 2016: Activiti goes enterprise: Die Evolution der BPM Sui...Alfresco Day Vienna 2016: Activiti goes enterprise: Die Evolution der BPM Sui...
Alfresco Day Vienna 2016: Activiti goes enterprise: Die Evolution der BPM Sui...
 
Alfresco Day Vienna 2016: Partner Lightning Talk: Westernacher
Alfresco Day Vienna 2016: Partner Lightning Talk: WesternacherAlfresco Day Vienna 2016: Partner Lightning Talk: Westernacher
Alfresco Day Vienna 2016: Partner Lightning Talk: Westernacher
 
Alfresco Day Vienna 2016: Bringing Content & Process together with the App De...
Alfresco Day Vienna 2016: Bringing Content & Process together with the App De...Alfresco Day Vienna 2016: Bringing Content & Process together with the App De...
Alfresco Day Vienna 2016: Bringing Content & Process together with the App De...
 
Alfresco Day Vienna 2016: Partner Lightning Talk - it-novum
Alfresco Day Vienna 2016: Partner Lightning Talk - it-novumAlfresco Day Vienna 2016: Partner Lightning Talk - it-novum
Alfresco Day Vienna 2016: Partner Lightning Talk - it-novum
 
Alfresco Day Vienna 2016: How to Achieve Digital Flow in the Enterprise - Joh...
Alfresco Day Vienna 2016: How to Achieve Digital Flow in the Enterprise - Joh...Alfresco Day Vienna 2016: How to Achieve Digital Flow in the Enterprise - Joh...
Alfresco Day Vienna 2016: How to Achieve Digital Flow in the Enterprise - Joh...
 
Alfresco Day Warsaw 2016 - Czy możliwe jest spełnienie wszystkich regulacji p...
Alfresco Day Warsaw 2016 - Czy możliwe jest spełnienie wszystkich regulacji p...Alfresco Day Warsaw 2016 - Czy możliwe jest spełnienie wszystkich regulacji p...
Alfresco Day Warsaw 2016 - Czy możliwe jest spełnienie wszystkich regulacji p...
 
Alfresco Day Warsaw 2016: Identyfikacja i podpiselektroniczny - Safran
Alfresco Day Warsaw 2016: Identyfikacja i podpiselektroniczny - SafranAlfresco Day Warsaw 2016: Identyfikacja i podpiselektroniczny - Safran
Alfresco Day Warsaw 2016: Identyfikacja i podpiselektroniczny - Safran
 
Alfresco Day Warsaw 2016: Advancing the Flow of Digital Business
Alfresco Day Warsaw 2016: Advancing the Flow of Digital BusinessAlfresco Day Warsaw 2016: Advancing the Flow of Digital Business
Alfresco Day Warsaw 2016: Advancing the Flow of Digital Business
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

PLAT-7 Spring Web Scripts and Spring Surf

  • 1. Spring Surf & Web Scripts! Dave Draper – UI Engineer - @_DaveDraper!
  • 2. History lesson... 2007 • Alfresco 2.0 introduces first REST API (early WebScripts concepts)! • Alfresco 2.1 introduces WebScripts! • REST framework, JSR-311 (Jax-RS) URI Index! • Scriptable controllers (or backed by Spring Java Beans)! • FreeMarker template output (or Java output stream)! 2008 • Alfresco Web Framework demo-ware (model objects, JSP, FTL)! • Alfresco Page Render (WebScripts as components on a page)! • Combined, productised and renamed to Surf! • Alfresco Share 3.0, 3.1 – Alfresco collaboration and DM – modern XHTML and Ajax based interface!
  • 3. History lesson (cont)... Early 2009 • Alfresco Share 3.2! • First contact between Alfresco and Spring Source! Late 2009 • Alfresco Surf and WebScripts integrated with Spring MVC! • Alfresco Surf and WebScripts contributed as Spring Extension – Spring WebScripts and Spring Surf! • Alfresco Share 3.3 – refactored onto Spring WebScripts and Spring Surf!! 2010 • 3 Milestones and RC1 release! • Alfresco Share 3.4 – using SpringSurf RC1!
  • 4. History lesson (cont)... 2011 • Alfresco Team! • New extensibility capabilities added! • Version 1.0.0 releases! • Alfresco Share 4.0!
  • 5. What Are WebScripts? • Services bound to a URIs which respond to HTTP methods such as GET, POST, PUT and DELETE! • Support multiple formats (HTML, JSON & XML)! • A framework for creating a REST API! • Made up of descriptor, controller, properties, configuration and presentation files!
  • 6. WebScripts! • Descriptor (XML) • Controller (JavaScript/Java Spring Bean) • Response Formats (FreeMarker) • I18N properties (Text) • Configuration (XML)
  • 7. Response Formats! •  Available formats • HTML! • Text! • XML! • ATOM! • RSS! • JSON! •  Set default in Descriptor (if more than one available) •  Request by: • Extension (e.g. /script1.html, /script1.json, etc)! • Format request parameter (e.g. /script1?format=xml)!
  • 8. Why Use Web Scripts? •  Rapid development (no server restarts) •  Separation of concerns (MVC) •  Localization •  Extensibility •  FreeMarker and JavaScript
  • 9. But What Is Spring Surf ? •  An extension to Spring MVC •  A set of controllers, resolvers and views •  A way of breaking an HTML page into re- usable composite parts •  An interface to the Alfresco Repository •  The framework that underpins Alfresco Share
  • 10. Example Spring Surf Objects •  Pages •  Template Instances •  Regions •  Chrome •  Components •  Sub-Components
  • 11. Sub-­‐ Component   Component   Region   Region-­‐Chrome   Components   Chrome   Template-­‐Instance   Page  
  • 12. Mistakes were made… •  Chrome •  Scopes •  No Component nesting •  1-1 Region/Component binding •  Spring Roo •  Tools •  Difficult to match output to source
  • 13. …but there is lots of good stuff ! •  Themes •  Model Object stores (file system, classpath, remote, etc) •  Presets / object creation •  URI templates •  Remote connections •  Authentication •  Extensibility •  Endlessly configurable
  • 14. What can you do with it? • Rapid web-tier view composition – Spring MVC View Resolver! • FreeMarker, JSP, Groovy, PHP pages! • WebScript, FTL, JSP, Groovy, PHP components! • Simple JavaScript, Groovy controllers! • Remote API – REST request/response processing! • WebScripts – standalone REST API tier! • Portlets!
  • 15. What you SHOULD do with it?! • Customize Alfresco Share! • Use WebScripts and FreeMarker! • Use JavaScript controllers! • Use Endpoints to contact an Alfresco Repository in standalone applications!
  • 17. WebScript and Surf Object lookup!
  • 18. Authentication (WebScripts & Surf Pages)! •  Use <authentication> element •  Available types: • “none”! • “guest”! • “user”! • “admin”! •  Authenticates against Alfresco Repository •  Can use “runas” property with WebScripts only
  • 19. URI Templates (WebScripts)! •  Use tokens in URL • e.g. “/x/{token1}/y/{token2}/z”! •  Can define multiple URLs in single descriptor •  Use “url.templateArgs” to access • ${url.templateArgs.token1}!
  • 20. URI Templates (Surf Pages)! •  Define “uri-template” in <alfresco-config> (e.g. “share-config- custom.xml) • Include {pageid} token for Page mapping! • Or ensure Page exists (e.g. Created through Preset)! •  Use page.url.templateArgs to access tokens • e.g. ${page.url.templateArgs.token1}!
  • 21. Surf Configuration! •  Configuration object • Site home page! • Site theme! •  Surf.xml • Object type implementations (e.g. AdvancedComponent)! • User factories! • Site configuration! • Chrome! • Page type (e.g. Login)! • Module Deployment! •  Spring Application Context • Services (configuration loading, user factories, persistence, remote access, etc)! • Controllers (login controllers, etc)! • Interceptors!
  • 22. Custom Home Page! •  From: http://blogs.alfresco.com/wp/ddraper/2011/11/01/advanced- share-customization-part-1/ •  Optionally override <site-configuration> in “surf.xml” • Default is “slingshot.site.configuration”! •  Set <root-page> property in Configuration object
  • 23. Custom Login Page! •  From: http://blogs.alfresco.com/wp/ddraper/2011/11/03/advanced- share-customization-part-2/ •  Create Page and Template-Instance objects for custom login page •  Define new default “login” Page-Type object
  • 24. Regions and Components •  Regions define location into which Components can be bound •  Binding done through region-id, source-id and scope o  Forced 1-1 bindings o  Flawed concept for Component switching •  Sub-Components introduced as a workaround •  Components SHOULD use ComponentType or Processor but are “optimized” to use WebScript URL
  • 25. Remote API • Connectors & Authenticators! • XML configure access to “endpoints” – obtained by id! • Access HTTP methods through JavaScript controller or Ajax via proxy controller! • Endpoints hide the URL stem from scripts – authentication encapsulated by connectors and authenticators! • Connect to multiple REST sources; alfresco, wiki, search!
  • 26. Remote API – Example! var conn = remote.connect("alfresco"); var json = conn.get("/api/products/" + args.filter); if (json.status == 200) { // Create JavaScript objects from the response var obj = eval('(' + json + ')'); if (obj) { // Perform processing on the js objects // set results into the model for the template model.results = somearray; } }
  • 27. Model Object Stores • Persisters – read model object definitions from classpath, WEB-INF, JARs! • Alfresco legacy locations and Spring “friendly” locations! o Migration of Alfresco Surf 3.2 apps! o New locations require less files, folders! • Read and write to remote location and local file system! • Example - Alfresco Share stores pages and components for dynamic dashboards in the repository!
  • 28. Component .head.ftl template! •  Allow WebScripts to add JavaScript and CSS dependencies into HTML <head> •  Use ${head} in Template Instance to output dependencies into <head> •  Use <@script> to automatically switch between .js and –min.js <link rel="stylesheet" type="text/css" href="${page.url.context}/ products/products.css" /> <script src="${page.url.context}/products/products.js"></script>
  • 29. Useful Runtime Tools •  /service/index o  Browse WebScripts o  WebScript refresh o  SurfBug toggle
  • 30. Roadmap! •  Forking from Spring back into Alfresco •  Continued development (more extensibility features, performance improvements) •  Continued use in Alfresco projects •  More blogging, forums and documentation
  • 31. How do I use it?! • You CAN SVN checkout, maven build: https://src.springframework.org/svn/se-surf/trunk! • You SHOULD use Alfresco Community JARs when available!
  • 32. Learn More! •  Blog posts: • http://blogs.alfresco.com/wp/ewinlof/! • http://blogs.alfresco.com/wp/kevinr/! • http://blogs.alfresco.com/wp/ddraper/! • http://mindthegab.com/! •  Alfresco Forum: “Surf Development”