Does your application open or save files? Maybe it does both. Does it support saving files to Box? What about SharePoint, a corporate file share or any other CMIS-based (Content Management Interoperability Services)? It may seem like supporting all of these options would mean a lot of work. Supporting them all individually would be just that; unless you make use of the BEMS (BlackBerry Enterprise Mobility Server) Docs Service.
The BEMS Docs Service supports all the storage options mentioned above. It exposes them using a common REST interface that you can easily access in any BlackBerry Dynamics application. I’m going to cover a few features in this blog post, but for a full list of the BEMS Docs Service APIs, refer to the Docs REST API Documentation.
To jump straight to sample applications you can try, we have an Android sample and iOS Sample available. Let’s walk through the Android sample called BEMSDocsServiceSample.
Discovering the Docs Service
BEMS is discoverable by BlackBerry Dynamics applications using the BlackBerry Dynamics service discovery. This isn’t specific to BEMS, but is a method any local or remote service can advertise itself. UEM administrators have the capability to enable and disable these services for UEM users. The first few steps use service discovery to determine if the user’s BlackBerry Dynamics environment has an active BEMS Docs service that they are entitled to use. We query for this using the getServiceProvidersFor method.
The BD Authentication Token is received by the application in the onGDAuthTokenSuccess callback method of the DocsList class in the sample app. Now that it has the token, the app can add it to the HTTP requests made to the BEMS servers like this:
After receiving the BD Authentication Token, the sample application makes a REST call to BEMS to obtain a list of repositories. After adding the headers, the REST call is a pretty simple one:
The BEMSDocsServiceSample keeps track of the current directory the user is viewing. This allows for easy navigation into and back out of directories in a storage system. To view the files and folders in a storage system it appends those values to the base URL.
//Creates the request to list files in a specified directory.
//Check if we are going into a new directory or back a level
//Append the requested repo/directory to the end of the current path.
pathCrumbs += "/"+ Uri.encode(path);
//Add the current path to the end of the request URL.
String url = "/docs/1"+ pathCrumbs;
//Load the URL.
JSON is returned that lists available storage systems, or files and directories if a path is added to the end of the requested URL. BEMSDocsServiceSample parses this in the parseList method and triggers display of the result in a list shown to the user.
These basic steps should get you started with integrating the BESM Docs Service into your application. Have a look at the Docs REST API Documentation and explore the other features of these samples.
About Mark Sohm
Senior Technical Solutions Manager on the Solution Architects team.
Mark Sohm joined BlackBerry in 2003 and currently works as a Senior Technical Solutions Manager on the Solutions Architects team. Mark Sohm has been helping developers create applications using BlackBerry technologies for over 15 years, starting way back with the very first BlackBerry JDK on BlackBerry OS 3.6 through to BlackBerry 10 and now Android with BlackBerry Dynamics and Android Enterprise.
functioning of the site, while others are to help us understand how you use it. Read more here about our cookies, and how you can