Search in sources :

Example 1 with TopologyEditorToolbar

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);
}
Also used : TopologyEditorToolbar(com.hortonworks.streamline.streams.catalog.TopologyEditorToolbar) Permission(com.hortonworks.streamline.streams.security.Permission) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Timed(com.codahale.metrics.annotation.Timed)

Example 2 with TopologyEditorToolbar

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);
}
Also used : TopologyEditorToolbar(com.hortonworks.streamline.streams.catalog.TopologyEditorToolbar) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) PUT(javax.ws.rs.PUT)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)2 TopologyEditorToolbar (com.hortonworks.streamline.streams.catalog.TopologyEditorToolbar)2 Path (javax.ws.rs.Path)2 Permission (com.hortonworks.streamline.streams.security.Permission)1 POST (javax.ws.rs.POST)1 PUT (javax.ws.rs.PUT)1