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

Sync staging with master #3232

Merged
merged 4 commits into from
Jun 11, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class AtlasTypeRegistry {
private static final Logger LOG = LoggerFactory.getLogger(AtlasTypeRegistry.class);
private static final int DEFAULT_LOCK_MAX_WAIT_TIME_IN_SECONDS = 15;

public static final ArrayList<String> TYPENAMES_TO_SKIP_SUPER_TYPE_CHECK = new ArrayList<String>() {{
add("Table");
}};
protected RegistryData registryData;
private final TypeRegistryUpdateSynchronizer updateSynchronizer;
private final Set<String> missingRelationshipDefs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,23 +141,6 @@ public boolean updateAlias(AtlasEntity.AtlasEntityWithExtInfo accessControl, Atl
return true;
}

public void rebuildAlias(AtlasEntity.AtlasEntityWithExtInfo accessControl) throws AtlasBaseException {
String aliasName = getAliasName(accessControl.getEntity());

Map<String, Object> filter;

if (PERSONA_ENTITY_TYPE.equals(accessControl.getEntity().getTypeName())) {
filter = getFilterForPersona(accessControl);
} else {
filter = getFilterForPurpose(accessControl.getEntity());
}

ESAliasRequestBuilder requestBuilder = new ESAliasRequestBuilder();
requestBuilder.addAction(ADD, new AliasAction(getIndexNameFromAliasIfExists(VERTEX_INDEX_NAME), aliasName, filter));

graph.createOrUpdateESAlias(requestBuilder);
}

@Override
public boolean deleteAlias(String aliasName) throws AtlasBaseException {
graph.deleteESAlias(getIndexNameFromAliasIfExists(VERTEX_INDEX_NAME), aliasName);
Expand All @@ -178,17 +161,6 @@ private Map<String, Object> getFilterForPersona(AtlasEntity.AtlasEntityWithExtIn
return esClausesToFilter(allowClauseList);
}

private Map<String, Object> getFilterForPersona(AtlasEntity.AtlasEntityWithExtInfo persona) throws AtlasBaseException {
List<Map<String, Object>> allowClauseList = new ArrayList<>();

List<AtlasEntity> policies = getPolicies(persona);
if (CollectionUtils.isNotEmpty(policies)) {
personaPolicyToESDslClauses(policies, allowClauseList);
}

return esClausesToFilter(allowClauseList);
}

private Map<String, Object> getFilterForPurpose(AtlasEntity purpose) throws AtlasBaseException {

List<Map<String, Object>> allowClauseList = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2716,10 +2716,6 @@ public void repairAccesscontrolAlias(String guid) throws AtlasBaseException {

AtlasAuthorizationUtils.verifyAccess(new AtlasEntityAccessRequest(typeRegistry, AtlasPrivilege.ENTITY_UPDATE, new AtlasEntityHeader(accesscontrolEntity.getEntity())));

if (accesscontrolEntity == null) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
}

// Validate accesscontrolEntity status
if (accesscontrolEntity.getEntity().getStatus() != ACTIVE) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_DELETED, guid);
Expand All @@ -2728,7 +2724,7 @@ public void repairAccesscontrolAlias(String guid) throws AtlasBaseException {
// Validate accesscontrolEntity type
String entityType = accesscontrolEntity.getEntity().getTypeName();
if (!PERSONA_ENTITY_TYPE.equals(entityType)) {
throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, entityType);
throw new AtlasBaseException(AtlasErrorCode.OPERATION_NOT_SUPPORTED, entityType);
}

List<AtlasObjectId> policies = (List<AtlasObjectId>) accesscontrolEntity.getEntity().getRelationshipAttribute(REL_ATTR_POLICIES);
Expand All @@ -2737,7 +2733,7 @@ public void repairAccesscontrolAlias(String guid) throws AtlasBaseException {
}

// Rebuild alias
this.esAliasStore.rebuildAlias(accesscontrolEntity);
this.esAliasStore.updateAlias(accesscontrolEntity, null);

RequestContext.get().endMetricRecord(metric);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasEnumType;
import org.apache.atlas.type.AtlasStructType;
import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.atlas.type.AtlasType;
import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
import org.apache.atlas.util.FileUtils;
import org.apache.atlas.utils.AtlasPerfMetrics;
import org.apache.atlas.utils.AtlasPerfMetrics.MetricRecorder;
Expand Down Expand Up @@ -349,14 +350,16 @@ public static AtlasVertex findByUniqueAttributes(AtlasGraph graph, AtlasEntityTy
vertex = findByTypeAndUniquePropertyName(graph, typeName, uniqAttrValues);

// if no instance of given typeName is found, try to find an instance of type's sub-type
if (vertex == null && !entitySubTypes.isEmpty()) {
// Added exception for few types to solve https://atlanhq.atlassian.net/browse/PLT-1638
if (vertex == null && !entitySubTypes.isEmpty() && !AtlasTypeRegistry.TYPENAMES_TO_SKIP_SUPER_TYPE_CHECK.contains(typeName)) {
vertex = findBySuperTypeAndUniquePropertyName(graph, typeName, uniqAttrValues);
}
} else {
vertex = findByTypeAndPropertyName(graph, typeName, attrNameValues);

// if no instance of given typeName is found, try to find an instance of type's sub-type
if (vertex == null && !entitySubTypes.isEmpty()) {
// Added exception for few types to solve https://atlanhq.atlassian.net/browse/PLT-1638
if (vertex == null && !entitySubTypes.isEmpty() && !AtlasTypeRegistry.TYPENAMES_TO_SKIP_SUPER_TYPE_CHECK.contains(typeName)) {
vertex = findBySuperTypeAndPropertyName(graph, typeName, attrNameValues);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1932,7 +1932,7 @@ public void repairIndexByTypeName(@PathParam("typename") String typename, @Query
}

@POST
@Path("/repairAccesscontrolAlias/{guid}")
@Path("/repair/accesscontrolAlias/{guid}")
@Timed
public void repairAccessControlAlias(@PathParam("guid") String guid) throws AtlasBaseException {
Servlets.validateQueryParamLength("guid", guid);
Expand Down
Loading