Skip to content

Commit

Permalink
Pass in empty allowlist to parser (#373)
Browse files Browse the repository at this point in the history
* Pass in empty allowlist to parser

* fix

* fix

* fix

---------

Co-authored-by: Jesse Jia <[email protected]>
  • Loading branch information
zhixuanjia and Jesse Jia authored Mar 20, 2024
1 parent a64d0ca commit b3c21a8
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.linkedin.data.schema.RecordDataSchema;
import com.linkedin.data.template.DataTemplateUtil;
import com.linkedin.data.template.RecordTemplate;
import com.linkedin.metadata.annotations.AlwaysAllowList;
import com.linkedin.metadata.annotations.AspectIngestionAnnotation;
import com.linkedin.metadata.annotations.AspectIngestionAnnotationArray;
import com.linkedin.metadata.annotations.GmaAnnotation;
Expand Down Expand Up @@ -61,7 +62,7 @@ public static <ASPECT extends RecordTemplate> AspectIngestionAnnotationArray par

try {
final RecordDataSchema schema = (RecordDataSchema) DataTemplateUtil.getSchema(aspectClass);
final Optional<GmaAnnotation> gmaAnnotation = new GmaAnnotationParser().parse(schema);
final Optional<GmaAnnotation> gmaAnnotation = new GmaAnnotationParser(new AlwaysAllowList()).parse(schema);

// Return empty array if user did not specify any ingestion annotation on the aspect.
if (!gmaAnnotation.isPresent() || !gmaAnnotation.get().hasAspect() || !gmaAnnotation.get().getAspect().hasIngestion()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import com.linkedin.data.schema.RecordDataSchema;
import com.linkedin.data.template.DataTemplateUtil;
import com.linkedin.data.template.RecordTemplate;
import com.linkedin.metadata.annotations.AspectIngestionAnnotationArray;
import com.linkedin.metadata.annotations.DeltaEntityAnnotationArrayMap;
import com.linkedin.metadata.annotations.GmaAnnotation;
import com.linkedin.metadata.annotations.GmaAnnotationParser;
import com.linkedin.metadata.aspect.AuditedAspect;
import com.linkedin.metadata.aspect.SoftDeletedAspect;
import com.linkedin.metadata.dao.EbeanMetadataAspect;
Expand All @@ -28,7 +25,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -57,26 +53,6 @@ private EBeanDAOUtils() {
// Utils class
}

/**
* Parse the ingestion mode annotation given an aspect class.
*/
@Nonnull
public static AspectIngestionAnnotationArray parseIngestionModeFromAnnotation(@Nonnull final String aspectCanonicalName) {
try {
final RecordDataSchema schema = (RecordDataSchema) DataTemplateUtil.getSchema(ClassUtils.loadClass(aspectCanonicalName));
final Optional<GmaAnnotation> gmaAnnotation = new GmaAnnotationParser().parse(schema);

// Return empty array if user did not specify any ingestion annotation on the aspect.
if (!gmaAnnotation.isPresent() || !gmaAnnotation.get().hasAspect() || !gmaAnnotation.get().getAspect().hasIngestion()) {
return new AspectIngestionAnnotationArray();
}

return gmaAnnotation.get().getAspect().getIngestion();
} catch (Exception e) {
throw new RuntimeException(String.format("Failed to parse the annotations for aspect %s", aspectCanonicalName), e);
}
}

/**
* Parse the delta annotation given an aspect class.
* @param aspectCanonicalName canonical name of an aspect
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.linkedin.metadata.annotations;

import com.google.common.annotations.VisibleForTesting;
import com.linkedin.data.schema.DataSchema;
import javax.annotation.Nonnull;


@VisibleForTesting
public class AlwaysAllowList implements GmaEntitiesAnnotationAllowList {
@Override
public void check(@Nonnull DataSchema schema, @Nonnull AspectAnnotation aspectAnnotation) {
Expand Down

0 comments on commit b3c21a8

Please sign in to comment.