[Owncloud] ownCloud News app API

Bernhard Posselt nukeawhale at gmail.com
Tue Jan 8 19:52:08 UTC 2013


On 01/08/2013 08:06 PM, Gregor Tätzner wrote:
> Hey lads,
>
> I was impatient, so I've started working on the external_api to have something 
> to play with:
>
> https://github.com/BrummbQ/apps/tree/news_externalapi/news
> branch: news_externalapi
>
> it's based on the new news_angularjs branch. Regarding the API calls in 
> routes.php I'm following this paper: 
> http://info.apigee.com/Portals/62317/docs/web%20api.pdf
> I think it's a good read.
>
> But before digging deeper, we should clarify things. alessandro was proposing 
> some kind of "business layer". Is it really necessary? Are there any 
> drawbacks? Whats about the overhead? I think performance is really important 
> here, but I'm no big php guy.
Overhead: One additional Object creation which can be neglected.

Benefit: It helps to avoid Code Duplication which improves Testability,
Stability and Maintainability.

The basic problem is: Our controllers return JSON or HTML, for the API
we'll likely need XML or a different JSON structure. Also, I dont want
to break the API if i need a different resultstructure for the website.

To not duplicate the logic in the controllers, the logic has to be put
into a seperate layer, the businesslayer, which will be called from both
the API and the controllers. There the proper return format is being
generated.
>
> OC_OCS_Result (that thing that constructs the api response) is rather 
> undemanding: It just needs a php array with key value pairs.
>
> so what do you think?
>

OC_OCS_Result will very likely be used in the API layer classes.
Businesslayer and OC_OCS_Result arent mutually exclusive.

To clarify how a request will work:

1. Some program (e.g. Akkregator) calls the link /news/api/items/all
2. This link will call ItemsAPI->all()
3. This will call the ItemsBusinessLayer->getAll()
4. This will call the ItemMapper->getAll() which executes an SQL statement
5. The returned entries from the DB will be put into simple PHP objects
and put into an array
6. The array will be returned back to the ItemsAPI->all() method, where
it is returned with something like: return OC_OCS_Result($items);




More information about the Owncloud mailing list