28.01.2013 Views

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

○ Ensure proper limits are in place on the maximum amount of memory that the XML processing engine<br />

can use, the amount of nested entities that the XML code can have, and the maximum length of entity<br />

names, attribute names, and so on. This practice helps prevent the triggering of potential issues.<br />

9.2.4 Writing Server-Side JavaScript Applications<br />

<strong>SAP</strong> <strong>HANA</strong> Extended Application Services (<strong>SAP</strong> <strong>HANA</strong> XS) supports server-side application programming in<br />

JavaScript. The server-side application you develop can use a collection of JavaScript APIs to expose authorized<br />

data to client requests, for example, to be consumed by a client GUI such as a Web browser including <strong>SAP</strong>UI5<br />

applications and mobile clients.<br />

Since JavaScript programs are stored in the <strong>SAP</strong> <strong>HANA</strong> repository, the steps in this task description assume that<br />

you have already created a workspace and a project (of type XS Project), and that you have shared the project<br />

with other members of the development team. To write a server-side JavaScript application, you must perform<br />

the following high-level steps.<br />

1. Create a root package for your application, for example, helloxsjs.<br />

2. Create an application descriptor for your application and place it in the root package you created in the<br />

previous step.<br />

The application descriptor is the core file that you use to describe an application's availability within <strong>SAP</strong><br />

<strong>HANA</strong> Extended Application Services. The application-descriptor file has no contents and no name; it only has<br />

the file extension .xsapp.<br />

Note: For backward compatibility, content is allowed in the .xsapp file but ignored.<br />

3. Create an application-access file and place it in the package to which you want to grant access.<br />

The application-access file does not have a name; it only has the file extension .xsaccess. The contents of<br />

the .xsaccess file must be formatted according to JavaScript Object Notation (JSON) rules and associated<br />

with the package the file belongs to. The rules defined in the .xsaccess file apply to the package it resides in<br />

as well as any subpackages lower in the package hierarchy.<br />

4. If you used the authorization keyword in the application-access file (.xsaccess) file for your application,<br />

create an application-privileges file for the application and define the application privileges.<br />

The application-privileges file does not have a name; it only has the file extension .xsprivileges. The<br />

contents of the .xsprivileges file must be formatted according to JavaScript Object Notation (JSON)<br />

rules. Multiple .xsprivileges files are allowed, but only at different levels in the package hierarchy; you<br />

cannot place two .xsprivileges files in the same application package. The privileges defined in<br />

a .xsprivileges file are bound to the package to which the file belongs and can only be applied to this<br />

package and its subpackages.<br />

Note: The .xsprivileges file lists the authorization levels available for granting to an application<br />

package; the .xsaccess file defines which authorization level is assigned to which application<br />

package.<br />

5. Create the server-side JavaScript files that contain the application logic.<br />

218<br />

You can use the available JavaScript APIs (for example, the database or request-processing API) to expose<br />

authorized data to client requests.<br />

P U B L I C<br />

© 2012 <strong>SAP</strong> AG. All rights reserved.<br />

<strong>SAP</strong> <strong>HANA</strong> <strong>Developer</strong> <strong>Guide</strong><br />

Writing Server-Side JavaScript Applications

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!