private void setupMockGadgetAdminStore(boolean isAllowed) { EasyMock.expect(gadgetAdminStore.checkFeatureAdminInfo(EasyMock.isA(Gadget.class))) .andReturn(isAllowed).anyTimes(); EasyMock.expect(gadgetAdminStore.getAdditionalRpcServiceIds(EasyMock.isA(Gadget.class))) .andReturn(Sets.newHashSet(RPC_SERVICE_3)); }
private void setupMockGadgetAdminStore(boolean isAllowed) { EasyMock.expect(gadgetAdminStore.checkFeatureAdminInfo(EasyMock.isA(Gadget.class))) .andReturn(isAllowed).anyTimes(); EasyMock.expect(gadgetAdminStore.getAdditionalRpcServiceIds(EasyMock.isA(Gadget.class))) .andReturn(Sets.newHashSet(RPC_SERVICE_3)); }
private void setupGadgetAdminStore() { EasyMock.expect(gadgetAdminStore.checkFeatureAdminInfo(isA(Gadget.class))) .andReturn(true).anyTimes(); EasyMock.expect(gadgetAdminStore.getAdditionalRpcServiceIds(isA(Gadget.class))) .andReturn((Sets.newHashSet(RPC_SERVICE_3))).anyTimes(); }
private void setupGadgetAdminStore() { EasyMock.expect(gadgetAdminStore.checkFeatureAdminInfo(isA(Gadget.class))) .andReturn(true).anyTimes(); EasyMock.expect(gadgetAdminStore.getAdditionalRpcServiceIds(isA(Gadget.class))) .andReturn((Sets.newHashSet(RPC_SERVICE_3))).anyTimes(); }
/** * Gets the set of allowed RPC service ids. * * @param gadget * the gadget to get the service ids for. * @return the set of allowed RPC service ids. */ private Set<String> getRpcServiceIds(Gadget gadget) { GadgetContext context = gadget.getContext(); Set<String> rpcEndpoints = Sets.newHashSet(gadgetAdminStore.getAdditionalRpcServiceIds(gadget)); List<Feature> modulePrefFeatures = gadget.getSpec().getModulePrefs().getAllFeatures(); List<String> featureNames = Lists.newArrayList(); for(Feature feature : modulePrefFeatures) { if(gadgetAdminStore.isAllowedFeature(feature, gadget)) { featureNames.add(feature.getName()); } } try { FeatureRegistry featureRegistry = featureRegistryProvider.get(context.getRepository()); LookupResult result = featureRegistry.getFeatureResources(context, featureRegistry.getFeatures(featureNames), null); List<FeatureBundle> bundles = result.getBundles(); for (FeatureBundle bundle : bundles) { rpcEndpoints.addAll(bundle.getApis(ApiDirective.Type.RPC, false)); } } catch (GadgetException e) { LOG.log(Level.WARNING, "Error getting features from feature registry", e); } return rpcEndpoints; }