@Override public ShortResourceList getList(SecurityContext sc, String nameLike, Integer page, Integer entries) throws BadRequestWebEx { User authUser = extractAuthUser(sc); nameLike = nameLike.replaceAll("[*]", "%"); try { return new ShortResourceList(resourceService.getList(nameLike, page, entries, authUser)); } catch (BadRequestServiceEx ex) { throw new BadRequestWebEx(ex.getMessage()); } }
@Override public ShortResourceList getResources(SecurityContext sc, SearchFilter filter) { User authUser = extractAuthUser(sc); try { return new ShortResourceList(resourceService.getResources(filter, authUser)); } catch (BadRequestServiceEx e) { if (LOGGER.isInfoEnabled()) LOGGER.info(e.getMessage()); throw new BadRequestWebEx(e.getMessage()); } catch (InternalErrorServiceEx e) { if (LOGGER.isInfoEnabled()) LOGGER.info(e.getMessage()); throw new InternalErrorWebEx(e.getMessage()); } }
@Override public ShortResourceList getAll(SecurityContext sc, Integer page, Integer entries) throws BadRequestWebEx { User authUser = extractAuthUser(sc); try { return new ShortResourceList(resourceService.getAll(page, entries, authUser)); } catch (BadRequestServiceEx ex) { throw new BadRequestWebEx(ex.getMessage()); } }
@Override public ShortResourceList updateSecurityRules(SecurityContext sc, ShortResourceList resourcesToSet, Long groupId, Boolean canRead, Boolean canWrite) throws BadRequestWebEx, NotFoundWebEx { List<ShortResource> srll = new ArrayList<ShortResource>(); if(groupId == null || groupId < 0){ throw new BadRequestWebEx("The groupId is null or less than 0..."); } if(resourcesToSet == null || resourcesToSet.isEmpty()){ throw new BadRequestWebEx("The resources set provided is null or empty..."); } List<ShortResource> sl = resourcesToSet.getList(); List<Long> slOnlyIds = new ArrayList<Long>(); for(ShortResource sr : sl){ if(sr.getId() < 0){ throw new BadRequestWebEx("One or more ids in resource set is less than 0... check the resources list."); } slOnlyIds.add(sr.getId()); } try { srll = userGroupService.updateSecurityRules(groupId, slOnlyIds, canRead, canWrite); } catch (NotFoundServiceEx e) { LOGGER.error(e.getMessage(), e); throw new NotFoundWebEx(e.getMessage()); } catch (BadRequestServiceEx e) { LOGGER.error(e.getMessage(), e); throw new BadRequestWebEx(e.getMessage()); } ShortResourceList srl = new ShortResourceList(srll); return srl; }
return new ShortResourceList(resources);