-
Notifications
You must be signed in to change notification settings - Fork 4
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
AJ-1438: disable most entity APIs for Azure workspaces #2641
Changes from 4 commits
a4d5914
2fe90bd
cb8c66b
21f106c
518e06f
11fc9ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -540,44 +540,31 @@ class EntityService(protected val ctx: RawlsRequestContext, | |
} | ||
} | ||
|
||
def copyEntities(entityCopyDef: EntityCopyDefinition, | ||
uri: Uri, | ||
linkExistingEntities: Boolean | ||
): Future[EntityCopyResponse] = | ||
getV2WorkspaceContextAndPermissions(entityCopyDef.destinationWorkspace, | ||
SamWorkspaceActions.write, | ||
Some(WorkspaceAttributeSpecs(all = false)) | ||
) flatMap { destWorkspaceContext => | ||
getV2WorkspaceContextAndPermissions(entityCopyDef.sourceWorkspace, | ||
SamWorkspaceActions.read, | ||
Some(WorkspaceAttributeSpecs(all = false)) | ||
) flatMap { sourceWorkspaceContext => | ||
dataSource.inTransaction { dataAccess => | ||
for { | ||
sourceAD <- DBIO.from( | ||
samDAO.getResourceAuthDomain(SamResourceTypeNames.workspace, sourceWorkspaceContext.workspaceId, ctx) | ||
) | ||
destAD <- DBIO.from( | ||
samDAO.getResourceAuthDomain(SamResourceTypeNames.workspace, destWorkspaceContext.workspaceId, ctx) | ||
) | ||
result <- authDomainCheck(sourceAD.toSet, destAD.toSet) flatMap { _ => | ||
val entityNames = entityCopyDef.entityNames | ||
val entityType = entityCopyDef.entityType | ||
val copyResults = traceDBIOWithParent("checkAndCopyEntities", ctx)(s1 => | ||
dataAccess.entityQuery.checkAndCopyEntities(sourceWorkspaceContext, | ||
destWorkspaceContext, | ||
entityType, | ||
entityNames, | ||
linkExistingEntities, | ||
s1 | ||
) | ||
) | ||
copyResults | ||
} | ||
} yield result | ||
} | ||
} | ||
} | ||
def copyEntities(entityCopyDef: EntityCopyDefinition, linkExistingEntities: Boolean): Future[EntityCopyResponse] = | ||
for { | ||
destWsCtx <- getV2WorkspaceContextAndPermissions(entityCopyDef.destinationWorkspace, | ||
SamWorkspaceActions.write, | ||
Some(WorkspaceAttributeSpecs(all = false)) | ||
) | ||
sourceWsCtx <- getV2WorkspaceContextAndPermissions(entityCopyDef.sourceWorkspace, | ||
SamWorkspaceActions.read, | ||
Some(WorkspaceAttributeSpecs(all = false)) | ||
) | ||
sourceAD <- samDAO.getResourceAuthDomain(SamResourceTypeNames.workspace, sourceWsCtx.workspaceId, ctx) | ||
destAD <- samDAO.getResourceAuthDomain(SamResourceTypeNames.workspace, destWsCtx.workspaceId, ctx) | ||
_ = authDomainCheck(sourceAD.toSet, destAD.toSet) | ||
entityRequestArguments = EntityRequestArguments(destWsCtx, ctx, None, None) | ||
entityProvider <- entityManager.resolveProviderFuture(entityRequestArguments) | ||
entityCopyResponse <- entityProvider | ||
.copyEntities(sourceWsCtx, | ||
destWsCtx, | ||
entityCopyDef.entityType, | ||
entityCopyDef.entityNames, | ||
linkExistingEntities, | ||
ctx | ||
) | ||
.recover(bigQueryRecover) | ||
} yield entityCopyResponse | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While moving the important implementation inside the |
||
|
||
def batchUpdateEntitiesInternal(workspaceName: WorkspaceName, | ||
entityUpdates: Seq[EntityUpdateDefinition], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,14 +132,14 @@ trait WorkspaceSupport { | |
} yield () | ||
|
||
// can't use withClonedAuthDomain because the Auth Domain -> no Auth Domain logic is different | ||
def authDomainCheck(sourceWorkspaceADs: Set[String], destWorkspaceADs: Set[String]): ReadWriteAction[Boolean] = | ||
def authDomainCheck(sourceWorkspaceADs: Set[String], destWorkspaceADs: Set[String]): Boolean = | ||
// if the source has any auth domains, the dest must also *at least* have those auth domains | ||
if (sourceWorkspaceADs.subsetOf(destWorkspaceADs)) DBIO.successful(true) | ||
if (sourceWorkspaceADs.subsetOf(destWorkspaceADs)) true | ||
else { | ||
val missingGroups = sourceWorkspaceADs -- destWorkspaceADs | ||
val errorMsg = | ||
s"Source workspace has an Authorization Domain containing the groups ${missingGroups.mkString(", ")}, which are missing on the destination workspace" | ||
DBIO.failed(new RawlsExceptionWithErrorReport(ErrorReport(StatusCodes.UnprocessableEntity, errorMsg))) | ||
throw new RawlsExceptionWithErrorReport(ErrorReport(StatusCodes.UnprocessableEntity, errorMsg)) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
|
||
// WorkspaceContext helpers | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -317,7 +317,7 @@ trait EntityApiService extends UserInfoDirectives { | |
entity(as[EntityCopyDefinition]) { copyDefinition => | ||
complete { | ||
entityServiceConstructor(ctx) | ||
.copyEntities(copyDefinition, request.uri, linkExistingEntitiesBool) | ||
.copyEntities(copyDefinition, linkExistingEntitiesBool) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea why the request URI was passed into |
||
.map { response => | ||
if ( | ||
response.hardConflicts.isEmpty && (response.softConflicts.isEmpty || linkExistingEntitiesBool) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the heart of the PR: throw an error for non-
RawlsWorkspace
workspaces.