Content Demo
Archer provides two different ways to access content records, each with their own advantages and disadvantages.
Two ways to get content via Archer's APIs
The classic webservices SOAP API allows for searches to be conducted, much like what is available via the Advanced Search UI. This allows records to be retrieved based on conditional statements, similar to the WHERE clause in a SQL query.
The newer REST API allows content to be retrieved strictly by content Id. The REST API provides methods to return a single content record or a set of multiple records, but none of these methods support conditional searches the way the SOAP API does. In all cases you must already know the content Id(s) in question before calling the REST API "get content" methods.
Different use cases may make one approach preferable to the other, so neither can be said to be best in all circumstances.
The Content Demo application shows how to retrieve Archer content via each of the Archer APIs, using both of these approaches. It also highlights how Estrelica.Core can help you build complex queries for the Search API.
Unfortunately, the results returned by the two APIs are not interchangeable. The SOAP search API returns records as xml, while the REST content API returns records as JSON1. Each format requires a different skillset and a different way of parsing the result to extract the record details.
1 despite the documentation's claim that the REST API also supports xml results. All tests indicate that providing an "application/xml" Accept header only causes the Archer server to throw a 500 "Internal Server Error" exception.
Estrelica.Core to the rescue
Wouldn't it be preferable to have a single programming model to work with, so that you could use the same approach to evaluate content regardless of whether it was retrieved from the SOAP or REST API?
Estrelica.Core's Content resolver provides that capability, via a method named ContentAccess(). This may be called on the output of any and all of the methods discussed above. Whether it's an XElement node retrieved from the SOAP Search engine or a series of JSON dictionaries returned by any of the REST "get content by id" methods, ContentAccess() will convert it into an IArcherContentAccess object, which provides a common interface for working with Archer content, regardless of which format it was retrieved in.
The Content Demo application includes a demonstration of how ContentAccess() can be used to read Archer records very simply. The CHUM Tool and the User Access Processor also demonstrate its use.
Creating, updating and deleting records
When it's necessary to create new records, modify existing records, or delete records from the Archer system, Estrelica.Core's Content resolver handles that as well. The IArcherContentAccess interface includes a ForEdit() method which puts the record object into edit mode. While it's in this mode, it exposes a new IArcherContentEdit interface which provides editor classes for each of the editable Archer field types. These editor classes make it simple to deal with the different data types and constraints used by each of the field types.
The Content Demo application includes a demonstration of the full CRUD (Create, Read, Update, Delete) process using the ForEdit() method. It first inserts a record describing Estrelica.Core into the core "Applications" application, then reads it back to verify its field values, edits the record to change a few fields and performs a second readback verfication, then deletes the record.