Skip to content

Commit

Permalink
Merge branch 'develop' into 6574-filenames #6574
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed May 6, 2020
2 parents dc77ac1 + 5285381 commit e79280b
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 24 deletions.
2 changes: 1 addition & 1 deletion conf/docker-aio/c7.dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM centos:7
# OS dependencies
RUN yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
RUN yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
#RUN yum install -y java-1.8.0-openjdk-headless postgresql-server sudo epel-release unzip perl curl httpd
RUN yum install -y java-1.8.0-openjdk-devel postgresql96-server sudo epel-release unzip perl curl httpd
RUN yum install -y jq lsof awscli
Expand Down
2 changes: 1 addition & 1 deletion doc/sphinx-guides/source/developers/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Without this "burrito" key in place, REST Assured will not be able to create use
Root Dataverse Permissions
^^^^^^^^^^^^^^^^^^^^^^^^^^

In your browser, log in as dataverseAdmin (password: admin) and click the "Edit" button for your root dataverse. Navigate to Permissions, then the Edit Access button. Under "Who can add to this dataverse?" choose "Anyone with a dataverse account can add sub dataverses" if it isn't set to this already.
In your browser, log in as dataverseAdmin (password: admin) and click the "Edit" button for your root dataverse. Navigate to Permissions, then the Edit Access button. Under "Who can add to this dataverse?" choose "Anyone with a Dataverse account can add sub dataverses and datasets" if it isn't set to this already.

Alternatively, this same step can be done with this script: ``scripts/search/tests/grant-authusers-add-on-root``

Expand Down
8 changes: 8 additions & 0 deletions doc/sphinx-guides/source/installation/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,14 @@ Note: The "About" link will not appear in the navbar until this option is set.

``curl -X PUT -d http://dataverse.example.edu http://localhost:8080/api/admin/settings/:NavbarAboutUrl``

:NavbarGuidesUrl
++++++++++++++++

Set ``:NavbarGuidesUrl`` to a fully-qualified URL which will be used for the "User Guide" link in the navbar.

Note: by default, the URL is composed from the settings ``:GuidesBaseUrl`` and ``:GuidesVersion`` below.

``curl -X PUT -d http://example.edu/fancy-dataverse-guide http://localhost:8080/api/admin/settings/:NavbarGuidesUrl``

:GuidesBaseUrl
++++++++++++++
Expand Down
6 changes: 3 additions & 3 deletions doc/sphinx-guides/source/installation/prerequisites.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,16 @@ Installing PostgreSQL

Version 9.6 is strongly recommended because it is the version developers and QA test with::

# yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# yum makecache fast
# yum install -y postgresql96-server
# /usr/pgsql-9.6/bin/postgresql96-setup initdb
# /usr/bin/systemctl start postgresql-9.6
# /usr/bin/systemctl enable postgresql-9.6

Note that the steps above are specific to RHEL/CentOS 7. For RHEL/CentOS 6 use::
Note that the steps above are specific to RHEL/CentOS 7. For RHEL/CentOS 8 use::

# yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-centos96-9.6-3.noarch.rpm
# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# yum makecache fast
# yum install -y postgresql96-server
# service postgresql-9.6 initdb
Expand Down
2 changes: 1 addition & 1 deletion scripts/vagrant/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ java -version
javac -version

# switching to postgresql-9.6 per #4709
yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum makecache fast
yum install -y postgresql96-server
/usr/pgsql-9.6/bin/postgresql96-setup initdb
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/DataFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import edu.harvard.iq.dataverse.util.FileUtil;
import edu.harvard.iq.dataverse.util.ShapefileHandler;
import edu.harvard.iq.dataverse.util.StringUtil;
import edu.harvard.iq.dataverse.worldmapauth.WorldMapToken;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
Expand Down Expand Up @@ -214,6 +215,13 @@ public void setGuestbookResponses(List<GuestbookResponse> guestbookResponses) {
this.guestbookResponses = guestbookResponses;
}

// The WorldMap LayerMetadata and AuthToken are here to facilitate a
// clean cascade delete when the DataFile is deleted:
@OneToOne(mappedBy="dataFile", orphanRemoval = true, cascade={CascadeType.REMOVE, CascadeType.MERGE, CascadeType.PERSIST})
private MapLayerMetadata mapLayerMetadata;
@OneToMany(mappedBy="dataFile", orphanRemoval = true, cascade={CascadeType.REMOVE, CascadeType.MERGE, CascadeType.PERSIST})
private List<WorldMapToken> worldMapTokens;

