Skip to content

Commit

Permalink
Merge pull request #5540 from nickgros/SWC-6776a
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgros authored Oct 3, 2024
2 parents dfdc9e8 + 87a4fd0 commit 1226c24
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3295,4 +3295,32 @@ public FluentFuture<Void> deleteSessionAccessToken() {
String url = getAuthServiceUrl() + SESSION_ACCESS_TOKEN;
return getFuture(cb -> doDelete(url, cb));
}

public void getEntityBenefactorAcl(
String entityId,
AsyncCallback<AccessControlList> cb
) {
// Retrieving the benefactor ACL is always permitted regardless of permissions, so only retrieve that part of the bundle.
EntityBundleRequest request = new EntityBundleRequest();
request.setIncludeBenefactorACL(true);
String url = getRepoServiceUrl() + ENTITY + "/" + entityId + BUNDLE2;

doPost(
url,
request,
OBJECT_TYPE.EntityBundle,
true,
new AsyncCallback<EntityBundle>() {
@Override
public void onSuccess(EntityBundle result) {
cb.onSuccess(result.getBenefactorAcl());
}

@Override
public void onFailure(Throwable caught) {
cb.onFailure(caught);
}
}
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -791,25 +791,30 @@ public void onSuccess(Entity result) {
entity = result;
view.showInfo(DisplayConstants.TEXT_LINK_SUCCESS);
if (successHandler != null) {
synapseClient.getEntityBenefactorAcl(
jsClient.getEntityBenefactorAcl(
result.getId(),
new AsyncCallback<AccessControlList>() {
@Override
public void onSuccess(AccessControlList benefactorAcl) {
successHandler.onSuccessfulUpload(benefactorAcl.getId());
if (benefactorAcl.getId().equals(entity.getId())) {
// Don't show the ACL modal if the entity is its own benefactor
successHandler.onSuccessfulUpload(null);
} else {
successHandler.onSuccessfulUpload(benefactorAcl.getId());
}
entityUpdated();
}

@Override
public void onFailure(Throwable caught) {
view.showErrorMessage(caught.getMessage());
// Upload was still a success, benefactor ID is not required to continue
successHandler.onSuccessfulUpload(null);
entityUpdated();
}
}
);
}

entityUpdated();
}

@Override
Expand Down Expand Up @@ -1025,24 +1030,30 @@ private void uploadSuccess() {
view.resetToInitialState();
resetUploadProgress();
if (successHandler != null) {
synapseClient.getEntityBenefactorAcl(
parentEntityId,
jsClient.getEntityBenefactorAcl(
entityId,
new AsyncCallback<AccessControlList>() {
@Override
public void onSuccess(AccessControlList benefactorAcl) {
successHandler.onSuccessfulUpload(benefactorAcl.getId());
if (benefactorAcl.getId().equals(entityId)) {
// Don't show the ACL modal if the entity is its own benefactor
successHandler.onSuccessfulUpload(null);
} else {
successHandler.onSuccessfulUpload(benefactorAcl.getId());
}
entityUpdated();
}

@Override
public void onFailure(Throwable caught) {
view.showErrorMessage(caught.getMessage());
// Upload was still a success, benefactor ID is not required to continue.
successHandler.onSuccessfulUpload(null);
entityUpdated();
}
}
);
}
entityUpdated();
}

private void resetUploadProgress() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public void testSetNewExternalPath() throws Exception {
// associate the path.
AsyncMockStubber
.callSuccessWith(new AccessControlList().setId(UPLOAD_BENEFACTOR_ID))
.when(mockSynapseClient)
.when(mockSynapseJavascriptClient)
.getEntityBenefactorAcl(anyString(), any(AsyncCallback.class));

uploader.setExternalFilePath(
Expand All @@ -312,7 +312,7 @@ public void testSetNewExternalPath() throws Exception {
eq(storageLocationId),
any()
);
verify(mockSynapseClient)
verify(mockSynapseJavascriptClient)
.getEntityBenefactorAcl(anyString(), any(AsyncCallback.class));
verify(mockView).showInfo(anyString());
verify(mockUploadSuccessHandler).onSuccessfulUpload(UPLOAD_BENEFACTOR_ID);
Expand Down Expand Up @@ -420,14 +420,14 @@ public void testDirectUploadHappyCase() throws Exception {
.getEntity(anyString(), any(OBJECT_TYPE.class), any(AsyncCallback.class));
AsyncMockStubber
.callSuccessWith(new AccessControlList().setId(UPLOAD_BENEFACTOR_ID))
.when(mockSynapseClient)
.when(mockSynapseJavascriptClient)
.getEntityBenefactorAcl(anyString(), any(AsyncCallback.class));
uploader.handleUploads();
verify(mockGlobalApplicationState).clearDropZoneHandler(); // SWC-5161 (cleared on handleUploads)
verify(mockView).disableSelectionDuringUpload();
verify(mockSynapseClient)
.setFileEntityFileHandle(any(), any(), any(), any());
verify(mockSynapseClient)
verify(mockSynapseJavascriptClient)
.getEntityBenefactorAcl(anyString(), any(AsyncCallback.class));
verify(mockView).hideLoading();
assertEquals(UploadType.S3, uploader.getCurrentUploadType());
Expand Down

0 comments on commit 1226c24

Please sign in to comment.