Skip to content

Commit

Permalink
Merge '3747-compute-button-UI' into 2909-3747-swift-compute-button #2909
Browse files Browse the repository at this point in the history
 #3747

This is a new branch based on 3747-swift-with-derivative-file-support

Conflicts (3747-swift-with-derivative-file-support wins):
doc/sphinx-guides/source/installation/config.rst
src/main/java/edu/harvard/iq/dataverse/dataaccess/DataAccess.java
src/main/java/edu/harvard/iq/dataverse/dataaccess/SwiftAccessIO.java
  • Loading branch information
pdurbin committed May 1, 2017
2 parents 7dc197a + 5a06dd7 commit 7eb50dc
Show file tree
Hide file tree
Showing 17 changed files with 637 additions and 439 deletions.
9 changes: 8 additions & 1 deletion doc/sphinx-guides/source/installation/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ The default checksum algorithm used is MD5 and should be sufficient for establis
:ShibPassiveLoginEnabled
++++++++++++++++++++++++

Set ``ShibPassiveLoginEnabled`` to true to enable passive login for Shibboleth. When this feature is enabled, an additional Javascript file (isPassive.js) will be loaded for every page. It will generate a passive login request to your Shibboleth SP when an anonymous user navigates to the site. A cookie named "_check_is_passive_dv" will be created to keep track of whether or not a passive login request has already been made for the user.
Set ``:ShibPassiveLoginEnabled`` to true to enable passive login for Shibboleth. When this feature is enabled, an additional Javascript file (isPassive.js) will be loaded for every page. It will generate a passive login request to your Shibboleth SP when an anonymous user navigates to the site. A cookie named "_check_is_passive_dv" will be created to keep track of whether or not a passive login request has already been made for the user.

This implementation follows the example on the Shibboleth wiki documentation page for the isPassive feature: https://wiki.shibboleth.net/confluence/display/SHIB2/isPassive

Expand All @@ -648,3 +648,10 @@ It is recommended that you configure additional error handling for your Service
You can set the value of "#THIS PAGE#" to the url of your Dataverse homepage, or any other page on your site that is accessible to anonymous users and will have the isPassive.js file loaded.

``curl -X PUT -d true http://localhost:8080/api/admin/settings/:ShibPassiveLoginEnabled``

:ComputeBaseUrl
+++++++++++++++

Set the base URL for the "Compute" button for a dataset.

``curl -X PUT -d 'https://giji.massopencloud.org/application/dataverse?containerName=' http://localhost:8080/api/admin/settings/:ComputeBaseUrl``
11 changes: 9 additions & 2 deletions src/main/java/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ curator=Curator
explore=Explore
download=Download
deaccession=Deaccession
share=Share
link=Link
linked=Linked
harvested=Harvested
apply=Apply
Expand Down Expand Up @@ -1250,6 +1252,10 @@ file.originalChecksumType=Original File {0}
file.checksum.exists.tip=A file with this checksum already exists in the dataset.
file.selectedThumbnail=Thumbnail
file.selectedThumbnail.tip=The thumbnail for this file is used as the default thumbnail for the dataset. Click 'Advanced Options' button of another file to select that file.
file.cloudStorageAccess=Cloud Storage Access
file.cloudStorageAccess.tip=The container name for this dataset needed to access files in cloud storage.
file.copy=Copy
file.compute=Compute

file.metaData.dataFile.dataTab.variables=Variables
file.metaData.dataFile.dataTab.observations=Observations
Expand Down Expand Up @@ -1288,6 +1294,7 @@ file.spss-porExtraLabels.title=Upload an additional text file with extra variabl
file.spss-porExtraLabels.selectToAddBtn=Select File to Add
file.ingestFailed=Tabular Data Ingest Failed
file.explore.twoRavens=TwoRavens
file.map=Map
file.mapData=Map Data
file.mapData.worldMap=WorldMap
file.mapData.unpublished.header=Data Not Published
Expand Down Expand Up @@ -1453,7 +1460,7 @@ file.downloadDialog.header=Download File
file.downloadDialog.tip=Please confirm and/or complete the information needed below in order to download files in this dataset.
file.downloadDialog.termsTip=I accept these Terms of Use.

file.search.placeholder=Search these data files...
file.search.placeholder=Search this dataset...
file.results.btn.sort=Sort
file.results.btn.sort.option.nameAZ=Name (A-Z)
file.results.btn.sort.option.nameZA=Name (Z-A)
Expand Down Expand Up @@ -1517,7 +1524,7 @@ file.general.metadata.label=General Metadata
file.description.label=Description
file.tags.label=Tags
file.lastupdated.label=Last Updated
file.DatasetVersion=Dataset Version
file.DatasetVersion=Version

