SlideShare a Scribd company logo
1 of 27
Download to read offline
Alfresco Surf Code Camp
Remoting and Component API
Objectives

                 By the end of this module you should know
                     •    Useful JavaScript objects
                     •    Surf remoting concepts
                     •    How & why you'd use Surf's proxy
                     •    How to retrieve and work with XML and JSON returned by scripts
                          in the Repository tier




12/01/09   Optaros and Client confidential. All rights reserved.                           2
Surf API

             Objects and Methods available to Renderers

             Renderer Types
              • Web Script
              • FreeMarker
              • Java
              • JSP




12/01/09                                                  3
Surf API Brief Examples

             JavaScript Example
             var username = context.user.id;




             FreeMarker Example
             <#assign username = context.user.id>
             ${username}




             JSP Example
             <%
                  String username = RequestUtil.getRequestContext().getUser().getId();
             %>
             <%=username%>



12/01/09                                                                                 4
Web Scripts and FreeMarker

             Focus only on the Web Script and FreeMarker API
              • http://wiki.alfresco.com/wiki/Surf_Platform_-_Freemarker_Template_and_Jav


             Java API not yet documented online




12/01/09                                                                             5
Renderer Root Scoped Objects

             context
              • The request context

             user
              • The current user

             content
              • The content object being rendered

             instance
              • The renderer instance (equivalent of quot;thisquot;)‫‏‬

             sitedata
              • Site Construction helper

             remote
              • Connection management helper




12/01/09                                                        6
Root-scoped: context ScriptRequestContext

             The request context for the currently executing page

             Useful variables:
              • page         The page being rendered
              • template     The template being used to render
              • user         The current user
              • content      The content object being dispatched (if available)‫‏‬

             Examples:
             var page = context.page;

             model.pageName = page.title;
             model.pageDescription = page.description;

             model.templateId = context.template.id;




