Mercurial > lada > lada-server
changeset 261:07c4186cbfab
Enable read access on all objects for authorized users.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Tue, 16 Jul 2013 11:18:05 +0200 |
parents | 0de24f5e7c01 |
children | f4b359aa9127 |
files | src/main/java/de/intevation/lada/rest/LKommentarMService.java src/main/java/de/intevation/lada/rest/LKommentarService.java src/main/java/de/intevation/lada/rest/LMessungService.java src/main/java/de/intevation/lada/rest/LMesswertService.java src/main/java/de/intevation/lada/rest/LOrtService.java src/main/java/de/intevation/lada/rest/LStatusService.java src/main/java/de/intevation/lada/rest/LZusatzwertService.java |
diffstat | 7 files changed, 45 insertions(+), 66 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/rest/LKommentarMService.java Tue Jul 16 08:24:34 2013 +0200 +++ b/src/main/java/de/intevation/lada/rest/LKommentarMService.java Tue Jul 16 11:18:05 2013 +0200 @@ -79,15 +79,12 @@ return new Response(false, 609, new ArrayList<LKommentarM>()); } String probeId = params.getFirst("probeId"); - if (authentication.hasAccess(headers, probeId)) { - QueryBuilder<LKommentarM> builder = - new QueryBuilder<LKommentarM>( - repository.getEntityManager(), LKommentarM.class); - builder.and("probeId", probeId) - .and("messungsId", params.getFirst("messungsId")); - return repository.filter(builder.getQuery()); - } - return new Response(false, 698, new ArrayList<LKommentarM>()); + QueryBuilder<LKommentarM> builder = + new QueryBuilder<LKommentarM>( + repository.getEntityManager(), LKommentarM.class); + builder.and("probeId", probeId) + .and("messungsId", params.getFirst("messungsId")); + return repository.filter(builder.getQuery()); } catch(AuthenticationException ae) { return new Response(false, 699, new ArrayList<LKommentarM>());
--- a/src/main/java/de/intevation/lada/rest/LKommentarService.java Tue Jul 16 08:24:34 2013 +0200 +++ b/src/main/java/de/intevation/lada/rest/LKommentarService.java Tue Jul 16 11:18:05 2013 +0200 @@ -118,14 +118,11 @@ return new Response(false, 609, new ArrayList<LKommentarP>()); } String probeId = params.getFirst("probeId"); - if (authentication.hasAccess(headers, probeId)) { - QueryBuilder<LKommentarP> builder = - new QueryBuilder<LKommentarP>( - repository.getEntityManager(), LKommentarP.class); - builder.and("probeId", probeId); - return repository.filter(builder.getQuery()); - } - return new Response(false, 698, new ArrayList<LKommentarP>()); + QueryBuilder<LKommentarP> builder = + new QueryBuilder<LKommentarP>( + repository.getEntityManager(), LKommentarP.class); + builder.and("probeId", probeId); + return repository.filter(builder.getQuery()); } catch(AuthenticationException ae) { return new Response(false, 699, new ArrayList<LKommentarP>());
--- a/src/main/java/de/intevation/lada/rest/LMessungService.java Tue Jul 16 08:24:34 2013 +0200 +++ b/src/main/java/de/intevation/lada/rest/LMessungService.java Tue Jul 16 11:18:05 2013 +0200 @@ -77,15 +77,12 @@ return new Response(false, 609, new ArrayList<LMessung>()); } String probeId = params.getFirst("probeId"); - if (authentication.hasAccess(headers, probeId)) { - QueryBuilder<LMessung> builder = - new QueryBuilder<LMessung>( - repository.getEntityManager(), - LMessung.class); - builder.and("probeId", probeId); - return repository.filter(builder.getQuery()); - } - return new Response(false, 698, new ArrayList<LMessung>()); + QueryBuilder<LMessung> builder = + new QueryBuilder<LMessung>( + repository.getEntityManager(), + LMessung.class); + builder.and("probeId", probeId); + return repository.filter(builder.getQuery()); } catch(AuthenticationException ae) { return new Response(false, 699, new ArrayList<LMessung>());
--- a/src/main/java/de/intevation/lada/rest/LMesswertService.java Tue Jul 16 08:24:34 2013 +0200 +++ b/src/main/java/de/intevation/lada/rest/LMesswertService.java Tue Jul 16 11:18:05 2013 +0200 @@ -81,15 +81,12 @@ return new Response(false, 609, new ArrayList<LMesswert>()); } String probeId = params.getFirst("probeId"); - if (authentication.hasAccess(headers, probeId)) { - QueryBuilder<LMesswert> builder = - new QueryBuilder<LMesswert>( - repository.getEntityManager(), LMesswert.class); - builder.and("probeId", probeId) - .and("messungsId", params.getFirst("messungsId")); - return repository.filter(builder.getQuery()); - } - return new Response(false, 698, new ArrayList<LMesswert>()); + QueryBuilder<LMesswert> builder = + new QueryBuilder<LMesswert>( + repository.getEntityManager(), LMesswert.class); + builder.and("probeId", probeId) + .and("messungsId", params.getFirst("messungsId")); + return repository.filter(builder.getQuery()); } catch(AuthenticationException ae) { return new Response(false, 699, new ArrayList<LMesswert>());
--- a/src/main/java/de/intevation/lada/rest/LOrtService.java Tue Jul 16 08:24:34 2013 +0200 +++ b/src/main/java/de/intevation/lada/rest/LOrtService.java Tue Jul 16 11:18:05 2013 +0200 @@ -80,21 +80,18 @@ return new Response(false, 609, new ArrayList<LOrt>()); } String probeId = params.getFirst("probeId"); - if (authentication.hasAccess(headers, probeId)) { - QueryBuilder<LOrt> builder = - new QueryBuilder<LOrt>( - repository.getEntityManager(), LOrt.class); - builder.and("probeId", probeId); - Response response = repository.filter(builder.getQuery()); - List<LOrt> list = (List<LOrt>) response.getData(); - boolean readonly = authorization.isReadOnly(probeId); - for (LOrt ort: list) { - ort.setReadonly(readonly); - } - response.setData(list); - return response; + QueryBuilder<LOrt> builder = + new QueryBuilder<LOrt>( + repository.getEntityManager(), LOrt.class); + builder.and("probeId", probeId); + Response response = repository.filter(builder.getQuery()); + List<LOrt> list = (List<LOrt>) response.getData(); + boolean readonly = authorization.isReadOnly(probeId); + for (LOrt ort: list) { + ort.setReadonly(readonly); } - return new Response(false, 698, new ArrayList<LOrt>()); + response.setData(list); + return response; } catch(AuthenticationException ae) { return new Response(false, 699, new ArrayList<LOrt>());
--- a/src/main/java/de/intevation/lada/rest/LStatusService.java Tue Jul 16 08:24:34 2013 +0200 +++ b/src/main/java/de/intevation/lada/rest/LStatusService.java Tue Jul 16 11:18:05 2013 +0200 @@ -76,15 +76,12 @@ return new Response(false, 609, new ArrayList<LStatus>()); } String probeId = params.getFirst("probeId"); - if (authentication.hasAccess(headers, probeId)) { - QueryBuilder<LStatus> builder = - new QueryBuilder<LStatus>( - repository.getEntityManager(), LStatus.class); - builder.and("probeId", probeId) - .and("messungsId", params.getFirst("messungsId")); - return repository.filter(builder.getQuery()); - } - return new Response(false, 698, new ArrayList<LStatus>()); + QueryBuilder<LStatus> builder = + new QueryBuilder<LStatus>( + repository.getEntityManager(), LStatus.class); + builder.and("probeId", probeId) + .and("messungsId", params.getFirst("messungsId")); + return repository.filter(builder.getQuery()); } catch(AuthenticationException ae) { return new Response(false, 699, new ArrayList<LStatus>());
--- a/src/main/java/de/intevation/lada/rest/LZusatzwertService.java Tue Jul 16 08:24:34 2013 +0200 +++ b/src/main/java/de/intevation/lada/rest/LZusatzwertService.java Tue Jul 16 11:18:05 2013 +0200 @@ -73,14 +73,11 @@ return new Response(false, 609, new ArrayList<LZusatzWert>()); } String probeId = params.getFirst("probeId"); - if (authentication.hasAccess(headers, probeId)) { - QueryBuilder<LZusatzWert> builder = - new QueryBuilder<LZusatzWert>( - repository.getEntityManager(), LZusatzWert.class); - builder.and("probeId", probeId); - return repository.filter(builder.getQuery()); - } - return new Response(false, 698, new ArrayList<LZusatzWert>()); + QueryBuilder<LZusatzWert> builder = + new QueryBuilder<LZusatzWert>( + repository.getEntityManager(), LZusatzWert.class); + builder.and("probeId", probeId); + return repository.filter(builder.getQuery()); } catch(AuthenticationException ae) { return new Response(false, 699, new ArrayList<LZusatzWert>());