class RepositoryPermissionsJaxrsService {

    @POST
    @Consumes({"application/collection+xml", "application/collection+json"})
    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    public Response createPermissions(RepositoryPermissionListWrapper data) throws ErrorDescriptorException {
        List<RepositoryPermission> permissions = data.getPermissions();
        List<ObjectPermission> server = new ArrayList<ObjectPermission>(permissions.size());
        for (RepositoryPermission permission : permissions){
            server.add(converter.toServer(permission, null));
        }

        service.createPermissions(server);
        permissions.clear();
        for (ObjectPermission permission : server){
            permissions.add(converter.toClient(permission, null));
        }

        return Response.status(Response.Status.CREATED).entity(new RepositoryPermissionListWrapper(permissions)).build();
    }

}