HP ANYWHERE Enterprise Mobility Platform

needlessoybeanΚινητά – Ασύρματες Τεχνολογίες

10 Δεκ 2013 (πριν από 3 χρόνια και 8 μήνες)

176 εμφανίσεις

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

HP Anywhere


Hackathon

Tech
O
verview


Adi Ofry

System Architect

October 2013

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

Architecture Overview

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

3

Architectural Overview

IDE

HPA Container

HPA Platform

Enterprise App Store

On Premise and Cloud Sources

Dev

Zone

Apps

Developer Platform

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

4

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

HP Anywhere Client

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

7

Client Side Perspective


Bring
your own Javascript
framework:


Angular


Jquery

Mobile


Sencha


Enyo.js


Other …




Map your dependencies and resources in descriptor file and you're good to go.



You can write responsive application or separate between different form
-
factors:
SmartPhone
, Tablet,
Desktop.



© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

8

Client Side API


Besides the app resources, a set of APIs are automatically injected.



These
APIs are ‘
namespace’d

with HPA, and are mainly about:


Localization


User Profile


Device Capabilities


User Messages


Collaboration


© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

9

Mandatory API Implementation


Each app must implement minimal set of API in order to communicate with the framework.



function
openEntryPoint
(
ep
,
params
,
cb
, scope
)


The framework direct commands to the app through this
call.



HPA.framework.
setReady
(true
)
-

The app notifies the framework that it finished its loading and is ready to
accept commands.



Note, that only after you call
setReady

openEntryPoint

will be called by the container.



© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

Starting Development

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

11

How Do I Get User Information?


HPA.Profile.
getInfo
()


this method returns the current user data:


ID


Display Name


E
-
mail


Job
-
Title


Origin (internal/external)


URLs of user avatar in different sizes



For example getting the user display name:


HPA.Profile.
getInfo
().
displayName

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

12

Adapting To Different Locals


Under I10n








Place a <APP_ID>_<locale code>.properties


events.listTitle
=My Events



And to get it:


Client:

HPA.I18n.localize
('
events.listTitle
')


Server:
this.getString
(
userLocale
,

events.listTitle
”);

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

13

Define User Settings


<App ID>
-
user
-
settings.xml

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

14

Getting the Settings


var

sortOrderSettingValue

=


params.settings
['
events.sortSettings
']['
events.sortSettings.sortBy
'][0];

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

15

Using Device Capabilities


We can get Device Info by calling
PhoneGap

api

or calling HPA wrapping of the
api
.



You have two options:

1.
console.info("name= " + HPA.Device.deviceInfo.name
);

2.
HPA.Message.info(
window.parent.device.model
);



Connect from mobile or tablet to http://YOUR_IP:8080 go into your app and try to call the device info.



http://docs.phonegap.com/en/2.7.0/index.html



With HPA you can call
HPA.Device.deviceInfo

even from chrome. But the
PhoneGap

api

will fail since it
supports only mobile/tablet devices.




© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

HP Anywhere Server Side API

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

17

Extend and implement the Main App Service


Every app needs to extend
AbstractBTOServiceEE

@Service("Report")

public class
MainApp

extends
AbstractBTOServiceEE

{




}

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

18

Server API


To support HPA framework business logic you can (optional) implement special
apis

for example:



//Will add the support email to recommended users for conversation


public
Collection<
UserProfile
>
getRelatedUsers
(
Collection<
BTOContext
>
btoContexts
) throws
CustomException

{


Collection<
UserProfile
> output
= new
HashSet
<
UserProfile
>();


UserProfile

profile =
UserProfileFactory.createProfile
(
Consts.SUPPORT_EMAIL
);




output.add
(profile
);




return output;



}



© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

19

descriptor.xml

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

20

Implement some service that your client can call


Example for Spring REST service with all of the framework items injected:








You can return or get java beans which are serialized automatically to JSON for: the client

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

21

Java service (cont.)


You can interact with the client with plain text:


© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

22

Send Notification to client


Sometimes you want to create a new front page item for the user and send (push) notification to him so he
will open the relevant app.


You can do that by POST to a HPA REST service:

http://serverIp:serverPort/diamond/rest/api/V2/apps/<app name>/events


You need to send a JSON body


{


“id”: “eventId1”,



contextObjects
”: [ … ],


“message”: “The message to the user”,


“users”: [ { “id”: “adi@hp.com”, “
isNotify
”: “true” , …. } ]


“visibility”: “PRIVATE”,



notificationType
”: “
new.event.notification
”,


“subject”: “The relevant subject for the notification”

}


© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

23

Server Key Value Store Service


You can store information in the server side which is good for long term persistency or short term cache by
using the
KeyValueStorageService

in the server side.







Where:


Category

is like a schema (each app will use a different category).


Key

is the name of the item you want to save


Value

is the data you
wan$t

to save


TTL

is the time to keep the data in seconds. It will be removed automatically after the time period unless
given a
null

value.



© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

HP Anywhere Tips

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

25

CSRF Defence


HP Anywhere protect itself against CSRF attack.



In order to succeed doing a PUT / DELETE/ POST http requests to the server you must add X
-
CSRF
-
HPMEAP
header to any of these requests with any value inside it.



For example in angular:


$
http.defaults.headers.common
[
'X
-
CSRF
-
HPMEAP'
]='FROM
-
MINI
-
APP';


© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

26

Working with the simulator


Disable Cache in chrome when debugging and don’t forget to enable it back later and check for side effects



When working in simulator the app gets a version for cache. Every time to refresh the browser you get a
different version. So its hard to place a breakpoint in chrome. Just add a
debugger

line in the code, so it will
break there.



Default user & pass for the installed server is “admin”.



Changing configuration requires a rebuild of the app.


© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

HP Anywhere Specific
Functionality

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

28

Concepts


Activity



A new
engagement

around some
app instance
. The activity will pop up in your front page.



Entry Point


A place to jump into your app. It could be the top place which is the default or specific
deep link
into a page or applicative point.



Context Object


A
data object
to persist and to be share between apps.



Collaboration



A conversation going on at the
timeline
.


© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

29

Create Context Object On First Collaboration


Start of by telling the framework that you want
hasAutoContext

= true



HPA.Framework.setReady
({
hasDefaultAction
: true,
hasAutoContext
:
true
});

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

30

Saving Client State


State may be any value /
Json

you want to save.



State is saved per:


Activity


User


Entry
-
Point (app


page)



You may save state at any time.



When user returns to the activity the last saved state is loaded


© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

31

Saving Client
State
-

Example


Saving:





Loading in
openEntryPoint
:

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

32

Create Context Object And Add To Activity


Context Object (the business entity) is added to Activity (a front page item instance)

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

34

Getting Started


http://developer.hpanywhere.com/all
-
you
-
need
-
for
-
hackathon
/



HP Anywhere IDE



Events Cookbook App



HP Anywhere
api

docs





© Copyright 2012 Hewlett
-
Packard Development Company, L.P. The information contained herein is subject to change without notice
.

Thank you