-
Notifications
You must be signed in to change notification settings - Fork 534
Signposting #7919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signposting #7919
Changes from all commits
6a45404
770680e
a38f0df
c48df18
2868228
a55a378
db89d30
de12144
74dd56d
53f25b5
673eef0
6bc0f17
879f236
18ba37c
3950734
5abe639
3d644d1
65d69fe
7345f66
33fcb95
a2e5b64
ddb8780
f2fb557
9de4c35
1c6fde5
9752c6a
1c0cbbc
0c40649
c6d3df2
b441c65
690c450
200429a
ae21398
1211ec2
2e6deae
65d1ac0
545adb0
5106574
edf7cc8
d741c14
17d6450
1c25c23
7e20eae
891670b
ffe7b61
27b2f4e
0c11ff2
314f7d1
ce7f943
e06d9a9
3f52adc
300c1e7
313dae9
5ec179a
8a53bb6
8c92245
15e7f28
bb82e32
1411af0
190a0f9
bd07cb7
5011558
a656610
ce893a4
724e6e4
da8f52e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Signposting for DV 5.5 | ||
|
|
||
| This branch adds [Signposting](https://signposting.org/) support to DV 5.5. | ||
|
|
||
| There are 2 Signposting profile levels, level 1 and level 2. In this implementation, | ||
| * level 1 links are shown in | ||
| HTTP header, which can be fetched by `curl -I https://domain/link-to-article`. | ||
| * The level 2 linkset can be fetched by visiting the dedicated linkset page for | ||
| that artifact. The link can be seen in level 1 links with key name `rel="linkset"`. | ||
|
|
||
| The configuration is stored as JSON string in the `Bundle.properties` file, key name is | ||
| `signposting.configuration.SignpostingConf`. Please see a sample configuration below with explaination for each of the | ||
| config items. | ||
|
|
||
| ```json | ||
| { | ||
| "license": { | ||
| "CC0": "https://creativecommons.org/licenses/cc0/" | ||
| }, | ||
| "describedby": { | ||
| "doi": "https://doi.org/", | ||
| "type": "application/vnd.citationstyles.csl+json" | ||
| }, | ||
| "useDefaultFileType": true, | ||
| "defaultFileTypeValue": "https://schema.org/Dataset", | ||
| "maxItems": 5, | ||
| "maxAuthors": 5 | ||
| } | ||
| ``` | ||
|
|
||
| * The `license` is a `dict` contains the URI for `CC0`. Please be noted that this is a | ||
| temporary solution as all the licenses should be given by `multi-license` support once it's merged. | ||
| * `describedby` is required by [Signposting](https://signposting.org/). It shows the link to the metadata | ||
| which describes the resources that is the origin of the link. | ||
| * `useDefaultFileType` and `defaultFileTypeValue` are used in combination to provide extra `Dataset` type to DV | ||
| datasets. `AboutPage` is required by `Signposting`, hence always present in the datasets. Whilst a second type | ||
| could be configured to better reflect the actual scholarly type of the dataset. | ||
| * `maxItems` sets the max number of items/files which will be shown in `level 1` profile. Datasets with | ||
| too many files will not show any file link in `level 1` profile. They will be shown in `level 2` linkset only. | ||
| * `maxAuthors` Same with `maxItems`, `maxAuthors` sets the max number of authors to be shown in `level 1` profile. | ||
| If amount of authors exceeds this value, no link of authors will be shown in `level 1` profile. | ||
|
|
||
| Note: Authors without author link will not be counted nor shown in any profile/linkset. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,11 +45,8 @@ | |
| import edu.harvard.iq.dataverse.search.SearchFilesServiceBean; | ||
| import edu.harvard.iq.dataverse.search.SortBy; | ||
| import edu.harvard.iq.dataverse.settings.SettingsServiceBean; | ||
| import edu.harvard.iq.dataverse.util.ArchiverUtil; | ||
| import edu.harvard.iq.dataverse.util.BundleUtil; | ||
| import edu.harvard.iq.dataverse.util.FileSortFieldAndOrder; | ||
| import edu.harvard.iq.dataverse.util.FileUtil; | ||
| import edu.harvard.iq.dataverse.util.JsfHelper; | ||
| import edu.harvard.iq.dataverse.util.*; | ||
|
|
||
| import static edu.harvard.iq.dataverse.util.JsfHelper.JH; | ||
| import static edu.harvard.iq.dataverse.util.StringUtil.isEmpty; | ||
|
|
||
|
|
@@ -85,6 +82,8 @@ | |
|
|
||
| import org.primefaces.event.FileUploadEvent; | ||
| import org.primefaces.model.file.UploadedFile; | ||
|
|
||
| import javax.json.*; | ||
| import javax.validation.ConstraintViolation; | ||
| import org.apache.commons.httpclient.HttpClient; | ||
| //import org.primefaces.context.RequestContext; | ||
|
|
@@ -130,6 +129,7 @@ | |
| import edu.harvard.iq.dataverse.search.SearchServiceBean; | ||
| import edu.harvard.iq.dataverse.search.SearchUtil; | ||
| import edu.harvard.iq.dataverse.search.SolrClientService; | ||
| import edu.harvard.iq.dataverse.util.SignpostingResources; | ||
| import java.util.Comparator; | ||
| import org.apache.solr.client.solrj.SolrQuery; | ||
| import org.apache.solr.client.solrj.impl.HttpSolrClient; | ||
|
|
@@ -1917,7 +1917,7 @@ private String init(boolean initFull) { | |
| logger.warning("Problem getting rsync script (Command Exception): " + cex.getLocalizedMessage()); | ||
| } | ||
| } | ||
|
|
||
| tooLargeToDownload = getSizeOfDatasetNumeric() > settingsWrapper.getZipDownloadLimit(); | ||
| tooLargeToDownloadOriginal = getSizeOfDatasetOrigNumeric() > settingsWrapper.getZipDownloadLimit(); | ||
| tooLargeToDownloadArchival = getSizeOfDatasetArchivalNumeric() > settingsWrapper.getZipDownloadLimit(); | ||
|
|
@@ -2940,15 +2940,15 @@ public void startDownloadAllOriginal(){ | |
| this.setSelectedFiles(workingVersion.getFileMetadatas()); | ||
| startDownload(true); | ||
| } | ||
|
|
||
| public void startDownloadSelectedArchival() { | ||
| startDownload(false); | ||
| } | ||
|
|
||
| public void startDownloadSelectedOriginal() { | ||
| startDownload(true); | ||
| } | ||
|
|
||
| private void startDownload(boolean downloadOriginal){ | ||
| boolean guestbookRequired = isDownloadPopupRequired(); | ||
| boolean validate = validateFilesForDownload(guestbookRequired, downloadOriginal); | ||
|
|
@@ -3019,15 +3019,15 @@ public boolean validateFilesForDownload(boolean guestbookRequired, boolean downl | |
| setValidateFilesOutcome("Mixed"); | ||
| return true; | ||
| } | ||
|
|
||
| if (guestbookRequired) { | ||
| setValidateFilesOutcome("GuestbookRequired"); | ||
| } | ||
|
|
||
| return true; | ||
|
|
||
| } | ||
|
|
||
| private void updateGuestbookResponse (boolean guestbookRequired, boolean downloadOriginal) { | ||
| // Note that the GuestbookResponse object may still have information from | ||
| // the last download action performed by the user. For example, it may | ||
|
|
@@ -5477,4 +5477,15 @@ public boolean isFileDeleted (DataFile dataFile) { | |
|
|
||
| return dataFile.getDeleted(); | ||
| } | ||
|
|
||
| /** | ||
| * Add Signposting | ||
| * @return String | ||
| */ | ||
| public String getSignpostingLinkHeader() { | ||
| if (!workingVersion.isReleased()) | ||
| return "DRAFT"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why DRAFT? is this expected with SignPosting? Or should the header not be included if the dataset is draft? |
||
| SignpostingResources sr = new SignpostingResources(systemConfig, workingVersion, settingsService.getValueForKey(SettingsServiceBean.Key.SignpostingConf)); | ||
| return sr.getLinks(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,7 +78,6 @@ | |
| import edu.harvard.iq.dataverse.ingest.IngestServiceBean; | ||
| import edu.harvard.iq.dataverse.privateurl.PrivateUrl; | ||
| import edu.harvard.iq.dataverse.S3PackageImporter; | ||
| import static edu.harvard.iq.dataverse.api.AbstractApiBean.error; | ||
| import edu.harvard.iq.dataverse.api.dto.RoleAssignmentDTO; | ||
| import edu.harvard.iq.dataverse.batch.util.LoggingUtil; | ||
| import edu.harvard.iq.dataverse.dataaccess.DataAccess; | ||
|
|
@@ -104,9 +103,13 @@ | |
| import edu.harvard.iq.dataverse.util.FileUtil; | ||
| import edu.harvard.iq.dataverse.util.SystemConfig; | ||
| import edu.harvard.iq.dataverse.util.json.JsonParseException; | ||
| import edu.harvard.iq.dataverse.util.SignpostingResources; | ||
| import edu.harvard.iq.dataverse.search.IndexServiceBean; | ||
| import static edu.harvard.iq.dataverse.util.json.JsonPrinter.*; | ||
| import static edu.harvard.iq.dataverse.util.json.JsonPrinter.jsonLinkset; | ||
| import static edu.harvard.iq.dataverse.util.json.NullSafeJsonBuilder.jsonObjectBuilder; | ||
|
|
||
| import edu.harvard.iq.dataverse.util.json.JsonPrinter; | ||
| import edu.harvard.iq.dataverse.util.json.NullSafeJsonBuilder; | ||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
|
|
@@ -535,7 +538,31 @@ public Response getVersionMetadataBlock( @PathParam("id") String datasetId, | |
| return notFound("metadata block named " + blockName + " not found"); | ||
| }); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Add Signposting | ||
| * @param datasetId | ||
| * @param versionId | ||
| * @param uriInfo | ||
| * @param headers | ||
| * @return | ||
| */ | ||
| @GET | ||
| @Path("{id}/versions/{versionId}/linkset") | ||
| public Response getLinkset( @PathParam("id") String datasetId, @PathParam("versionId") String versionId, @Context UriInfo uriInfo, @Context HttpHeaders headers) { | ||
| if ( ":draft".equals(versionId) ) { | ||
| return badRequest("The :draft version can be viewed"); | ||
| } | ||
| return response( req -> { | ||
| DatasetVersion dsv = getDatasetVersionOrDie(req, versionId, findDatasetOrDie(datasetId), uriInfo, headers); | ||
| String dataverseSiteUrl = systemConfig.getDataverseSiteUrl(); | ||
| String anchor = dataverseSiteUrl + "/dataset.xhtml?persistentId=" + dsv.getDataset().getPersistentURL(); | ||
| String signpostingConf = settingsService.getValueForKey(SettingsServiceBean.Key.SignpostingConf, BundleUtil.getStringFromBundle("signposting.configuration.SignpostingConf")); | ||
| if (signpostingConf.isEmpty()) return notFound("Configuration key for signposting is empty [SignpostingConf]"); | ||
| if (dsv.getId() == null) return notFound("Dataset not found: Id is empty"); | ||
|
Comment on lines
+561
to
+562
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering about the error responses - not sure I would want users to know whether the config key exists. One option would just be to send no message or "Signposting not enabled". I also wonder if 501/not implemented or 409/conflict be better for the first? |
||
| return okLinkset(JsonPrinter.jsonLinkset(new SignpostingResources(systemConfig, dsv, signpostingConf))); | ||
| }); | ||
| } | ||
| @GET | ||
| @Path("{id}/modifyRegistration") | ||
| public Response updateDatasetTargetURL(@PathParam("id") String id ) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see from code below that this is just a default setting and that there is SignpostingConf setting as well. Minimally, the docs should indicate that it is set-able without editing the Bundle. More deeply - I'm not sure the Bundle is the right place for a default, i.e. it isn't something that should be internationalized. If it is easier to get a default for the whole setting, should it go in the code instead? Or?