Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fix(GMS): Adding Rest.li Validation in GMS" #2754

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.linkedin.metadata.entity.EntityService;
import com.linkedin.metadata.restli.RestliUtils;
import com.linkedin.parseq.Task;
import com.linkedin.restli.common.HttpStatus;
import com.linkedin.restli.server.annotations.Optional;
import com.linkedin.restli.server.annotations.QueryParam;
import com.linkedin.restli.server.annotations.RestLiCollection;
Expand All @@ -19,9 +18,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static com.linkedin.metadata.resources.ResourceUtils.*;


/**
* Single unified resource for fetching, updating, searching, & browsing DataHub entities
*/
Expand Down Expand Up @@ -50,10 +46,9 @@ public Task<VersionedAspect> get(
final VersionedAspect aspect = _entityService.getVersionedAspect(urn, aspectName, version);
if (aspect == null) {
throw RestliUtils.resourceNotFoundException();
} else {
validateRecord(aspect, HttpStatus.S_500_INTERNAL_SERVER_ERROR);
}
return aspect;
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@
import com.linkedin.metadata.search.SearchService;
import com.linkedin.metadata.search.utils.BrowsePathUtils;
import com.linkedin.parseq.Task;
import com.linkedin.restli.common.HttpStatus;
import com.linkedin.restli.common.validation.RestLiDataValidator;
import com.linkedin.restli.server.annotations.Action;
import com.linkedin.restli.server.annotations.ActionParam;
import com.linkedin.restli.server.annotations.Optional;
import com.linkedin.restli.server.annotations.QueryParam;
import com.linkedin.restli.server.annotations.RestLiCollection;
import com.linkedin.restli.server.annotations.RestMethod;
import com.linkedin.restli.server.annotations.ValidatorParam;
import com.linkedin.restli.server.resources.CollectionResourceTaskTemplate;
import java.net.URISyntaxException;
import java.time.Clock;
Expand All @@ -42,7 +39,6 @@
import org.slf4j.LoggerFactory;

import static com.linkedin.metadata.PegasusUtils.urnToEntityName;
import static com.linkedin.metadata.resources.ResourceUtils.*;
import static com.linkedin.metadata.restli.RestliConstants.ACTION_AUTOCOMPLETE;
import static com.linkedin.metadata.restli.RestliConstants.ACTION_BROWSE;
import static com.linkedin.metadata.restli.RestliConstants.ACTION_GET_BROWSE_PATHS;
Expand Down Expand Up @@ -99,8 +95,6 @@ public Task<Entity> get(@Nonnull String urnStr, @QueryParam(PARAM_ASPECTS) @Opti
final Entity entity = _entityService.getEntity(urn, projectedAspects);
if (entity == null) {
throw RestliUtils.resourceNotFoundException();
} else {
validateRecord(entity, HttpStatus.S_500_INTERNAL_SERVER_ERROR);
}
return entity;
});
Expand All @@ -122,17 +116,13 @@ public Task<Map<String, Entity>> batchGet(
return _entityService.getEntities(urns, projectedAspects)
.entrySet()
.stream()
.peek(entry -> validateRecord(entry.getValue(), HttpStatus.S_500_INTERNAL_SERVER_ERROR))
.collect(Collectors.toMap(entry -> entry.getKey().toString(), Map.Entry::getValue));
});
}

@Action(name = ACTION_INGEST)
@Nonnull
public Task<Void> ingest(@ActionParam(PARAM_ENTITY) @Nonnull Entity entity, @ValidatorParam RestLiDataValidator validator) throws URISyntaxException {

validateRecord(entity, HttpStatus.S_422_UNPROCESSABLE_ENTITY);

public Task<Void> ingest(@ActionParam(PARAM_ENTITY) @Nonnull Entity entity) throws URISyntaxException {
final Set<String> projectedAspects = new HashSet<>(Arrays.asList("browsePaths"));
final RecordTemplate snapshotRecord = RecordUtils.getSelectedRecordTemplateFromUnion(entity.getValue());
final Urn urn = com.linkedin.metadata.dao.utils.ModelUtils.getUrnFromSnapshot(snapshotRecord);
Expand All @@ -154,10 +144,6 @@ public Task<Void> ingest(@ActionParam(PARAM_ENTITY) @Nonnull Entity entity, @Val
@Action(name = ACTION_BATCH_INGEST)
@Nonnull
public Task<Void> batchIngest(@ActionParam(PARAM_ENTITIES) @Nonnull Entity[] entities) throws URISyntaxException {
for (Entity entity : entities) {
validateRecord(entity, HttpStatus.S_422_UNPROCESSABLE_ENTITY);
}

final AuditStamp auditStamp =
new AuditStamp().setTime(_clock.millis()).setActor(Urn.createFromString(DEFAULT_ACTOR));
return RestliUtils.toTask(() -> {
Expand Down

This file was deleted.