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

moved a requestAccess method from FileDownloadServiceBean to FileDown… #3627

Merged
merged 1 commit into from
Feb 7, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/FileDownloadHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package edu.harvard.iq.dataverse;

import edu.harvard.iq.dataverse.authorization.Permission;
import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser;
import edu.harvard.iq.dataverse.authorization.users.GuestUser;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -29,6 +30,9 @@ public class FileDownloadHelper implements java.io.Serializable {

@EJB
PermissionServiceBean permissionService;

@EJB
FileDownloadServiceBean fileDownloadService;


private final Map<Long, Boolean> fileDownloadPermissionMap = new HashMap<>(); // { FileMetadata.id : Boolean }
Expand Down Expand Up @@ -174,7 +178,21 @@ public boolean doesSessionUserHavePermission(Permission permissionToCheck, FileM
// return true/false
return hasPermission;
}



public void requestAccess(DataFile file) {
if (fileDownloadService.requestAccess(file.getId())) {
// update the local file object so that the page properly updates
file.getFileAccessRequesters().add((AuthenticatedUser) session.getUser());

// create notifications
fileDownloadService.sendRequestFileAccessNotification(file.getOwner(), file.getId());
}

}


//todo: potential cleanup - are these methods needed?
public DataverseSession getSession() {
return session;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,18 +399,7 @@ public void downloadCitationBibtex(FileMetadata fileMetadata, Dataset dataset) {
}



public void requestAccess(DataFile file) {
if (requestAccess(file.getId())) {
// update the local file object so that the page properly updates
file.getFileAccessRequesters().add((AuthenticatedUser) session.getUser());

// create notifications
sendRequestFileAccessNotification(file.getOwner(), file.getId());
}

}


public boolean requestAccess(Long fileId) {
DataFile file = datafileService.find(fileId);
if (!file.getFileAccessRequesters().contains((AuthenticatedUser) session.getUser())) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/file-download-button-fragment.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
<p:commandLink type="button" styleClass="btn btn-default" rendered="#{fileDownloadHelper.session.user.authenticated
and !fileMetadata.datasetVersion.deaccessioned
and fileMetadata.dataFile.owner.fileAccessRequest and !(fileDownloadHelper.canDownloadFile(fileMetadata))}"
actionListener="#{fileDownloadService.requestAccess(fileMetadata.dataFile)}"
actionListener="#{fileDownloadHelper.requestAccess(fileMetadata.dataFile)}"
update="@this"
disabled="#{fileMetadata.dataFile.fileAccessRequesters.contains(dataverseSession.user)}">
<!-- Request Access -->
Expand Down