Skip to content

Commit

Permalink
Merge remote-tracking branch 'IQSS/develop' into IQSS/11126-Payara6.2…
Browse files Browse the repository at this point in the history
…024.12
  • Loading branch information
qqmyers committed Feb 19, 2025
2 parents 634e964 + 0f42773 commit 2101234
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/release-notes/10541-root-alias-name2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The [tutorial](https://dataverse-guide--11201.org.readthedocs.build/en/11201/container/running/demo.html#root-collection-customization-alias-name-etc) on running Dataverse in Docker has been updated to explain how to configure the root collection using a JSON file. See also #10541 and #11201.
27 changes: 27 additions & 0 deletions doc/sphinx-guides/source/container/running/demo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ To stop the containers hit ``Ctrl-c`` (hold down the ``Ctrl`` key and then hit t

To start the containers, run ``docker compose up``.

.. _starting-over:

Deleting Data and Starting Over
-------------------------------

Expand All @@ -46,6 +48,8 @@ Starting Fresh

For this exercise, please start fresh by stopping all containers and removing the ``data`` directory.

.. _demo-persona:

Creating and Running a Demo Persona
+++++++++++++++++++++++++++++++++++

Expand Down Expand Up @@ -137,6 +141,29 @@ In the example below of configuring :ref:`:FooterCopyright` we use the default u

One you make this change it should be visible in the copyright in the bottom left of every page.

Root Collection Customization (Alias, Name, etc.)
+++++++++++++++++++++++++++++++++++++++++++++++++

Before running ``docker compose up`` for the first time, you can customize the root collection by placing a JSON file in the right place.

First, in the "demo" directory you created (see :ref:`demo-persona`), create a subdirectory called "config":

``mkdir demo/config``

Next, download :download:`dataverse-complete.json <../../_static/api/dataverse-complete.json>` and put it in the "config" directory you just created. The contents of your "demo" directory should look something like this:

.. code-block:: bash
% find demo
demo
demo/config
demo/config/dataverse-complete.json
demo/init.sh
Edit ``dataverse-complete.json`` to have the values you want. You'll want to refer to :ref:`update-dataverse-api` in the API Guide to understand the format. In that documentation you can find optional parameters as well.

To test your JSON file, run ``docker compose up``. Again, this only works when you are running ``docker compose up`` for the first time. (You can always start over. See :ref:`starting-over`.)

Multiple Languages
++++++++++++++++++

Expand Down
10 changes: 10 additions & 0 deletions modules/container-configbaker/scripts/bootstrap/demo/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ echo ""
echo "Setting DOI provider to \"FAKE\"..."
curl -sS -X PUT -d FAKE "${DATAVERSE_URL}/api/admin/settings/:DoiProvider"

API_TOKEN=$(grep apiToken "/tmp/setup-all.sh.out" | jq ".data.apiToken" | tr -d \")
export API_TOKEN

ROOT_COLLECTION_JSON=/scripts/bootstrap/demo/config/dataverse-complete.json
if [ -f $ROOT_COLLECTION_JSON ]; then
echo ""
echo "Updating root collection based on $ROOT_COLLECTION_JSON..."
curl -sS -X PUT -H "X-Dataverse-key:$API_TOKEN" "$DATAVERSE_URL/api/dataverses/:root" --upload-file $ROOT_COLLECTION_JSON
fi

echo ""
echo "Revoke the key that allows for creation of builtin users..."
curl -sS -X DELETE "${DATAVERSE_URL}/api/admin/settings/BuiltinUsers.KEY"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import edu.harvard.iq.dataverse.*;
import edu.harvard.iq.dataverse.authorization.AuthenticationServiceBean;
import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser;
import edu.harvard.iq.dataverse.search.IndexServiceBean;
import edu.harvard.iq.dataverse.util.BundleUtil;

import java.sql.Timestamp;
Expand Down Expand Up @@ -60,6 +61,7 @@ public class IngestMessageBean implements MessageListener {
@EJB IngestServiceBean ingestService;
@EJB UserNotificationServiceBean userNotificationService;
@EJB AuthenticationServiceBean authenticationServiceBean;
@EJB IndexServiceBean indexService;


public IngestMessageBean() {
Expand Down Expand Up @@ -111,6 +113,7 @@ public void onMessage(Message message) {
// and "mixed success and failure" emails. Now we never list successfully
// ingested files so this line is commented out.
// sbIngestedFiles.append(String.format("<li>%s</li>", datafile.getCurrentName()));
indexService.asyncIndexDataset(datafile.getOwner(), true);
} else {
logger.warning("Error occurred during ingest job for file id " + datafile_id + "!");
sbIngestedFiles.append(String.format("<li>%s</li>", datafile.getCurrentName()));
Expand Down
53 changes: 53 additions & 0 deletions src/test/java/edu/harvard/iq/dataverse/api/SearchIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@

import static jakarta.ws.rs.core.Response.Status.*;
import static java.lang.Thread.sleep;
import java.nio.file.Path;
import java.nio.file.Paths;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
Expand Down Expand Up @@ -1838,4 +1842,53 @@ public void testShowTypeCounts() throws InterruptedException {
.body("data.total_count_per_object_type.Datasets", CoreMatchers.is(0))
.body("data.total_count_per_object_type.Files", CoreMatchers.is(0));
}

@Test
public void testTabularFiles() throws IOException {
Response createUser = UtilIT.createRandomUser();
createUser.then().assertThat().statusCode(OK.getStatusCode());
String apiToken = UtilIT.getApiTokenFromResponse(createUser);

Response createDataverseResponse = UtilIT.createRandomDataverse(apiToken);
createDataverseResponse.prettyPrint();
createDataverseResponse.then().assertThat()
.statusCode(CREATED.getStatusCode());

String dataverseAlias = UtilIT.getAliasFromResponse(createDataverseResponse);

Response createDataset = UtilIT.createRandomDatasetViaNativeApi(dataverseAlias, apiToken);
createDataset.prettyPrint();
createDataset.then().assertThat()
.statusCode(CREATED.getStatusCode());

Integer datasetId = UtilIT.getDatasetIdFromResponse(createDataset);
String datasetPid = UtilIT.getDatasetPersistentIdFromResponse(createDataset);

Path pathToDataFile = Paths.get(java.nio.file.Files.createTempDirectory(null) + File.separator + "data.csv");
String contentOfCsv = ""
+ "name,pounds,species,treats\n"
+ "Midnight,15,dog,milkbones\n"
+ "Tiger,17,cat,cat grass\n"
+ "Panther,21,cat,cat nip\n";
java.nio.file.Files.write(pathToDataFile, contentOfCsv.getBytes());

Response uploadFile = UtilIT.uploadFileViaNative(datasetId.toString(), pathToDataFile.toString(), apiToken);
uploadFile.prettyPrint();
uploadFile.then().assertThat()
.statusCode(OK.getStatusCode())
.body("data.files[0].label", equalTo("data.csv"));

assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + pathToDataFile);

Long fileId = JsonPath.from(uploadFile.body().asString()).getLong("data.files[0].dataFile.id");

Response search = UtilIT.search("entityId:" + fileId, apiToken);
search.prettyPrint();
search.then().assertThat()
.statusCode(OK.getStatusCode())
.body("data.items[0].name", is("data.tab"))
.body("data.items[0].variables", is(4))
.body("data.items[0].observations", is(3));
}

}

0 comments on commit 2101234

Please sign in to comment.