Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/IQSS/dataverse into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
donsizemore committed May 21, 2019
2 parents 430b4ce + aa59755 commit 20558d6
Show file tree
Hide file tree
Showing 21 changed files with 307 additions and 98 deletions.
2 changes: 1 addition & 1 deletion doc/sphinx-guides/source/admin/dataverses-datasets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,5 @@ As a superuser, click "Update Current Version" when publishing. (This option is
Diagnose Constraint Violations Issues in Datasets
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

To identifiy invalid data values in specific datasets (if, for example, an attempt to edit a dataset results in a ConstraintViolationException in the server log), or to check all the datasets in the Dataverse for constraint violations, see :ref:`Dataset Validation <dataset-validation-api>` in the :doc:`/api/native-api` section of the User Guide.
To identify invalid data values in specific datasets (if, for example, an attempt to edit a dataset results in a ConstraintViolationException in the server log), or to check all the datasets in the Dataverse for constraint violations, see :ref:`Dataset Validation <dataset-validation-api>` in the :doc:`/api/native-api` section of the User Guide.

24 changes: 23 additions & 1 deletion doc/sphinx-guides/source/api/dataaccess.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,18 @@ It returns a zipped bundle that contains the data in the following formats:
* Data (Variable) metadata record, in DDI XML;
* File citation, in Endnote and RIS formats.


Parameters:
~~~~~~~~~~~
none.

``fileMetadataId``

============== ===========
Value Description
============== ===========
ID Exports file with specific file metadata ``ID``.
============== ===========


Data Variable Metadata Access
-----------------------------
Expand Down Expand Up @@ -177,6 +186,19 @@ Example:
</dataDscr>
</codeBook>
Parameters:
~~~~~~~~~~~

``fileMetadataId``

============== ===========
Value Description
============== ===========
ID Exports file with specific file metadata ``ID``. For example for data file with id 6 and file metadata id 2: ``curl 'http://localhost:8080/api/access/datafile/6/metadata/ddi?fileMetadataId=2'``
============== ===========


More information on DDI is available in the :doc:`/user/tabulardataingest/ingestprocess` section of the User Guide.

Advanced options/Parameters:
Expand Down
15 changes: 2 additions & 13 deletions doc/sphinx-guides/source/developers/making-releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Making Releases
.. contents:: |toctitle|
:local:

Use the number of the milestone with a "v" in front for the relase tag. For example: ``v4.6.2``.
Use the number of the milestone with a "v" in front for the release tag. For example: ``v4.6.2``.

Create the release GitHub issue and branch
------------------------------------------
Expand All @@ -32,18 +32,7 @@ Add the version being released to the lists in the following two files:

Here's an example commit where three of the four files above were updated at once: https://github.com/IQSS/dataverse/commit/99e23f96ec362ac2f524cb5cd80ca375fa13f196

2. Save the EJB Database Create Script
======================================

Save the script ``domains/domain1/generated/ejb/dataverse/dataverse_VDCNet-ejbPU_createDDL.jdbc`` created by EJB during the deployment of the release candidate. **Important:** add semicolons to the ends of the SQL commands in the EJB-generated file (see below)! Save the resulting file as ``scripts/database/create/create_v{VERSION_TAG}.sql`` using the version number tag for the release. For example:

.. code-block:: none
sed 's/$/;/' dataverse_VDCNet-ejbPU_createDDL.jdbc > scripts/database/create/create_v4.10.sql
(We are saving the script above to support the new experimental process for updating the database across multiple versions; see ``scripts/database/README_upgrade_across_versions.txt`` for more information.)

3. Check in the Changes Above...
2. Check in the Changes Above...
================================

... into the release branch, make a pull request and merge the release branch into develop.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ValidationMessages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ user.lastName=Please enter your last name.
user.invalidEmail=Please enter a valid email address.
user.enterUsername=Please enter a username.
user.usernameLength=Username must be between 2 and 60 characters.
user.illegalCharacters=Found an illegal character(s). Valid characters are a-Z, 0-9, '_', '-', and '.'."
user.illegalCharacters=Found an illegal character(s). Valid characters are a-Z, 0-9, '_', '-', and '.'.

user.enterNickname=Please enter a nickname.
user.nicknameLength=Nickname must be at most 30 characters.
Expand Down Expand Up @@ -46,4 +46,4 @@ password.retype=The new password is blank: re-type it again.
password.current=Please enter your current password.
password.validate=Password reset page default email message.
guestbook.name=Enter a name for the guestbook
guestbook.name=Enter a name for the guestbook
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class ConfigureFragmentBean implements java.io.Serializable{
private Long fileId = null;
private ExternalToolHandler toolHandler = null;
private String messageApi = "";
private Long fileMetadataId = null;

@EJB
DataFileServiceBean datafileService;
Expand Down Expand Up @@ -95,7 +96,7 @@ public ExternalToolHandler getConfigurePopupToolHandler() {
}


toolHandler = new ExternalToolHandler(tool, datafileService.find(fileId), apiToken);
toolHandler = new ExternalToolHandler(tool, datafileService.find(fileId), apiToken, datafileService.findFileMetadata(fileMetadataId));

return toolHandler;
}
Expand All @@ -116,8 +117,10 @@ public void generateApiToken() {

}

public void setConfigureFileId(Long setFileId) {
public void setConfigureIds(Long setFileId, Long setFileMetadataId) {

fileId = setFileId;
fileMetadataId = setFileMetadataId;
}

public String getMessageApi() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -1853,7 +1853,7 @@ public String getJsonLd() {
} else {
if (FileUtil.isPubliclyDownloadable(fileMetadata)) {
String nullDownloadType = null;
fileObject.add("contentUrl", dataverseSiteUrl + FileUtil.getFileDownloadUrlPath(nullDownloadType, fileMetadata.getDataFile().getId(), false));
fileObject.add("contentUrl", dataverseSiteUrl + FileUtil.getFileDownloadUrlPath(nullDownloadType, fileMetadata.getDataFile().getId(), false, fileMetadata.getId()));
}
}
fileArray.add(fileObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void writeGuestbookAndStartBatchDownload(GuestbookResponse guestbookRespo
writeGuestbookResponseRecord(guestbookResponse);
}

redirectToDownloadAPI(guestbookResponse.getFileFormat(), fileId, true);
redirectToDownloadAPI(guestbookResponse.getFileFormat(), fileId, true, null);
return;
}

Expand Down Expand Up @@ -138,7 +138,7 @@ public void writeGuestbookAndStartFileDownload(GuestbookResponse guestbookRespon
}

// Make sure to set the "do not write Guestbook response" flag to TRUE when calling the Access API:
redirectToDownloadAPI(format, fileMetadata.getDataFile().getId(), true);
redirectToDownloadAPI(format, fileMetadata.getDataFile().getId(), true, fileMetadata.getId());
logger.fine("issued file download redirect for filemetadata "+fileMetadata.getId()+", datafile "+fileMetadata.getDataFile().getId());
}

Expand Down Expand Up @@ -215,8 +215,8 @@ private void redirectToBatchDownloadAPI(String multiFileString, Boolean guestboo

}

private void redirectToDownloadAPI(String downloadType, Long fileId, boolean guestBookRecordAlreadyWritten) {
String fileDownloadUrl = FileUtil.getFileDownloadUrlPath(downloadType, fileId, guestBookRecordAlreadyWritten);
private void redirectToDownloadAPI(String downloadType, Long fileId, boolean guestBookRecordAlreadyWritten, Long fileMetadataId) {
String fileDownloadUrl = FileUtil.getFileDownloadUrlPath(downloadType, fileId, guestBookRecordAlreadyWritten, fileMetadataId);
logger.fine("Redirecting to file download url: " + fileDownloadUrl);
try {
FacesContext.getCurrentInstance().getExternalContext().redirect(fileDownloadUrl);
Expand All @@ -226,7 +226,7 @@ private void redirectToDownloadAPI(String downloadType, Long fileId, boolean gue
}

private void redirectToDownloadAPI(String downloadType, Long fileId) {
redirectToDownloadAPI(downloadType, fileId, true);
redirectToDownloadAPI(downloadType, fileId, true, null);
}

private void redirectToBatchDownloadAPI(String multiFileString, Boolean downloadOriginal){
Expand Down Expand Up @@ -258,7 +258,7 @@ public void explore(GuestbookResponse guestbookResponse, FileMetadata fmd, Exter
if(dataFile.getFileMetadata()==null) {
dataFile=datafileService.find(dataFile.getId());
}
ExternalToolHandler externalToolHandler = new ExternalToolHandler(externalTool, dataFile, apiToken);
ExternalToolHandler externalToolHandler = new ExternalToolHandler(externalTool, dataFile, apiToken, fmd);
// Back when we only had TwoRavens, the downloadType was always "Explore". Now we persist the name of the tool (i.e. "TwoRavens", "Data Explorer", etc.)
guestbookResponse.setDownloadtype(externalTool.getDisplayName());
String toolUrl = externalToolHandler.getToolUrlWithQueryParams();
Expand Down Expand Up @@ -479,4 +479,4 @@ public void sendRequestFileAccessNotification(Dataset dataset, Long fileId, Auth



}
}
42 changes: 29 additions & 13 deletions src/main/java/edu/harvard/iq/dataverse/api/Access.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public class Access extends AbstractApiBean {
@Path("datafile/bundle/{fileId}")
@GET
@Produces({"application/zip"})
public BundleDownloadInstance datafileBundle(@PathParam("fileId") String fileId, @QueryParam("gbrecs") boolean gbrecs, @QueryParam("key") String apiToken, @Context UriInfo uriInfo, @Context HttpHeaders headers, @Context HttpServletResponse response) /*throws NotFoundException, ServiceUnavailableException, PermissionDeniedException, AuthorizationRequiredException*/ {
public BundleDownloadInstance datafileBundle(@PathParam("fileId") String fileId, @QueryParam("fileMetadataId") Long fileMetadataId,@QueryParam("gbrecs") boolean gbrecs, @QueryParam("key") String apiToken, @Context UriInfo uriInfo, @Context HttpHeaders headers, @Context HttpServletResponse response) /*throws NotFoundException, ServiceUnavailableException, PermissionDeniedException, AuthorizationRequiredException*/ {


GuestbookResponse gbr = null;
Expand All @@ -207,9 +207,14 @@ public BundleDownloadInstance datafileBundle(@PathParam("fileId") String fileId,

DownloadInfo dInfo = new DownloadInfo(df);
BundleDownloadInstance downloadInstance = new BundleDownloadInstance(dInfo);

FileMetadata fileMetadata = df.getFileMetadata();
DatasetVersion datasetVersion = df.getOwner().getLatestVersion();

FileMetadata fileMetadata = null;

if (fileMetadataId == null) {
fileMetadata = df.getFileMetadata();
} else {
fileMetadata = dataFileService.findFileMetadata(fileMetadataId);
}

downloadInstance.setFileCitationEndNote(new DataCitation(fileMetadata).toEndNoteString());
downloadInstance.setFileCitationRIS(new DataCitation(fileMetadata).toRISString());
Expand All @@ -223,7 +228,8 @@ public BundleDownloadInstance datafileBundle(@PathParam("fileId") String fileId,
dfId,
outStream,
null,
null);
null,
fileMetadataId);

downloadInstance.setFileDDIXML(outStream.toString());

Expand Down Expand Up @@ -382,8 +388,8 @@ public DownloadInstance datafile(@PathParam("fileId") String fileId, @QueryParam
@Path("datafile/{fileId}/metadata")
@GET
@Produces({"text/xml"})
public String tabularDatafileMetadata(@PathParam("fileId") String fileId, @QueryParam("exclude") String exclude, @QueryParam("include") String include, @Context HttpHeaders header, @Context HttpServletResponse response) throws NotFoundException, ServiceUnavailableException /*, PermissionDeniedException, AuthorizationRequiredException*/ {
return tabularDatafileMetadataDDI(fileId, exclude, include, header, response);
public String tabularDatafileMetadata(@PathParam("fileId") String fileId, @QueryParam("fileMetadataId") Long fileMetadataId, @QueryParam("exclude") String exclude, @QueryParam("include") String include, @Context HttpHeaders header, @Context HttpServletResponse response) throws NotFoundException, ServiceUnavailableException /*, PermissionDeniedException, AuthorizationRequiredException*/ {
return tabularDatafileMetadataDDI(fileId, fileMetadataId, exclude, include, header, response);
}

/*
Expand All @@ -393,7 +399,7 @@ public String tabularDatafileMetadata(@PathParam("fileId") String fileId, @Query
@Path("datafile/{fileId}/metadata/ddi")
@GET
@Produces({"text/xml"})
public String tabularDatafileMetadataDDI(@PathParam("fileId") String fileId, @QueryParam("exclude") String exclude, @QueryParam("include") String include, @Context HttpHeaders header, @Context HttpServletResponse response) throws NotFoundException, ServiceUnavailableException /*, PermissionDeniedException, AuthorizationRequiredException*/ {
public String tabularDatafileMetadataDDI(@PathParam("fileId") String fileId, @QueryParam("fileMetadataId") Long fileMetadataId, @QueryParam("exclude") String exclude, @QueryParam("include") String include, @Context HttpHeaders header, @Context HttpServletResponse response) throws NotFoundException, ServiceUnavailableException /*, PermissionDeniedException, AuthorizationRequiredException*/ {
String retValue = "";

DataFile dataFile = null;
Expand All @@ -406,8 +412,16 @@ public String tabularDatafileMetadataDDI(@PathParam("fileId") String fileId, @Qu
}

response.setHeader("Content-disposition", "attachment; filename=\"dataverse_files.zip\"");

String fileName = dataFile.getFileMetadata().getLabel().replaceAll("\\.tab$", "-ddi.xml");

FileMetadata fm = null;
if (fileMetadataId == null) {
fm = dataFile.getFileMetadata();
} else {
fm = dataFileService.findFileMetadata(fileMetadataId);
}

String fileName = fm.getLabel().replaceAll("\\.tab$", "-ddi.xml");

response.setHeader("Content-disposition", "attachment; filename=\""+fileName+"\"");
response.setHeader("Content-Type", "application/xml; name=\""+fileName+"\"");

Expand All @@ -419,7 +433,8 @@ public String tabularDatafileMetadataDDI(@PathParam("fileId") String fileId, @Qu
dataFileId,
outStream,
exclude,
include);
include,
fileMetadataId);

retValue = outStream.toString();

Expand All @@ -439,7 +454,7 @@ public String tabularDatafileMetadataDDI(@PathParam("fileId") String fileId, @Qu
@GET
@Produces({ "application/xml" })

public String dataVariableMetadataDDI(@PathParam("varId") Long varId, @QueryParam("exclude") String exclude, @QueryParam("include") String include, @Context HttpHeaders header, @Context HttpServletResponse response) /*throws NotFoundException, ServiceUnavailableException, PermissionDeniedException, AuthorizationRequiredException*/ {
public String dataVariableMetadataDDI(@PathParam("varId") Long varId, @QueryParam("fileMetadataId") Long fileMetadataId, @QueryParam("exclude") String exclude, @QueryParam("include") String include, @Context HttpHeaders header, @Context HttpServletResponse response) /*throws NotFoundException, ServiceUnavailableException, PermissionDeniedException, AuthorizationRequiredException*/ {
String retValue = "";

ByteArrayOutputStream outStream = null;
Expand All @@ -450,7 +465,8 @@ public String dataVariableMetadataDDI(@PathParam("varId") Long varId, @QueryPara
varId,
outStream,
exclude,
include);
include,
fileMetadataId);
} catch (Exception e) {
// For whatever reason we've failed to generate a partial
// metadata record requested. We simply return an empty string.
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/edu/harvard/iq/dataverse/api/Meta.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class Meta {
@GET
@Produces({ "application/xml" })

public String variable(@PathParam("varId") Long varId, @QueryParam("exclude") String exclude, @QueryParam("include") String include, @Context HttpHeaders header, @Context HttpServletResponse response) /*throws NotFoundException, ServiceUnavailableException, PermissionDeniedException, AuthorizationRequiredException*/ {
public String variable(@PathParam("varId") Long varId, @QueryParam("fileMetadataId") Long fileMetadataId, @QueryParam("exclude") String exclude, @QueryParam("include") String include, @Context HttpHeaders header, @Context HttpServletResponse response) /*throws NotFoundException, ServiceUnavailableException, PermissionDeniedException, AuthorizationRequiredException*/ {
String retValue = "";

ByteArrayOutputStream outStream = null;
Expand All @@ -84,7 +84,8 @@ public String variable(@PathParam("varId") Long varId, @QueryParam("exclude") St
varId,
outStream,
exclude,
include);
include,
fileMetadataId);
} catch (Exception e) {
// For whatever reason we've failed to generate a partial
// metadata record requested. We simply return an empty string.
Expand All @@ -103,7 +104,7 @@ public String variable(@PathParam("varId") Long varId, @QueryParam("exclude") St
@Path("datafile/{fileId}")
@GET
@Produces({"text/xml"})
public String datafile(@PathParam("fileId") Long fileId, @QueryParam("exclude") String exclude, @QueryParam("include") String include, @Context HttpHeaders header, @Context HttpServletResponse response) throws NotFoundException, ServiceUnavailableException /*, PermissionDeniedException, AuthorizationRequiredException*/ {
public String datafile(@PathParam("fileId") Long fileId, @QueryParam("fileMetadataId") Long fileMetadataId, @QueryParam("exclude") String exclude, @QueryParam("include") String include, @Context HttpHeaders header, @Context HttpServletResponse response) throws NotFoundException, ServiceUnavailableException /*, PermissionDeniedException, AuthorizationRequiredException*/ {
String retValue = "";

DataFile dataFile = null;
Expand All @@ -129,7 +130,8 @@ public String datafile(@PathParam("fileId") Long fileId, @QueryParam("exclude")
fileId,
outStream,
exclude,
include);
include,
fileMetadataId);

retValue = outStream.toString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public class VariableMetadata implements Serializable {
@Column(columnDefinition="TEXT")
private String literalquestion;

/**
* postquestion: post question, metadata variable field.
*/
@Column(columnDefinition="TEXT")
private String postquestion;

/**
* interviewinstruction: Interview Instruction, metadata variable field.
*/
Expand Down Expand Up @@ -147,6 +153,10 @@ public void setLiteralquestion(String literalquestion) {
this.literalquestion = literalquestion;
}

public String getPostquestion() {return this.postquestion;}

public void setPostquestion(String postquestion) {this.postquestion = postquestion;}

public String getInterviewinstruction() {
return this.interviewinstruction;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ private void processQstn(XMLStreamReader xmlr, VariableMetadata newVM) throws XM
} else if (xmlr.getLocalName().equals("ivuInstr")) {
String text = parseText(xmlr, false);
newVM.setInterviewinstruction(text);
} else if (xmlr.getLocalName().equals("postQTxt")) {
String text = parseText(xmlr, false);
newVM.setPostquestion(text);
}
} else if (event == XMLStreamConstants.END_ELEMENT) {
if (xmlr.getLocalName().equals("qstn")) return;
Expand Down
Loading

0 comments on commit 20558d6

Please sign in to comment.