@Test(expected = ActionDeniedException.class) public void testViewListingWithNoParamsGuest() throws Exception { final List<View> views = new ArrayList<View>(); views.add(ViewTestHelper.createMockView("framework.mapfull")); doReturn(views).when(viewService).getViewsForUser(anyLong()); final ActionParameters params = createActionParams(); verifyResponseNotWritten(params); handler.handleAction(params); }
public void handleAction(final ActionParameters params) throws ActionException { params.requireLoggedInUser(); final long userId = params.getUser().getId(); final String type = params.getHttpParam(ViewTypes.VIEW_TYPE, ViewTypes.USER); final List<View> views = viewService.getViewsForUser(userId); for (View view : views) { if (view.getType() == null) { view.setType(ViewTypes.USER); } } final List<JSONObject> viewsAsJsonObjects = views.stream() .filter(v -> type.equalsIgnoreCase(v.getType())) .map(v -> viewToJSONObject(v)) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); final JSONArray viewArray = new JSONArray(viewsAsJsonObjects); final JSONObject ret = JSONHelper.createJSONObject(KEY_VIEWS, viewArray); ResponseHelper.writeResponse(params, ret); }
GetViewsHandler extends ActionHandler { public void handleAction(final ActionParameters params) throws ActionException { params.requireLoggedInUser(); final long userId = params.getUser().getId(); final String type = params.getHttpParam(ViewTypes.VIEW_TYPE, ViewTypes.USER); final List<View> views = viewService.getViewsForUser(userId); for (View view : views) { if (view.getType() == null) { view.setType(ViewTypes.USER); } } final List<JSONObject> viewsAsJsonObjects = views.stream() .filter(v -> type.equalsIgnoreCase(v.getType())) .map(v -> viewToJSONObject(v)) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); final JSONArray viewArray = new JSONArray(viewsAsJsonObjects); final JSONObject ret = JSONHelper.createJSONObject(KEY_VIEWS, viewArray); ResponseHelper.writeResponse(params, ret); } }
GetViewsHandler extends ActionHandler { public void handleAction(final ActionParameters params) throws ActionException { params.requireLoggedInUser(); final long userId = params.getUser().getId(); final String type = params.getHttpParam(ViewTypes.VIEW_TYPE, ViewTypes.USER); final List<View> views = viewService.getViewsForUser(userId); for (View view : views) { if (view.getType() == null) { view.setType(ViewTypes.USER); } } final List<JSONObject> viewsAsJsonObjects = views.stream() .filter(v -> type.equalsIgnoreCase(v.getType())) .map(v -> viewToJSONObject(v)) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); final JSONArray viewArray = new JSONArray(viewsAsJsonObjects); final JSONObject ret = JSONHelper.createJSONObject(KEY_VIEWS, viewArray); ResponseHelper.writeResponse(params, ret); }  }
GetViewsHandler extends ActionHandler { public void handleAction(final ActionParameters params) throws ActionException { params.requireLoggedInUser(); final long userId = params.getUser().getId(); final String type = params.getHttpParam(ViewTypes.VIEW_TYPE, ViewTypes.USER); final List<View> views = viewService.getViewsForUser(userId); for (View view : views) { if (view.getType() == null) { view.setType(ViewTypes.USER); } } final List<JSONObject> viewsAsJsonObjects = views.stream() .filter(v -> type.equalsIgnoreCase(v.getType())) .map(v -> viewToJSONObject(v)) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); final JSONArray viewArray = new JSONArray(viewsAsJsonObjects); final JSONObject ret = JSONHelper.createJSONObject(KEY_VIEWS, viewArray); ResponseHelper.writeResponse(params, ret); }  void setViewService(final ViewService service); void init(); void handleAction(final ActionParameters params); }
GetViewsHandler extends ActionHandler { public void handleAction(final ActionParameters params) throws ActionException { params.requireLoggedInUser(); final long userId = params.getUser().getId(); final String type = params.getHttpParam(ViewTypes.VIEW_TYPE, ViewTypes.USER); final List<View> views = viewService.getViewsForUser(userId); for (View view : views) { if (view.getType() == null) { view.setType(ViewTypes.USER); } } final List<JSONObject> viewsAsJsonObjects = views.stream() .filter(v -> type.equalsIgnoreCase(v.getType())) .map(v -> viewToJSONObject(v)) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); final JSONArray viewArray = new JSONArray(viewsAsJsonObjects); final JSONObject ret = JSONHelper.createJSONObject(KEY_VIEWS, viewArray); ResponseHelper.writeResponse(params, ret); }  void setViewService(final ViewService service); void init(); void handleAction(final ActionParameters params); static final String KEY_DESCRIPTION; static final String KEY_ISPUBLIC; static final String KEY_ISDEFAULT; static final String KEY_PUBDOMAIN; static final String KEY_VIEWS; static final String KEY_METADATA; static final String KEY_SRSNAME; }