12/01/09                                                                           7
Root-scoped: user
           ScriptUser

             The current user

             Useful variables:
              • firstName         The user’s first name
              • lastName          The user’s last name
              • fullName          A full name representation of the user
              • properties        An associative array of custom properties

             Examples:
             var user = context.user;

             model.fullName = user.fullName;
             model.email = user.companyEmail;
             model.team = user.properties[“{http://www.alfresco.org/model/content/1.0}team”];




12/01/09                                                                                  8
Root-scoped: remote
           ScriptRemote

             A remote connection helper

             Access to Alfresco Web Framework remoting faciltiies

             Stateless Connections

             Stateful Connections (scoped to user)‫‏‬

             Credential Management and Binding (stateful)‫‏‬

             Credential Vault (persistent and non-persistent)‫‏‬

             Customizable (XML config driven)‫‏‬




12/01/09                                                            9
Remoting Configurations

             Configurable definitions for:
              • Endpoints
              • Connectors
              • Authenticators

             These are entirely configurable

             webscript-framework-config-remote.xml
              • /WEB-INF/classes/alfresco




12/01/09                                             10
Remoting Configurations

             Get a connector for a given endpoint

             Endpoints
              • any arbitrary id
              • defines connection information to               Endpoint
                the remote location

             Connector                                         Connector

              • knows how to “talk” with specific types
                of back end servers
                                                              Authenticator

             Authenticator
              • knows how to “handshake” for authentication
                with back end servers
              • Alfresco Ticket, MediaWiki, WordPress, etc.



12/01/09                                                                      11
Remoting Configurations




                             www.wikipedia.org              alfresco.com
                Endpoint




                               HTTP               RMI             Alfresco
              Connectors




           Authenticators   mediawiki            alfresco          wordpress




12/01/09                                                                       12
Remote Configuration Endpoints

             Endpoints
             <config evaluator=quot;string-comparequot; condition=quot;Remotequot;>
               <remote>
                 <endpoint>
                   <id>alfresco</id>
                   <name>Alfresco - user access</name>
                   <connector-id>alfresco</connector-id>
                   <endpoint-url>http://localhost:8080/alfresco/s</endpoint-url>
                   <identity>user</identity>
                 </endpoint>
               </remote>
             </config>




             Properties
              • id           The endpoint ID
              • connector-id      The ID of the connector when connecting
              • endpoint-url      The base URL for the connection
              • identity          How to manage user connection state

12/01/09                                                                           13
Remote Configuration Connectors

             Connectors
             <config evaluator=quot;string-comparequot; condition=quot;Remotequot;>
               <remote>
                 <connector>
                   <id>alfresco</id>
                   <name>Alfresco Connector</name>
                   <class>org.alfresco.connector.AlfrescoConnector</class>
                   <authenticator-id>alfresco-ticket</authenticator-id>
                 </connector>
               </remote>
             </config>




             Properties
              • id                     The connector ID
              • class                  The Java implementation class name
              • authenticator-id       The ID of the authenticator to use




12/01/09                                                                     14
Remote Configuration Authenticators

             Authenticator
             <config evaluator=quot;string-comparequot; condition=quot;Remotequot;>
               <remote>
                 <authenticator>
                   <id>alfresco-ticket</id>
                   <name>Alfresco Authenticator</name>
                   <class>org.alfresco.connector.AlfrescoAuthenticator</class>
                 </authenticator>
               </remote>
             </config>




             Properties
              • id           The authenticator ID
              • class        The Java implementation class name




12/01/09                                                                         15
Root-scoped: remote
           ScriptRemote

             connect(endpointId)‫‏‬
              • Retrieves a ScriptRemoteConnector instance for the given
                endpoint
              • Creates a new Connector
              • Binds it to the given endpoint
              • Binds it to the current user

             ScriptRemoteConnector Methods
              • get(uri)‫‏‬
              • post(uri, body)‫‏‬
              • post(uri, body, contentType)‫‏‬
              • put(uri, body)‫‏‬
              • put(uri, body, contentType)‫‏‬
              • delete(uri)‫‏‬



12/01/09                                                                   16
Example #1: HTML

            JavaScript
            // get a connector to the Alfresco Endpoint
            // this endpoint has a base URI of /alfresco/service
            var connector = remote.connect(“alfresco”);

            // retrieve the index of web scripts
            var html = connector.get(“/index”);

            // store html onto model
            model.html = html;




            FreeMarker
            ${html}




12/01/09                                                           17
Example #2: CMIS XML

             JavaScript
            // get a connector to the Alfresco Endpoint
            var connector = remote.connect(“alfresco”);

            // retrieve the company home folder
            var cmis = connector.get(“/api/path/workspace/SpacesStore”);




12/01/09                                                                   18
Example #2: CMIS XML
           <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?>
           <entry xmlns=quot;http://www.w3.org/2005/Atomquot; xmlns:app=quot;http://www.w3.org/2007/appquot; xmlns:cmis=quot;http://www.cmis.org/2008/05quot;
           xmlns:alf=quot;http://www.alfresco.orgquot;>
             <author><name>System</name></author>
             <content>56923743-7436-482e-b1cf-eda326d11dc2</content>
             <id>urn:uuid:56923743-7436-482e-b1cf-eda326d11dc2</id>
             <link rel=quot;selfquot; href=quot;http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/56923743-7436-482e-b1cf-
           eda326d11dc2quot;/>
             <link rel=quot;editquot; href=quot;http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/56923743-7436-482e-b1cf-
           eda326d11dc2quot;/>
             <link rel=quot;cmis-allowableactionsquot; href=quot;http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/56923743-
           7436-482e-b1cf-eda326d11dc2/permissionsquot;/>
             <link rel=quot;cmis-relationshipsquot; href=quot;http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/56923743-7436-
           482e-b1cf-eda326d11dc2/associationsquot;/>
             <link rel=quot;cmis-childrenquot; href=quot;http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/56923743-7436-482e-
           b1cf-eda326d11dc2/childrenquot;/>
             <link rel=quot;cmis-descendantsquot; href=quot;http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/56923743-7436-
           482e-b1cf-eda326d11dc2/descendantsquot;/>
             <link rel=quot;cmis-typequot; href=quot;http://localhost:8080/alfresco/service/api/type/folderquot;/>
             <link rel=quot;cmis-repositoryquot; href=quot;http://localhost:8080/alfresco/service/api/repositoryquot;/>
             <published>2008-09-10T09:16:32.421-05:00</published>
             <summary>The company root space</summary>
             <title>Company Home</title>
             <updated>2008-09-10T09:17:19.328-05:00</updated>
             <cmis:object>
               <cmis:properties>
                 <cmis:propertyId cmis:name=quot;ObjectIdquot;><cmis:value>workspace://SpacesStore/56923743-7436-482e-b1cf-
           eda326d11dc2</cmis:value></cmis:propertyId>
                 <cmis:propertyString cmis:name=quot;BaseTypequot;><cmis:value>folder</cmis:value></cmis:propertyString>
                 <cmis:propertyString cmis:name=quot;ObjectTypeIdquot;><cmis:value>folder</cmis:value></cmis:propertyString>
                 <cmis:propertyString cmis:name=quot;CreatedByquot;><cmis:value>System</cmis:value></cmis:propertyString>
                 <cmis:propertyDateTime cmis:name=quot;CreationDatequot;><cmis:value>2008-09-10T09:16:32.421-
           05:00</cmis:value></cmis:propertyDateTime>
                 <cmis:propertyString cmis:name=quot;LastModifiedByquot;><cmis:value>System</cmis:value></cmis:propertyString>
                 <cmis:propertyDateTime cmis:name=quot;LastModificationDatequot;><cmis:value>2008-09-10T09:17:19.328-
           05:00</cmis:value></cmis:propertyDateTime>
                 <cmis:propertyString cmis:name=quot;Namequot;><cmis:value>Company Home</cmis:value></cmis:propertyString>
                 <cmis:propertyId cmis:name=quot;ParentIdquot;/>
               </cmis:properties>
             </cmis:object>
             <cmis:terminator/>
             <app:edited>2008-09-10T09:17:19.328-05:00</app:edited>
             <alf:icon>http://localhost:8080/alfresco/images/icons/space-icon-default-16.gif</alf:icon>
           </entry>

12/01/09                                                                                                                                 19
Example #2: CMIS XML

             Essentially…
            <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?>
            <entry xmlns=quot;http://www.w3.org/2005/Atomquot; xmlns:app=quot;http://www.w3.org/2007/appquot;
                   xmlns:cmis=quot;http://www.cmis.org/2008/05quot;
                   xmlns:alf=quot;http://www.alfresco.orgquot;>

              <cmis:object>
                <cmis:properties>

                  <cmis:propertyId cmis:name=quot;ObjectIdquot;>
                    <cmis:value>
                      workspace://SpacesStore/56923743-7436-482e-b1cf-eda326d11dc2
                    </cmis:value>
                  </cmis:propertyId>

                  <cmis:propertyString cmis:name=quot;Namequot;>
                    <cmis:value>Company Home</cmis:value>
                  </cmis:propertyString>

                </cmis:properties>
              </cmis:object>

              <cmis:terminator/>

            </entry>


12/01/09                                                                                 20
Example #2: CMIS XML

             JavaScript
            // get a connector to the Alfresco Endpoint
            var connector = remote.connect(“alfresco”);

            // retrieve the company home folder
            var cmis = connector.get(“/api/path/workspace/SpacesStore”);

            // load XML into E4X
            var xml = new XML(cmis);

            // populate the model
            var properties = xml.*::object.*::properties;
            model.id = properties.(@name=“ObjectId”).*::value;
            model.name = properties.(@name=“Name”).*::value;




             FreeMarker
             Object id: ${id}
             <br/>
             Object name: ${name}

12/01/09                                                                   21
Example #3: JSON

             JavaScript
             // get a connector to the Alfresco Endpoint
             var connector = remote.connect(“alfresco”);

             // retrieve a content object
             var nodeRef = “workspace://SpacesStore/56923743-7436-482e-b1cf-eda326d11dc2”;
             var data = connector.get(“/api/metadata?nodeRef=” + nodeRef);




12/01/09                                                                                 22
Example #3: JSON

           {
               quot;typequot;: quot;{http://www.alfresco.org/model/content/1.0}folderquot;,
               quot;aspectsquot;: [
                   quot;{http://www.alfresco.org/model/content/1.0}auditablequot;,
                   quot;{http://www.alfresco.org/model/application/1.0}uifacetsquot;,
                   quot;{http://www.alfresco.org/model/system/1.0}referenceablequot;
               ],
               quot;nodeRefquot;: quot;workspace://SpacesStore/56923743-7436-482e-b1cf-eda326d11dc2quot;,
               quot;propertiesquot;: {
                   quot;{http://www.alfresco.org/model/application/1.0}iconquot;: quot;space-icon-defaultquot;,
                   quot;{http://www.alfresco.org/model/content/1.0}descriptionquot;: quot;The company root spacequot;,
                   quot;{http://www.alfresco.org/model/system/1.0}node-uuidquot;: quot;56923743-7436-482e-b1cf-eda326d11dc2
                   quot;{http://www.alfresco.org/model/system/1.0}node-dbidquot;: 15,
                   quot;{http://www.alfresco.org/model/content/1.0}titlequot;: quot;Company Homequot;,
                   quot;{http://www.alfresco.org/model/content/1.0}createdquot;: quot;Wed Sep 10 09:16:32 CDT 2008quot;,
                   quot;{http://www.alfresco.org/model/content/1.0}modifierquot;: quot;Systemquot;,
                   quot;{http://www.alfresco.org/model/content/1.0}modifiedquot;: quot;Wed Sep 10 09:17:19 CDT 2008quot;,
                   quot;{http://www.alfresco.org/model/content/1.0}creatorquot;: quot;Systemquot;,
                   quot;{http://www.alfresco.org/model/system/1.0}store-protocolquot;: quot;workspacequot;,
                   quot;{http://www.alfresco.org/model/content/1.0}namequot;: quot;Company Homequot;,
                   quot;{http://www.alfresco.org/model/system/1.0}store-identifierquot;: quot;SpacesStorequot;
               },
               quot;mimetypequot;: quot;application/octet-streamquot;
           }




12/01/09                                                                                                  23
Example #3: JSON

             JavaScript
             // get a connector to the Alfresco Endpoint
             var connector = remote.connect(“alfresco”);

             // retrieve a content object
             var nodeRef = “workspace://SpacesStore/56923743-7436-482e-b1cf-eda326d11dc2”;
             var data = connector.get(“/api/metadata?nodeRef=” + nodeRef);

             // create a javascript object from the json
             var json = eval('(' + data + ')');

             // populate the model
             model.id = json.nodeRef;
             model.name = json.properties[“{http://www.alfresco.org/model/content/1.0}name“];




             FreeMarker
             Object id: ${id}
             <br/>
             Object name: ${name}


12/01/09                                                                                 24
Proxy Services

             You can either use connectors directly or via a proxy

             Alfresco Surf provides a proxy servlet that uses this
             connector facility underneath the hood



             http://labs3c:8580/sample/proxy/{endpointId}/{uri}




12/01/09                                                             25
Proxy Services

             http://labs3c:8580/sample/proxy/alfresco/index
              • Identifies the “alfresco” endpoint
              • The base URI on the endpoint is “/alfresco/service”
              • This proxies through to:
                http://labs3c:8080/alfresco/service/index
              • User connector session state is stamped onto the proxied
                connection

             Optimizations
              • No buffering
              • Headers are captured and some retained if related to connector
                sessions
              • Input and output streams flow through




12/01/09                                                                         26
Wrap-up

                 In this module, you learned...
                     •    Useful JavaScript objects
                     •    Surf remoting concepts
                     •    How & why you'd use Surf's proxy
                     •    How to retrieve and work with XML and JSON returned by scripts
                          in the Repository tier




12/01/09   Optaros and Client confidential. All rights reserved.                           27

More Related Content

Viewers also liked

Optaros Surf Code Camp Lab 3
Optaros Surf Code Camp Lab 3Optaros Surf Code Camp Lab 3
Optaros Surf Code Camp Lab 3Jeff Potts
 
Debatdevi Presentacion S Tolliver Vcat
Debatdevi Presentacion S Tolliver VcatDebatdevi Presentacion S Tolliver Vcat
Debatdevi Presentacion S Tolliver VcatSTolliver
 
Alfresco: The Story of How Open Source Disrupted the ECM Market
Alfresco: The Story of How Open Source Disrupted the ECM MarketAlfresco: The Story of How Open Source Disrupted the ECM Market
Alfresco: The Story of How Open Source Disrupted the ECM MarketJeff Potts
 

Viewers also liked (6)

Optaros Surf Code Camp Lab 3
Optaros Surf Code Camp Lab 3Optaros Surf Code Camp Lab 3
Optaros Surf Code Camp Lab 3
 
Debatdevi Presentacion S Tolliver Vcat
Debatdevi Presentacion S Tolliver VcatDebatdevi Presentacion S Tolliver Vcat
Debatdevi Presentacion S Tolliver Vcat
 
Alfresco: The Story of How Open Source Disrupted the ECM Market
Alfresco: The Story of How Open Source Disrupted the ECM MarketAlfresco: The Story of How Open Source Disrupted the ECM Market
Alfresco: The Story of How Open Source Disrupted the ECM Market
 
Review
ReviewReview
Review
 
Hot spring
Hot springHot spring
Hot spring
 
Caracteristicas1
Caracteristicas1Caracteristicas1
Caracteristicas1
 

Similar to Optaros Surf Code Camp Api

Optaros Surf Code Camp Lab 2
Optaros Surf Code Camp Lab 2Optaros Surf Code Camp Lab 2
Optaros Surf Code Camp Lab 2Jeff Potts
 
Introduction to Alfresco Surf Platform
Introduction to Alfresco Surf PlatformIntroduction to Alfresco Surf Platform
Introduction to Alfresco Surf PlatformAlfresco Software
 
Optaros Surf Code Camp Walkthrough 1
Optaros Surf Code Camp Walkthrough 1Optaros Surf Code Camp Walkthrough 1
Optaros Surf Code Camp Walkthrough 1Jeff Potts
 
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008Association Paris-Web
 
Optaros Surf Code Camp Lab 1
Optaros Surf Code Camp Lab 1Optaros Surf Code Camp Lab 1
Optaros Surf Code Camp Lab 1Jeff Potts
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixBruce Snyder
 
Apache Roller, Acegi Security and Single Sign-on
Apache Roller, Acegi Security and Single Sign-onApache Roller, Acegi Security and Single Sign-on
Apache Roller, Acegi Security and Single Sign-onMatt Raible
 
Project Avatar (Lyon JUG & Alpes JUG - March 2014)
Project Avatar (Lyon JUG & Alpes JUG  - March 2014)Project Avatar (Lyon JUG & Alpes JUG  - March 2014)
Project Avatar (Lyon JUG & Alpes JUG - March 2014)David Delabassee
 
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur! Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur! David Delabassee
 
ghfghg
ghfghgghfghg
ghfghghoefo
 
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014Puppet
 
GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012Arun Gupta
 
Cloud Best Practices
Cloud Best PracticesCloud Best Practices
Cloud Best PracticesEric Bottard
 
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!Masoud Kalali
 
UEMB200: Next Generation of Endpoint Management Architecture and Discovery Se...
UEMB200: Next Generation of Endpoint Management Architecture and Discovery Se...UEMB200: Next Generation of Endpoint Management Architecture and Discovery Se...
UEMB200: Next Generation of Endpoint Management Architecture and Discovery Se...Ivanti
 
GlassFish REST Administration Backend
GlassFish REST Administration BackendGlassFish REST Administration Backend
GlassFish REST Administration BackendArun Gupta
 

Similar to Optaros Surf Code Camp Api (20)

Optaros Surf Code Camp Lab 2
Optaros Surf Code Camp Lab 2Optaros Surf Code Camp Lab 2
Optaros Surf Code Camp Lab 2
 
Introduction to Alfresco Surf Platform
Introduction to Alfresco Surf PlatformIntroduction to Alfresco Surf Platform
Introduction to Alfresco Surf Platform
 
Spring Surf 101
Spring Surf 101Spring Surf 101
Spring Surf 101
 
Spring and DWR
Spring and DWRSpring and DWR
Spring and DWR
 
Optaros Surf Code Camp Walkthrough 1
Optaros Surf Code Camp Walkthrough 1Optaros Surf Code Camp Walkthrough 1
Optaros Surf Code Camp Walkthrough 1
 
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
 
Optaros Surf Code Camp Lab 1
Optaros Surf Code Camp Lab 1Optaros Surf Code Camp Lab 1
Optaros Surf Code Camp Lab 1
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMix
 
Apache Roller, Acegi Security and Single Sign-on
Apache Roller, Acegi Security and Single Sign-onApache Roller, Acegi Security and Single Sign-on
Apache Roller, Acegi Security and Single Sign-on
 
Project Avatar (Lyon JUG & Alpes JUG - March 2014)
Project Avatar (Lyon JUG & Alpes JUG  - March 2014)Project Avatar (Lyon JUG & Alpes JUG  - March 2014)
Project Avatar (Lyon JUG & Alpes JUG - March 2014)
 
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur! Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
 
ghfghg
ghfghgghfghg
ghfghg
 
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
 
GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012
 
Cloud Best Practices
Cloud Best PracticesCloud Best Practices
Cloud Best Practices
 
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
 
Servlet30 20081218
Servlet30 20081218Servlet30 20081218
Servlet30 20081218
 
UEMB200: Next Generation of Endpoint Management Architecture and Discovery Se...
UEMB200: Next Generation of Endpoint Management Architecture and Discovery Se...UEMB200: Next Generation of Endpoint Management Architecture and Discovery Se...
UEMB200: Next Generation of Endpoint Management Architecture and Discovery Se...
 
GlassFish REST Administration Backend
GlassFish REST Administration BackendGlassFish REST Administration Backend
GlassFish REST Administration Backend
 
Api Design
Api DesignApi Design
Api Design
 

More from Jeff Potts

No Docker? No Problem: Automating installation and config with Ansible
No Docker? No Problem: Automating installation and config with AnsibleNo Docker? No Problem: Automating installation and config with Ansible
No Docker? No Problem: Automating installation and config with AnsibleJeff Potts
 
Moving From Actions & Behaviors to Microservices
Moving From Actions & Behaviors to MicroservicesMoving From Actions & Behaviors to Microservices
Moving From Actions & Behaviors to MicroservicesJeff Potts
 
Flexible Permissions Management with ACL Templates
Flexible Permissions Management with ACL TemplatesFlexible Permissions Management with ACL Templates
Flexible Permissions Management with ACL TemplatesJeff Potts
 
Moving Gigantic Files Into and Out of the Alfresco Repository
Moving Gigantic Files Into and Out of the Alfresco RepositoryMoving Gigantic Files Into and Out of the Alfresco Repository
Moving Gigantic Files Into and Out of the Alfresco RepositoryJeff Potts
 
Could Alfresco Survive a Zombie Attack?
Could Alfresco Survive a Zombie Attack?Could Alfresco Survive a Zombie Attack?
Could Alfresco Survive a Zombie Attack?Jeff Potts
 
Connecting Content Management Apps with CMIS
Connecting Content Management Apps with CMISConnecting Content Management Apps with CMIS
Connecting Content Management Apps with CMISJeff Potts
 
The Challenges of Keeping Bees
The Challenges of Keeping BeesThe Challenges of Keeping Bees
The Challenges of Keeping BeesJeff Potts
 
Getting Started With CMIS
Getting Started With CMISGetting Started With CMIS
Getting Started With CMISJeff Potts
 
Alfresco: What every developer should know
Alfresco: What every developer should knowAlfresco: What every developer should know
Alfresco: What every developer should knowJeff Potts
 
CMIS: An Open API for Managing Content
CMIS: An Open API for Managing ContentCMIS: An Open API for Managing Content
CMIS: An Open API for Managing ContentJeff Potts
 
Apache Chemistry in Action: Using CMIS and your favorite language to unlock c...
Apache Chemistry in Action: Using CMIS and your favorite language to unlock c...Apache Chemistry in Action: Using CMIS and your favorite language to unlock c...
Apache Chemistry in Action: Using CMIS and your favorite language to unlock c...Jeff Potts
 
Join the Alfresco community
Join the Alfresco communityJoin the Alfresco community
Join the Alfresco communityJeff Potts
 
Intro to the Alfresco Public API
Intro to the Alfresco Public APIIntro to the Alfresco Public API
Intro to the Alfresco Public APIJeff Potts
 
Apache Chemistry in Action
Apache Chemistry in ActionApache Chemistry in Action
Apache Chemistry in ActionJeff Potts
 
Building Content-Rich Java Apps in the Cloud with the Alfresco API
Building Content-Rich Java Apps in the Cloud with the Alfresco APIBuilding Content-Rich Java Apps in the Cloud with the Alfresco API
Building Content-Rich Java Apps in the Cloud with the Alfresco APIJeff Potts
 
Alfresco Community Survey 2012 Results
Alfresco Community Survey 2012 ResultsAlfresco Community Survey 2012 Results
Alfresco Community Survey 2012 ResultsJeff Potts
 
Getting Started with CMIS
Getting Started with CMISGetting Started with CMIS
Getting Started with CMISJeff Potts
 
Relational Won't Cut It: Architecting Content Centric Apps
Relational Won't Cut It: Architecting Content Centric AppsRelational Won't Cut It: Architecting Content Centric Apps
Relational Won't Cut It: Architecting Content Centric AppsJeff Potts
 
Alfresco SAUG: State of ECM
Alfresco SAUG: State of ECMAlfresco SAUG: State of ECM
Alfresco SAUG: State of ECMJeff Potts
 
Alfresco SAUG: CMIS & Integrations
Alfresco SAUG: CMIS & IntegrationsAlfresco SAUG: CMIS & Integrations
Alfresco SAUG: CMIS & IntegrationsJeff Potts
 

More from Jeff Potts (20)

No Docker? No Problem: Automating installation and config with Ansible
No Docker? No Problem: Automating installation and config with AnsibleNo Docker? No Problem: Automating installation and config with Ansible
No Docker? No Problem: Automating installation and config with Ansible
 
Moving From Actions & Behaviors to Microservices
Moving From Actions & Behaviors to MicroservicesMoving From Actions & Behaviors to Microservices
Moving From Actions & Behaviors to Microservices
 
Flexible Permissions Management with ACL Templates
Flexible Permissions Management with ACL TemplatesFlexible Permissions Management with ACL Templates
Flexible Permissions Management with ACL Templates
 
Moving Gigantic Files Into and Out of the Alfresco Repository
Moving Gigantic Files Into and Out of the Alfresco RepositoryMoving Gigantic Files Into and Out of the Alfresco Repository
Moving Gigantic Files Into and Out of the Alfresco Repository
 
Could Alfresco Survive a Zombie Attack?
Could Alfresco Survive a Zombie Attack?Could Alfresco Survive a Zombie Attack?
Could Alfresco Survive a Zombie Attack?
 
Connecting Content Management Apps with CMIS
Connecting Content Management Apps with CMISConnecting Content Management Apps with CMIS
Connecting Content Management Apps with CMIS
 
The Challenges of Keeping Bees
The Challenges of Keeping BeesThe Challenges of Keeping Bees
The Challenges of Keeping Bees
 
Getting Started With CMIS
Getting Started With CMISGetting Started With CMIS
Getting Started With CMIS
 
Alfresco: What every developer should know
Alfresco: What every developer should knowAlfresco: What every developer should know
Alfresco: What every developer should know
 
CMIS: An Open API for Managing Content
CMIS: An Open API for Managing ContentCMIS: An Open API for Managing Content
CMIS: An Open API for Managing Content
 
Apache Chemistry in Action: Using CMIS and your favorite language to unlock c...
Apache Chemistry in Action: Using CMIS and your favorite language to unlock c...Apache Chemistry in Action: Using CMIS and your favorite language to unlock c...
Apache Chemistry in Action: Using CMIS and your favorite language to unlock c...
 
Join the Alfresco community
Join the Alfresco communityJoin the Alfresco community
Join the Alfresco community
 
Intro to the Alfresco Public API
Intro to the Alfresco Public APIIntro to the Alfresco Public API
Intro to the Alfresco Public API
 
Apache Chemistry in Action
Apache Chemistry in ActionApache Chemistry in Action
Apache Chemistry in Action
 
Building Content-Rich Java Apps in the Cloud with the Alfresco API
Building Content-Rich Java Apps in the Cloud with the Alfresco APIBuilding Content-Rich Java Apps in the Cloud with the Alfresco API
Building Content-Rich Java Apps in the Cloud with the Alfresco API
 
Alfresco Community Survey 2012 Results
Alfresco Community Survey 2012 ResultsAlfresco Community Survey 2012 Results
Alfresco Community Survey 2012 Results
 
Getting Started with CMIS
Getting Started with CMISGetting Started with CMIS
Getting Started with CMIS
 
Relational Won't Cut It: Architecting Content Centric Apps
Relational Won't Cut It: Architecting Content Centric AppsRelational Won't Cut It: Architecting Content Centric Apps
Relational Won't Cut It: Architecting Content Centric Apps
 
Alfresco SAUG: State of ECM
Alfresco SAUG: State of ECMAlfresco SAUG: State of ECM
Alfresco SAUG: State of ECM
 
Alfresco SAUG: CMIS & Integrations
Alfresco SAUG: CMIS & IntegrationsAlfresco SAUG: CMIS & Integrations
Alfresco SAUG: CMIS & Integrations
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
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 WorkerThousandEyes
 

Recently uploaded (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
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
 

Optaros Surf Code Camp Api

  • 1. Alfresco Surf Code Camp Remoting and Component API
  • 2. Objectives By the end of this module you should know • Useful JavaScript objects • Surf remoting concepts • How & why you'd use Surf's proxy • How to retrieve and work with XML and JSON returned by scripts in the Repository tier 12/01/09 Optaros and Client confidential. All rights reserved. 2
  • 3. Surf API Objects and Methods available to Renderers Renderer Types • Web Script • FreeMarker • Java • JSP 12/01/09 3
  • 4. Surf API Brief Examples JavaScript Example var username = context.user.id; FreeMarker Example <#assign username = context.user.id> ${username} JSP Example <% String username = RequestUtil.getRequestContext().getUser().getId(); %> <%=username%> 12/01/09 4
  • 5. Web Scripts and FreeMarker Focus only on the Web Script and FreeMarker API • http://wiki.alfresco.com/wiki/Surf_Platform_-_Freemarker_Template_and_Jav Java API not yet documented online 12/01/09 5
  • 6. Renderer Root Scoped Objects context • The request context user • The current user content • The content object being rendered instance • The renderer instance (equivalent of quot;thisquot;)‫‏‬ sitedata • Site Construction helper remote • Connection management helper 12/01/09 6
  • 7. Root-scoped: context ScriptRequestContext The request context for the currently executing page Useful variables: • page The page being rendered • template The template being used to render • user The current user • content The content object being dispatched (if available)‫‏‬ Examples: var page = context.page; model.pageName = page.title; model.pageDescription = page.description; model.templateId = context.template.id; 12/01/09 7
  • 8. Root-scoped: user ScriptUser The current user Useful variables: • firstName The user’s first name • lastName The user’s last name • fullName A full name representation of the user • properties An associative array of custom properties Examples: var user = context.user; model.fullName = user.fullName; model.email = user.companyEmail; model.team = user.properties[“{http://www.alfresco.org/model/content/1.0}team”]; 12/01/09 8
  • 9. Root-scoped: remote ScriptRemote A remote connection helper Access to Alfresco Web Framework remoting faciltiies Stateless Connections Stateful Connections (scoped to user)‫‏‬ Credential Management and Binding (stateful)‫‏‬ Credential Vault (persistent and non-persistent)‫‏‬ Customizable (XML config driven)‫‏‬ 12/01/09 9
  • 10. Remoting Configurations Configurable definitions for: • Endpoints • Connectors • Authenticators These are entirely configurable webscript-framework-config-remote.xml • /WEB-INF/classes/alfresco 12/01/09 10
  • 11. Remoting Configurations Get a connector for a given endpoint Endpoints • any arbitrary id • defines connection information to Endpoint the remote location Connector Connector • knows how to “talk” with specific types of back end servers Authenticator Authenticator • knows how to “handshake” for authentication with back end servers • Alfresco Ticket, MediaWiki, WordPress, etc. 12/01/09 11
  • 12. Remoting Configurations www.wikipedia.org alfresco.com Endpoint HTTP RMI Alfresco Connectors Authenticators mediawiki alfresco wordpress 12/01/09 12
  • 13. Remote Configuration Endpoints Endpoints <config evaluator=quot;string-comparequot; condition=quot;Remotequot;> <remote> <endpoint> <id>alfresco</id> <name>Alfresco - user access</name> <connector-id>alfresco</connector-id> <endpoint-url>http://localhost:8080/alfresco/s</endpoint-url> <identity>user</identity> </endpoint> </remote> </config> Properties • id The endpoint ID • connector-id The ID of the connector when connecting • endpoint-url The base URL for the connection • identity How to manage user connection state 12/01/09 13
  • 14. Remote Configuration Connectors Connectors <config evaluator=quot;string-comparequot; condition=quot;Remotequot;> <remote> <connector> <id>alfresco</id> <name>Alfresco Connector</name> <class>org.alfresco.connector.AlfrescoConnector</class> <authenticator-id>alfresco-ticket</authenticator-id> </connector> </remote> </config> Properties • id The connector ID • class The Java implementation class name • authenticator-id The ID of the authenticator to use 12/01/09 14
  • 15. Remote Configuration Authenticators Authenticator <config evaluator=quot;string-comparequot; condition=quot;Remotequot;> <remote> <authenticator> <id>alfresco-ticket</id> <name>Alfresco Authenticator</name> <class>org.alfresco.connector.AlfrescoAuthenticator</class> </authenticator> </remote> </config> Properties • id The authenticator ID • class The Java implementation class name 12/01/09 15
  • 16. Root-scoped: remote ScriptRemote connect(endpointId)‫‏‬ • Retrieves a ScriptRemoteConnector instance for the given endpoint • Creates a new Connector • Binds it to the given endpoint • Binds it to the current user ScriptRemoteConnector Methods • get(uri)‫‏‬ • post(uri, body)‫‏‬ • post(uri, body, contentType)‫‏‬ • put(uri, body)‫‏‬ • put(uri, body, contentType)‫‏‬ • delete(uri)‫‏‬ 12/01/09 16
  • 17. Example #1: HTML JavaScript // get a connector to the Alfresco Endpoint // this endpoint has a base URI of /alfresco/service var connector = remote.connect(“alfresco”); // retrieve the index of web scripts var html = connector.get(“/index”); // store html onto model model.html = html; FreeMarker ${html} 12/01/09 17
  • 18. Example #2: CMIS XML JavaScript // get a connector to the Alfresco Endpoint var connector = remote.connect(“alfresco”); // retrieve the company home folder var cmis = connector.get(“/api/path/workspace/SpacesStore”); 12/01/09 18
  • 19. Example #2: CMIS XML <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?> <entry xmlns=quot;http://www.w3.org/2005/Atomquot; xmlns:app=quot;http://www.w3.org/2007/appquot; xmlns:cmis=quot;http://www.cmis.org/2008/05quot; xmlns:alf=quot;http://www.alfresco.orgquot;> <author><name>System</name></author> <content>56923743-7436-482e-b1cf-eda326d11dc2</content> <id>urn:uuid:56923743-7436-482e-b1cf-eda326d11dc2</id> <link rel=quot;selfquot; href=quot;http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/56923743-7436-482e-b1cf- eda326d11dc2quot;/> <link rel=quot;editquot; href=quot;http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/56923743-7436-482e-b1cf- eda326d11dc2quot;/> <link rel=quot;cmis-allowableactionsquot; href=quot;http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/56923743- 7436-482e-b1cf-eda326d11dc2/permissionsquot;/> <link rel=quot;cmis-relationshipsquot; href=quot;http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/56923743-7436- 482e-b1cf-eda326d11dc2/associationsquot;/> <link rel=quot;cmis-childrenquot; href=quot;http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/56923743-7436-482e- b1cf-eda326d11dc2/childrenquot;/> <link rel=quot;cmis-descendantsquot; href=quot;http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/56923743-7436- 482e-b1cf-eda326d11dc2/descendantsquot;/> <link rel=quot;cmis-typequot; href=quot;http://localhost:8080/alfresco/service/api/type/folderquot;/> <link rel=quot;cmis-repositoryquot; href=quot;http://localhost:8080/alfresco/service/api/repositoryquot;/> <published>2008-09-10T09:16:32.421-05:00</published> <summary>The company root space</summary> <title>Company Home</title> <updated>2008-09-10T09:17:19.328-05:00</updated> <cmis:object> <cmis:properties> <cmis:propertyId cmis:name=quot;ObjectIdquot;><cmis:value>workspace://SpacesStore/56923743-7436-482e-b1cf- eda326d11dc2</cmis:value></cmis:propertyId> <cmis:propertyString cmis:name=quot;BaseTypequot;><cmis:value>folder</cmis:value></cmis:propertyString> <cmis:propertyString cmis:name=quot;ObjectTypeIdquot;><cmis:value>folder</cmis:value></cmis:propertyString> <cmis:propertyString cmis:name=quot;CreatedByquot;><cmis:value>System</cmis:value></cmis:propertyString> <cmis:propertyDateTime cmis:name=quot;CreationDatequot;><cmis:value>2008-09-10T09:16:32.421- 05:00</cmis:value></cmis:propertyDateTime> <cmis:propertyString cmis:name=quot;LastModifiedByquot;><cmis:value>System</cmis:value></cmis:propertyString> <cmis:propertyDateTime cmis:name=quot;LastModificationDatequot;><cmis:value>2008-09-10T09:17:19.328- 05:00</cmis:value></cmis:propertyDateTime> <cmis:propertyString cmis:name=quot;Namequot;><cmis:value>Company Home</cmis:value></cmis:propertyString> <cmis:propertyId cmis:name=quot;ParentIdquot;/> </cmis:properties> </cmis:object> <cmis:terminator/> <app:edited>2008-09-10T09:17:19.328-05:00</app:edited> <alf:icon>http://localhost:8080/alfresco/images/icons/space-icon-default-16.gif</alf:icon> </entry> 12/01/09 19
  • 20. Example #2: CMIS XML Essentially… <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?> <entry xmlns=quot;http://www.w3.org/2005/Atomquot; xmlns:app=quot;http://www.w3.org/2007/appquot; xmlns:cmis=quot;http://www.cmis.org/2008/05quot; xmlns:alf=quot;http://www.alfresco.orgquot;> <cmis:object> <cmis:properties> <cmis:propertyId cmis:name=quot;ObjectIdquot;> <cmis:value> workspace://SpacesStore/56923743-7436-482e-b1cf-eda326d11dc2 </cmis:value> </cmis:propertyId> <cmis:propertyString cmis:name=quot;Namequot;> <cmis:value>Company Home</cmis:value> </cmis:propertyString> </cmis:properties> </cmis:object> <cmis:terminator/> </entry> 12/01/09 20
  • 21. Example #2: CMIS XML JavaScript // get a connector to the Alfresco Endpoint var connector = remote.connect(“alfresco”); // retrieve the company home folder var cmis = connector.get(“/api/path/workspace/SpacesStore”); // load XML into E4X var xml = new XML(cmis); // populate the model var properties = xml.*::object.*::properties; model.id = properties.(@name=“ObjectId”).*::value; model.name = properties.(@name=“Name”).*::value; FreeMarker Object id: ${id} <br/> Object name: ${name} 12/01/09 21
  • 22. Example #3: JSON JavaScript // get a connector to the Alfresco Endpoint var connector = remote.connect(“alfresco”); // retrieve a content object var nodeRef = “workspace://SpacesStore/56923743-7436-482e-b1cf-eda326d11dc2”; var data = connector.get(“/api/metadata?nodeRef=” + nodeRef); 12/01/09 22
  • 23. Example #3: JSON { quot;typequot;: quot;{http://www.alfresco.org/model/content/1.0}folderquot;, quot;aspectsquot;: [ quot;{http://www.alfresco.org/model/content/1.0}auditablequot;, quot;{http://www.alfresco.org/model/application/1.0}uifacetsquot;, quot;{http://www.alfresco.org/model/system/1.0}referenceablequot; ], quot;nodeRefquot;: quot;workspace://SpacesStore/56923743-7436-482e-b1cf-eda326d11dc2quot;, quot;propertiesquot;: { quot;{http://www.alfresco.org/model/application/1.0}iconquot;: quot;space-icon-defaultquot;, quot;{http://www.alfresco.org/model/content/1.0}descriptionquot;: quot;The company root spacequot;, quot;{http://www.alfresco.org/model/system/1.0}node-uuidquot;: quot;56923743-7436-482e-b1cf-eda326d11dc2 quot;{http://www.alfresco.org/model/system/1.0}node-dbidquot;: 15, quot;{http://www.alfresco.org/model/content/1.0}titlequot;: quot;Company Homequot;, quot;{http://www.alfresco.org/model/content/1.0}createdquot;: quot;Wed Sep 10 09:16:32 CDT 2008quot;, quot;{http://www.alfresco.org/model/content/1.0}modifierquot;: quot;Systemquot;, quot;{http://www.alfresco.org/model/content/1.0}modifiedquot;: quot;Wed Sep 10 09:17:19 CDT 2008quot;, quot;{http://www.alfresco.org/model/content/1.0}creatorquot;: quot;Systemquot;, quot;{http://www.alfresco.org/model/system/1.0}store-protocolquot;: quot;workspacequot;, quot;{http://www.alfresco.org/model/content/1.0}namequot;: quot;Company Homequot;, quot;{http://www.alfresco.org/model/system/1.0}store-identifierquot;: quot;SpacesStorequot; }, quot;mimetypequot;: quot;application/octet-streamquot; } 12/01/09 23
  • 24. Example #3: JSON JavaScript // get a connector to the Alfresco Endpoint var connector = remote.connect(“alfresco”); // retrieve a content object var nodeRef = “workspace://SpacesStore/56923743-7436-482e-b1cf-eda326d11dc2”; var data = connector.get(“/api/metadata?nodeRef=” + nodeRef); // create a javascript object from the json var json = eval('(' + data + ')'); // populate the model model.id = json.nodeRef; model.name = json.properties[“{http://www.alfresco.org/model/content/1.0}name“]; FreeMarker Object id: ${id} <br/> Object name: ${name} 12/01/09 24
  • 25. Proxy Services You can either use connectors directly or via a proxy Alfresco Surf provides a proxy servlet that uses this connector facility underneath the hood http://labs3c:8580/sample/proxy/{endpointId}/{uri} 12/01/09 25
  • 26. Proxy Services http://labs3c:8580/sample/proxy/alfresco/index • Identifies the “alfresco” endpoint • The base URI on the endpoint is “/alfresco/service” • This proxies through to: http://labs3c:8080/alfresco/service/index • User connector session state is stamped onto the proxied connection Optimizations • No buffering • Headers are captured and some retained if related to connector sessions • Input and output streams flow through 12/01/09 26
  • 27. Wrap-up In this module, you learned... • Useful JavaScript objects • Surf remoting concepts • How & why you'd use Surf's proxy • How to retrieve and work with XML and JSON returned by scripts in the Repository tier 12/01/09 Optaros and Client confidential. All rights reserved. 27