use of com.hortonworks.streamline.streams.catalog.TopologyEditorToolbar in project streamline by hortonworks.
the class TopologyEditorToolbarResource method addTopologyEditorToolbar.
/**
* 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);
}
use of com.hortonworks.streamline.streams.catalog.TopologyEditorToolbar in project streamline by hortonworks.
the class TopologyEditorToolbarResource method addOrUpdateTopologyEditorToolbar.
@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);
}
Aggregations