file.metadataTab.fileMetadata.header=File Metadata
file.metadataTab.fileMetadata.persistentid.label=Data File Persistent ID
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.harvard.iq.dataverse;

import edu.harvard.iq.dataverse.authorization.AuthenticationServiceBean;
import edu.harvard.iq.dataverse.dataaccess.SwiftAccessIO;
import edu.harvard.iq.dataverse.authorization.Permission;
import edu.harvard.iq.dataverse.authorization.providers.builtin.BuiltinUserServiceBean;
import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser;
Expand Down Expand Up @@ -369,6 +370,46 @@ public String getDataverseSiteUrl() {
public void setDataverseSiteUrl(String dataverseSiteUrl) {
this.dataverseSiteUrl = dataverseSiteUrl;
}

public String getSwiftContainerName(){
String swiftContainerName = null;
String swiftFolderPathSeparator = "-";
if (persistentId != null) {
dataset = datasetService.findByGlobalId(persistentId);
String authorityNoSlashes = dataset.getAuthority().replace(dataset.getDoiSeparator(), swiftFolderPathSeparator);
swiftContainerName = dataset.getProtocol() + swiftFolderPathSeparator + authorityNoSlashes.replace(".", swiftFolderPathSeparator)
+ swiftFolderPathSeparator + dataset.getIdentifier();
logger.info("Swift container name: " + swiftContainerName);
}

return swiftContainerName;
}

//assumes that *ALL* files in ONE specified container are stored in swift backend
//could be changed
//SF
public Boolean isSwiftStorage(){
Boolean swiftBool = false;
//dataset = datasetService.findByGlobalId(persistentId);
Long datasetVersion = workingVersion.getId();
if (datasetVersion != null) {
int unlimited = 0;
int maxResults = unlimited;
List<FileMetadata> metadatas = datafileService.findFileMetadataByDatasetVersionId(datasetVersion, maxResults, fileSortField, fileSortOrder);
logger.info("metadatas " + metadatas);
if (metadatas != null && metadatas.size() > 0) {
if ("swift".equals(System.getProperty("dataverse.files.storage-driver-id"))
&& metadatas.get(0).getDataFile().getStorageIdentifier().startsWith("swift://")) {
swiftBool = true;
}
}
}
return swiftBool;
}

public String getComputeUrl() {
return settingsService.getValueForKey(SettingsServiceBean.Key.ComputeBaseUrl) + getSwiftContainerName();
}

public DataFile getSelectedDownloadFile() {
return selectedDownloadFile;
Expand Down
26 changes: 25 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/FilePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public List< String[]> getExporters(){
return retList;
}


public String restrictFile(boolean restricted) {
String fileNames = null;
String termsOfAccess = this.fileMetadata.getDatasetVersion().getTermsOfUseAndAccess().getTermsOfAccess();
Expand Down Expand Up @@ -542,7 +543,30 @@ public void setSelectedTabIndex(int selectedTabIndex) {
this.selectedTabIndex = selectedTabIndex;
}


public Boolean isSwiftStorage () {
Boolean swiftBool = false;
if (file.getStorageIdentifier().startsWith("swift://")){
swiftBool = true;
}
return swiftBool;
}

public String getSwiftContainerName(){
String swiftContainerName = null;
String swiftFolderPathSeparator = "-";

String authorityNoSlashes = file.getOwner().getAuthority().replace(file.getOwner().getDoiSeparator(), swiftFolderPathSeparator);
swiftContainerName = file.getOwner().getProtocol() + swiftFolderPathSeparator + authorityNoSlashes.replace(".", swiftFolderPathSeparator)
+ swiftFolderPathSeparator + file.getOwner().getIdentifier();
logger.info("Swift container name: " + swiftContainerName);

return swiftContainerName;
}

public String getComputeUrl() {
return settingsService.getValueForKey(SettingsServiceBean.Key.ComputeBaseUrl) + getSwiftContainerName();
}

private List<DataFile> allRelatedFiles() {
List<DataFile> dataFiles = new ArrayList();
DataFile dataFileToTest = fileMetadata.getDataFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static DataFileIO createNewDataFileIO(DataFile df, String storageTag, Str

dataFileIO.open(DataAccessOption.WRITE_ACCESS);
return dataFileIO;
}
}


}
}
10 changes: 10 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/dataaccess/DataFileIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public DataFileIO(DataFile dataFile, DataAccessRequest req) {
private String varHeader;
private String errorMessage;

//private String swiftContainerName;

private Boolean isLocalFile = false;
private Boolean isRemoteAccess = false;
private Boolean isHttpAccess = false;
Expand Down Expand Up @@ -228,6 +230,10 @@ public String getRemoteUrl() {
return remoteUrl;
}

// public String getSwiftContainerName(){
// return swiftContainerName;
// }

public GetMethod getHTTPMethod() {
return method;
}
Expand Down Expand Up @@ -313,6 +319,10 @@ public void setRemoteUrl(String u) {
remoteUrl = u;
}

// public void setSwiftContainerName(String u){
// swiftContainerName = u;
// }

public void setHTTPMethod(GetMethod hm) {
method = hm;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,13 +455,14 @@ private StoredObject initializeSwiftFileObject(boolean writeAccess, String auxIt
swiftEndPoint = p.getProperty("swift.default.endpoint");

//swiftFolderPath = this.getDataFile().getOwner().getDisplayName();
String swiftFolderPathSeparator = "_";
String swiftFolderPathSeparator = "-";
String authorityNoSlashes = this.getDataFile().getOwner().getAuthority().replace(this.getDataFile().getOwner().getDoiSeparator(), swiftFolderPathSeparator);
swiftFolderPath = this.getDataFile().getOwner().getProtocol() + swiftFolderPathSeparator +
authorityNoSlashes.replace(".", swiftFolderPathSeparator) +
swiftFolderPathSeparator + this.getDataFile().getOwner().getIdentifier();

swiftFileName = storageIdentifier;
//setSwiftContainerName(swiftFolderPath);
//swiftFileName = this.getDataFile().getDisplayName();
//Storage Identifier is now updated after the object is uploaded on Swift.
this.getDataFile().setStorageIdentifier("swift://"+swiftEndPoint+":"+swiftFolderPath+":"+swiftFileName);
Expand Down Expand Up @@ -589,6 +590,8 @@ Account authenticateWithSwift(String swiftEndPoint) throws IOException {
String swiftEndPointSecretKey = p.getProperty("swift.password." + swiftEndPoint);
String swiftEndPointTenantName = p.getProperty("swift.tenant." + swiftEndPoint);
String swiftEndPointAuthMethod = p.getProperty("swift.auth_type." + swiftEndPoint);
String swiftEndPointUrl = p.getProperty("swift.swift_endpoint." + swiftEndPoint);
String swiftEndPointTenantId = p.getProperty("swift.tenant_id." + swiftEndPoint);

if (swiftEndPointAuthUrl == null || swiftEndPointUsername == null || swiftEndPointSecretKey == null
|| "".equals(swiftEndPointAuthUrl) || "".equals(swiftEndPointUsername) || "".equals(swiftEndPointSecretKey)) {
Expand All @@ -611,6 +614,7 @@ Account authenticateWithSwift(String swiftEndPoint) throws IOException {
if (swiftEndPointAuthMethod.equals("keystone")) {
account = new AccountFactory()
.setTenantName(swiftEndPointTenantName)
// .setTenantId(swiftEndPointTenantId)
.setUsername(swiftEndPointUsername)
.setPassword(swiftEndPointSecretKey)
.setAuthUrl(swiftEndPointAuthUrl)
Expand Down Expand Up @@ -662,4 +666,5 @@ private String getSwiftFileURI(StoredObject fileObject) throws IOException {
return fileUri;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class SettingsServiceBean {
* So there.
*/
public enum Key {
ComputeBaseUrl,
IdentifierGenerationStyle,
OAuth2CallbackUrl,
DefaultAuthProvider,
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/dataset-license-terms.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="text-right margin-bottom"
jsf:rendered="#{dataverseSession.user.authenticated and empty editMode and !widgetWrapper.widgetView
and permissionsWrapper.canIssueUpdateDatasetCommand(DatasetPage.dataset)}">
<p:commandLink type="button" styleClass="btn btn-default" actionListener="#{DatasetPage.edit('LICENSE')}"
<p:commandLink type="button" styleClass="btn btn-default btn-access" actionListener="#{DatasetPage.edit('LICENSE')}"
update="@form,:messagePanel" oncomplete="javascript:post_edit_terms()" disabled="#{DatasetPage.locked}">
<f:setPropertyActionListener target="#{DatasetPage.selectedTabIndex}" value="0" />
<span class="glyphicon glyphicon-briefcase"/> #{bundle['file.dataFilesTab.terms.editTermsBtn']}
Expand Down
Loading

0 comments on commit 7eb50dc

Please sign in to comment.