private char ingestStatus = INGEST_STATUS_NONE;

@OneToOne(mappedBy = "thumbnailFile")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import edu.harvard.iq.dataverse.GlobalIdServiceBean;
import edu.harvard.iq.dataverse.UserNotification;
import java.sql.Timestamp;
import java.util.Date;

/**
* Deletes a data file, both DB entity and filesystem object.
Expand Down Expand Up @@ -210,6 +213,31 @@ public FileVisitResult postVisitDirectory(final Path dir, final IOException e)
} catch (Exception e) {
logger.log(Level.WARNING, "Identifier deletion was not successfull:", e.getMessage());
}

// If there is a Map Layer associated with this file, we may need to
// try and remove the layer data on the WorldMap side.
if (ctxt.mapLayerMetadata().findMetadataByDatafile(doomed) != null) {
// (We need an AuthenticatedUser in order to produce a WorldMap token!)
String id = getUser().getIdentifier();
id = id.startsWith("@") ? id.substring(1) : id;
AuthenticatedUser authenticatedUser = ctxt.authentication().getAuthenticatedUser(id);
try {
ctxt.mapLayerMetadata().deleteMapLayerFromWorldMap(doomed, authenticatedUser);

// We have the dedicatd command DeleteMapLayerMetadataCommand, but
// there's no need to use it explicitly, since the Dataverse-side
// MapLayerMetadata entity will be deleted by the database
// cascade on the DataFile. -- L.A. Apr. 2020

} catch (Exception ex) {
// We are not going to treat it as a fatal condition and bail out,
// but we will send a notification to the user, warning them
// there may still be some data associated with the mapped layer,
// on the WorldMap side, un-deleted:
ctxt.notifications().sendNotification(authenticatedUser, new Timestamp(new Date().getTime()), UserNotification.Type.MAPLAYERDELETEFAILED, doomed.getFileMetadata().getId());
}

}
DataFile doomedAndMerged = ctxt.em().merge(doomed);
ctxt.em().remove(doomedAndMerged);
/**
Expand Down
19 changes: 19 additions & 0 deletions src/main/webapp/addDataFormFragment.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<ui:composition xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui"
xmlns:jsf="http://xmlns.jcp.org/jsf">
<!-- Add Data Form - not logged in... -->
<p:dialog id="addDataGuest" header="#{bundle['dataverse.results.dialog.addDataGuest.header']}" widgetVar="addData_popup" modal="true">
<p class="help-block">
<h:outputText value="#{dataverseHeaderFragment.signupAllowed ? bundle['dataverse.results.dialog.addDataGuest.msg.signup'] : bundle['dataverse.results.dialog.addDataGuest.msg']}" escape="false"></h:outputText>
</p>
<div class="button-block">
<ui:fragment rendered="#{dataverseHeaderFragment.signupAllowed}">
<a class="btn btn-default" href="#{dataverseHeaderFragment.getSignupUrl(navigationWrapper.redirectPage)}" title="#{bundle['dataverse.results.dialog.addDataGuest.signup.title']}">#{bundle['signup']}</a>
</ui:fragment>
<a class="btn btn-default" href="/loginpage.xhtml#{navigationWrapper.redirectPage}" title="#{bundle['dataverse.results.dialog.addDataGuest.login.title']}">#{bundle['login']}</a>
</div>
</p:dialog>
</ui:composition>
13 changes: 9 additions & 4 deletions src/main/webapp/dataverse_header.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
xmlns:of="http://omnifaces.org/functions"
xmlns:iqbs="http://xmlns.jcp.org/jsf/composite/iqbs">
<o:resourceInclude path="/CustomizationFilesServlet?customFileType=header" rendered="#{!widgetWrapper.widgetView}"/>
<o:importFunctions type="edu.harvard.iq.dataverse.authorization.groups.impl.builtin.AuthenticatedUsers" />
<ui:param name="showAddDataverseLink" value="#{permissionServiceBean.userOn(AuthenticatedUsers:get(),dataverseServiceBean.findRootDataverse()).canIssueCommand('CreateDataverseCommand') }"/>
<ui:param name="showAddDatasetLink" value="#{permissionServiceBean.userOn(AuthenticatedUsers:get(),dataverseServiceBean.findRootDataverse()).canIssueCommand('AbstractCreateDatasetCommand') }"/>
<ui:param name="showAddDataGroup" value="#{showAddDataverseLink or showAddDatasetLink}"/>

<div id="dataverse-header-block">
<!-- Navbar Panel -->
<nav id="navbarFixed" class="navbar navbar-default navbar-fixed-top" jsf:rendered="#{!widgetWrapper.widgetView}">
Expand All @@ -31,15 +36,15 @@
</div>
<div class="collapse navbar-collapse" id="topNavBar">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<li class="dropdown" jsf:rendered="#{showAddDataGroup}">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">#{bundle['dataverse.results.btn.addData']} <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<li jsf:rendered="#{showAddDataverseLink}">
<h:outputLink value="/dataverse.xhtml?ownerId=#{dataverseServiceBean.findRootDataverse().id}">
<h:outputText value="#{bundle['dataverse.results.btn.addData.newDataverse']}"/>
</h:outputLink>
</li>
<li>
<li jsf:rendered="#{showAddDatasetLink}">
<h:outputLink value="/dataset.xhtml?ownerId=#{dataverseServiceBean.findRootDataverse().id}">
<h:outputText value="#{bundle['dataverse.results.btn.addData.newDataset']}"/>
</h:outputLink>
Expand Down Expand Up @@ -69,7 +74,7 @@
</h:outputLink>
</li>
<li>
<h:outputLink value="#{settingsWrapper.guidesBaseUrl}/#{systemConfig.guidesVersion}/user" target="_blank" rel="noopener">
<h:outputLink value="#{settingsWrapper.get(':NavbarGuidesUrl', settingsWrapper.guidesBaseUrl.concat('/').concat(systemConfig.guidesVersion).concat('/user'))}" target="_blank" rel="noopener">
<h:outputText value="#{bundle['header.guides.user']}"/>
</h:outputLink>
</li>
Expand Down
13 changes: 2 additions & 11 deletions src/main/webapp/search-include-fragment.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -657,15 +657,6 @@
actionListener="#{SearchIncludeFragment.setDisplayCardValues()}" />
</h:form>

<p:dialog id="addDataGuest" header="#{bundle['dataverse.results.dialog.addDataGuest.header']}" widgetVar="addData_popup" modal="true">
<p class="help-block">
<h:outputText value="#{dataverseHeaderFragment.signupAllowed ? bundle['dataverse.results.dialog.addDataGuest.msg.signup'] : bundle['dataverse.results.dialog.addDataGuest.msg']}" escape="false"></h:outputText>
</p>
<div class="button-block">
<ui:fragment rendered="#{dataverseHeaderFragment.signupAllowed}">
<a class="btn btn-default" href="#{dataverseHeaderFragment.getSignupUrl(navigationWrapper.redirectPage)}" title="#{bundle['dataverse.results.dialog.addDataGuest.signup.title']}">#{bundle['signup']}</a>
</ui:fragment>
<a class="btn btn-default" href="/loginpage.xhtml#{navigationWrapper.redirectPage}" title="#{bundle['dataverse.results.dialog.addDataGuest.login.title']}">#{bundle['login']}</a>
</div>
</p:dialog>
<ui:include src="addDataFormFragment.xhtml"></ui:include>

</ui:composition>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.UUID;

import static com.jayway.restassured.RestAssured.given;
import static javax.ws.rs.core.Response.Status.FORBIDDEN;
import static javax.ws.rs.core.Response.Status.OK;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.fail;
import static org.hamcrest.CoreMatchers.equalTo;
Expand Down Expand Up @@ -118,6 +118,8 @@ public void tearDownDataverse() {
@Test
public void testJsonParserWithDirectoryLabels() {
try {
//SEK 4/14/2020 need to be super user to add a dataset with files
UtilIT.makeSuperUser(testName).then().assertThat().statusCode(OK.getStatusCode());

// try to create a dataset with directory labels that contain both leading and trailing file separators
//Should work now
Expand All @@ -134,8 +136,6 @@ public void testJsonParserWithDirectoryLabels() {

// create dataset and set id
System.out.println("Creating dataset....");
//SEK 4/14/2020 need to be super user to add a dataset with files
UtilIT.makeSuperUser(testName);
dsId = given()
.header(keyString, token)
.body(IOUtils.toString(classLoader.getResourceAsStream("json/complete-dataset-with-files.json")))
Expand Down

0 comments on commit e79280b

Please sign in to comment.