utilizing the open ntf domino api
TRANSCRIPT
![Page 1: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/1.jpg)
Boost your JAVA Code with the OpenNTF API
Oliver BusseWe4IT GmbH, GermanyMarch 17, 2016
![Page 2: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/2.jpg)
Oliver Busse• „Bleeding Yellow“ since R4.5• Software Architect at We4IT
• Member of the development team ofAveedo® Application Framework
• IBM Champion for ICS in 2015 + 2016• OpenNTF Member Director• XPages Advocate• IBM Bluemix curious
@zeromancer1972www.oliverbusse.com
![Page 3: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/3.jpg)
Agenda• What is the OpenNTF Domino API?• Setup and Implementation• Other Considerations• Tons of examples
![Page 4: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/4.jpg)
What is the OpenNTF Domino API?
![Page 5: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/5.jpg)
What is the OpenNTF Domino API?• It‘s an open source project on OpenNTF• It‘s was started in April 2013• It‘s maintained by generous developers you may know• It fills the gaps and gives the power you always wanted
in Java for Domino• It‘s often refered to as „ODA“
![Page 6: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/6.jpg)
What is the OpenNTF Domino API? (cont‘d)• The ODA consists of several packages• core• formula• rest• xsp• …
• It‘s an OSGi plugin• It‘s designed for running on the Domino server (9.0.x+)• It‘s designed for XPages (Java, SSJS) and Plugins• It can‘t be used in Java Agents
![Page 7: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/7.jpg)
Key developers of the ODA• Nathan T. Freeman• Paul S. Withers• Jesse Gallagher• Roland Praml• Martin Jinoch• René Winkelmeyer• Tim Tripcony (never forgotten)
![Page 8: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/8.jpg)
Setup and Implementation
![Page 9: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/9.jpg)
Resources• Grab it from OpenNTF (recommended)• http://www.openntf.org/main.nsf/project.xsp?r=project/
OpenNTF%20Domino%20API• Grab it from the Git-Repo• https://github.com/OpenNTF/org.openntf.domino
• Grab it from the OpenNTF Stash• https://stash.openntf.org/projects/ODA
![Page 10: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/10.jpg)
System Logging• Since the ODA is an OSGi plugin you can install it via the
update site mechanism• It runs as an extension to the XSP runtime on the HTTP
server JVM• It comes with it‘s own logger
![Page 11: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/11.jpg)
Setup: prepare the server• Set the signer of the NSF as „Sign or run…“
in server document‘s security section
![Page 12: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/12.jpg)
Setup: prepare the updatesite• Create an
updatesite NSF• Name it whatever
you want• Make sure you set
ACL to let the server READ documents
![Page 13: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/13.jpg)
Setup: import ODA into update site• Find the site.xml file to import it as a local
update site into your NSF• After import goto „Actions, Sign all
Content“
![Page 14: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/14.jpg)
Setup: add the ODA to server startup• Add a new line to your server‘s notes.ini file
• edit file manually or• use a configuration setting (prefered)
• OSGI_HTTP_DYNAMIC_BUNDLES=updatesite.nsf
![Page 15: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/15.jpg)
Setup: add the ODA to server startup• This is what you should see when the
server starts:HTTP JVM: CLFAD0330I: NSF Based plugins are being installed in the OSGi runtime. For more information please consult the log
• Check the plugins with– tell http osgi ss openntf
![Page 16: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/16.jpg)
Setup: prepare Domino Designer• Open DDE‘s preferences
• Goto „Domino Designer“ section• Activate „Enable Eclipse plug-in install“
• Open the update site NSF you just created• Goto „Actions, Show URLs“• Copy one of the two URLs to clipboard
• Goto „File, Application, Install“• Choose „Search for new features to install“• On the next screen „Add (a) Remote Location“• Enter a name for it and paste the URL in the clipboard• On the next screen check the ODA entry and click next/yes if you are asked to
![Page 17: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/17.jpg)
Other Considerations
![Page 18: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/18.jpg)
Other Considerations• ODA utilizes the OpenLog project• XspOpenLogUtil.logEvent(…)• XspOpenLogUtil.logError(…)
• Get familiar with the OpenLog project from OpenNTF• Create a new OpenLog.nsf file in your server‘s root (if
you haven‘t already)
![Page 19: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/19.jpg)
Examples
![Page 20: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/20.jpg)
Examples• Session handling• View handling (loops)• Document & Field handling• DateTime enhancements• Transactions• Xots• Graphs
![Page 21: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/21.jpg)
Session handling
![Page 22: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/22.jpg)
Session handling: different approaches• Extension Library• ExtlibUtil.getCurrentSession();• ExtlibUtil.getCurrentSessionAsSigner();• ExtlibUtil.getCurrentSessionAsSignerWithFullAccess();• needs exception handling
• XSPUtil• like ExtlibUtil• needs exception handling
• Factory• Factory.getSession();• uses enums for different session types• no exception handling needed!
![Page 23: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/23.jpg)
View handling
![Page 24: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/24.jpg)
View handling: what you are used to (1)
![Page 25: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/25.jpg)
View handling: what you are used to (2)
![Page 26: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/26.jpg)
What you now are able to do
![Page 27: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/27.jpg)
Document handling
![Page 28: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/28.jpg)
Safe lines of code by using new methods• New creation methods
• Database.createDocument(String, Object, …)• Database.createDocument(HashMap fields)
• Alternatives to replaceItemValue• Document.put(String field, Object o)• Document.putAll(HashMap fields)
• Alternatives to getItemValueXXX• Document.get(Object o) // document acts like a Map<?>• Document.getItemValue(String field, Class type)
![Page 29: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/29.jpg)
getItemValue: what you are used to• getItemValue returns a Vector• Vectors are not type save• editor / compiler complains non-type-safety• they can contain „anything“• you have to check what is inside
• if the item does not exist you are running into trouble…
![Page 30: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/30.jpg)
getItemValue: what you can do now• cast to a type of your choice
• ArrayList<?> values = doc.getItemValue(„foo", ArrayList.class);
• forget type safety• define your own!
• a non existing item is returned as null, not as empty Vector• can be handled
![Page 31: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/31.jpg)
DateTime enhancements
![Page 32: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/32.jpg)
DateTime enhancements• Session.createDateTime(y,m,d,hh,mm,ss)• uses int values
• conversion toJavaDate() not necessary• DateTime.isBefore();• DateTime.isAfter();
• useful comparisons• DateTime.equalsIgnoreDate();• DateTime.equalsIgnoreTime();
![Page 33: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/33.jpg)
Transactions
![Page 34: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/34.jpg)
Transactions• ODA adds transactional capabilities to your
Notes data• You can modify documents without saving
them individually (e.g. in a loop)• You can also rollback every modification if
you need to (e.g. when you run into an error)
![Page 35: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/35.jpg)
Transactions (cont‘d)• Create a new DatabaseTransaction object from the
database• DatabaseTransaction txn = db.startTransaction();
• Perform your modifications• Decide whether to commit or rollback• txn.commit();• txn.rollback();
![Page 36: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/36.jpg)
Xots
![Page 37: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/37.jpg)
Xots• Xots = XPages OSGi Tasklet Service• It‘s the extended version of DOTS (Domino Tasklet
Service)• Use cases• Can be coded inside the NSF, no plugin project needed• Multi-threaded tasks like Runnable, but you can return values• Bulk execution of time consuming code
• very new feature (alpha)
![Page 38: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/38.jpg)
Xots (cont‘d)• Advantages• More granular time and event triggering than in Agents• Can run with server-side permissions• Runs in a shared container (JVM) unlikely of an Agent which
runs in a dedicated JVM• you can exchange data between tasklets• It‘s coded in a plain Java class and not in an Agent design
element• You can use SCM systems
![Page 39: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/39.jpg)
Xots (cont‘d)• Core elements of tasklet
• Interface Callable<?>• Interface Future<?>
• get() method to get the return value(s)• only if you are interested in a return value
• Class Xots from the ODA• submit() method to create a tasklet• schedule() methods to create a periodic tasklet
• use the PeriodicScheduler!
![Page 40: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/40.jpg)
„Graphs“
http://whatis.techtarget.com/definition/graph-database
![Page 41: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/41.jpg)
Graph DBA graph database, also called a graph-oriented database, is a type of NoSQL database that uses graph theory to store, map and query
relationships.
A graph database is essentially a collection of nodes and edges. Each node represents an entity (such as a person or business) and
each edge represents a connection or relationship between two nodes.
http://whatis.techtarget.com/definition/graph-database
![Page 42: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/42.jpg)
Graphs – terminology• Vertices (Nodes)• Properties (Key-Value pairs)
• Edges• Connections, Relations between Vertices
• ElementStores• for us: NSF databases
• MetaverseIDs• Replica + UNID (hashed)• internal use only (don‘t care about them)
![Page 43: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/43.jpg)
Graph DB – in Domino?• Vertices and Edges are stored as Documents• The data container is a NSF• The ElementStore defines the filepath to the NSF• An ElementStore can hold different types of Vertices• Usually you create one ElementStore for each Vertice
type
![Page 44: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/44.jpg)
Let‘s see the demo &some code
![Page 45: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/45.jpg)
Resources• The XPages demo application
• https://bitbucket.org/zeromancer1972/sutol-2015-oda-graph-demo• A nice glossary
• http://www.intec.co.uk/from-xpages-to-web-app-glossary/• OpenNTF Domino API
• http://www.openntf.org/main.nsf/project.xsp?r=project/OpenNTF%20Domino%20API• http://www.openntf.org/main.nsf/project.xsp?r=project/OpenNTF%20Domino%20API%20Demo
%20Database• Xots
• http://www.intec.co.uk/xots-background-and-multithreaded-tasks-the-openntf-domino-api-way-part-one/
• http://www.intec.co.uk/xots-background-and-multithreaded-tasks-the-openntf-domino-api-way-part-two/
• http://www.intec.co.uk/xots-background-and-multithreaded-tasks-the-openntf-domino-api-way-part-three/
• Graphs• http://de.slideshare.net/ktree19/the-graph-revolution
![Page 46: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/46.jpg)
Q & A
![Page 47: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/47.jpg)
Thank you!
![Page 48: Utilizing the open ntf domino api](https://reader035.vdocuments.site/reader035/viewer/2022062316/58eb84951a28abbf788b45cb/html5/thumbnails/48.jpg)
www.we4it.com