Search in sources :

Example 1 with CommandContext

use of edu.harvard.iq.dataverse.engine.command.CommandContext in project dataverse by IQSS.

the class FinalizeDatasetPublicationCommand method notifyUsersFileDownload.

// These notification methods are fairly similar, but it was cleaner to create a few copies.
// If more notifications are needed in this command, they should probably be collapsed.
private void notifyUsersFileDownload(CommandContext ctxt, DvObject subject) {
    Timestamp timestamp = new Timestamp(new Date().getTime());
    ctxt.roles().directRoleAssignments(subject).stream().filter(ra -> ra.getRole().permissions().contains(Permission.DownloadFile)).flatMap(ra -> ctxt.roleAssignees().getExplicitUsers(ctxt.roleAssignees().getRoleAssignee(ra.getAssigneeIdentifier())).stream()).distinct().forEach(au -> ctxt.notifications().sendNotification(au, timestamp, UserNotification.Type.GRANTFILEACCESS, theDataset.getId()));
}
Also used : AuthenticatedUser(edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser) DatasetLock(edu.harvard.iq.dataverse.DatasetLock) DatasetFieldConstant(edu.harvard.iq.dataverse.DatasetFieldConstant) Date(java.util.Date) DataverseRequest(edu.harvard.iq.dataverse.engine.command.DataverseRequest) TriggerType(edu.harvard.iq.dataverse.workflow.WorkflowContext.TriggerType) SettingsServiceBean(edu.harvard.iq.dataverse.settings.SettingsServiceBean) CommandContext(edu.harvard.iq.dataverse.engine.command.CommandContext) Level(java.util.logging.Level) ExportException(edu.harvard.iq.dataverse.export.ExportException) Permission(edu.harvard.iq.dataverse.authorization.Permission) BundleUtil(edu.harvard.iq.dataverse.util.BundleUtil) DvObject(edu.harvard.iq.dataverse.DvObject) DatasetField(edu.harvard.iq.dataverse.DatasetField) CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException) Dataverse(edu.harvard.iq.dataverse.Dataverse) RequiredPermissions(edu.harvard.iq.dataverse.engine.command.RequiredPermissions) ExportService(edu.harvard.iq.dataverse.export.ExportService) Timestamp(java.sql.Timestamp) Dataset(edu.harvard.iq.dataverse.Dataset) DataFile(edu.harvard.iq.dataverse.DataFile) IOException(java.io.IOException) Logger(java.util.logging.Logger) DatasetVersionUser(edu.harvard.iq.dataverse.DatasetVersionUser) UserNotification(edu.harvard.iq.dataverse.UserNotification) PrivateUrl(edu.harvard.iq.dataverse.privateurl.PrivateUrl) DatasetVersion(edu.harvard.iq.dataverse.DatasetVersion) IllegalCommandException(edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException) IdServiceBean(edu.harvard.iq.dataverse.IdServiceBean) Timestamp(java.sql.Timestamp) Date(java.util.Date)

Example 2 with CommandContext

use of edu.harvard.iq.dataverse.engine.command.CommandContext in project dataverse by IQSS.

the class FinalizeDatasetPublicationCommand method notifyUsersDatasetPublish.

private void notifyUsersDatasetPublish(CommandContext ctxt, DvObject subject) {
    Timestamp timestamp = new Timestamp(new Date().getTime());
    ctxt.roles().rolesAssignments(subject).stream().filter(ra -> ra.getRole().permissions().contains(Permission.ViewUnpublishedDataset) || ra.getRole().permissions().contains(Permission.DownloadFile)).flatMap(ra -> ctxt.roleAssignees().getExplicitUsers(ctxt.roleAssignees().getRoleAssignee(ra.getAssigneeIdentifier())).stream()).distinct().forEach(au -> ctxt.notifications().sendNotification(au, timestamp, UserNotification.Type.PUBLISHEDDS, theDataset.getLatestVersion().getId()));
}
Also used : AuthenticatedUser(edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser) DatasetLock(edu.harvard.iq.dataverse.DatasetLock) DatasetFieldConstant(edu.harvard.iq.dataverse.DatasetFieldConstant) Date(java.util.Date) DataverseRequest(edu.harvard.iq.dataverse.engine.command.DataverseRequest) TriggerType(edu.harvard.iq.dataverse.workflow.WorkflowContext.TriggerType) SettingsServiceBean(edu.harvard.iq.dataverse.settings.SettingsServiceBean) CommandContext(edu.harvard.iq.dataverse.engine.command.CommandContext) Level(java.util.logging.Level) ExportException(edu.harvard.iq.dataverse.export.ExportException) Permission(edu.harvard.iq.dataverse.authorization.Permission) BundleUtil(edu.harvard.iq.dataverse.util.BundleUtil) DvObject(edu.harvard.iq.dataverse.DvObject) DatasetField(edu.harvard.iq.dataverse.DatasetField) CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException) Dataverse(edu.harvard.iq.dataverse.Dataverse) RequiredPermissions(edu.harvard.iq.dataverse.engine.command.RequiredPermissions) ExportService(edu.harvard.iq.dataverse.export.ExportService) Timestamp(java.sql.Timestamp) Dataset(edu.harvard.iq.dataverse.Dataset) DataFile(edu.harvard.iq.dataverse.DataFile) IOException(java.io.IOException) Logger(java.util.logging.Logger) DatasetVersionUser(edu.harvard.iq.dataverse.DatasetVersionUser) UserNotification(edu.harvard.iq.dataverse.UserNotification) PrivateUrl(edu.harvard.iq.dataverse.privateurl.PrivateUrl) DatasetVersion(edu.harvard.iq.dataverse.DatasetVersion) IllegalCommandException(edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException) IdServiceBean(edu.harvard.iq.dataverse.IdServiceBean) Timestamp(java.sql.Timestamp) Date(java.util.Date)

Aggregations

DataFile (edu.harvard.iq.dataverse.DataFile)2 Dataset (edu.harvard.iq.dataverse.Dataset)2 DatasetField (edu.harvard.iq.dataverse.DatasetField)2 DatasetFieldConstant (edu.harvard.iq.dataverse.DatasetFieldConstant)2 DatasetLock (edu.harvard.iq.dataverse.DatasetLock)2 DatasetVersion (edu.harvard.iq.dataverse.DatasetVersion)2 DatasetVersionUser (edu.harvard.iq.dataverse.DatasetVersionUser)2 Dataverse (edu.harvard.iq.dataverse.Dataverse)2 DvObject (edu.harvard.iq.dataverse.DvObject)2 IdServiceBean (edu.harvard.iq.dataverse.IdServiceBean)2 UserNotification (edu.harvard.iq.dataverse.UserNotification)2 Permission (edu.harvard.iq.dataverse.authorization.Permission)2 AuthenticatedUser (edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser)2 CommandContext (edu.harvard.iq.dataverse.engine.command.CommandContext)2 DataverseRequest (edu.harvard.iq.dataverse.engine.command.DataverseRequest)2 RequiredPermissions (edu.harvard.iq.dataverse.engine.command.RequiredPermissions)2 CommandException (edu.harvard.iq.dataverse.engine.command.exception.CommandException)2 IllegalCommandException (edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException)2 ExportException (edu.harvard.iq.dataverse.export.ExportException)2 ExportService (edu.harvard.iq.dataverse.export.ExportService)2