use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class JcrFeedRolesTest method testRemoveMembership.
@Test
public void testRemoveMembership() {
metadata.commit(() -> {
this.feedProvider.findById(idA).getRoleMembership("testViewer").ifPresent(m -> m.addMember(TEST_USER3));
this.feedProvider.findById(idA).getRoleMembership("testEditor").ifPresent(m -> m.addMember(TEST_USER3));
this.feedProvider.findById(idB).getRoleMembership("testEditor").ifPresent(m -> m.addMember(TEST_USER3));
}, JcrMetadataAccess.SERVICE);
metadata.read(() -> {
Feed feedA = this.feedProvider.getFeed(idA);
assertThat(feedA.getDescription()).isNotNull().isEqualTo("Feed A");
assertThat(feedA.getJson()).isNotNull();
assertThat(feedA.getState()).isNotNull();
Feed feedB = this.feedProvider.getFeed(idB);
assertThat(feedB.getDescription()).isNotNull().isEqualTo("Feed B");
assertThat(feedB.getJson()).isNotNull();
assertThat(feedB.getState()).isNotNull();
}, TEST_USER3);
metadata.commit(() -> {
this.feedProvider.findById(idA).getRoleMembership("testEditor").ifPresent(m -> m.removeMember(TEST_USER3));
}, JcrMetadataAccess.SERVICE);
metadata.read(() -> {
Feed feedA = this.feedProvider.getFeed(idA);
assertThat(feedA.getDescription()).isNotNull().isEqualTo("Feed A");
assertThat(feedA.getJson()).isNull();
assertThat(feedA.getState()).isNull();
Feed feedB = this.feedProvider.getFeed(idB);
assertThat(feedB.getDescription()).isNotNull().isEqualTo("Feed B");
assertThat(feedB.getJson()).isNotNull();
assertThat(feedB.getState()).isNotNull();
}, TEST_USER3);
metadata.commit(() -> {
this.feedProvider.findById(idA).getRoleMembership("testViewer").ifPresent(m -> m.removeMember(TEST_USER3));
this.feedProvider.findById(idB).getRoleMembership("testEditor").ifPresent(m -> m.removeMember(TEST_USER3));
}, JcrMetadataAccess.SERVICE);
metadata.read(() -> {
Feed feedA = this.feedProvider.getFeed(idA);
assertThat(feedA).isNull();
Feed feedB = this.feedProvider.getFeed(idB);
assertThat(feedB).isNull();
}, TEST_USER3);
}
use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class JcrFeedProvider method findByCategoryId.
@Override
public List<? extends Feed> findByCategoryId(Category.ID categoryId) {
String query = "SELECT e.* from " + EntityUtil.asQueryProperty(JcrFeed.NODE_TYPE) + " as e " + "INNER JOIN [" + CategoryDetails.NODE_TYPE + "] as det on ISCHILDNODE(e, det)" + "INNER JOIN [" + JcrCategory.NODE_TYPE + "] as cat on ISCHILDNODE(det, cat)" + "WHERE cat.[mode:id] = $id";
Map<String, String> bindParams = new HashMap<>();
bindParams.put("id", categoryId.toString());
try {
QueryResult result = JcrQueryUtil.query(getSession(), query, bindParams);
// not accessible. For now filter the result based on the feed summary access.
return JcrQueryUtil.queryResultStream(result, JcrFeed.class).filter(feed -> feed.getFeedSummary().isPresent()).collect(Collectors.toList());
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Unable to getFeeds for Category ", e);
}
}
use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class JcrFeedProvider method enableFeed.
//
// @Override
// public com.thinkbiganalytics.metadata.api.feed.FeedSource.ID resolveSource(Serializable sid) {
// return new JcrFeedSource.FeedSourceId((sid));
// }
//
// @Override
// public com.thinkbiganalytics.metadata.api.feed.FeedDestination.ID resolveDestination(Serializable sid) {
// return new JcrFeedDestination.FeedDestinationId(sid);
// }
@Override
public boolean enableFeed(Feed.ID id) {
Feed feed = getFeed(id);
if (accessController.isEntityAccessControlled()) {
feed.getAllowedActions().checkPermission(FeedAccessControl.ENABLE_DISABLE);
}
if (!feed.getState().equals(Feed.State.ENABLED)) {
feed.setState(Feed.State.ENABLED);
// Enable any SLAs on this feed
List<ServiceLevelAgreement> serviceLevelAgreements = feed.getServiceLevelAgreements();
if (serviceLevelAgreements != null) {
for (ServiceLevelAgreement sla : serviceLevelAgreements) {
JcrServiceLevelAgreement jcrSla = (JcrServiceLevelAgreement) sla;
jcrSla.enable();
}
}
return true;
}
return false;
}
use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class JcrFeedProvider method addPostFeedChangeAction.
/**
* Registers an action that produces a feed change event upon a successful transaction commit.
*
* @param feed the feed to being created
*/
private void addPostFeedChangeAction(Feed feed, ChangeType changeType) {
Feed.State state = feed.getState();
Feed.ID id = feed.getId();
String feedName = feed.getQualifiedName();
final Principal principal = SecurityContextHolder.getContext().getAuthentication();
Consumer<Boolean> action = (success) -> {
if (success) {
FeedChange change = new FeedChange(changeType, feedName, feedName, id, state);
FeedChangeEvent event = new FeedChangeEvent(change, DateTime.now(), principal);
metadataEventService.notify(event);
}
};
JcrMetadataAccess.addPostTransactionAction(action);
}
use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class JobRepoFeedOperationsProvider method findLatestCompleted.
@Override
public List<FeedOperation> findLatestCompleted(Feed.ID feedId) {
return metadata.read(() -> {
List<FeedOperation> operations = new ArrayList<>();
Feed feed = this.feedProvider.getFeed(feedId);
if (feed != null) {
BatchJobExecution latestJobExecution = this.jobExecutionProvider.findLatestCompletedJobForFeed(feed.getQualifiedName());
if (latestJobExecution != null) {
LOG.debug("Latest completed job execution id {} ", latestJobExecution.getJobExecutionId());
operations.add(createOperation(latestJobExecution));
}
}
return operations;
});
}
Aggregations