Skip to content

Commit

Permalink
Merge branch 'develop' into 3353-batch-job-import
Browse files Browse the repository at this point in the history
  • Loading branch information
bmckinney committed Dec 8, 2016
2 parents 702bbd9 + 7591e36 commit c9402b9
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,31 @@ public void initBreadcrumbs(DvObject dvObject) {
dvObject instanceof Dataset ? JH.localize("newDataset") : null );
}
}

public void initBreadcrumbsForFileMetadata(FileMetadata fmd) {
if (fmd == null) {
return;
}

breadcrumbs.clear();

//First Add regular breadcrumb for the data file
DvObject dvObject = fmd.getDataFile();
breadcrumbs.add(0, new Breadcrumb(dvObject, dvObject.getDisplayName()));

//Get the Dataset Owning the Datafile and add version to the breadcrumb
dvObject = dvObject.getOwner();
String optionalUrlExtension = "&version=" + fmd.getDatasetVersion().getSemanticVersion();
breadcrumbs.add(0, new Breadcrumb(dvObject, dvObject.getDisplayName(), optionalUrlExtension));

// now get Dataverse Owner of the dataset and proceed as usual
dvObject = dvObject.getOwner();
while (dvObject != null) {
breadcrumbs.add(0, new Breadcrumb(dvObject, dvObject.getDisplayName()));
dvObject = dvObject.getOwner();
}

}

public Long getUnreadNotificationCount(Long userId){

Expand Down Expand Up @@ -222,8 +247,15 @@ public void addBreadcrumb (String linkString){
public static class Breadcrumb {

private final String breadcrumbText;
private DvObject dvObject = null;
private String url = null;
private DvObject dvObject = null;
private String url = null;
private String optionalUrlExtension = null;

public Breadcrumb( DvObject dvObject, String breadcrumbText, String optionalUrlExtension ) {
this.breadcrumbText = breadcrumbText;
this.dvObject = dvObject;
this.optionalUrlExtension = optionalUrlExtension;
}

public Breadcrumb( DvObject dvObject, String breadcrumbText) {
this.breadcrumbText = breadcrumbText;
Expand All @@ -250,6 +282,9 @@ public DvObject getDvObject() {
public String getUrl() {
return url;
}


public String getOptionalUrlExtension() {
return optionalUrlExtension;
}
}
}
20 changes: 2 additions & 18 deletions src/main/java/edu/harvard/iq/dataverse/FileDownloadHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class FileDownloadHelper implements java.io.Serializable {


private final Map<Long, Boolean> fileDownloadPermissionMap = new HashMap<>(); // { FileMetadata.id : Boolean }
private final Map<String, Boolean> datasetPermissionMap = new HashMap<>(); // { Permission human_name : Boolean }




Expand Down Expand Up @@ -169,24 +169,8 @@ public boolean doesSessionUserHavePermission(Permission permissionToCheck, FileM
return false;
}



String permName = permissionToCheck.getHumanName();

// Has this check already been done?
//
if (this.datasetPermissionMap.containsKey(permName)){
// Yes, return previous answer
return this.datasetPermissionMap.get(permName);
}

// Check the permission
//
boolean hasPermission = this.permissionService.userOn(this.session.getUser(), objectToCheck).has(permissionToCheck);

// Save the permission
this.datasetPermissionMap.put(permName, hasPermission);


// return true/false
return hasPermission;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/dataverse_header.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
</a>
</ui:fragment>
<ui:fragment rendered="#{breadcrumb.dvObject.instanceofDataset}">
<c:set var="dsUrl" value="/dataset.xhtml?persistentId=#{breadcrumb.dvObject.globalId}"/>
<c:set var="dsUrl" value="/dataset.xhtml?persistentId=#{breadcrumb.dvObject.globalId}#{breadcrumb.optionalUrlExtension }"/>
<a id="breadcrumbLnk#{status.index}" href="#{widgetWrapper.isWidgetTarget(breadcrumb.dvObject) ? widgetWrapper.wrapURL(dsUrl) : dsUrl}" target="#{!widgetWrapper.widgetView or widgetWrapper.isWidgetTarget(breadcrumb.dvObject) ? '' : '_blank'}">
<h:outputText value="#{breadcrumb.breadcrumbText}"/>
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/file.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<f:viewParam name="fileId" value="#{FilePage.fileId}"/>
<f:viewParam name="version" value="#{FilePage.version}"/>
<f:viewAction action="#{FilePage.init}" />
<f:viewAction action="#{dataverseHeaderFragment.initBreadcrumbs(FilePage.file)}"/>
<f:viewAction action="#{dataverseHeaderFragment.initBreadcrumbsForFileMetadata(FilePage.fileMetadata)}"/>
</f:metadata>
<h:form id="fileForm">
<div id="topDatasetBlock" class="row">
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/filesFragment.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@
</ui:fragment>

<!-- Restricted File Icon -->
<div class="file-icon-restricted-block" jsf:rendered="#{fileMetadata.restricted and ((empty fileMetadata.dataFile.id) or !(fileDownloadHelper.canDownloadFile(fileMetadata)) )}">
<div class="file-icon-restricted-block" jsf:rendered="#{fileMetadata.restricted and !fileDownloadHelper.canDownloadFile(fileMetadata)}">
<span class="glyphicon glyphicon-lock text-danger"/>
</div>
<div class="file-icon-restricted-block" jsf:rendered="#{!(empty fileMetadata.dataFile.id) and fileMetadata.restricted and fileDownloadHelper.canDownloadFile(fileMetadata) }">
<div class="file-icon-restricted-block" jsf:rendered="#{fileMetadata.restricted and fileDownloadHelper.canDownloadFile(fileMetadata) }">
<span class="icon-unlock text-success"/>
</div>
</div>
Expand Down

0 comments on commit c9402b9

Please sign in to comment.