diff --git a/hopsworks-api/src/main/java/io/hops/hopsworks/api/featurestore/FeaturestoreKeywordBuilder.java b/hopsworks-api/src/main/java/io/hops/hopsworks/api/featurestore/FeaturestoreKeywordBuilder.java index 9e61de08cc..034dd1e127 100644 --- a/hopsworks-api/src/main/java/io/hops/hopsworks/api/featurestore/FeaturestoreKeywordBuilder.java +++ b/hopsworks-api/src/main/java/io/hops/hopsworks/api/featurestore/FeaturestoreKeywordBuilder.java @@ -63,7 +63,7 @@ private URI uri(UriInfo uriInfo, Project project, private URI uri(UriInfo uriInfo, Project project, Featurestore featurestore, TrainingDataset trainingDataset) { return uri(uriInfo, project, featurestore) - .path(ResourceRequest.Name.FEATUREGROUPS.toString().toLowerCase()) + .path(ResourceRequest.Name.TRAININGDATASETS.toString().toLowerCase()) .path(Integer.toString(trainingDataset.getId())) .path(ResourceRequest.Name.KEYWORDS.toString().toLowerCase()) .build(); diff --git a/hopsworks-api/src/main/java/io/hops/hopsworks/api/featurestore/FeaturestoreKeywordResource.java b/hopsworks-api/src/main/java/io/hops/hopsworks/api/featurestore/FeaturestoreKeywordResource.java index 59941beff7..6487ffee1d 100644 --- a/hopsworks-api/src/main/java/io/hops/hopsworks/api/featurestore/FeaturestoreKeywordResource.java +++ b/hopsworks-api/src/main/java/io/hops/hopsworks/api/featurestore/FeaturestoreKeywordResource.java @@ -20,20 +20,17 @@ import io.hops.hopsworks.api.filter.AllowedProjectRoles; import io.hops.hopsworks.api.filter.Audience; import io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired; -import io.hops.hopsworks.api.jwt.JWTHelper; import io.hops.hopsworks.common.api.ResourceRequest; import io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupController; import io.hops.hopsworks.common.featurestore.keyword.KeywordDTO; import io.hops.hopsworks.common.featurestore.metadata.FeatureStoreKeywordControllerIface; import io.hops.hopsworks.exceptions.FeaturestoreException; -import io.hops.hopsworks.exceptions.MetadataException; import io.hops.hopsworks.jwt.annotation.JWTRequired; import io.hops.hopsworks.persistence.entity.featurestore.Featurestore; import io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup; import io.hops.hopsworks.persistence.entity.featurestore.featureview.FeatureView; import io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.TrainingDataset; import io.hops.hopsworks.persistence.entity.project.Project; -import io.hops.hopsworks.persistence.entity.user.Users; import io.hops.hopsworks.persistence.entity.user.security.apiKey.ApiScope; import io.hops.hopsworks.restutils.RESTCodes; import io.swagger.annotations.Api; @@ -70,8 +67,6 @@ public class FeaturestoreKeywordResource { @EJB private FeatureViewController featureViewController; @EJB - private JWTHelper jwtHelper; - @EJB private FeaturestoreKeywordBuilder featurestoreKeywordBuilder; @Inject private FeatureStoreKeywordControllerIface keywordCtrl; @@ -137,7 +132,7 @@ public Response getKeywords(@Context SecurityContext sc, @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "Create keywords or replace existing ones") - @AllowedProjectRoles({AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST}) + @AllowedProjectRoles({AllowedProjectRoles.DATA_OWNER}) @JWTRequired(acceptedTokens = {Audience.API, Audience.JOB}, allowedUserRoles = {"HOPS_ADMIN", "HOPS_USER", "HOPS_SERVICE_USER"}) @ApiKeyRequired(acceptedScopes = {ApiScope.FEATURESTORE}, @@ -169,7 +164,7 @@ public Response replaceKeywords(@Context SecurityContext sc, @DELETE @ApiOperation(value = "Delete a keyword") - @AllowedProjectRoles({AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST}) + @AllowedProjectRoles({AllowedProjectRoles.DATA_OWNER}) @JWTRequired(acceptedTokens = {Audience.API, Audience.JOB}, allowedUserRoles = {"HOPS_ADMIN", "HOPS_USER", "HOPS_SERVICE_USER"}) @ApiKeyRequired(acceptedScopes = {ApiScope.FEATURESTORE}, @@ -178,9 +173,7 @@ public Response deleteKeywords(@Context SecurityContext sc, @Context UriInfo uriInfo, @Context HttpServletRequest req, @QueryParam("keyword") String keyword) - throws FeaturestoreException, MetadataException { - Users user = jwtHelper.getUserPrincipal(sc); - + throws FeaturestoreException { ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.KEYWORDS); KeywordDTO dto; if (featuregroup != null) { diff --git a/hopsworks-api/src/main/java/io/hops/hopsworks/api/featurestore/tag/FeatureStoreTagResource.java b/hopsworks-api/src/main/java/io/hops/hopsworks/api/featurestore/tag/FeatureStoreTagResource.java index 7c13d799d5..3ab5cb72b9 100644 --- a/hopsworks-api/src/main/java/io/hops/hopsworks/api/featurestore/tag/FeatureStoreTagResource.java +++ b/hopsworks-api/src/main/java/io/hops/hopsworks/api/featurestore/tag/FeatureStoreTagResource.java @@ -107,11 +107,11 @@ protected abstract TagsDTO buildGetTags(UriInfo uriInfo, ResourceRequest request @Path("/{name}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - @AllowedProjectRoles({AllowedProjectRoles.DATA_SCIENTIST, AllowedProjectRoles.DATA_OWNER}) + @AllowedProjectRoles({AllowedProjectRoles.DATA_OWNER}) @JWTRequired(acceptedTokens = {Audience.API, Audience.JOB}, - allowedUserRoles = {"HOPS_ADMIN", "HOPS_USER", "HOPS_SERVICE_USER"}) + allowedUserRoles = {"HOPS_ADMIN", "HOPS_USER"}) @ApiKeyRequired(acceptedScopes = {ApiScope.FEATURESTORE}, - allowedUserRoles = {"HOPS_ADMIN", "HOPS_USER", "HOPS_SERVICE_USER"}) + allowedUserRoles = {"HOPS_ADMIN", "HOPS_USER"}) public Response putTag(@Context SecurityContext sc, @Context HttpServletRequest req, @Context UriInfo uriInfo, @@ -132,7 +132,7 @@ public Response putTag(@Context SecurityContext sc, @PUT @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - @AllowedProjectRoles({AllowedProjectRoles.DATA_SCIENTIST, AllowedProjectRoles.DATA_OWNER}) + @AllowedProjectRoles({AllowedProjectRoles.DATA_OWNER}) @JWTRequired(acceptedTokens = {Audience.API, Audience.JOB}, allowedUserRoles = {"HOPS_ADMIN", "HOPS_USER", "HOPS_SERVICE_USER"}) @ApiKeyRequired(acceptedScopes = {ApiScope.FEATURESTORE}, @@ -162,7 +162,7 @@ public Response putTags(@Context SecurityContext sc, @Context UriInfo uriInfo, @ApiOperation( value = "Get all tags attached", response = TagsDTO.class) @GET @Produces(MediaType.APPLICATION_JSON) - @AllowedProjectRoles({AllowedProjectRoles.DATA_SCIENTIST, AllowedProjectRoles.DATA_OWNER}) + @AllowedProjectRoles({AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST}) @JWTRequired(acceptedTokens = {Audience.API, Audience.JOB}, allowedUserRoles = {"HOPS_ADMIN", "HOPS_USER", "HOPS_SERVICE_USER"}) @ApiKeyRequired(acceptedScopes = {ApiScope.FEATURESTORE}, @@ -182,7 +182,7 @@ public Response getTags(@Context SecurityContext sc, @Context UriInfo uriInfo, @GET @Path("/{name}") @Produces(MediaType.APPLICATION_JSON) - @AllowedProjectRoles({AllowedProjectRoles.DATA_SCIENTIST, AllowedProjectRoles.DATA_OWNER}) + @AllowedProjectRoles({AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST}) @JWTRequired(acceptedTokens = {Audience.API, Audience.JOB}, allowedUserRoles = {"HOPS_ADMIN", "HOPS_USER", "HOPS_SERVICE_USER"}) @ApiKeyRequired(acceptedScopes = {ApiScope.FEATURESTORE}, @@ -209,7 +209,7 @@ public Response getTag(@Context SecurityContext sc, @Context UriInfo uriInfo, @ApiOperation( value = "Delete all attached tags") @DELETE @Produces(MediaType.APPLICATION_JSON) - @AllowedProjectRoles({AllowedProjectRoles.DATA_SCIENTIST, AllowedProjectRoles.DATA_OWNER}) + @AllowedProjectRoles({AllowedProjectRoles.DATA_OWNER}) @JWTRequired(acceptedTokens = {Audience.API, Audience.JOB}, allowedUserRoles = {"HOPS_ADMIN", "HOPS_USER", "HOPS_SERVICE_USER"}) @ApiKeyRequired(acceptedScopes = {ApiScope.FEATURESTORE}, @@ -225,7 +225,7 @@ public Response deleteTags(@Context SecurityContext sc, @DELETE @Path("/{name}") @Produces(MediaType.APPLICATION_JSON) - @AllowedProjectRoles({AllowedProjectRoles.DATA_SCIENTIST, AllowedProjectRoles.DATA_OWNER}) + @AllowedProjectRoles({AllowedProjectRoles.DATA_OWNER}) @JWTRequired(acceptedTokens = {Audience.API, Audience.JOB}, allowedUserRoles = {"HOPS_ADMIN", "HOPS_USER", "HOPS_SERVICE_USER"}) @ApiKeyRequired(acceptedScopes = {ApiScope.FEATURESTORE}, diff --git a/hopsworks-common/src/main/java/io/hops/hopsworks/common/commands/featurestore/search/SearchFSCommandExecutor.java b/hopsworks-common/src/main/java/io/hops/hopsworks/common/commands/featurestore/search/SearchFSCommandExecutor.java index 27c4337962..7162020f2a 100644 --- a/hopsworks-common/src/main/java/io/hops/hopsworks/common/commands/featurestore/search/SearchFSCommandExecutor.java +++ b/hopsworks-common/src/main/java/io/hops/hopsworks/common/commands/featurestore/search/SearchFSCommandExecutor.java @@ -138,7 +138,7 @@ public void process() { try { processInt(); } catch (Exception t) { - LOGGER.log(Level.INFO, "Command processing failed with error:", t); + LOGGER.log(Level.INFO, "Command processing failed with error:", t.getStackTrace()); } } schedule(); diff --git a/hopsworks-common/src/main/java/io/hops/hopsworks/common/commands/featurestore/search/SearchFSOpenSearchController.java b/hopsworks-common/src/main/java/io/hops/hopsworks/common/commands/featurestore/search/SearchFSOpenSearchController.java index 57f4a9506a..86e0418a76 100644 --- a/hopsworks-common/src/main/java/io/hops/hopsworks/common/commands/featurestore/search/SearchFSOpenSearchController.java +++ b/hopsworks-common/src/main/java/io/hops/hopsworks/common/commands/featurestore/search/SearchFSOpenSearchController.java @@ -240,13 +240,15 @@ private FeaturegroupXAttr.FullDTO getFGXAttr(FeaturegroupDTO dto) { private FeatureViewXAttrDTO getFVXAttr(FeatureView featureView) { Map featuregroups = new HashMap<>(); for(TrainingDatasetFeature feature : featureView.getFeatures()) { - FeaturegroupXAttr.SimplifiedDTO featuregroup = featuregroups.get(feature.getFeatureGroup().getId()); - if(featuregroup == null) { - featuregroup = new FeaturegroupXAttr.SimplifiedDTO(feature.getFeatureGroup().getFeaturestore().getId(), - feature.getFeatureGroup().getName(), feature.getFeatureGroup().getVersion()); - featuregroups.put(feature.getFeatureGroup().getId(), featuregroup); + if (feature.getFeatureGroup() != null) { + FeaturegroupXAttr.SimplifiedDTO featuregroup = featuregroups.get(feature.getFeatureGroup().getId()); + if (featuregroup == null) { + featuregroup = new FeaturegroupXAttr.SimplifiedDTO(feature.getFeatureGroup().getFeaturestore().getId(), + feature.getFeatureGroup().getName(), feature.getFeatureGroup().getVersion()); + featuregroups.put(feature.getFeatureGroup().getId(), featuregroup); + } + featuregroup.addFeature(feature.getName()); } - featuregroup.addFeature(feature.getName()); } return new FeatureViewXAttrDTO(featureView.getFeaturestore().getId(), featureView.getDescription(), @@ -274,13 +276,15 @@ private TrainingDatasetXAttrDTO getTDXAttr(TrainingDatasetDTO trainingDatasetDTO private List fromTrainingDatasetQuery(TrainingDatasetDTO trainingDatasetDTO) { Map featuregroups = new HashMap<>(); for(TrainingDatasetFeatureDTO feature : trainingDatasetDTO.getFeatures()) { - FeaturegroupXAttr.SimplifiedDTO featuregroup = featuregroups.get(feature.getFeaturegroup().getId()); - if(featuregroup == null) { - featuregroup = new FeaturegroupXAttr.SimplifiedDTO(feature.getFeaturegroup().getFeaturestoreId(), - feature.getFeaturegroup().getName(), feature.getFeaturegroup().getVersion()); - featuregroups.put(feature.getFeaturegroup().getId(), featuregroup); + if(feature.getFeaturegroup() != null) { + FeaturegroupXAttr.SimplifiedDTO featuregroup = featuregroups.get(feature.getFeaturegroup().getId()); + if (featuregroup == null) { + featuregroup = new FeaturegroupXAttr.SimplifiedDTO(feature.getFeaturegroup().getFeaturestoreId(), + feature.getFeaturegroup().getName(), feature.getFeaturegroup().getVersion()); + featuregroups.put(feature.getFeaturegroup().getId(), featuregroup); + } + featuregroup.addFeature(feature.getName()); } - featuregroup.addFeature(feature.getName()); } return new ArrayList<>(featuregroups.values()); }