Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Loading in …3
×
1 of 25

Introduction about Alfresco webscript

3

Share

Introduction about Alfresco webscript

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Introduction about Alfresco webscript

  1. 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. 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. 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. 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. 5. Confidential, Copyright © Quanticate Who Am I? • 3+ years experience in Java related technologies • Frequent blogger • Knowledge sharing in Alfresco Forums
  6. 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. 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. 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. 9. Confidential, Copyright © Quanticate Types of Web Scripts • Data Web Script • Presentation Web Script
  10. 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. 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. 12. Confidential, Copyright © Quanticate Web Script Framework
  13. 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. 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. 15. Confidential, Copyright © Quanticate Web Script without controller -Demo
  16. 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. 17. Confidential, Copyright © Quanticate JavaScript backed Web Script -Demo
  18. 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. 19. Confidential, Copyright © Quanticate Java backed Web Script - Demo
  20. 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. 21. Confidential, Copyright © Quanticate Unit testing for Java backed web scripts-Demo
  22. 22. Confidential, Copyright © Quanticate
  23. 23. Confidential, Copyright © Quanticate Reference Links • https://wiki.alfresco.com/wiki/Web_Scripts • Book - Professional Alfresco
  24. 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. 25. Confidential, Copyright © Quanticate

×