[ 
http://jira.amdatu.org/jira/browse/AMDATU-208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=10473#comment-10473
 ] 

Angelo van der Sijpt commented on AMDATU-208:
---------------------------------------------

I believe that considering the _combined_ API the wrong approach here.

We have TenantManagementService as an API, and TenantStorageProvider as an SPI, 
which are governed by different rules:
- the API is intended to make life easier for a user of the service, 
encapsulating the logic decisions for this service (e.g., if a tenant does not 
exist, return null), and 
- the SPI is intended to make life easier for the provider of a storage 
service, e.g. by not differentiating between creates and updates, and not 
worrying about uniqueness-rules.

I agree with Bram that if we decide to make this change, we should document it 
somewhere as the default pattern for these kind of 'two-staged' repository 
services.

> Refactor CRUD API of Tenant services to be consistent with retuning null and 
> throwing checked exceptions
> --------------------------------------------------------------------------------------------------------
>
>                 Key: AMDATU-208
>                 URL: http://jira.amdatu.org/jira/browse/AMDATU-208
>             Project: Amdatu
>          Issue Type: Task
>          Components: Amdatu Core - Tenant
>    Affects Versions: 0.1.0
>            Reporter: Ivo Ladage - van Doorn
>            Assignee: Ivo Ladage - van Doorn
>             Fix For: 0.1.0
>
>
> The current CRUD API of the (combined) TenantManagementService and 
> TenantStorageProvider uses the following inconsistent approach:
> create(id)  -> returns null if an entity with that id already exists
> update(id) -> creates a new entity if it didn't exist yet
> delete(id)  -> throws checked exception if it doesn't exist
> get(id)       ->  returns null if it doesn't exist
> I believe this is not consistent and not correct. IMHO this is how a typical 
> CRUD API should look like:
> create(id)  -> throws checked AlreadyExistsException if an entity with that 
> id already exists
> update(id) -> throws checked NotFoundException if an entity with that id does 
> not exist
> delete(id)  -> throws checked NotFoundException if an entity with that id 
> does not exist
> get(id)       -> returns null OR throws checked NotFoundException if it 
> doesn't exist (either of the two seems ok to me) 

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to