-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix_play_cookie
- Loading branch information
Showing
125 changed files
with
5,704 additions
and
744 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...ore/src/main/java/com/linkedin/datahub/graphql/resolvers/domain/DeleteDomainResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.linkedin.datahub.graphql.resolvers.domain; | ||
|
||
import com.linkedin.common.urn.Urn; | ||
import com.linkedin.datahub.graphql.QueryContext; | ||
import com.linkedin.datahub.graphql.authorization.AuthorizationUtils; | ||
import com.linkedin.datahub.graphql.exception.AuthorizationException; | ||
import com.linkedin.entity.client.EntityClient; | ||
import com.linkedin.r2.RemoteInvocationException; | ||
import graphql.schema.DataFetcher; | ||
import graphql.schema.DataFetchingEnvironment; | ||
import java.util.concurrent.CompletableFuture; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
|
||
/** | ||
* Resolver responsible for hard deleting a particular DataHub Corp Group | ||
*/ | ||
@Slf4j | ||
public class DeleteDomainResolver implements DataFetcher<CompletableFuture<Boolean>> { | ||
|
||
private final EntityClient _entityClient; | ||
|
||
public DeleteDomainResolver(final EntityClient entityClient) { | ||
_entityClient = entityClient; | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Boolean> get(final DataFetchingEnvironment environment) throws Exception { | ||
final QueryContext context = environment.getContext(); | ||
final String domainUrn = environment.getArgument("urn"); | ||
final Urn urn = Urn.createFromString(domainUrn); | ||
return CompletableFuture.supplyAsync(() -> { | ||
|
||
if (AuthorizationUtils.canManageDomains(context) || AuthorizationUtils.canDeleteEntity(urn, context)) { | ||
try { | ||
_entityClient.deleteEntity(urn, context.getAuthentication()); | ||
|
||
// Asynchronously Delete all references to the entity (to return quickly) | ||
CompletableFuture.runAsync(() -> { | ||
try { | ||
_entityClient.deleteEntityReferences(urn, context.getAuthentication()); | ||
} catch (RemoteInvocationException e) { | ||
log.error(String.format("Caught exception while attempting to clear all entity references for Domain with urn %s", urn), e); | ||
} | ||
}); | ||
|
||
return true; | ||
} catch (Exception e) { | ||
throw new RuntimeException(String.format("Failed to perform delete against domain with urn %s", domainUrn), e); | ||
} | ||
} | ||
throw new AuthorizationException("Unauthorized to perform this action. Please contact your DataHub administrator."); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.