From c9750a0cb53dd216eb088481c3fa7de92495f799 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Tue, 22 Jun 2021 15:46:26 -0400 Subject: [PATCH 01/78] initial external status label impl Conflicts: src/main/java/propertyFiles/Bundle.properties --- .../harvard/iq/dataverse/DatasetVersion.java | 10 ++ .../harvard/iq/dataverse/MailServiceBean.java | 7 ++ .../iq/dataverse/UserNotification.java | 2 +- .../harvard/iq/dataverse/api/Datasets.java | 12 +++ .../providers/builtin/DataverseUserPage.java | 1 + .../impl/SetExternalStatusCommand.java | 91 +++++++++++++++++++ .../harvard/iq/dataverse/util/MailUtil.java | 2 + src/main/java/propertyFiles/Bundle.properties | 3 + src/main/webapp/dataset.xhtml | 1 + src/main/webapp/dataverseuser.xhtml | 10 ++ src/main/webapp/file.xhtml | 1 + 11 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java b/src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java index 1f0467577a2..0eb516232f7 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java @@ -171,6 +171,8 @@ public enum License { @OneToMany(mappedBy = "datasetVersion", cascade={CascadeType.REMOVE, CascadeType.MERGE, CascadeType.PERSIST}) private List workflowComments; + @Column(nullable=true) + private String externalStatusLabel; public Long getId() { return this.id; @@ -1952,4 +1954,12 @@ public String getLocaleLastUpdateTime() { return DateUtil.formatDate(new Timestamp(lastUpdateTime.getTime())); } + public String getExternalStatusLabel() { + return externalStatusLabel; + } + + public void setExternalStatusLabel(String externalStatusLabel) { + this.externalStatusLabel = externalStatusLabel; + } + } diff --git a/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java index 619f6577b61..ccf30f00ff7 100644 --- a/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java @@ -522,6 +522,12 @@ public String getMessageTextBasedOnNotification(UserNotification userNotificatio String[] paramArrayWorkflowFailure = {version.getDataset().getDisplayName(), getDatasetLink(version.getDataset()), comment}; messageText += MessageFormat.format(pattern, paramArrayWorkflowFailure); return messageText; + case STATUSUPDATED: + version = (DatasetVersion) targetObject; + pattern = BundleUtil.getStringFromBundle("notification.email.status"); + String[] paramArrayStatus = {version.getDataset().getDisplayName(), version.getExternalStatusLabel()}; + messageText += MessageFormat.format(pattern, paramArrayStatus); + return messageText; case CREATEACC: InternetAddress systemAddress = getSystemAddress(); String accountCreatedMessage = BundleUtil.getStringFromBundle("notification.email.welcome", Arrays.asList( @@ -621,6 +627,7 @@ private Object getObjectOfNotification (UserNotification userNotification){ case RETURNEDDS: case WORKFLOW_SUCCESS: case WORKFLOW_FAILURE: + case STATUSUPDATED: return versionService.find(userNotification.getObjectId()); case CREATEACC: return userNotification.getUser(); diff --git a/src/main/java/edu/harvard/iq/dataverse/UserNotification.java b/src/main/java/edu/harvard/iq/dataverse/UserNotification.java index 78f8f38206b..8c0f7e3da16 100644 --- a/src/main/java/edu/harvard/iq/dataverse/UserNotification.java +++ b/src/main/java/edu/harvard/iq/dataverse/UserNotification.java @@ -30,7 +30,7 @@ public enum Type { ASSIGNROLE, REVOKEROLE, CREATEDV, CREATEDS, CREATEACC, SUBMITTEDDS, RETURNEDDS, PUBLISHEDDS, REQUESTFILEACCESS, GRANTFILEACCESS, REJECTFILEACCESS, FILESYSTEMIMPORT, CHECKSUMIMPORT, CHECKSUMFAIL, CONFIRMEMAIL, APIGENERATED, INGESTCOMPLETED, INGESTCOMPLETEDWITHERRORS, - PUBLISHFAILED_PIDREG, WORKFLOW_SUCCESS, WORKFLOW_FAILURE + PUBLISHFAILED_PIDREG, WORKFLOW_SUCCESS, WORKFLOW_FAILURE, STATUSUPDATED }; private static final long serialVersionUID = 1L; diff --git a/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java b/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java index 226b4092078..42f6a74e847 100644 --- a/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java +++ b/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java @@ -69,6 +69,7 @@ import edu.harvard.iq.dataverse.engine.command.impl.RequestRsyncScriptCommand; import edu.harvard.iq.dataverse.engine.command.impl.ReturnDatasetToAuthorCommand; import edu.harvard.iq.dataverse.engine.command.impl.SetDatasetCitationDateCommand; +import edu.harvard.iq.dataverse.engine.command.impl.SetExternalStatusCommand; import edu.harvard.iq.dataverse.engine.command.impl.SubmitDatasetForReviewCommand; import edu.harvard.iq.dataverse.engine.command.impl.UpdateDatasetVersionCommand; import edu.harvard.iq.dataverse.engine.command.impl.UpdateDatasetTargetURLCommand; @@ -1556,6 +1557,17 @@ public Response returnToAuthor(@PathParam("id") String idSupplied, String jsonBo } } + @PUT + @Path("{id}/setExternalStatus") + public Response setExternalStatus(@PathParam("id") String idSupplied, @QueryParam("label") String label) { + try { + execCommand(new SetExternalStatusCommand(createDataverseRequest(findUserOrDie()), findDatasetOrDie(idSupplied), label)); + return ok("External Status updated"); + } catch (WrappedResponse wr) { + return wr.getResponse(); + } + } + @GET @Path("{id}/uploadsid") @Deprecated diff --git a/src/main/java/edu/harvard/iq/dataverse/authorization/providers/builtin/DataverseUserPage.java b/src/main/java/edu/harvard/iq/dataverse/authorization/providers/builtin/DataverseUserPage.java index d050dbc0dbd..f38965ff28a 100644 --- a/src/main/java/edu/harvard/iq/dataverse/authorization/providers/builtin/DataverseUserPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/authorization/providers/builtin/DataverseUserPage.java @@ -492,6 +492,7 @@ public void displayNotification() { case RETURNEDDS: case WORKFLOW_SUCCESS: case WORKFLOW_FAILURE: + case STATUSUPDATED: userNotification.setTheObject(datasetVersionService.find(userNotification.getObjectId())); break; diff --git a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java new file mode 100644 index 00000000000..25d48b488ac --- /dev/null +++ b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java @@ -0,0 +1,91 @@ +package edu.harvard.iq.dataverse.engine.command.impl; + +import edu.harvard.iq.dataverse.Dataset; +import edu.harvard.iq.dataverse.DatasetLock; +import edu.harvard.iq.dataverse.DatasetVersionUser; +import edu.harvard.iq.dataverse.UserNotification; +import edu.harvard.iq.dataverse.authorization.Permission; +import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser; +import edu.harvard.iq.dataverse.batch.util.LoggingUtil; +import edu.harvard.iq.dataverse.engine.command.AbstractCommand; +import edu.harvard.iq.dataverse.engine.command.CommandContext; +import edu.harvard.iq.dataverse.engine.command.DataverseRequest; +import edu.harvard.iq.dataverse.engine.command.RequiredPermissions; +import edu.harvard.iq.dataverse.engine.command.exception.CommandException; +import edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException; +import edu.harvard.iq.dataverse.util.BundleUtil; +import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; +import java.util.List; +import java.util.concurrent.Future; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.solr.client.solrj.SolrServerException; + +@RequiredPermissions(Permission.EditDataset) +public class SetExternalStatusCommand extends AbstractDatasetCommand { + + String label; + + public SetExternalStatusCommand(DataverseRequest aRequest, Dataset dataset, String label) { + super(aRequest, dataset); + this.label=label; + } + + @Override + public Dataset execute(CommandContext ctxt) throws CommandException { + + if (getDataset().getLatestVersion().isReleased()) { + throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.submit.failure.isReleased"), this); + } + Pattern pattern = Pattern.compile("/[\\w ]+/g"); + Matcher matcher = pattern.matcher(label); + if(!matcher.matches()) { + throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.submit.failure"), this); + } + getDataset().getLatestVersion().setExternalStatusLabel(label); + Dataset updatedDataset = save(ctxt); + + return updatedDataset; + } + + public Dataset save(CommandContext ctxt) throws CommandException { + + getDataset().getEditVersion().setLastUpdateTime(getTimestamp()); + getDataset().setModificationTime(getTimestamp()); + + Dataset savedDataset = ctxt.em().merge(getDataset()); + ctxt.em().flush(); + + updateDatasetUser(ctxt); + + AuthenticatedUser requestor = getUser().isAuthenticated() ? (AuthenticatedUser) getUser() : null; + + List authUsers = ctxt.permissions().getUsersWithPermissionOn(Permission.PublishDataset, savedDataset); + for (AuthenticatedUser au : authUsers) { + ctxt.notifications().sendNotification(au, new Timestamp(new Date().getTime()), UserNotification.Type.SUBMITTEDDS, savedDataset.getLatestVersion().getId(), "", requestor, false); + } + + // TODO: What should we do with the indexing result? Print it to the log? + return savedDataset; + } + + @Override + public boolean onSuccess(CommandContext ctxt, Object r) { + boolean retVal = true; + Dataset dataset = (Dataset) r; + + try { + Future indexString = ctxt.index().indexDataset(dataset, true); + } catch (IOException | SolrServerException e) { + String failureLogText = "Post submit for review indexing failed. You can kickoff a re-index of this dataset with: \r\n curl http://localhost:8080/api/admin/index/datasets/" + dataset.getId().toString(); + failureLogText += "\r\n" + e.getLocalizedMessage(); + LoggingUtil.writeOnSuccessFailureLog(this, failureLogText, dataset); + retVal = false; + } + return retVal; + } + +} diff --git a/src/main/java/edu/harvard/iq/dataverse/util/MailUtil.java b/src/main/java/edu/harvard/iq/dataverse/util/MailUtil.java index 7ca702cabbe..e776592b955 100644 --- a/src/main/java/edu/harvard/iq/dataverse/util/MailUtil.java +++ b/src/main/java/edu/harvard/iq/dataverse/util/MailUtil.java @@ -58,6 +58,8 @@ public static String getSubjectTextBasedOnNotification(UserNotification userNoti return BundleUtil.getStringFromBundle("notification.email.workflow.success.subject", rootDvNameAsList); case WORKFLOW_FAILURE: return BundleUtil.getStringFromBundle("notification.email.workflow.failure.subject", rootDvNameAsList); + case STATUSUPDATED: + return BundleUtil.getStringFromBundle("notification.email.status.change.subject", rootDvNameAsList); case CREATEACC: return BundleUtil.getStringFromBundle("notification.email.create.account.subject", rootDvNameAsList); case CHECKSUMFAIL: diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index 77248d76ea8..afdf3e6b4d3 100644 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -203,6 +203,7 @@ notification.wasPublished={0} was published in {1}. notification.publishFailedPidReg={0} in {1} could not be published due to a failure to register, or update the Global Identifier for the dataset or one of the files in it. Contact support if this continues to happen. notification.workflowFailed=An external workflow run on {0} in {1} has failed. Check your email and/or view the Dataset page which may have additional details. Contact support if this continues to happen. notification.workflowSucceeded=An external workflow run on {0} in {1} has succeeded. Check your email and/or view the Dataset page which may have additional details. +notification.statusUpdated=The status of dataset {0} has been updated to {1}. notification.ingestCompleted=Dataset {1} ingest has successfully finished. notification.ingestCompletedWithErrors=Dataset {1} ingest has finished with errors. @@ -681,6 +682,8 @@ notification.email.workflow.success.subject={0}: Your dataset has been processed notification.email.workflow.success=A workflow running on {0} (view at {1}) succeeded: {2} notification.email.workflow.failure.subject={0}: Failed to process your dataset notification.email.workflow.failure=A workflow running on {0} (view at {1}) failed: {2} +notification.email.status.change.subject={0}: Dataset Status Change +notification.email.status.change=The Status of the dataset ({0}) has changed to {1} notification.email.workflow.nullMessage=No additional message sent from the workflow. notification.email.create.account.subject={0}: Your account has been created notification.email.assign.role.subject={0}: You have been assigned a role diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index 995d6188cc6..977ac704456 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -114,6 +114,7 @@ + diff --git a/src/main/webapp/dataverseuser.xhtml b/src/main/webapp/dataverseuser.xhtml index 3e48e16404c..c7c3873ef1f 100644 --- a/src/main/webapp/dataverseuser.xhtml +++ b/src/main/webapp/dataverseuser.xhtml @@ -334,6 +334,16 @@ + + + + + #{item.theObject.getDataset().getDisplayName()} + + + + + diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 0e4931e7086..13e6e0b9440 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -68,6 +68,7 @@ + From 19dcce1c4fda90b8f9454451ff8c9750cdf85676 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Tue, 22 Jun 2021 16:24:43 -0400 Subject: [PATCH 02/78] typos, update errors, change regexp Conflicts: src/main/java/propertyFiles/Bundle.properties --- src/main/java/edu/harvard/iq/dataverse/api/Datasets.java | 6 +++++- .../engine/command/impl/SetExternalStatusCommand.java | 6 +++++- src/main/java/propertyFiles/Bundle.properties | 2 ++ src/main/webapp/dataset.xhtml | 2 +- src/main/webapp/file.xhtml | 2 +- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java b/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java index 42f6a74e847..87f47efed05 100644 --- a/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java +++ b/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java @@ -86,6 +86,7 @@ import edu.harvard.iq.dataverse.dataaccess.ImageThumbConverter; import edu.harvard.iq.dataverse.dataaccess.S3AccessIO; import edu.harvard.iq.dataverse.engine.command.exception.CommandException; +import edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException; import edu.harvard.iq.dataverse.engine.command.exception.UnforcedCommandException; import edu.harvard.iq.dataverse.engine.command.impl.GetDatasetStorageSizeCommand; import edu.harvard.iq.dataverse.engine.command.impl.RevokeRoleCommand; @@ -1560,11 +1561,14 @@ public Response returnToAuthor(@PathParam("id") String idSupplied, String jsonBo @PUT @Path("{id}/setExternalStatus") public Response setExternalStatus(@PathParam("id") String idSupplied, @QueryParam("label") String label) { + logger.info("Label is " + label); try { execCommand(new SetExternalStatusCommand(createDataverseRequest(findUserOrDie()), findDatasetOrDie(idSupplied), label)); return ok("External Status updated"); } catch (WrappedResponse wr) { - return wr.getResponse(); + //Just change to Bad Request and send + //ToDo - check in api call + return Response.fromResponse(wr.getResponse()).status(Response.Status.BAD_REQUEST).build(); } } diff --git a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java index 25d48b488ac..b77b95bda86 100644 --- a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java +++ b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java @@ -19,6 +19,7 @@ import java.util.Date; import java.util.List; import java.util.concurrent.Future; +import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -27,6 +28,8 @@ @RequiredPermissions(Permission.EditDataset) public class SetExternalStatusCommand extends AbstractDatasetCommand { + private static final Logger logger = Logger.getLogger(SetExternalStatusCommand.class.getName()); + String label; public SetExternalStatusCommand(DataverseRequest aRequest, Dataset dataset, String label) { @@ -40,9 +43,10 @@ public Dataset execute(CommandContext ctxt) throws CommandException { if (getDataset().getLatestVersion().isReleased()) { throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.submit.failure.isReleased"), this); } - Pattern pattern = Pattern.compile("/[\\w ]+/g"); + Pattern pattern = Pattern.compile("(/^[\\w ]+$/"); Matcher matcher = pattern.matcher(label); if(!matcher.matches()) { + logger.info("Label rejected: " + label); throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.submit.failure"), this); } getDataset().getLatestVersion().setExternalStatusLabel(label); diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index afdf3e6b4d3..32ebfed471e 100644 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -1329,6 +1329,8 @@ dataset.submit.failure=Dataset Submission Failed - {0} dataset.submit.failure.null=Can't submit for review. Dataset is null. dataset.submit.failure.isReleased=Latest version of dataset is already released. Only draft versions can be submitted for review. dataset.submit.failure.inReview=You cannot submit this dataset for review because it is already in review. +dataset.status.failure=Status update failed +dataset.status.failure.isReleased=Latest version of dataset is already released. Status can only be set on draft versions dataset.rejectMessage=Return this dataset to contributor for modification. dataset.rejectMessage.label=Return to Author Reason dataset.rejectWatermark=Please enter a reason for returning this dataset to its author(s). diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index 977ac704456..b59ea71aaad 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -114,7 +114,7 @@ - + diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 13e6e0b9440..b83511c23f2 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -68,7 +68,7 @@ - + From c5b215a4785820dee930c1149a403738563cc5a9 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Tue, 22 Jun 2021 16:31:14 -0400 Subject: [PATCH 03/78] typo missing ) --- .../dataverse/engine/command/impl/SetExternalStatusCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java index b77b95bda86..30ac73f906d 100644 --- a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java +++ b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java @@ -43,7 +43,7 @@ public Dataset execute(CommandContext ctxt) throws CommandException { if (getDataset().getLatestVersion().isReleased()) { throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.submit.failure.isReleased"), this); } - Pattern pattern = Pattern.compile("(/^[\\w ]+$/"); + Pattern pattern = Pattern.compile("(/^[\\w ]+$)/"); Matcher matcher = pattern.matcher(label); if(!matcher.matches()) { logger.info("Label rejected: " + label); From d0d996c5db18c6f9bce932b52e58077d8700c059 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Tue, 22 Jun 2021 16:38:25 -0400 Subject: [PATCH 04/78] fix regexp, use new error msgs --- .../engine/command/impl/SetExternalStatusCommand.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java index 30ac73f906d..8c01dacc519 100644 --- a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java +++ b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java @@ -41,13 +41,13 @@ public SetExternalStatusCommand(DataverseRequest aRequest, Dataset dataset, Stri public Dataset execute(CommandContext ctxt) throws CommandException { if (getDataset().getLatestVersion().isReleased()) { - throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.submit.failure.isReleased"), this); + throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.status.failure.isReleased"), this); } - Pattern pattern = Pattern.compile("(/^[\\w ]+$)/"); + Pattern pattern = Pattern.compile("(^[\\w ]+$)"); Matcher matcher = pattern.matcher(label); if(!matcher.matches()) { logger.info("Label rejected: " + label); - throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.submit.failure"), this); + throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.status.failure"), this); } getDataset().getLatestVersion().setExternalStatusLabel(label); Dataset updatedDataset = save(ctxt); From 044cbbc8b64033790d988b67b5e72901d3376519 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Tue, 22 Jun 2021 16:55:24 -0400 Subject: [PATCH 05/78] allow delete, clear upon publication --- .../edu/harvard/iq/dataverse/api/Datasets.java | 14 ++++++++++++++ .../FinalizeDatasetPublicationCommand.java | 3 +++ .../command/impl/SetExternalStatusCommand.java | 18 +++++++++++------- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java b/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java index 87f47efed05..ade41c3131a 100644 --- a/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java +++ b/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java @@ -1572,6 +1572,20 @@ public Response setExternalStatus(@PathParam("id") String idSupplied, @QueryPara } } + @DELETE + @Path("{id}/setExternalStatus") + public Response deleteExternalStatus(@PathParam("id") String idSupplied) { + + try { + execCommand(new SetExternalStatusCommand(createDataverseRequest(findUserOrDie()), findDatasetOrDie(idSupplied), null)); + return ok("External Status deleted"); + } catch (WrappedResponse wr) { + //Just change to Bad Request and send + //ToDo - check in api call + return Response.fromResponse(wr.getResponse()).status(Response.Status.BAD_REQUEST).build(); + } + } + @GET @Path("{id}/uploadsid") @Deprecated diff --git a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/FinalizeDatasetPublicationCommand.java b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/FinalizeDatasetPublicationCommand.java index 4fa07dedede..c33bf03f469 100644 --- a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/FinalizeDatasetPublicationCommand.java +++ b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/FinalizeDatasetPublicationCommand.java @@ -114,6 +114,9 @@ public Dataset execute(CommandContext ctxt) throws CommandException { theDataset.setPublicationDate(new Timestamp(new Date().getTime())); } + //Clear any external status + theDataset.getLatestVersion().setExternalStatusLabel(null); + // update metadata theDataset.getLatestVersion().setReleaseTime(getTimestamp()); theDataset.getLatestVersion().setLastUpdateTime(getTimestamp()); diff --git a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java index 8c01dacc519..ccfdbe15751 100644 --- a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java +++ b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java @@ -43,13 +43,17 @@ public Dataset execute(CommandContext ctxt) throws CommandException { if (getDataset().getLatestVersion().isReleased()) { throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.status.failure.isReleased"), this); } - Pattern pattern = Pattern.compile("(^[\\w ]+$)"); - Matcher matcher = pattern.matcher(label); - if(!matcher.matches()) { - logger.info("Label rejected: " + label); - throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.status.failure"), this); + if (label == null) { + getDataset().getLatestVersion().setExternalStatusLabel(label); + } else { + Pattern pattern = Pattern.compile("(^[\\w ]+$)"); + Matcher matcher = pattern.matcher(label); + if (!matcher.matches()) { + logger.info("Label rejected: " + label); + throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.status.failure"), this); + } + getDataset().getLatestVersion().setExternalStatusLabel(label); } - getDataset().getLatestVersion().setExternalStatusLabel(label); Dataset updatedDataset = save(ctxt); return updatedDataset; @@ -69,7 +73,7 @@ public Dataset save(CommandContext ctxt) throws CommandException { List authUsers = ctxt.permissions().getUsersWithPermissionOn(Permission.PublishDataset, savedDataset); for (AuthenticatedUser au : authUsers) { - ctxt.notifications().sendNotification(au, new Timestamp(new Date().getTime()), UserNotification.Type.SUBMITTEDDS, savedDataset.getLatestVersion().getId(), "", requestor, false); + ctxt.notifications().sendNotification(au, new Timestamp(new Date().getTime()), UserNotification.Type.STATUSUPDATED, savedDataset.getLatestVersion().getId(), "", requestor, false); } // TODO: What should we do with the indexing result? Print it to the log? From 149baa3f6700c6723f1be4e05dc6127524a9a446 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Tue, 22 Jun 2021 17:12:31 -0400 Subject: [PATCH 06/78] typo --- src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java index ccf30f00ff7..e2d5fbded36 100644 --- a/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java @@ -524,7 +524,7 @@ public String getMessageTextBasedOnNotification(UserNotification userNotificatio return messageText; case STATUSUPDATED: version = (DatasetVersion) targetObject; - pattern = BundleUtil.getStringFromBundle("notification.email.status"); + pattern = BundleUtil.getStringFromBundle("notification.email.status.change"); String[] paramArrayStatus = {version.getDataset().getDisplayName(), version.getExternalStatusLabel()}; messageText += MessageFormat.format(pattern, paramArrayStatus); return messageText; From 21efbb8ad896e996d88d41a15a3604938027b3ea Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Tue, 22 Jun 2021 17:21:41 -0400 Subject: [PATCH 07/78] don't say null in email --- src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java index e2d5fbded36..3760d1004f2 100644 --- a/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/MailServiceBean.java @@ -525,7 +525,7 @@ public String getMessageTextBasedOnNotification(UserNotification userNotificatio case STATUSUPDATED: version = (DatasetVersion) targetObject; pattern = BundleUtil.getStringFromBundle("notification.email.status.change"); - String[] paramArrayStatus = {version.getDataset().getDisplayName(), version.getExternalStatusLabel()}; + String[] paramArrayStatus = {version.getDataset().getDisplayName(), (version.getExternalStatusLabel()==null) ? "" : version.getExternalStatusLabel()}; messageText += MessageFormat.format(pattern, paramArrayStatus); return messageText; case CREATEACC: From dac5389ad2ecb6840aae4823fa264c901c113f66 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Thu, 24 Jun 2021 14:27:04 -0400 Subject: [PATCH 08/78] fix: get the datasetversion --- src/main/webapp/file.xhtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index b83511c23f2..481012eb021 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -68,7 +68,7 @@ - + From 346af0dd837161e4b0421873fac3c8405c3b6c1e Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Mon, 28 Jun 2021 13:19:17 -0400 Subject: [PATCH 09/78] require publish permission, add label list setting Conflicts: src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java src/main/java/propertyFiles/Bundle.properties --- .../impl/SetExternalStatusCommand.java | 22 +++++++++++++------ .../settings/SettingsServiceBean.java | 6 ++++- src/main/java/propertyFiles/Bundle.properties | 3 ++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java index ccfdbe15751..f3f1b7f9021 100644 --- a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java +++ b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java @@ -13,9 +13,11 @@ import edu.harvard.iq.dataverse.engine.command.RequiredPermissions; import edu.harvard.iq.dataverse.engine.command.exception.CommandException; import edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException; +import edu.harvard.iq.dataverse.settings.SettingsServiceBean; import edu.harvard.iq.dataverse.util.BundleUtil; import java.io.IOException; import java.sql.Timestamp; +import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.concurrent.Future; @@ -25,7 +27,7 @@ import org.apache.solr.client.solrj.SolrServerException; -@RequiredPermissions(Permission.EditDataset) +@RequiredPermissions(Permission.PublishDataset) public class SetExternalStatusCommand extends AbstractDatasetCommand { private static final Logger logger = Logger.getLogger(SetExternalStatusCommand.class.getName()); @@ -46,13 +48,19 @@ public Dataset execute(CommandContext ctxt) throws CommandException { if (label == null) { getDataset().getLatestVersion().setExternalStatusLabel(label); } else { - Pattern pattern = Pattern.compile("(^[\\w ]+$)"); - Matcher matcher = pattern.matcher(label); - if (!matcher.matches()) { - logger.info("Label rejected: " + label); - throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.status.failure"), this); + String allowedLabels = ctxt.settings().getValueForKey(SettingsServiceBean.Key.AllowedCurationLabels, ""); + if (Arrays.asList(allowedLabels.split("\\s*,\\s*")).contains(label)) { + Pattern pattern = Pattern.compile("(^[\\w ]+$)"); + Matcher matcher = pattern.matcher(label); + if (!matcher.matches()) { + logger.info("Label rejected: " + label); + throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.status.failure.badformat"), this); + } + getDataset().getLatestVersion().setExternalStatusLabel(label); + } else { + logger.info("Label not found: " + label); + throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.status.failure.notallowed"), this); } - getDataset().getLatestVersion().setExternalStatusLabel(label); } Dataset updatedDataset = save(ctxt); diff --git a/src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java index 02637bfa8df..a48de83e558 100644 --- a/src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java @@ -433,7 +433,11 @@ Whether Harvesting (OAI) service is enabled * Installation Brand Name is always included (default/false) or is not included * when the Distributor field (citation metadatablock) is set (true) */ - ExportInstallationAsDistributorOnlyWhenNotSet + ExportInstallationAsDistributorOnlyWhenNotSet, + /** + * A comma separated list of the allowed labels. These should correspond to the states in an organizations curation process. + */ + AllowedCurationLabels ; @Override diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index 32ebfed471e..4811bcdc821 100644 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -1329,7 +1329,8 @@ dataset.submit.failure=Dataset Submission Failed - {0} dataset.submit.failure.null=Can't submit for review. Dataset is null. dataset.submit.failure.isReleased=Latest version of dataset is already released. Only draft versions can be submitted for review. dataset.submit.failure.inReview=You cannot submit this dataset for review because it is already in review. -dataset.status.failure=Status update failed +dataset.status.failure.notallowed=Status update failed - label not allowed +dataset.status.failure.badformat=Status update failed - label can only include alphanumeric characters and internal spaces. dataset.status.failure.isReleased=Latest version of dataset is already released. Status can only be set on draft versions dataset.rejectMessage=Return this dataset to contributor for modification. dataset.rejectMessage.label=Return to Author Reason From 017254db0c18993238b1bdd92dd020008120ae6d Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Tue, 20 Jul 2021 17:51:59 -0400 Subject: [PATCH 10/78] add status label in search results --- src/main/webapp/search-include-fragment.xhtml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/webapp/search-include-fragment.xhtml b/src/main/webapp/search-include-fragment.xhtml index f70b321cea4..07eecc087a0 100644 --- a/src/main/webapp/search-include-fragment.xhtml +++ b/src/main/webapp/search-include-fragment.xhtml @@ -590,6 +590,7 @@ + From cda78c266b17b6412aa967bfdffb0403ff6fded3 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Tue, 20 Jul 2021 18:25:20 -0400 Subject: [PATCH 11/78] make external status searchable/fix display in search --- conf/solr/8.8.1/schema.xml | 1 + .../iq/dataverse/search/IndexServiceBean.java | 3 +++ .../harvard/iq/dataverse/search/SearchFields.java | 2 ++ .../iq/dataverse/search/SearchServiceBean.java | 4 ++++ .../iq/dataverse/search/SolrSearchResult.java | 12 ++++++++++++ src/main/webapp/search-include-fragment.xhtml | 2 +- 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/conf/solr/8.8.1/schema.xml b/conf/solr/8.8.1/schema.xml index c6f6cd37cd6..3d46a8336be 100644 --- a/conf/solr/8.8.1/schema.xml +++ b/conf/solr/8.8.1/schema.xml @@ -162,6 +162,7 @@ + diff --git a/src/main/java/edu/harvard/iq/dataverse/search/IndexServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/search/IndexServiceBean.java index bfc2af2fcc4..2f6bcfbd394 100644 --- a/src/main/java/edu/harvard/iq/dataverse/search/IndexServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/search/IndexServiceBean.java @@ -781,6 +781,9 @@ private String addOrUpdateDataset(IndexableDataset indexableDataset, Set d if (datasetVersion.isInReview()) { solrInputDocument.addField(SearchFields.PUBLICATION_STATUS, IN_REVIEW_STRING); } + if(datasetVersion.getExternalStatusLabel()!=null) { + solrInputDocument.addField(SearchFields.EXTERNAL_STATUS, datasetVersion.getExternalStatusLabel()); + } for (DatasetField dsf : datasetVersion.getFlatDatasetFields()) { diff --git a/src/main/java/edu/harvard/iq/dataverse/search/SearchFields.java b/src/main/java/edu/harvard/iq/dataverse/search/SearchFields.java index a14cac88f1e..422e74f2207 100644 --- a/src/main/java/edu/harvard/iq/dataverse/search/SearchFields.java +++ b/src/main/java/edu/harvard/iq/dataverse/search/SearchFields.java @@ -220,6 +220,8 @@ public class SearchFields { * i.e. "Unpublished", "Draft" (multivalued) */ public static final String PUBLICATION_STATUS = "publicationStatus"; + + public static final String EXTERNAL_STATUS = "externalStatus"; /** * @todo reconcile different with Solr schema.xml where type is Long rather * than String. diff --git a/src/main/java/edu/harvard/iq/dataverse/search/SearchServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/search/SearchServiceBean.java index 8969d7523cd..ceed424cbce 100644 --- a/src/main/java/edu/harvard/iq/dataverse/search/SearchServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/search/SearchServiceBean.java @@ -427,6 +427,10 @@ public SolrQueryResponse search(DataverseRequest dataverseRequest, List matchedFields; + //External Status Label (enabled via AllowedCurationLabels setting) + private String externalStatus; + /** * @todo: remove name? */ @@ -1205,4 +1208,13 @@ public String getNameOfDataverse() { public void setNameOfDataverse(String id) { this.nameOfDataverse = id; } + + public String getExternalStatus() { + return externalStatus; + } + + public void setExternalStatus(String externalStatus) { + this.externalStatus = externalStatus; + + } } diff --git a/src/main/webapp/search-include-fragment.xhtml b/src/main/webapp/search-include-fragment.xhtml index 07eecc087a0..59bf368fa57 100644 --- a/src/main/webapp/search-include-fragment.xhtml +++ b/src/main/webapp/search-include-fragment.xhtml @@ -590,7 +590,7 @@ - + From 62166f2412ca1a77983953cf101e32b70dd353c5 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Tue, 20 Jul 2021 20:35:42 -0400 Subject: [PATCH 12/78] add to dataset card --- src/main/webapp/search-include-fragment.xhtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/search-include-fragment.xhtml b/src/main/webapp/search-include-fragment.xhtml index 59bf368fa57..1b21f0ebd70 100644 --- a/src/main/webapp/search-include-fragment.xhtml +++ b/src/main/webapp/search-include-fragment.xhtml @@ -525,6 +525,7 @@ +
@@ -590,7 +591,6 @@ -
From 7ceef90eb777c4cad7a616bed635359a3fc0db63 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 21 Jul 2021 10:36:21 -0400 Subject: [PATCH 13/78] add curation status menu Conflicts: src/main/webapp/dataset.xhtml --- .../edu/harvard/iq/dataverse/DatasetPage.java | 13 +++ .../harvard/iq/dataverse/SettingsWrapper.java | 9 ++ src/main/java/propertyFiles/Bundle.properties | 4 + src/main/webapp/dataset.xhtml | 101 ++++++++++-------- 4 files changed, 83 insertions(+), 44 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java index d441faf7ec6..f8f18756f17 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java @@ -100,6 +100,7 @@ import edu.harvard.iq.dataverse.engine.command.impl.PublishDatasetResult; import edu.harvard.iq.dataverse.engine.command.impl.RestrictFileCommand; import edu.harvard.iq.dataverse.engine.command.impl.ReturnDatasetToAuthorCommand; +import edu.harvard.iq.dataverse.engine.command.impl.SetExternalStatusCommand; import edu.harvard.iq.dataverse.engine.command.impl.SubmitDatasetForReviewCommand; import edu.harvard.iq.dataverse.externaltools.ExternalTool; import edu.harvard.iq.dataverse.externaltools.ExternalToolServiceBean; @@ -5477,4 +5478,16 @@ public boolean isFileDeleted (DataFile dataFile) { return dataFile.getDeleted(); } + + public void setExternalStatus(String status) { + try { + commandEngine.submit(new SetExternalStatusCommand(dvRequestService.getDataverseRequest(), dataset, status)); + JH.addMessage(FacesMessage.SEVERITY_INFO, BundleUtil.getStringFromBundle("dataset.externalstatus.header"), + BundleUtil.getStringFromBundle("dataset.externalstatus.info", Arrays.asList(status))); + } catch (CommandException ex) { + String msg = BundleUtil.getStringFromBundle("dataset.externalstatus.cantchange"); + logger.warning("Unable to change external status to " + status + " for dataset id " + dataset.getId() + ". Message to user: " + msg + " Exception: " + ex); + JsfHelper.addErrorMessage(msg); + } + } } diff --git a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java index eb4527f2aaa..739ce99f426 100644 --- a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java +++ b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java @@ -276,5 +276,14 @@ public boolean displayChronologicalDateFacets() { } + List allowedExternalStatuses = null; + + public List getAllowedExternalStatuses() { + String names = get(SettingsServiceBean.Key.AllowedCurationLabels.toString(), ""); + if (allowedExternalStatuses == null) { + allowedExternalStatuses.addAll(Arrays.asList(names.split(",\\s"))); + } + return allowedExternalStatuses; + } } diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index 4811bcdc821..f129b97551b 100644 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -1278,6 +1278,7 @@ dataset.shareBtn=Share dataset.publishBtn=Publish Dataset dataset.editBtn=Edit Dataset +dataset.changestatus=Change Curation Status dataset.editBtn.itemLabel.upload=Files (Upload) dataset.editBtn.itemLabel.metadata=Metadata dataset.editBtn.itemLabel.terms=Terms @@ -1515,6 +1516,9 @@ dataset.privateurl.roleassigeeTitle=Private URL Enabled dataset.privateurl.createdSuccess=Success! dataset.privateurl.disabledSuccess=You have successfully disabled the Private URL for this unpublished dataset. dataset.privateurl.noPermToCreate=To create a Private URL you must have the following permissions: {0}. +dataset.externalstatus.header=Curation Status Changed +dataset.externalstatus.info=Curation Status is now {0} +dataset.externalstatus.cantchange=Unable to change Curation Status. Please contact the administrator. file.display.label=Change View file.display.table=Table file.display.tree=Tree diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index b59ea71aaad..4f9d9ea6f82 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -279,51 +279,64 @@ - -
-
- - - - - - - - - - - - - #{bundle['dataset.publishBtn']} - - -
From 2c5ae21db837fd2bb5139613b703bce1405fb210 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 21 Jul 2021 10:45:28 -0400 Subject: [PATCH 14/78] handle nulls --- src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java index 739ce99f426..aac5523f756 100644 --- a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java +++ b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java @@ -280,7 +280,8 @@ public boolean displayChronologicalDateFacets() { public List getAllowedExternalStatuses() { String names = get(SettingsServiceBean.Key.AllowedCurationLabels.toString(), ""); - if (allowedExternalStatuses == null) { + if (names != null && allowedExternalStatuses == null) { + allowedExternalStatuses = new ArrayList(); allowedExternalStatuses.addAll(Arrays.asList(names.split(",\\s"))); } return allowedExternalStatuses; From 6dbc26a64409de6207866e10da35bb5c733a9be4 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 21 Jul 2021 10:52:17 -0400 Subject: [PATCH 15/78] fix update --- src/main/webapp/dataset.xhtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index 4f9d9ea6f82..927a7627a8d 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -328,7 +328,7 @@ From 1648080d55a6f87f86093c4484bafa4376262889 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 21 Jul 2021 11:10:42 -0400 Subject: [PATCH 17/78] typo getting bundled string --- src/main/webapp/dataset.xhtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index 37a8258a102..60c6536fbf8 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -335,7 +335,7 @@
  • - #{dataset.removestatus} + #{bundle['dataset.removestatus']}
  • From b3a20c390b7a10b514abd52d04e16c6585dad0b5 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 21 Jul 2021 11:21:26 -0400 Subject: [PATCH 18/78] bundle typo, move remove outside repeat --- src/main/java/propertyFiles/Bundle.properties | 2 +- src/main/webapp/dataset.xhtml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index 3df2f38ec22..08dd70b68d7 100644 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -1279,7 +1279,7 @@ dataset.publishBtn=Publish Dataset dataset.editBtn=Edit Dataset dataset.changestatus=Change Curation Status -dataset.changestatus=Remove Current Status +dataset.removestatus=Remove Current Status dataset.editBtn.itemLabel.upload=Files (Upload) dataset.editBtn.itemLabel.metadata=Metadata dataset.editBtn.itemLabel.terms=Terms diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index 60c6536fbf8..50a9e13eb72 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -332,13 +332,13 @@ #{status} - -
  • - - #{bundle['dataset.removestatus']} - -
  • + +
  • + + #{bundle['dataset.removestatus']} + +
  • From 74e36229b06d361012d9b0736246ee6153b74581 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 21 Jul 2021 13:16:33 -0400 Subject: [PATCH 19/78] update dataset after status change --- src/main/java/edu/harvard/iq/dataverse/DatasetPage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java index f8f18756f17..2287e63ce7b 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java @@ -5481,9 +5481,9 @@ public boolean isFileDeleted (DataFile dataFile) { public void setExternalStatus(String status) { try { - commandEngine.submit(new SetExternalStatusCommand(dvRequestService.getDataverseRequest(), dataset, status)); + dataset = commandEngine.submit(new SetExternalStatusCommand(dvRequestService.getDataverseRequest(), dataset, status)); JH.addMessage(FacesMessage.SEVERITY_INFO, BundleUtil.getStringFromBundle("dataset.externalstatus.header"), - BundleUtil.getStringFromBundle("dataset.externalstatus.info", Arrays.asList(status))); + status==null ? "" : BundleUtil.getStringFromBundle("dataset.externalstatus.info", Arrays.asList(status))); } catch (CommandException ex) { String msg = BundleUtil.getStringFromBundle("dataset.externalstatus.cantchange"); logger.warning("Unable to change external status to " + status + " for dataset id " + dataset.getId() + ". Message to user: " + msg + " Exception: " + ex); From 25dbdc1c08c7b3621c17f8cb596ed215b783615c Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 21 Jul 2021 15:23:40 -0400 Subject: [PATCH 20/78] debug publish button --- src/main/webapp/dataset.xhtml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index 50a9e13eb72..25442a751f4 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -283,6 +283,9 @@
    + + + From 839bc34231c2befce3085c7b79beadca08b086a4 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 21 Jul 2021 15:35:31 -0400 Subject: [PATCH 21/78] show menu when enabled --- src/main/webapp/dataset.xhtml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index 25442a751f4..6a999d16c5c 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -283,15 +283,12 @@
    - - - - + - + From 250cb2ccc44757c111bf79e114f81d8a7ce66df9 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 21 Jul 2021 15:49:54 -0400 Subject: [PATCH 22/78] fix carat --- src/main/webapp/dataset.xhtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index 6a999d16c5c..6818e64d12f 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -294,7 +294,7 @@ - #{showPublishLink ? bundle['dataset.publishBtn'] : (DatasetPage.dataset.latestVersion.inReview ? bundle['dataset.disabledSubmittedBtn'] : bundle['dataset.submitBtn'])} + #{showPublishLink ? bundle['dataset.publishBtn'] : (DatasetPage.dataset.latestVersion.inReview ? bundle['dataset.disabledSubmittedBtn'] : bundle['dataset.submitBtn'])}
    From 47637629a959bb0ece02eb13a02e215de556a34d Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Mon, 26 Jul 2021 16:11:53 -0400 Subject: [PATCH 28/78] restrict ext status label visibility to those who can publish --- src/main/java/edu/harvard/iq/dataverse/FilePage.java | 4 ++++ .../harvard/iq/dataverse/search/SearchIncludeFragment.java | 4 ++++ src/main/webapp/dataset.xhtml | 2 +- src/main/webapp/file.xhtml | 2 +- src/main/webapp/search-include-fragment.xhtml | 2 +- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/FilePage.java b/src/main/java/edu/harvard/iq/dataverse/FilePage.java index 045ac1f934a..f3488d950db 100644 --- a/src/main/java/edu/harvard/iq/dataverse/FilePage.java +++ b/src/main/java/edu/harvard/iq/dataverse/FilePage.java @@ -238,6 +238,10 @@ public String init() { private boolean canViewUnpublishedDataset() { return permissionsWrapper.canViewUnpublishedDataset( dvRequestService.getDataverseRequest(), fileMetadata.getDatasetVersion().getDataset()); } + + public boolean canPublishDataset(){ + return permissionsWrapper.canIssuePublishDatasetCommand(fileMetadata.getDatasetVersion().getDataset()); + } public FileMetadata getFileMetadata() { diff --git a/src/main/java/edu/harvard/iq/dataverse/search/SearchIncludeFragment.java b/src/main/java/edu/harvard/iq/dataverse/search/SearchIncludeFragment.java index 09ab372c687..81adef74c57 100644 --- a/src/main/java/edu/harvard/iq/dataverse/search/SearchIncludeFragment.java +++ b/src/main/java/edu/harvard/iq/dataverse/search/SearchIncludeFragment.java @@ -1249,6 +1249,10 @@ public String dataFileSizeDisplay(DataFile datafile) { } + public boolean canPublishDataset(long datasetId){ + return permissionsWrapper.canIssuePublishDatasetCommand(dvObjectService.findDvObject(datasetId)); + } + public void setDisplayCardValues() { Set harvestedDatasetIds = null; diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index b647387eef3..b7836dc6004 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -114,7 +114,7 @@ - + diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index e238a66a8a5..8669f683c78 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -68,7 +68,7 @@ - + diff --git a/src/main/webapp/search-include-fragment.xhtml b/src/main/webapp/search-include-fragment.xhtml index fecac6ec99f..d84096d8b83 100644 --- a/src/main/webapp/search-include-fragment.xhtml +++ b/src/main/webapp/search-include-fragment.xhtml @@ -525,7 +525,7 @@ - +
    From 2bf2686f82af2e9518b847fcd4b1830c22fffed4 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Mon, 26 Jul 2021 18:15:26 -0400 Subject: [PATCH 29/78] handle string conversion --- .../iq/dataverse/search/SearchIncludeFragment.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/search/SearchIncludeFragment.java b/src/main/java/edu/harvard/iq/dataverse/search/SearchIncludeFragment.java index 81adef74c57..79e430c81c6 100644 --- a/src/main/java/edu/harvard/iq/dataverse/search/SearchIncludeFragment.java +++ b/src/main/java/edu/harvard/iq/dataverse/search/SearchIncludeFragment.java @@ -1249,8 +1249,15 @@ public String dataFileSizeDisplay(DataFile datafile) { } - public boolean canPublishDataset(long datasetId){ + public boolean canPublishDataset(String id){ + try { + //Should only be called with a valid id (set during indexing) but catch/log any exception. + Long datasetId = Long.parseLong(id); return permissionsWrapper.canIssuePublishDatasetCommand(dvObjectService.findDvObject(datasetId)); + } catch (NumberFormatException nfe) { + logger.warning("canPublishDataset called with dataset id: " + id); + return false; + } } public void setDisplayCardValues() { From 25cfbac30b79da200efa4772a6a2d467315c1475 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Mon, 26 Jul 2021 18:29:49 -0400 Subject: [PATCH 30/78] use entityId directly Conflicts: src/main/webapp/search-include-fragment.xhtml --- .../iq/dataverse/search/SearchIncludeFragment.java | 9 +-------- src/main/webapp/search-include-fragment.xhtml | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/search/SearchIncludeFragment.java b/src/main/java/edu/harvard/iq/dataverse/search/SearchIncludeFragment.java index 79e430c81c6..f4e97a3842a 100644 --- a/src/main/java/edu/harvard/iq/dataverse/search/SearchIncludeFragment.java +++ b/src/main/java/edu/harvard/iq/dataverse/search/SearchIncludeFragment.java @@ -1249,15 +1249,8 @@ public String dataFileSizeDisplay(DataFile datafile) { } - public boolean canPublishDataset(String id){ - try { - //Should only be called with a valid id (set during indexing) but catch/log any exception. - Long datasetId = Long.parseLong(id); + public boolean canPublishDataset(Long datasetId){ return permissionsWrapper.canIssuePublishDatasetCommand(dvObjectService.findDvObject(datasetId)); - } catch (NumberFormatException nfe) { - logger.warning("canPublishDataset called with dataset id: " + id); - return false; - } } public void setDisplayCardValues() { diff --git a/src/main/webapp/search-include-fragment.xhtml b/src/main/webapp/search-include-fragment.xhtml index d84096d8b83..cb542ec776d 100644 --- a/src/main/webapp/search-include-fragment.xhtml +++ b/src/main/webapp/search-include-fragment.xhtml @@ -525,7 +525,7 @@ - +
    From 448e212e673cc0b470931de1ed6743cabb1aa051 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Thu, 29 Jul 2021 09:53:31 -0400 Subject: [PATCH 31/78] update flyway --- ...{V5.5.0.4__externalstatus.sql => V5.5.0.6__externalstatus.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V5.5.0.4__externalstatus.sql => V5.5.0.6__externalstatus.sql} (100%) diff --git a/src/main/resources/db/migration/V5.5.0.4__externalstatus.sql b/src/main/resources/db/migration/V5.5.0.6__externalstatus.sql similarity index 100% rename from src/main/resources/db/migration/V5.5.0.4__externalstatus.sql rename to src/main/resources/db/migration/V5.5.0.6__externalstatus.sql From 11e45a2aedde1f210bc3dc6d5b316995e5b70c85 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Fri, 30 Jul 2021 10:34:14 -0400 Subject: [PATCH 32/78] update workingVersion after status change --- src/main/java/edu/harvard/iq/dataverse/DatasetPage.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java index c29f4561e76..14a66addd8b 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java @@ -5492,6 +5492,7 @@ public boolean isFileDeleted (DataFile dataFile) { public void setExternalStatus(String status) { try { dataset = commandEngine.submit(new SetExternalStatusCommand(dvRequestService.getDataverseRequest(), dataset, status)); + workingVersion=dataset.getLatestVersion(); if (status == null || status.isEmpty()) { JsfHelper.addInfoMessage(BundleUtil.getStringFromBundle("dataset.externalstatus.removed")); } else { From d4b2d8d922fddfc7aeb5ae1e3da17742ddbc3916 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Fri, 30 Jul 2021 15:34:52 -0400 Subject: [PATCH 33/78] missing
    and spacing --- src/main/webapp/dataset.xhtml | 123 +++++++++++++++++----------------- 1 file changed, 62 insertions(+), 61 deletions(-) diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index b7836dc6004..a261e9c28ea 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -280,70 +280,71 @@
    - -
    -
    - - - - - - - - - - - - - #{showPublishLink ? bundle['dataset.publishBtn'] : (DatasetPage.dataset.latestVersion.inReview ? bundle['dataset.disabledSubmittedBtn'] : bundle['dataset.submitBtn'])} - - - +
    From b135cdcee0c6cae3033810cd44ce8968a32ca46c Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Fri, 30 Jul 2021 15:35:07 -0400 Subject: [PATCH 34/78] don't create list if empty --- src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java index 1bf99749e12..11cd4def44d 100644 --- a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java +++ b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java @@ -296,7 +296,7 @@ public boolean shouldBeAnonymized(DatasetField df) { public List getAllowedExternalStatuses() { String names = get(SettingsServiceBean.Key.AllowedCurationLabels.toString(), ""); - if (names != null && allowedExternalStatuses == null) { + if (!names.isEmpty() && allowedExternalStatuses == null) { allowedExternalStatuses = new ArrayList(); allowedExternalStatuses.addAll(Arrays.asList(names.split("\\s*,\\s*"))); } From cb876cb6caa7de766f7e483878c39d2685ab4896 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Fri, 30 Jul 2021 17:35:31 -0400 Subject: [PATCH 35/78] fix menu/button logic --- src/main/webapp/dataset.xhtml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index a261e9c28ea..318df88f5ee 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -285,17 +285,17 @@
    - + - + - #{showPublishLink ? bundle['dataset.publishBtn'] : (DatasetPage.dataset.latestVersion.inReview ? bundle['dataset.disabledSubmittedBtn'] : bundle['dataset.submitBtn'])} + #{showPublishLink ? bundle['dataset.publishBtn'] : (DatasetPage.dataset.latestVersion.inReview ? bundle['dataset.disabledSubmittedBtn'] : bundle['dataset.submitBtn'])}
    +
    + + #{bundle.curationLabels} + + +
    + + + + +
    +
    From b24e77565d056077ba3f45a493976f6486f5af5e Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Mon, 20 Sep 2021 15:57:13 -0400 Subject: [PATCH 41/78] failed refactor fix --- src/main/java/edu/harvard/iq/dataverse/DvObjectContainer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/DvObjectContainer.java b/src/main/java/edu/harvard/iq/dataverse/DvObjectContainer.java index a31571a28d7..be8c4912d80 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DvObjectContainer.java +++ b/src/main/java/edu/harvard/iq/dataverse/DvObjectContainer.java @@ -104,7 +104,7 @@ public void setMetadataLanguage(String ml) { public String getEffectiveCurationLabelSetName() { String setName = curationLabelSetName; - if (StringUtils.isBlank(setName) || setName.equals(SystemConfig.defaultCurationLabelSet)) { + if (StringUtils.isBlank(setName) || setName.equals(SystemConfig.DEFAULTCURATIONLABELSET)) { if (this.getOwner() != null) { setName = this.getOwner().getEffectiveCurationLabelSetName(); } else { @@ -116,7 +116,7 @@ public String getEffectiveCurationLabelSetName() { public String getCurationLabelSetName() { if (curationLabelSetName == null) { - return SystemConfig.defaultCurationLabelSet; + return SystemConfig.DEFAULTCURATIONLABELSET; } return curationLabelSetName; } From db4e136b07b7d8fdcf01b20996293dbd54faac4a Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Mon, 20 Sep 2021 17:04:31 -0400 Subject: [PATCH 42/78] sql script update --- .../edu/harvard/iq/dataverse/DvObjectContainer.java | 10 +++++----- .../db/migration/V5.6.0.1__curationlabels.sql | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/db/migration/V5.6.0.1__curationlabels.sql diff --git a/src/main/java/edu/harvard/iq/dataverse/DvObjectContainer.java b/src/main/java/edu/harvard/iq/dataverse/DvObjectContainer.java index be8c4912d80..8bde808252f 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DvObjectContainer.java +++ b/src/main/java/edu/harvard/iq/dataverse/DvObjectContainer.java @@ -100,10 +100,10 @@ public void setMetadataLanguage(String ml) { /* Dataverse collections can be configured to allow use of Curation labels and have this inheritable value to decide which set of labels to use. * This mechanism is similar to that for the storageDriver except that there is an addition option to disable use of labels. */ - private String curationLabelSetName = null; + private String externalLabelSetName = null; public String getEffectiveCurationLabelSetName() { - String setName = curationLabelSetName; + String setName = externalLabelSetName; if (StringUtils.isBlank(setName) || setName.equals(SystemConfig.DEFAULTCURATIONLABELSET)) { if (this.getOwner() != null) { setName = this.getOwner().getEffectiveCurationLabelSetName(); @@ -115,14 +115,14 @@ public String getEffectiveCurationLabelSetName() { } public String getCurationLabelSetName() { - if (curationLabelSetName == null) { + if (externalLabelSetName == null) { return SystemConfig.DEFAULTCURATIONLABELSET; } - return curationLabelSetName; + return externalLabelSetName; } public void setCurationLabelSetName(String setName) { - this.curationLabelSetName = setName; + this.externalLabelSetName = setName; } } diff --git a/src/main/resources/db/migration/V5.6.0.1__curationlabels.sql b/src/main/resources/db/migration/V5.6.0.1__curationlabels.sql new file mode 100644 index 00000000000..0f2c799482a --- /dev/null +++ b/src/main/resources/db/migration/V5.6.0.1__curationlabels.sql @@ -0,0 +1,4 @@ +ALTER TABLE datasetversion ADD COLUMN IF NOT EXISTS externalstatuslabel varchar(32); +ALTER TABLE dataverse ADD COLUMN IF NOT EXISTS externallabelsetname varchar(32); +ALTER TABLE dataset ADD COLUMN IF NOT EXISTS externallabelsetname varchar(32); + From c6c5604041d8a0d4d24c1bc9109bca137432f7da Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Mon, 20 Sep 2021 22:24:41 -0400 Subject: [PATCH 43/78] more debug info --- src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java b/src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java index d1f9c2aabdd..1cab5881866 100644 --- a/src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java +++ b/src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java @@ -1116,7 +1116,8 @@ public Map getCurationLabels() { } } } catch (Exception e) { - logger.warning("Unable to parse " + SettingsServiceBean.Key.AllowedCurationLabels.name()); + logger.warning("Unable to parse " + SettingsServiceBean.Key.AllowedCurationLabels.name() + ": " + e.getLocalizedMessage()); + e.printStackTrace(); } return labelMap; } From a45b2e744cadd9d13ad11a71df078ec74931558c Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Mon, 20 Sep 2021 22:43:11 -0400 Subject: [PATCH 44/78] change loop --- .../edu/harvard/iq/dataverse/util/SystemConfig.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java b/src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java index 1cab5881866..c190f6f3cde 100644 --- a/src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java +++ b/src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java @@ -23,6 +23,7 @@ import java.time.Year; import java.util.Arrays; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -1101,15 +1102,21 @@ public Map getCurationLabels() { JsonObject labelSets = jsonReader.readObject(); for (String key : labelSets.keySet()) { JsonArray labels = (JsonArray) labelSets.getJsonArray(key); + String[] labelArray = new String[labels.size()]; + boolean allLabelsOK = true; - String[] labelArray = labels.toArray(String[]::new); - for (String label : labelArray) { + Iterator iter = labels.iterator(); + int i=0; + while(iter.hasNext()) { + String label = ((JsonString)iter.next()).getString(); Matcher matcher = pattern.matcher(label); if (!matcher.matches()) { logger.warning("Label rejected: " + label + ", Label set " + key + " ignored."); allLabelsOK = false; break; } + labelArray[i] = label; + i++; } if (allLabelsOK) { labelMap.put(key, labelArray); From fa4a6715f48bf5ff980916bf43f9acd0a553cab4 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Tue, 21 Sep 2021 09:23:57 -0400 Subject: [PATCH 45/78] fix default, update label setting menu and command Conflicts: src/main/java/edu/harvard/iq/dataverse/DataversePage.java src/main/java/propertyFiles/Bundle.properties src/main/webapp/dataset.xhtml --- .../edu/harvard/iq/dataverse/DatasetPage.java | 4 +++ .../harvard/iq/dataverse/DataversePage.java | 18 +++++------ .../harvard/iq/dataverse/SettingsWrapper.java | 13 ++++---- .../impl/SetExternalStatusCommand.java | 30 ++++++++++++------- src/main/java/propertyFiles/Bundle.properties | 2 +- src/main/webapp/dataset.xhtml | 8 ++--- src/main/webapp/dataverse.xhtml | 2 +- 7 files changed, 45 insertions(+), 32 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java index 94139c570b1..fa7f6280ac3 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java @@ -5533,4 +5533,8 @@ public void setExternalStatus(String status) { JsfHelper.addErrorMessage(msg); } } + + public List getAllowedExternalStatuses() { + return settingsWrapper.getAllowedExternalStatuses(dataset); + } } diff --git a/src/main/java/edu/harvard/iq/dataverse/DataversePage.java b/src/main/java/edu/harvard/iq/dataverse/DataversePage.java index 7571e6a2953..0c18bfe48a4 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DataversePage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DataversePage.java @@ -1211,24 +1211,24 @@ public Set> getMetadataLanguages() { return settingsWrapper.getMetadataLanguages(this.dataverse).entrySet(); } - public Set getCurationLabelSetOptions() { - Set setNames = new HashSet(); + public Set> getCurationLabelSetOptions() { + HashMap setNames = new HashMap(); Set allowedSetNames = systemConfig.getCurationLabels().keySet(); if (allowedSetNames.size() > 0) { // Add an entry for the default (inherited from an ancestor or the system // default) - String inheritedLabelSet = getCurationLabelSetName(); + String inheritedLabelSet = getCurationLabelSetNameLabel(); if (!StringUtils.isBlank(inheritedLabelSet)) { - setNames.add(inheritedLabelSet); + setNames.put(inheritedLabelSet,SystemConfig.DEFAULTCURATIONLABELSET); } // Add an entry for disabled - setNames.add(SystemConfig.CURATIONLABELSDISABLED); - setNames.addAll(allowedSetNames); + setNames.put(SystemConfig.CURATIONLABELSDISABLED, SystemConfig.CURATIONLABELSDISABLED); + allowedSetNames.forEach(name -> {setNames.put(name, name);}); } - return setNames; + return setNames.entrySet(); } - public String getCurationLabelSetName() { + public String getCurationLabelSetNameLabel() { Dataverse parent = dataverse.getOwner(); String setName = null; boolean fromAncestor = false; @@ -1244,7 +1244,7 @@ public String getCurationLabelSetName() { parent = parent.getOwner(); } } - if (fromAncestor) { + if (fromAncestor && setName!=null) { setName = setName + " " + BundleUtil.getStringFromBundle("dataverse.storage.inherited"); } else { setName = setName + " " + BundleUtil.getStringFromBundle("dataverse.storage.default"); diff --git a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java index 5aec24a1947..c874fdcf0e8 100644 --- a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java +++ b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java @@ -6,6 +6,7 @@ package edu.harvard.iq.dataverse; import edu.harvard.iq.dataverse.branding.BrandingUtil; +import edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException; import edu.harvard.iq.dataverse.settings.Setting; import edu.harvard.iq.dataverse.settings.SettingsServiceBean; import edu.harvard.iq.dataverse.settings.SettingsServiceBean.Key; @@ -375,13 +376,13 @@ public String getDefaultMetadataLanguage() { List allowedExternalStatuses = null; - public List getAllowedExternalStatuses() { - String names = get(SettingsServiceBean.Key.AllowedCurationLabels.toString(), ""); - if (!names.isEmpty() && allowedExternalStatuses == null) { - allowedExternalStatuses = new ArrayList(); - allowedExternalStatuses.addAll(Arrays.asList(names.split("\\s*,\\s*"))); + public List getAllowedExternalStatuses(Dataset d) { + String setName = d.getEffectiveCurationLabelSetName(); + if(setName.equals(SystemConfig.CURATIONLABELSDISABLED)) { + return new ArrayList(); } - return allowedExternalStatuses; + String[] labelArray = systemConfig.getCurationLabels().get(setName); + return Arrays.asList(labelArray); } } diff --git a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java index df0cfc51d55..97bbfae91f4 100644 --- a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java +++ b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/SetExternalStatusCommand.java @@ -15,6 +15,8 @@ import edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException; import edu.harvard.iq.dataverse.settings.SettingsServiceBean; import edu.harvard.iq.dataverse.util.BundleUtil; +import edu.harvard.iq.dataverse.util.SystemConfig; + import java.io.IOException; import java.sql.Timestamp; import java.util.Arrays; @@ -49,19 +51,25 @@ public Dataset execute(CommandContext ctxt) throws CommandException { throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.status.failure.isReleased"), this); } if (label==null || label.isEmpty()) { - getDataset().getLatestVersion().setExternalStatusLabel(label); + getDataset().getLatestVersion().setExternalStatusLabel(null); } else { - String allowedLabels = ctxt.settings().getValueForKey(SettingsServiceBean.Key.AllowedCurationLabels, ""); - if (Arrays.asList(allowedLabels.split("\\s*,\\s*")).contains(label)) { - Pattern pattern = Pattern.compile("(^[\\w ]+$)"); - Matcher matcher = pattern.matcher(label); - if (!matcher.matches()) { - logger.info("Label rejected: " + label); - throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.status.failure.badformat"), this); + String setName = getDataset().getEffectiveCurationLabelSetName(); + if(setName.equals(SystemConfig.CURATIONLABELSDISABLED)) { + logger.info("External status labeling disbaled for dataset id: " + getDataset().getId()); + throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.status.failure.disabled"), this); + + } + String[] labelArray = ctxt.systemConfig().getCurationLabels().get(setName); + boolean found = false; + for(String name: labelArray) { + if(name.equals(label)) { + found=true; + getDataset().getLatestVersion().setExternalStatusLabel(label); + break; } - getDataset().getLatestVersion().setExternalStatusLabel(label); - } else { - logger.info("Label not found: " + label); + } + if(!found) { + logger.info("Label not found: " + label + " in set " + setName); throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.status.failure.notallowed"), this); } } diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index ca1f8b22d8b..cab1d123c3e 100644 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -1340,7 +1340,7 @@ dataset.submit.failure.null=Can't submit for review. Dataset is null. dataset.submit.failure.isReleased=Latest version of dataset is already released. Only draft versions can be submitted for review. dataset.submit.failure.inReview=You cannot submit this dataset for review because it is already in review. dataset.status.failure.notallowed=Status update failed - label not allowed -dataset.status.failure.badformat=Status update failed - label can only include alphanumeric characters and internal spaces. +dataset.status.failure.disabled=Status labeling disabled for this dataset dataset.status.failure.isReleased=Latest version of dataset is already released. Status can only be set on draft versions dataset.rejectMessage=Return this dataset to contributor for modification. dataset.rejectMessage.label=Return to Author Reason diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index 92f3bacfbc8..b0aec04b22c 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -285,17 +285,17 @@
    - + - + - #{showPublishLink ? bundle['dataset.publishBtn'] : (DatasetPage.dataset.latestVersion.inReview ? bundle['dataset.disabledSubmittedBtn'] : bundle['dataset.submitBtn'])} + #{showPublishLink ? bundle['dataset.publishBtn'] : (DatasetPage.dataset.latestVersion.inReview ? bundle['dataset.disabledSubmittedBtn'] : bundle['dataset.submitBtn'])}