Confidential, Copyright © Quanticate Alfresco Web Scripts Ashwini Swamy Java Developer ashwini.swamy@quanticate.com © Alfresco and the Alfresco logo are trademarks of Alfresco Software, Inc .
Confidential, Copyright © Quanticate Agenda • Quanticate Overview • Who Am I ? • What is a Web Scripts? • Why we need web Scripts? • Types of Web Scripts • Sample Web Script • Sample Web Script using Javascript • Sample Web Script using Java backed web script • Unit testing for Java backed web scripts
Confidential, Copyright © Quanticate Quanticate Overview • 12+ years of success journey in CRO industry • What we do  Biostatistics Services  Clinical Programming Services  Clinical Data Management  Medical Writing Services  Pharmacovigilance Services  Clinical Trial Technology  Centralized Clinical Data Sciences  QuantiCliQ - Clinical Intelligence from Quanticate • 200+ employees • Awards  5 Category Winner in 2014 CRO Leadership Awards  Innovation in the 2013 CRO Leadership Awards
Confidential, Copyright © Quanticate Quanticate Overview Quanticate Branches  Hitchin, Hertfordshire, UK (HQ)  Manchester, UK  Canterbury, UK  Edinburgh, UK  Durham, North Carolina, US (US HQ)  Warsaw, Poland  Bloemfontein, South Africa  Bangalore, India (2 Offices)
Confidential, Copyright © Quanticate Who Am I? • 3+ years experience in Java related technologies • Frequent blogger • Knowledge sharing in Alfresco Forums
Confidential, Copyright © Quanticate What is Web Scripts? • Service bound to a URI which responds to HTTP methods such as GET, POST, PUT and DELETE. • Provides RESTful API to programmatically interact with the Alfresco content residing in the content repository.
Confidential, Copyright © Quanticate Why we need Web Scripts? • Build custom URI-identified and HTTP accessible Content Management Web Services • Easily access, manage, and cross-link your content via a tailored RESTful API
Confidential, Copyright © Quanticate Web Scripts Solutions • Integrating Alfresco with third-party systems • Developing data services • Developing UI services such as portlets • Customising search • Acting as a backend to client tools such as Orbeon Forms • Integrating with Microsoft Office
Confidential, Copyright © Quanticate Types of Web Scripts • Data Web Script • Presentation Web Script
Confidential, Copyright © Quanticate Data Web Scripts • Encapsulate access and modification of content/data held in the content repository • Server interface for client applications to query, retrieve, update, and perform processes, using request and response formats such as XML and JSON.
Confidential, Copyright © Quanticate Presentation Web Scripts • Built on top of Alfresco Spring Surf framework • Allows us to build user interfaces such as a dashlet for Alfresco Share. • Hosted in the Alfresco Content Application Server or in a separate presentation server
Confidential, Copyright © Quanticate Web Script Framework
Confidential, Copyright © Quanticate Web Script Framework Components Web script comprises the following 3 components • A description document - .desc.xml – ShortName – Description – Webscript URI – Authentication – None, guest, user and admin – Transaction mode - Read-Only like – Output format – JSON or XML • An optional controller script - .js or Java class • FreeMarker response templates – Either html.ftl or json.ftl
Confidential, Copyright © Quanticate Web Script without controller • Description document file • Free marker template file to render response • No controller defined <webscript> <shortname>Hello world</shortname> <description>Sample Hello world webscript</description> <url>/com/quanticate/hello</url> <format default="json"/> <authentication>user</authentication> </webscript>
Confidential, Copyright © Quanticate Web Script without controller -Demo
Confidential, Copyright © Quanticate JavaScript backed Web Script • Description document file • FTL to render response • Controller - Server side Javascript function main(){ // Get the user name of the person to get var userName = url.extension; // Do we want to return containing groups? var groups = true; // Get the person who has that user name var person = people.getPerson(userName); if (person != null) { model.person = person; } else { status.setCode(status.STATUS_NOT_FOUND, "Person " + userName + " does not exist"); } } main();
Confidential, Copyright © Quanticate JavaScript backed Web Script -Demo
Confidential, Copyright © Quanticate Java backed Web Script • Description document file • Free marker template file to render response • Controller • Spring configuration for registering our Web script Java class (bean injection) Map<String, Object> siteInfoMap = new HashMap<String, Object>(); String userName = AuthenticationUtil.getFullyAuthenticatedUser(); List<SiteInfo> siteInfos = siteService.listSites(userName); Pair<String, List<SiteInfo>> result = new Pair<String, List<SiteInfo>>( getPersonName(userName), siteInfos); siteInfoMap.put("siteInfos", result);
Confidential, Copyright © Quanticate Java backed Web Script - Demo
Confidential, Copyright © Quanticate Unit testing for Java backed web scripts • Test class extending Alfresco’s built-in test class BaseWebScriptTest • Free marker template file to render response • Controller • Spring configuration for registering web script Java class (bean injection) String BASE_URL=“/com/quanticate/sample” Response response = sendRequest(new GetRequest(BASE_URL), expectedStatus);
Confidential, Copyright © Quanticate Unit testing for Java backed web scripts-Demo
Confidential, Copyright © Quanticate
Confidential, Copyright © Quanticate Reference Links • https://wiki.alfresco.com/wiki/Web_Scripts • Book - Professional Alfresco
Confidential, Copyright © Quanticate Alfresco Forum https://forums.alfresco.com/users/ashwinis Quanticate OPDev Twitter https://twitter.com/quanticateopdev Twitter www.Twitter.com/ashwinies Baby Alfresco http://babyalfresco.blogspot.com
Confidential, Copyright © Quanticate

Introduction about Alfresco webscript

  • 1.
    Confidential, Copyright ©Quanticate Alfresco Web Scripts Ashwini Swamy Java Developer ashwini.swamy@quanticate.com © Alfresco and the Alfresco logo are trademarks of Alfresco Software, Inc .
  • 2.
    Confidential, Copyright ©Quanticate Agenda • Quanticate Overview • Who Am I ? • What is a Web Scripts? • Why we need web Scripts? • Types of Web Scripts • Sample Web Script • Sample Web Script using Javascript • Sample Web Script using Java backed web script • Unit testing for Java backed web scripts
  • 3.
    Confidential, Copyright ©Quanticate Quanticate Overview • 12+ years of success journey in CRO industry • What we do  Biostatistics Services  Clinical Programming Services  Clinical Data Management  Medical Writing Services  Pharmacovigilance Services  Clinical Trial Technology  Centralized Clinical Data Sciences  QuantiCliQ - Clinical Intelligence from Quanticate • 200+ employees • Awards  5 Category Winner in 2014 CRO Leadership Awards  Innovation in the 2013 CRO Leadership Awards
  • 4.
    Confidential, Copyright ©Quanticate Quanticate Overview Quanticate Branches  Hitchin, Hertfordshire, UK (HQ)  Manchester, UK  Canterbury, UK  Edinburgh, UK  Durham, North Carolina, US (US HQ)  Warsaw, Poland  Bloemfontein, South Africa  Bangalore, India (2 Offices)
  • 5.
    Confidential, Copyright ©Quanticate Who Am I? • 3+ years experience in Java related technologies • Frequent blogger • Knowledge sharing in Alfresco Forums
  • 6.
    Confidential, Copyright ©Quanticate What is Web Scripts? • Service bound to a URI which responds to HTTP methods such as GET, POST, PUT and DELETE. • Provides RESTful API to programmatically interact with the Alfresco content residing in the content repository.
  • 7.
    Confidential, Copyright ©Quanticate Why we need Web Scripts? • Build custom URI-identified and HTTP accessible Content Management Web Services • Easily access, manage, and cross-link your content via a tailored RESTful API
  • 8.
    Confidential, Copyright ©Quanticate Web Scripts Solutions • Integrating Alfresco with third-party systems • Developing data services • Developing UI services such as portlets • Customising search • Acting as a backend to client tools such as Orbeon Forms • Integrating with Microsoft Office
  • 9.
    Confidential, Copyright ©Quanticate Types of Web Scripts • Data Web Script • Presentation Web Script
  • 10.
    Confidential, Copyright ©Quanticate Data Web Scripts • Encapsulate access and modification of content/data held in the content repository • Server interface for client applications to query, retrieve, update, and perform processes, using request and response formats such as XML and JSON.
  • 11.
    Confidential, Copyright ©Quanticate Presentation Web Scripts • Built on top of Alfresco Spring Surf framework • Allows us to build user interfaces such as a dashlet for Alfresco Share. • Hosted in the Alfresco Content Application Server or in a separate presentation server
  • 12.
    Confidential, Copyright ©Quanticate Web Script Framework
  • 13.
    Confidential, Copyright ©Quanticate Web Script Framework Components Web script comprises the following 3 components • A description document - .desc.xml – ShortName – Description – Webscript URI – Authentication – None, guest, user and admin – Transaction mode - Read-Only like – Output format – JSON or XML • An optional controller script - .js or Java class • FreeMarker response templates – Either html.ftl or json.ftl
  • 14.
    Confidential, Copyright ©Quanticate Web Script without controller • Description document file • Free marker template file to render response • No controller defined <webscript> <shortname>Hello world</shortname> <description>Sample Hello world webscript</description> <url>/com/quanticate/hello</url> <format default="json"/> <authentication>user</authentication> </webscript>
  • 15.
    Confidential, Copyright ©Quanticate Web Script without controller -Demo
  • 16.
    Confidential, Copyright ©Quanticate JavaScript backed Web Script • Description document file • FTL to render response • Controller - Server side Javascript function main(){ // Get the user name of the person to get var userName = url.extension; // Do we want to return containing groups? var groups = true; // Get the person who has that user name var person = people.getPerson(userName); if (person != null) { model.person = person; } else { status.setCode(status.STATUS_NOT_FOUND, "Person " + userName + " does not exist"); } } main();
  • 17.
    Confidential, Copyright ©Quanticate JavaScript backed Web Script -Demo
  • 18.
    Confidential, Copyright ©Quanticate Java backed Web Script • Description document file • Free marker template file to render response • Controller • Spring configuration for registering our Web script Java class (bean injection) Map<String, Object> siteInfoMap = new HashMap<String, Object>(); String userName = AuthenticationUtil.getFullyAuthenticatedUser(); List<SiteInfo> siteInfos = siteService.listSites(userName); Pair<String, List<SiteInfo>> result = new Pair<String, List<SiteInfo>>( getPersonName(userName), siteInfos); siteInfoMap.put("siteInfos", result);
  • 19.
    Confidential, Copyright ©Quanticate Java backed Web Script - Demo
  • 20.
    Confidential, Copyright ©Quanticate Unit testing for Java backed web scripts • Test class extending Alfresco’s built-in test class BaseWebScriptTest • Free marker template file to render response • Controller • Spring configuration for registering web script Java class (bean injection) String BASE_URL=“/com/quanticate/sample” Response response = sendRequest(new GetRequest(BASE_URL), expectedStatus);
  • 21.
    Confidential, Copyright ©Quanticate Unit testing for Java backed web scripts-Demo
  • 22.
  • 23.
    Confidential, Copyright ©Quanticate Reference Links • https://wiki.alfresco.com/wiki/Web_Scripts • Book - Professional Alfresco
  • 24.
    Confidential, Copyright ©Quanticate Alfresco Forum https://forums.alfresco.com/users/ashwinis Quanticate OPDev Twitter https://twitter.com/quanticateopdev Twitter www.Twitter.com/ashwinies Baby Alfresco http://babyalfresco.blogspot.com
  • 25.