1. Trang chủ
  2. » Công Nghệ Thông Tin

Quản lý cấu hình web - part 33 docx

10 197 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 5,85 MB

Nội dung

Alfresco Surf and Web Editor [ 302 ] When you click on the Edit icon, it will open the window in which you can edit the title, description, or content. This window is using Alfresco's form service. You can specify which form ID you want to use for in-context editing. As described in the earlier section, with the markContent tag, you can specify the formId attribute, which species the form to use for in-context editing. For example: <awe:markContent id="<%=<<NODEREF>>%>" formId="description" title="Edit News Description" nestedMarker="true" /> Download the customer.war with modied les from the Packt website. Web Editor Framework Web Editor Framework consists of core components and UI widgets. The framework allows you to easily develop and add the plugin. This is achievable because of the nature of the framework, which is supplied by the support of hooks around core methods. The web editor is an event-driven framework. Every core method of a plugin res a before and an after event for that method. Download from Wow! eBook <www.wowebook.com> Chapter 9 [ 303 ] Core WEF Components The Core WEF Components are as follows: • WEF: The WEF object is responsible for bootstrapping the Web Editor framework onto the page. • Loader: The loader is responsible for setting up resources for modules (and any of their dependencies) to be loaded by the browser. • CongRegistry: The CongRegistry object is responsible for maintaining a registry of conguration objects for a specied plugin. • PluginRegistry: The PluginRegistry maintains a registry of plugins. • Base: The WEF.Base is the core class that all WEF components are based on. • Plugin: The Plugin component builds on Base and every plugin is expected to be the one that extends Plugin or one of its subclasses. • Widget: A widget is a UI element that can be interacted with. A dialog is a good example of a widget. • App: An App is just a plugin and adds no additional methods of its own. Core WEF Widgets The Core WEF Widgets are as follows: • Ribbon: The Ribbon component is responsible for displaying the ribbon at the top of the page and also for managing and/or registered toolbars and plugins. • Toolbar: The Toolbar component is a simple component that manages a collection of buttons. • Tabbed Toolbar: The Tabbed Toolbar manages a collection of toolbars that are rendered in different tabs. For more details on WEF, refer to the link: http://wiki. alfresco.com/wiki/Web_Editor_Framework. Summary The Alfresco Surf platform and tools are designed to help users create the next-generation WCM platform that covers both core management aspects and delivery capabilities. The Alfresco Web Editor is a Surf-based application incorporating the Alfresco Form Engine, which facilitates in-context editing of Alfresco repository content. Download from Wow! eBook <www.wowebook.com> Download from Wow! eBook <www.wowebook.com> Integrating WCM Using Web Scripts In this chapter, we will learn about web scripts and integration of WCM with external systems using web scripts. In previous chapters, you got an idea about why to use WCM, how to create web projects, and how to produce content in Alfresco WCM along with deployments to a different server. So far we discussed how we use Alfresco as a content production and delivery system and for serving the content. You may have your own application and may want to use Alfresco purely for web content management, which will just produce the content in Alfresco. But the presentation part of the application will not be handled by Alfresco. Here you can have your frontend application in any technology and you can use Alfresco WCM as the backend, which will serve the content to your application. Web script's RESTful service is one of the most easily available and widely used solutions to integrate the Alfresco WCM with any external system or application. By the end of this chapter, you will have learned about: • REST architecture • Web script framework in Alfresco • Components of web scripts • WCM-specic JavaScript and template APIs • Implementing web scripts in Alfresco • Using web scripts to integrate Alfresco WCM with any external system or application Download from Wow! eBook <www.wowebook.com> Integrating WCM Using Web Scripts [ 306 ] Concepts of WCM web scripts In this section, you will get an overview of web scripts in WCM. We will talk about the REST architecture and web script framework in Alfresco. We will also talk about the new features introduced for web scripts in Alfresco 3. At the end of this section, you will have a very good idea about the architectural benets of using RESTful web services, how it helps in providing solutions with the Alfresco WCM, and also how easy it is to integrate WCM with an external system. Overview of REST architecture In this section, we will discuss about the REST architecture and RESTful web services. You will also get an idea about how RESTful web services are different than our traditional SOAP-based web services and the advantages of using this approach over a traditional SOAP-based approach. What is REST REST (Representational State Transfer) is used to describe a Web Oriented Architecture rather than a Service-Oriented Architecture. It is an architectural style following the principles referred to as "RESTful". RESTful web services are resource-oriented services. You can identify and locate resources by a Uniform Resource Identier (URI). By making everything URL (URI)-based, you can access everything via that URL and use standard web commands such as Get and Post to access and update those things, something we call resources. REST's main principles • Resource-oriented states and functionalities that are abstracted into resources • Unique way of identifying resources • The idea of how operations on these resources are dened in terms of a single protocol for interacting with resources • A protocol that is client-server, stateless, cacheable, and layered • REST-oriented system design leads to systems that are open, scalable, extensible, and easy to understand Download from Wow! eBook <www.wowebook.com> Chapter 10 [ 307 ] This URL-based update of information contrasts with a very Remote Procedure Call- like interface of SOAP. The following points give an idea about how RESTful web services differ from SOAP-based web services: • Design approach: REST focuses on resources, whereas web services focus on messages, which are operations. • Less dependencies as there is no SOAP required. • Cacheable representation leads to improved response time and reduced server load. • No need for a separate resource directory due to the use of hyperlinks in representations. • Improves server scalability by reducing the need to maintain session state. This means that different servers can be used to handle different requests in a session. Alfresco web scripts overview Alfresco provides a web script framework based on REST architecture, which was described in the earlier section. RESTful web scripts provide a very suitable and exible solution to integrate Alfresco with any other application, and is usually the best solution out of all of the available options. With the help of web scripts, you can easily access the Alfresco repository and perform operations such as content searching, retrieval, manipulation, and so on with the help of services available in Alfresco, even from outside Alfresco. What is a web script A REST web script is simply a service bound to a URI and based on HTTP. So the technology that the external application is implemented on is irrelevant, that is, they are cross platform and cross language. You are not locked into any programming language or development environment. The web script framework lets you roll your own APIs, thereby allowing you to ne- tune the remote APIs that you expose to the external application. REST provides a convenient bridge between any native application and the content management. This allows you to place controls on your enterprise content to manage it and at the same time provide uniform access for a wide variety of client applications and services, such as browser, portal, search engine, or custom application. Download from Wow! eBook <www.wowebook.com> Integrating WCM Using Web Scripts [ 308 ] Why to use web scripts The advantages of using a web script for integrating external applications with Alfresco WCM are: • Build custom URI-identied and HTTP-accessible content management web services • Turn your Alfresco repository into a content management-powered HTTP server • Instead of having a single, monolithic system responsible for all aspects of a content-centric web application, this provides a design of loosely coupled sub-systems that are being integrated to create more agile solutions • This approach allows your content management system (Alfresco WCM) to have a exible and lightweight interface • Provides the exibility of not being locked into a presentation approach based on the content repository • Uses lightweight scripting technologies such as JavaScript and FreeMarker Alfresco web script framework Alfresco's web script framework follows the Model-View-Controller (MVC) pattern, which makes a developer's life easy. The Model-View-Controller design pattern decouples data access, business logic, and data presentation. By applying the MVC pattern, you can separate core business model functionality from the presentation and control logic that uses this functionality. Such separation allows multiple views to share the same enterprise data model, which makes supporting multiple clients easier to implement, test, and maintain. Download from Wow! eBook <www.wowebook.com> Chapter 10 [ 309 ] As shown in the previous gure, the Controller here is the server-side JavaScript. It can also be JavaBeans or a combination of both. The request rst comes to the REST Dispatcher, and Web script Run Time forwards this to the Controller, which is responsible for processing the request. It performs the required business logic with the help of Alfresco core services and populates the model with data, and then forwards the request to the View. A View is one or more FreeMarker templates and is responsible for generating the response in the proper format (XML, HTML, JSON, and so on) as a presentation layer. Finally, the Web script Run time will send the response back to the client. • Controller: JavaScript/JavaBeans • View: One or more FreeMarker templates • Model: Data structure, used to pass data between View and Controller What's new in Alfresco 3 web scripts Alfresco has introduced web scripts framework in older versions such as 2.1. With new releases of Alfresco, efforts are being made to enhance the capabilities of web scripts. Following are some of the enhancements for web scripts available from Alfresco 3 onwards: • Standalone component With this new Alfresco version 3, the web script architecture is refactored in such a way that you need not use the Alfresco repository server to host, but you can host it in any environment and even in tiers. This will allow web scripts to be used in a presentation layer to render UI. For example, the Alfresco Surf platform hosts the web script framework for reusable UI components. • URI templates comply with JSR-311 (JAX-RS) A URI template is simply a URI containing tokens that may be substituted with actual values. From Alfresco 3.0, this template syntax complies with the template syntax of JSR-311 (JAX-RS). • Run as user You can use the runas attribute with authentication in the description document for a web script. This will allow declaring an alternative username to run the web script, as this is valid for class path-stored web scripts only. • Ability to customize web scripts with web script-specic conguration Conguration is accessed via the config root object, which is available during both controller script and template execution. So, with the help of this, you can have web script-specic conguration, which can then be used in a controller or rendering template. Download from Wow! eBook <www.wowebook.com> Integrating WCM Using Web Scripts [ 310 ] • Per web script message bundle To localize the web script response, with Alfresco 3.0 and later, you can have a message bundle for each web script. • Improved form processing When posting a request of mime type multipart/form-data, formdata is available to the controller script as a root object. This root object allows a web script to read all elds. These multi-part form elds are also mapped to args/argsM. • Access to request headers With this version, Alfresco provides one more JavaScript root object named headers, which is an associative array of all request headers. In this way, you can access the request header as well from the web script controller script. • Request body processing The root object requestbody, which represents the content of a request body, is available with Alfresco 3. • Content negotiation You can have a negotiate element in a description document, which associates an Accept header mime type to a specic web script format of response; the value (mandatory) species the format while the accept attribute (mandatory) species the mime type. You can have zero or more negotiation elements, but to enable content negotiation you need the denition of at least one negotiate element. • Declarative and programmatic cache control You can have a cache element specied in the description document (declarative) for caching and set some child elements to congure the cache. Also, you can have a cache root object available in the controller, which helps to control the cache runtime (programmatic). You can override some denition time controls and also set expiry criteria with this root level object cache. • Web script families If you want to categorize similar or related web scripts in groups, you can congure a family element in the description document. The family tag may be repeated if the script belongs to more than one family. • Specialized kinds of web scripts A web script "kind" allows a Java-backed implementation to be named, and for any web script description document to state if it wants to use that implementation instead of the out-of-the-box one provided by Alfresco. Download from Wow! eBook <www.wowebook.com> Chapter 10 [ 311 ] Using web scripts with Alfresco WCM As described in Chapter 1, A Publishing Style Web CMS, Alfresco WCM is used for content production and content delivery. Alfresco supports two main models for content delivery—static and dynamic. With the dynamic delivery model, content is served from Alfresco; however, the rendering part will not be handled by it, but by some other application. This provides exibility in deciding what content to display and how it will be displayed on a page. Basically, a web script will act as a communication channel to fetch the content, which is being stored in Alfresco. With the dynamic content delivery model, content will be published to an Alfresco Runtime (as shown in the following gure) with ASR deployment, thereby making the content available for dynamic queries by basically any web technology (J2EE, PHP, Python, .NET, AJAX, Flash, Cold Fusion, and so on). Here the web script is a remote API used to query and retrieve the content from Alfresco Runtime: Download from Wow! eBook <www.wowebook.com> . FreeMarker Alfresco web script framework Alfresco's web script framework follows the Model-View-Controller (MVC) pattern, which makes a developer's life easy. The Model-View-Controller design. out-of-the-box one provided by Alfresco. Download from Wow! eBook <www.wowebook.com> Chapter 10 [ 311 ] Using web scripts with Alfresco WCM As described in Chapter 1, A Publishing Style Web. REST architecture • Web script framework in Alfresco • Components of web scripts • WCM-specic JavaScript and template APIs • Implementing web scripts in Alfresco • Using web scripts to integrate

Ngày đăng: 05/07/2014, 20:21

w