Skip to content
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

System warning #4413

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--
-- (c) Kitodo. Key to digital objects e. V. <[email protected]>
--
-- This file is part of the Kitodo project.
--
-- It is licensed under GNU General Public License version 3 or later.
--
-- For the full copyright and license information, please read the
-- GPL3-License.txt file that was distributed with this source code.
--

-- Insert authority to broadcast messages

INSERT IGNORE INTO authority (title) VALUES ('broadcastMessage_globalAssignable');

INSERT IGNORE INTO role_x_authority (role_id, authority_id)
SELECT (SELECT id FROM role WHERE title = 'Administration'), id FROM authority WHERE title = 'broadcastMessage_globalAssignable';
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/*
* (c) Kitodo. Key to digital objects e. V. <[email protected]>
*
* This file is part of the Kitodo project.
*
* It is licensed under GNU General Public License version 3 or later.
*
* For the full copyright and license information, please read the
* GPL3-License.txt file that was distributed with this source code.
*/

package org.kitodo.production.channel;

import java.util.HashMap;
import java.util.Set;

import javax.enterprise.context.ApplicationScoped;
import javax.faces.push.Push;
import javax.faces.push.PushContext;
import javax.inject.Inject;
import javax.inject.Named;

import org.kitodo.data.database.beans.User;
import org.kitodo.production.security.SecuritySession;
import org.kitodo.production.services.ServiceManager;

