Skip to content

Commit

Permalink
KYLO-3023 If a user doesnt have entity access to the feed it should r…
Browse files Browse the repository at this point in the history
…edirect.
  • Loading branch information
uralovs committed Nov 29, 2018
1 parent 8b6d82f commit 1852557
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,8 @@ public Response getLatestFeedVersion(@PathParam("feedId") String feedId,
return getMetadataService().getLatestFeedVersion(feedId, includeEntity)
.map(version -> Response.ok(version).build())
.orElse(Response.status(Status.NOT_FOUND).build());
} catch (FeedNotFoundException e) {
return Response.status(Status.NOT_FOUND).entity("Feed not found: " + feedId).build();
} catch (VersionNotFoundException e) {
return Response.status(Status.NOT_FOUND).build();
} catch (Exception e) {
Expand All @@ -616,6 +618,8 @@ public Response getDeployedFeedVersion(@PathParam("feedId") String feedId,
return getMetadataService().getDeployedFeedVersion(feedId, includeEntity)
.map(version -> Response.ok(version).build())
.orElse(Response.status(Status.NOT_FOUND).build());
} catch (FeedNotFoundException e) {
return Response.status(Status.NOT_FOUND).entity("Feed not found: " + feedId).build();
} catch (VersionNotFoundException e) {
return Response.status(Status.NOT_FOUND).build();
} catch (Exception e) {
Expand All @@ -637,6 +641,8 @@ public Response deployedFeedVersionExists(@PathParam("feedId") String feedId) {
return getMetadataService().getDeployedFeedVersion(feedId, false)
.map(version -> Response.ok("true").build())
.orElse(Response.ok("false").build());
} catch (FeedNotFoundException e) {
return Response.status(Status.NOT_FOUND).entity("Feed not found: " + feedId).build();
} catch (VersionNotFoundException e) {
return Response.ok("false").build();
} catch (Exception e) {
Expand All @@ -658,6 +664,8 @@ public Response draftFeedVersionExists(@PathParam("feedId") String feedId) {
return getMetadataService().getDraftFeedVersion(feedId, false)
.map(version -> Response.ok("true").build())
.orElse(Response.ok("false").build());
} catch (FeedNotFoundException e) {
return Response.status(Status.NOT_FOUND).entity("Feed not found: " + feedId).build();
} catch (VersionNotFoundException e) {
return Response.ok("false").build();
} catch (Exception e) {
Expand All @@ -683,6 +691,8 @@ public Response getDraftFeedVersion(@PathParam("feedId") String feedId,
.orElse(Response.status(Status.NOT_FOUND).build());
} catch (NifiConnectionException e ) {
throw e;
} catch (FeedNotFoundException e) {
return Response.status(Status.NOT_FOUND).entity("Feed not found: " + feedId).build();
} catch (VersionNotFoundException e) {
return Response.status(Status.NOT_FOUND).build();
} catch (Exception e) {
Expand All @@ -707,6 +717,8 @@ public Response getDraftFeedVersionEntity(@PathParam("feedId") String feedId) {
.orElse(Response.status(Status.NOT_FOUND).build());
} catch (NifiConnectionException e ) {
throw e;
} catch (FeedNotFoundException e) {
return Response.status(Status.NOT_FOUND).entity("Feed not found: " + feedId).build();
} catch (VersionNotFoundException e) {
return Response.status(Status.NOT_FOUND).build();
} catch (Exception e) {
Expand Down Expand Up @@ -882,6 +894,8 @@ public Response getFeedVersion(@PathParam("feedId") String feedId,
return getMetadataService().getFeedVersion(feedId, versionId, includeEntity)
.map(version -> Response.ok(version).build())
.orElse(Response.status(Status.NOT_FOUND).build());
} catch (FeedNotFoundException e) {
return Response.status(Status.NOT_FOUND).entity("Feed not found: " + feedId).build();
} catch (VersionNotFoundException e) {
return Response.status(Status.NOT_FOUND).build();
} catch (Exception e) {
Expand Down Expand Up @@ -949,7 +963,7 @@ public Response getFeedVersionDifference(@PathParam("feedId") String feedId,
EntityVersionDifference diff = getMetadataService().getFeedVersionDifference(feedId, fromVerId, toVerId);
return Response.ok(diff).build();
} catch (FeedNotFoundException e) {
return Response.status(Status.NOT_FOUND).build();
return Response.status(Status.NOT_FOUND).entity("Feed not found: " + feedId).build();
} catch (VersionNotFoundException e) {
return Response.status(Status.NOT_FOUND).build();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {HttpClient, HttpHeaders, HttpParams, HttpErrorResponse} from "@angular/common/http";
import {HttpClient, HttpErrorResponse, HttpHeaders, HttpParams} from "@angular/common/http";
import {Injectable, Injector, ViewContainerRef} from "@angular/core";
import {MatSnackBar} from "@angular/material/snack-bar";
import {TdDialogService} from "@covalent/core/dialogs";
Expand All @@ -18,7 +18,6 @@ import {filter} from "rxjs/operators/filter";
import {finalize} from "rxjs/operators/finalize";
import {tap} from "rxjs/operators/tap";
import {ReplaySubject} from "rxjs/ReplaySubject";
import {BehaviorSubject} from "rxjs/BehaviorSubject";
import {Subject} from "rxjs/Subject";
import {ISubscription} from "rxjs/Subscription";
import * as _ from "underscore";
Expand Down Expand Up @@ -840,9 +839,13 @@ export class DefineFeedService {
}, error1 => {
if(load && alertOnError && this.loadingFeedErrors[id] == undefined) {
this.loadingFeedErrors[id] = id;
let message = "There was an error attempting to load the feed";
if (error1.status == 404) {
message = "Feed not found";
}
this._dialogService.openAlert({
title:"Error loading feed",
message: "There was an error attempting to load the feed "
message: message
});
}
loadFeedSubject.error(error1)
Expand Down

0 comments on commit 1852557

Please sign in to comment.