public TopologyEditorToolbar addTopologyEditorToolbar(TopologyEditorToolbar toolbar) { if (toolbar.getUserId() == null) { toolbar.setUserId(-1L); } if (toolbar.getTimestamp() == null) { toolbar.setTimestamp(System.currentTimeMillis()); } this.dao.add(toolbar); return toolbar; }
public TopologyEditorToolbar addOrUpdateTopologyEditorToolbar(TopologyEditorToolbar toolbar) { if (toolbar.getUserId() == null) { toolbar.setUserId(-1L); } toolbar.setTimestamp(System.currentTimeMillis()); this.dao.addOrUpdate(toolbar); return toolbar; }
@PUT @Path("/system/topologyeditortoolbar") @Timed public Response addOrUpdateTopologyEditorToolbar(TopologyEditorToolbar toolbar, @Context SecurityContext securityContext) { Long userId = getUserId(securityContext); if (!userId.equals(toolbar.getUserId())) { throw new IllegalArgumentException("User id in the security context: '" + userId + "' does not match user id " + "in the request: '" + toolbar.getUserId() + "'"); } SecurityUtil.checkPermissions(authorizer, securityContext, TopologyEditorToolbar.NAMESPACE, userId, WRITE); TopologyEditorToolbar updated = catalogService.addOrUpdateTopologyEditorToolbar(toolbar); return WSUtils.respondEntity(updated, OK); }
/** * UI can send the toolbar data as a string. The backend will just map that information * with the currently logged in user (or userId -1 if running in non-secure mode). * * E.g. * <pre> * { * "data": "{ * \"sources\": [ * {\"bundleId\": 1}, * {\"type\":\"folder\", \"name\": \"Source Folder\",\"children\": [{\"bundleId\": 2},{\"bundleId\": 3}]} * ], * \"processors\": [...], * \"sinks\":[...] * }" * } * </pre> */ @POST @Path("/system/topologyeditortoolbar") @Timed public Response addTopologyEditorToolbar(TopologyEditorToolbar toolbar, @Context SecurityContext securityContext) { SecurityUtil.checkRole(authorizer, securityContext, Roles.ROLE_TOPOLOGY_ADMIN); long userId = getUserId(securityContext); toolbar.setUserId(userId); TopologyEditorToolbar added = catalogService.addTopologyEditorToolbar(toolbar); SecurityUtil.addAcl(authorizer, securityContext, TopologyEditorToolbar.NAMESPACE, userId, EnumSet.allOf(Permission.class)); return WSUtils.respondEntity(added, CREATED); }
public Optional<TopologyEditorToolbar> removeTopologyEditorToolbar(long userId) { return getTopologyEditorToolbar(userId) .map(toolbar -> dao.<TopologyEditorToolbar>remove(toolbar.getStorableKey())); }