@Named("SystemMessageChannel")
@ApplicationScoped
public class SystemMessageChannel {

@Inject
@Push
PushContext messageChannel;

private static final String SHOW_MESSAGE = "showMessage";
private static final String UPDATE_USER_TABLE = "updateUserTable";

private String userName = "";
private String message = "";
private HashMap<String, Boolean> currentUsers;

private String staticSystemMessage = "";
private Boolean showSystemMessage = false;

/**
* Inform connected websocket clients to show message.
*/
public void showMessage() {
messageChannel.send(SHOW_MESSAGE);
}

/**
* Inform connected websocket clients to update user table.
*/
public void updateUserTable() {
messageChannel.send(UPDATE_USER_TABLE);
}

/**
* Set message String.
*
* @param messageText message String
*/
public void setMessage(String messageText) {
this.message = messageText;
}

/**
* Get message String.
*
* @return message String
*/
public String getMessage() {
return this.message;
}

/**
* Acknowledge system message.
*
* @param user User that acknowledges system message
*/
public void acknowledge(User user) {
this.currentUsers.put(user.getLogin(), true);
this.updateUserTable();
}

/**
* Load list of current users.
*/
public void loadCurrentUsers() {
this.currentUsers = new HashMap<>();
for (SecuritySession session : ServiceManager.getSessionService().getActiveSessions()) {
this.currentUsers.put(session.getUserName(), null);
}
}

/**
* Reset status of current users.
*/
public void resetCurrentUsersStatus() {
this.currentUsers.replaceAll((n, v) -> false);
}

/**
* Get list of current users.
*
* @return list of current users
*/
public Set<String> getCurrentUsers() {
return this.currentUsers.keySet();
}

/**
* Return whether User with user name 'userName' acknowledged system message or not.
*
* @param userName user name of user to check
* @return whether user acknowledged system message or not
*/
public Boolean acknowledged(String userName) {
return this.currentUsers.get(userName);
}

/**
* Get user name of broadcaster.
*
* @return user name
*/
public String getUserName() {
return this.userName;
}

/**
* Set user name of broadcaster.
*
* @param name user name
*/
public void setUserName(String name) {
this.userName = name;
}

/**
* Send message String to connected clients.
*/
public void sendMessage() {
this.resetCurrentUsersStatus();
this.showMessage();
}

/**
* Get staticSystemMessage.
*
* @return value of staticSystemMessage
*/
public String getStaticSystemMessage() {
return staticSystemMessage;
}

/**
* Set staticSystemMessage.
*
* @param staticSystemMessage as java.lang.String
*/
public void setStaticSystemMessage(String staticSystemMessage) {
this.staticSystemMessage = staticSystemMessage;
}

/**
* Get showSystemMessage.
*
* @return value of showSystemMessage
*/
public boolean isShowSystemMessage() {
return showSystemMessage;
}

/**
* Set showSystemMessage.
*
* @param showSystemMessage as boolean
*/
public void setShowSystemMessage(boolean showSystemMessage) {
this.showSystemMessage = showSystemMessage;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,8 @@ public boolean hasAuthorityToViewSystemPage() {
return securityAccessService.hasAuthorityToViewIndexPage()
|| securityAccessService.hasAuthorityToViewTaskManagerPage()
|| securityAccessService.hasAuthorityToViewTermsPage()
|| securityAccessService.hasAuthorityToViewMigrationPage();
|| securityAccessService.hasAuthorityToViewMigrationPage()
|| securityAccessService.hasAuthorityToViewMessagePage();
}

/**
Expand Down Expand Up @@ -670,6 +671,15 @@ public boolean hasAuthorityToViewMigrationPage() {
return securityAccessService.hasAuthorityToViewMigrationPage();
}

/**
* Check if current user has authority to view message tab of system page.
*
* @return true if user has authority to view message tab of system page
*/
public boolean hasAuthorityToViewMessagePage() {
return securityAccessService.hasAuthorityToViewMessagePage();
}

/**
* Check if current user has authority to view task page. It returns true if
* user has "viewAllTasks" authority for client.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* (c) Kitodo. Key to digital objects e. V. <[email protected]>
*
* This file is part of the Kitodo project.
*
* It is licensed under GNU General Public License version 3 or later.
*
* For the full copyright and license information, please read the
* GPL3-License.txt file that was distributed with this source code.
*/

package org.kitodo.production.forms;

import java.io.Serializable;

import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;

import org.kitodo.production.channel.SystemMessageChannel;

@Named("SystemWarningForm")
@SessionScoped
public class SystemWarningForm implements Serializable {

@Inject
private SystemMessageChannel systemMessageChannel;

/**
* Set warning String.
*
* @param warningText warning String
*/
public void setWarning(String warningText) {
this.systemMessageChannel.setMessage(warningText);
}

/**
* Get warning String.
*
* @return warning String
*/
public String getWarning() {
return "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,15 @@ public boolean hasAuthorityToViewMigrationPage() {
return hasAnyAuthorityGlobal("viewMigration");
}

/**
* Check if the current user has the authority to view the message tab of the system page.
*
* @return true if the current user has the authority to view the message tab of the system page
*/
public boolean hasAuthorityToViewMessagePage() {
return hasAnyAuthorityGlobal("broadcastMessage");
}


private boolean hasAuthorityForTask(int taskId) throws DataException {
Integer processId = ServiceManager.getTaskService().findById(taskId).getProcess().getId();
Expand Down
6 changes: 6 additions & 0 deletions Kitodo/src/main/resources/messages/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mapping=ElasticSearch Mapping
NOT=Enth\u00E4lt nicht
NoCataloguePluginForCatalogue=Keines der verf\u00fcgbaren OPAC-Plugins unterst\u00fctzt diesen Katalog.
abDerErstenMarkiertenSeite=Ab der ersten markierten Seite
acknowledged=Best\u00E4tigt
active=Aktiv
ACTIVE=Aktiv
activeUsers=Aktive Benutzer
Expand Down Expand Up @@ -567,6 +568,7 @@ locked=Gesperrt
location=Standort
loggedIn=Angemeldet
logical=Logische
loggedInUsers=Angemeldete Benutzer
login=Login
loginNoteText=Kitodo.Production ist das Workflowmanagementmodul der Kitodo-Suite. Es unterst\u00FCtzt den Digitalisierungsprozess verschiedener Materialarten wie z.B. Drucken, Periodika, Handschriften, Noten und Musikalien, Einblattmedien und Dokumentennachl\u00E4ssen.
logout=Logout
Expand Down Expand Up @@ -859,6 +861,7 @@ selectProcess=Vorgang ausw\u00E4hlen
selectProject=Bitte Projekt ausw\u00E4hlen
selectTemplate=Bitte Produktionsvorlage ausw\u00E4hlen
selectWorkflow=Bitte Workflow ausw\u00E4hlen
send=Absenden
sendSolutionMessageNextTask=Meldung \u00FCber Probleml\u00F6sung an nachfolgende Station senden
sendSolutionMessage=Meldung \u00FCber Probleml\u00F6sung senden
sendSolutionMessageForAll=Meldung \u00FCber Probleml\u00F6sung f\u00FCr alle Schritte senden
Expand Down Expand Up @@ -932,6 +935,9 @@ systemErrorInformAdminMessage=Bitte informieren Sie einen Administrator!
systemErrorMessage=Es ist ein Fehler im System aufgetreten.
systemMaintenanceHeader=Systemwartung
systemMaintenanceMessage=Das System wird derzeit gewartet.
systemMessage=Systemnachricht
systemMessage.broadcast=Broadcast
systemMessage.static=Statische Systemnachricht
table=Tabelle
tableSize=Tabellengr\u00F6\u00DFe
task=Aufgabe
Expand Down
6 changes: 6 additions & 0 deletions Kitodo/src/main/resources/messages/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mapping=ElasticSearch mapping
NOT=does not contain
NoCataloguePluginForCatalogue=None of the OPAC plugins available is capable of reading this catalogue.
abDerErstenMarkiertenSeite=From first selected page
acknowledged=Acknowledged
active=Active
ACTIVE=Active
activeUsers=Current users
Expand Down Expand Up @@ -579,6 +580,7 @@ locked=Locked
location=Location
loggedIn=Logged in
logical=Logical
loggedInUsers=Logged in users
login=Login
loginNoteText=Kitodo.Production is the workflow management module in the Kitodo suite. It supports the process of digitising a range of material types, such as books, periodicals, manuscripts, printed music, single-sheet media, and document collections.
logout=Log out
Expand Down Expand Up @@ -874,6 +876,7 @@ selectProcess=Select process
selectProject=Please select a project
selectTemplate=Please select a template
selectWorkflow=Please select a workflow
send=Send
sendSolutionMessageNextTask=Send message about problem solution to following task
sendSolutionMessage=Send message about problem solution
sendSolutionMessageForAll=send troubleshooting message to all steps
Expand Down Expand Up @@ -948,6 +951,9 @@ systemErrorInformAdminMessage=Please inform an administrator!
systemErrorMessage=A system error occurred.
systemMaintenanceHeader=System maintenance
systemMaintenanceMessage=The system is currently under maintenance.
systemMessage=System message
systemMessage.broadcast=Broadcast
systemMessage.static=Static system message
table=Table
tableSize=Table size
task=Task
Expand Down
Loading