Skip to content

Commit

Permalink
Merge pull request #7193 from IQSS/7176-create-dataset-fix-save
Browse files Browse the repository at this point in the history
7176 create dataset fix save validation
  • Loading branch information
kcondon authored Aug 17, 2020
2 parents 1822683 + 9fd1d7f commit 4d0bef6
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 11 deletions.
30 changes: 25 additions & 5 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,15 @@ public enum DisplayMode {
private Long linkingDataverseId;
private List<SelectItem> linkingDVSelectItems;
private Dataverse linkingDataverse;
private Dataverse selectedHostDataverse;

public Dataverse getSelectedHostDataverse() {
return selectedHostDataverse;
}

public void setSelectedHostDataverse(Dataverse selectedHostDataverse) {
this.selectedHostDataverse = selectedHostDataverse;
}

// Version tab lists
private List<DatasetVersion> versionTabList = new ArrayList<>();
Expand Down Expand Up @@ -1796,8 +1805,9 @@ public String initCitation() {
}

public void updateOwnerDataverse() {
if (dataset.getOwner() != null && dataset.getOwner().getId() != null) {
ownerId = dataset.getOwner().getId();
if (selectedHostDataverse != null && selectedHostDataverse.getId() != null) {
ownerId = selectedHostDataverse.getId();
dataset.setOwner(selectedHostDataverse);
logger.info("New host dataverse id: "+ownerId);
// discard the dataset already created
//If a global ID was already assigned, as is true for direct upload, keep it (if files were already uploaded, they are at the path corresponding to the existing global id)
Expand All @@ -1811,7 +1821,12 @@ public void updateOwnerDataverse() {
init(true);
// rebuild the bred crumbs display:
dataverseHeaderFragment.initBreadcrumbs(dataset);
}
}
}

public boolean rsyncUploadSupported() {

return settingsWrapper.isRsyncUpload() && DatasetUtil.isAppropriateStorageDriver(dataset);
}

private String init(boolean initFull) {
Expand Down Expand Up @@ -1978,7 +1993,8 @@ private String init(boolean initFull) {
// create mode for a new child dataset
readOnly = false;
editMode = EditMode.CREATE;
dataset.setOwner(dataverseService.find(ownerId));
selectedHostDataverse = dataverseService.find(ownerId);
dataset.setOwner(selectedHostDataverse);
dataset.setProtocol(protocol);
dataset.setAuthority(authority);

Expand All @@ -1996,7 +2012,11 @@ private String init(boolean initFull) {
}
dataverseTemplates.addAll(dataverseService.find(ownerId).getTemplates());
if (!dataverseService.find(ownerId).isTemplateRoot()) {
dataverseTemplates.addAll(dataverseService.find(ownerId).getParentTemplates());
for (Template templateTest: dataverseService.find(ownerId).getParentTemplates()){
if(!dataverseTemplates.contains(templateTest)){
dataverseTemplates.add(templateTest);
}
}
}
Collections.sort(dataverseTemplates, (Template t1, Template t2) -> t1.getName().compareToIgnoreCase(t2.getName()));

Expand Down
8 changes: 5 additions & 3 deletions src/main/java/edu/harvard/iq/dataverse/EditDatafilesPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import edu.harvard.iq.dataverse.datacapturemodule.DataCaptureModuleUtil;
import edu.harvard.iq.dataverse.datacapturemodule.ScriptRequestResponse;
import edu.harvard.iq.dataverse.dataset.DatasetThumbnail;
import edu.harvard.iq.dataverse.dataset.DatasetUtil;
import edu.harvard.iq.dataverse.engine.command.Command;
import edu.harvard.iq.dataverse.engine.command.exception.CommandException;
import edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException;
Expand Down Expand Up @@ -3080,9 +3081,10 @@ public void saveAdvancedOptions() {

public boolean rsyncUploadSupported() {
// ToDo - rsync was written before multiple store support and currently is hardcoded to use the "s3" store.
// When those restrictions are lifted/rsync can be configured per store, this test should check that setting
// instead of testing for the 's3" store.
return settingsWrapper.isRsyncUpload() && dataset.getDataverseContext().getEffectiveStorageDriverId().equals("s3");
// When those restrictions are lifted/rsync can be configured per store, the test in the
// Dataset Util method should be updated

return settingsWrapper.isRsyncUpload() && DatasetUtil.isAppropriateStorageDriver(dataset);
}


Expand Down
11 changes: 10 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/dataset/DatasetUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,16 @@ public static List<DatasetField> getDatasetSummaryFields(DatasetVersion datasetV

return datasetFields;
}


public static boolean isAppropriateStorageDriver(Dataset dataset){
// ToDo - rsync was written before multiple store support and currently is hardcoded to use the "s3" store.
// When those restrictions are lifted/rsync can be configured per store, this test should check that setting
// instead of testing for the 's3" store,
//This method is used by both the dataset and edit files page so one change here
//will fix both
return dataset.getDataverseContext().getEffectiveStorageDriverId().equals("s3");
}

/**
* Given a dataset version, return it's size in human readable units such as
* 42.9 MB.There is a GetDatasetStorageSizeCommand but it's overly complex
Expand Down
3 changes: 2 additions & 1 deletion src/main/webapp/dataset.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@
emptyMessage="#{bundle['dataverse.host.autocomplete.nomatches']}"
scrollHeight="180" forceSelection="true"
minQueryLength="1" queryDelay="1000"
value="#{DatasetPage.dataset.owner}"
value="#{DatasetPage.selectedHostDataverse}"
multiple="false"
completeMethod="#{DatasetPage.completeHostDataverseMenuList}"
required="#{param['DO_DS_LINK_VALIDATION']}" requiredMessage="#{bundle['dataverse.link.select']}"
Expand Down Expand Up @@ -727,6 +727,7 @@
<ui:include src="editFilesFragment.xhtml">
<ui:param name="datasetPage" value="true"/>
<ui:param name="editDatafilesPage" value="false"/>
<ui:param name="rsyncSupported" value="#{DatasetPage.rsyncUploadSupported()}"/>
<ui:param name="dataverse" value="#{DatasetPage.dataset.owner}"/>
<ui:param name="dataset" value="#{DatasetPage.dataset}"/>
<ui:param name="version" value="#{DatasetPage.workingVersion}"/>
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/editFilesFragment.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@

</div>

<div jsf:id="rsyncPanel" jsf:rendered="#{EditDatafilesPage.rsyncUploadSupported() and !EditDatafilesPage.fileReplaceOperation}" class="panel panel-default">
<div jsf:id="rsyncPanel" jsf:rendered="#{rsyncSupported and !EditDatafilesPage.fileReplaceOperation}" class="panel panel-default">
<!-- NOTE: conditional logic for 'glyphicon-chevron-up' icon in rsync header if HTTP is off, but isn't scalable when a third upload mode is added -->
<div role="tab" id="headingRsync" data-toggle="collapse" data-target="#panelCollapseRsync" class="panel-heading text-info" aria-expanded="true" aria-controls="panelCollapseRsync">
#{bundle['file.fromRsync']} &#160;<span class="glyphicon #{!settingsWrapper.HTTPUpload ? 'glyphicon-chevron-up' : 'glyphicon-chevron-down'}"/>
Expand Down
1 change: 1 addition & 0 deletions src/main/webapp/editdatafiles.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<ui:param name="editDatafilesPage" value="true"/>
<ui:param name="createDataset" value="false"/>
<ui:param name="showFileButtonUpdate" value="true"/>
<ui:param name="rsyncSupported" value="#{EditDatafilesPage.rsyncUploadSupported()}"/>
<ui:param name="lockedFromEdits" value="#{EditDatafilesPage.lockedFromEdits}"/>
</ui:include>
</div>
Expand Down

0 comments on commit 4d0bef6

Please sign in to comment.