Merge remote-tracking branch 'origin/master' into feature/23103
This commit is contained in:
commit
8c455f0f05
|
@ -1 +1,2 @@
|
||||||
/org.eclipse.jdt.core.prefs
|
/org.eclipse.jdt.core.prefs
|
||||||
|
/org.eclipse.core.resources.prefs
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
eclipse.preferences.version=1
|
|
||||||
encoding//src/main/java=UTF-8
|
|
||||||
encoding//src/main/resources=UTF-8
|
|
||||||
encoding//src/test/java=UTF-8
|
|
||||||
encoding//src/test/resources=UTF-8
|
|
||||||
encoding/<project>=UTF-8
|
|
|
@ -13,15 +13,13 @@ public class FakeModerationThread extends ModerationThread {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(FakeModerationThread.class);
|
private static final Logger logger = LoggerFactory.getLogger(FakeModerationThread.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void postMessage(CMItemStatus cmItemStatus, String message) throws Exception {
|
protected void postMessage(String message) throws Exception {
|
||||||
|
|
||||||
logger.info("gCat is sending a message to the {} for item '{}' (id={}). ItemStatus={}, Message=\"{}\"",
|
logger.info("gCat is sending a message to the {} for item '{}' (id={}). ItemStatus={}, Message=\"{}\"",
|
||||||
ModerationThread.class.getSimpleName(), itemName, itemID, cmItemStatus, message);
|
ModerationThread.class.getSimpleName(), itemName, itemID, cmItemStatus, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postUserMessage(CMItemStatus cmItemStatus, String userMessage) throws Exception {
|
public void postUserMessage(CMItemStatus cmItemStatus, String userMessage) throws Exception {
|
||||||
|
|
||||||
logger.info("{} is sending a message to the {} for item '{}' (id={}). ItemStatus={}, Message=\"{}\"",
|
logger.info("{} is sending a message to the {} for item '{}' (id={}). ItemStatus={}, Message=\"{}\"",
|
||||||
SecretManagerProvider.instance.get().getUser().getUsername(),
|
SecretManagerProvider.instance.get().getUser().getUsername(),
|
||||||
ModerationThread.class.getSimpleName(), itemName, itemID, cmItemStatus, userMessage);
|
ModerationThread.class.getSimpleName(), itemName, itemID, cmItemStatus, userMessage);
|
||||||
|
@ -29,8 +27,8 @@ public class FakeModerationThread extends ModerationThread {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void createModerationThread() throws Exception {
|
protected void createModerationThread() throws Exception {
|
||||||
|
|
||||||
logger.info("Creating {} for item '{}' (id={})", ModerationThread.class.getSimpleName(), itemName, itemID);
|
logger.info("Creating {} for item '{}' (id={})", ModerationThread.class.getSimpleName(), itemName, itemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@ public abstract class ModerationThread {
|
||||||
protected String itemTitle;
|
protected String itemTitle;
|
||||||
protected String itemURL;
|
protected String itemURL;
|
||||||
|
|
||||||
|
protected boolean create;
|
||||||
|
protected CMItemStatus cmItemStatus;
|
||||||
protected boolean itemAuthor;
|
protected boolean itemAuthor;
|
||||||
|
|
||||||
protected CKANUser ckanUser;
|
protected CKANUser ckanUser;
|
||||||
|
@ -27,7 +29,9 @@ public abstract class ModerationThread {
|
||||||
|
|
||||||
public ModerationThread() {
|
public ModerationThread() {
|
||||||
this.objectMapper = new ObjectMapper();
|
this.objectMapper = new ObjectMapper();
|
||||||
itemAuthor = false;
|
this.itemAuthor = false;
|
||||||
|
this.create = false;
|
||||||
|
cmItemStatus = CMItemStatus.PENDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItemCoordinates(String itemID, String itemName, String itemTitle, String itemURL) {
|
public void setItemCoordinates(String itemID, String itemName, String itemTitle, String itemURL) {
|
||||||
|
@ -37,10 +41,6 @@ public abstract class ModerationThread {
|
||||||
this.itemURL = itemURL;
|
this.itemURL = itemURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isItemAuthor() {
|
|
||||||
return itemAuthor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItemAuthor(boolean itemAuthor) {
|
public void setItemAuthor(boolean itemAuthor) {
|
||||||
this.itemAuthor = itemAuthor;
|
this.itemAuthor = itemAuthor;
|
||||||
}
|
}
|
||||||
|
@ -51,54 +51,62 @@ public abstract class ModerationThread {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The message is sent as gCat
|
* The message is sent as gCat
|
||||||
|
*
|
||||||
* @param cmItemStatus
|
* @param cmItemStatus
|
||||||
* @param message
|
* @param message
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected abstract void postMessage(CMItemStatus cmItemStatus, String message) throws Exception;
|
protected abstract void postMessage(String message) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The message is sent as User
|
* The message is sent as User
|
||||||
|
*
|
||||||
* @param cmItemStatus
|
* @param cmItemStatus
|
||||||
* @param userMessage
|
* @param userMessage
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public abstract void postUserMessage(CMItemStatus cmItemStatus, String userMessage) throws Exception;
|
public abstract void postUserMessage(CMItemStatus cmItemStatus, String userMessage) throws Exception;
|
||||||
|
|
||||||
protected abstract void createModerationThread() throws Exception ;
|
protected abstract void createModerationThread() throws Exception;
|
||||||
|
|
||||||
public void postItemCreated() throws Exception{
|
public void postItemCreated() throws Exception {
|
||||||
createModerationThread();
|
createModerationThread();
|
||||||
|
create = true;
|
||||||
|
cmItemStatus = CMItemStatus.PENDING;
|
||||||
String fullName = ckanUser.getNameSurname();
|
String fullName = ckanUser.getNameSurname();
|
||||||
CMItemStatus cmItemStatus = CMItemStatus.PENDING;
|
String message = String.format(
|
||||||
String message = String.format("@**%s** created the item with name '%s' (id='%s'). The item is now in **%s** state and must be moderated.",
|
"@**%s** created the item with name '%s' (id='%s'). The item is now in **%s** state and must be moderated.",
|
||||||
fullName, itemName, itemID, cmItemStatus.getFancyValue());
|
fullName, itemName, itemID, cmItemStatus.getFancyValue());
|
||||||
postMessage(cmItemStatus, message);
|
postMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postItemUpdated() throws Exception {
|
public void postItemUpdated() throws Exception {
|
||||||
|
cmItemStatus = CMItemStatus.PENDING;
|
||||||
String fullName = ckanUser.getNameSurname();
|
String fullName = ckanUser.getNameSurname();
|
||||||
CMItemStatus cmItemStatus = CMItemStatus.PENDING;
|
String message = String.format(
|
||||||
String message = String.format("@**%s** updated the item with name '%s' (id='%s'). The item is now in **%s** state and must be moderated.",
|
"@**%s** updated the item with name '%s' (id='%s'). The item is now in **%s** state and must be moderated.",
|
||||||
fullName, itemName, itemID, cmItemStatus.getFancyValue());
|
fullName, itemName, itemID, cmItemStatus.getFancyValue());
|
||||||
postMessage(cmItemStatus, message);
|
postMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postItemRejected(String userMessage) throws Exception {
|
public void postItemRejected(String userMessage) throws Exception {
|
||||||
|
cmItemStatus = CMItemStatus.REJECTED;
|
||||||
String fullName = ckanUser.getNameSurname();
|
String fullName = ckanUser.getNameSurname();
|
||||||
CMItemStatus cmItemStatus = CMItemStatus.REJECTED;
|
String message = String.format(
|
||||||
String message = String.format("@**%s** **%s** the item with name '%s' (id='%s'). The author can delete the item or update it to try to meet moderators requests if any.",
|
"@**%s** **%s** the item with name '%s' (id='%s'). The author can delete the item or update it to try to meet moderators requests if any.",
|
||||||
fullName, cmItemStatus.getFancyValue(), itemName, itemID);
|
fullName, cmItemStatus.getFancyValue(), itemName, itemID);
|
||||||
postMessage(cmItemStatus, message);
|
postMessage(message);
|
||||||
postUserMessage(cmItemStatus, userMessage);
|
postUserMessage(cmItemStatus, userMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postItemApproved(String userMessage) throws Exception{
|
public void postItemApproved(String userMessage) throws Exception {
|
||||||
|
cmItemStatus = CMItemStatus.APPROVED;
|
||||||
String fullName = ckanUser.getNameSurname();
|
String fullName = ckanUser.getNameSurname();
|
||||||
CMItemStatus cmItemStatus = CMItemStatus.APPROVED;
|
String message = String.format(
|
||||||
String message = String.format("@**%s** **%s** the item with name '%s' (id='%s'). The item is now available in the catalogue. The item is available at %s",
|
"@**%s** **%s** the item with name '%s' (id='%s'). The item is now available in the catalogue. The item is available at %s",
|
||||||
fullName, cmItemStatus.getFancyValue(), itemName, itemID, itemURL);
|
fullName, cmItemStatus.getFancyValue(), itemName, itemID, itemURL);
|
||||||
postMessage(cmItemStatus, message);
|
postMessage(message);
|
||||||
postUserMessage(cmItemStatus, userMessage);
|
postUserMessage(cmItemStatus, userMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,7 @@ public class SocialMessageModerationThread extends ModerationThread {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(SocialMessageModerationThread.class);
|
private static final Logger logger = LoggerFactory.getLogger(SocialMessageModerationThread.class);
|
||||||
|
|
||||||
protected StringBuffer getMainItemInfo(CMItemStatus cmItemStatus) {
|
protected StringBuffer getMainItemInfo(StringBuffer stringBuffer) {
|
||||||
StringBuffer stringBuffer = new StringBuffer();
|
|
||||||
stringBuffer.append("Status: ");
|
stringBuffer.append("Status: ");
|
||||||
stringBuffer.append(cmItemStatus.getFancyValue());
|
stringBuffer.append(cmItemStatus.getFancyValue());
|
||||||
stringBuffer.append("\n");
|
stringBuffer.append("\n");
|
||||||
|
@ -43,37 +42,48 @@ public class SocialMessageModerationThread extends ModerationThread {
|
||||||
return stringBuffer;
|
return stringBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postItemCreated() throws Exception{
|
/**
|
||||||
|
* Create the message for an item that is created/updated
|
||||||
|
*/
|
||||||
|
public void postItemToBeManaged() throws Exception {
|
||||||
|
/*
|
||||||
|
* An example of created message is:
|
||||||
|
*
|
||||||
|
* [mister x] created / updated the following item
|
||||||
|
*
|
||||||
|
* Title: RESTful Transaction Model
|
||||||
|
* Name: my_first_restful_transaction_model
|
||||||
|
* ID: e31a6ba8-66ef-47b8-b61f-99a1366b4a69
|
||||||
|
* URL: https://data.dev.d4science.org/ctlg/devVRE/my_first_restful_transaction_model
|
||||||
|
*
|
||||||
|
* You are kindly requested to review it and decide either to APPROVE or REJECT it at <url of the item>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
cmItemStatus = CMItemStatus.PENDING;
|
||||||
String fullName = ckanUser.getNameSurname();
|
String fullName = ckanUser.getNameSurname();
|
||||||
CMItemStatus cmItemStatus = CMItemStatus.PENDING;
|
StringBuffer stringBuffer = new StringBuffer();
|
||||||
StringBuffer stringBuffer = getMainItemInfo(cmItemStatus);
|
|
||||||
|
|
||||||
stringBuffer.append("Message:\n");
|
|
||||||
stringBuffer.append(fullName);
|
stringBuffer.append(fullName);
|
||||||
stringBuffer.append(" created '");
|
stringBuffer.append(create ? " created " : " updated ");
|
||||||
stringBuffer.append(itemTitle);
|
stringBuffer.append("the following item\n\n");
|
||||||
stringBuffer.append("'. It is now in ");
|
stringBuffer = getMainItemInfo(stringBuffer);
|
||||||
stringBuffer.append(cmItemStatus.getFancyValue());
|
stringBuffer.append("You are kindly requested to review it and decide either to APPROVE or REJECT it.");
|
||||||
stringBuffer.append(" state and must be moderated.");
|
// stringBuffer.append("You are kindly requested to review it and decide either to APPROVE or REJECT at");
|
||||||
|
// String manageURL = getManageURL();
|
||||||
|
// stringBuffer.append(manageURL);
|
||||||
|
postMessage(stringBuffer.toString());
|
||||||
|
}
|
||||||
|
|
||||||
postMessage(cmItemStatus, stringBuffer.toString());
|
|
||||||
|
|
||||||
|
public void postItemCreated() throws Exception {
|
||||||
|
create = true;
|
||||||
|
cmItemStatus = CMItemStatus.PENDING;
|
||||||
|
postItemToBeManaged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postItemUpdated() throws Exception {
|
public void postItemUpdated() throws Exception {
|
||||||
String fullName = ckanUser.getNameSurname();
|
create = false;
|
||||||
CMItemStatus cmItemStatus = CMItemStatus.PENDING;
|
cmItemStatus = CMItemStatus.PENDING;
|
||||||
StringBuffer stringBuffer = getMainItemInfo(cmItemStatus);
|
postItemToBeManaged();
|
||||||
|
|
||||||
stringBuffer.append("Message:\n");
|
|
||||||
stringBuffer.append(fullName);
|
|
||||||
stringBuffer.append(" updated '");
|
|
||||||
stringBuffer.append(itemTitle);
|
|
||||||
stringBuffer.append("'. It is now in ");
|
|
||||||
stringBuffer.append(cmItemStatus.getFancyValue());
|
|
||||||
stringBuffer.append(" state and must be moderated.");
|
|
||||||
|
|
||||||
postMessage(cmItemStatus, stringBuffer.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected StringBuffer addUserWithRole(String fullName, String role, StringBuffer stringBuffer) {
|
protected StringBuffer addUserWithRole(String fullName, String role, StringBuffer stringBuffer) {
|
||||||
|
@ -84,80 +94,63 @@ public class SocialMessageModerationThread extends ModerationThread {
|
||||||
return stringBuffer;
|
return stringBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void postItemManaged(String userMessage) throws Exception {
|
||||||
|
create = false;
|
||||||
|
String fullName = ckanUser.getNameSurname();
|
||||||
|
StringBuffer stringBuffer = new StringBuffer();
|
||||||
|
stringBuffer = addUserWithRole(fullName, Moderated.CATALOGUE_MODERATOR, stringBuffer);
|
||||||
|
stringBuffer.append(cmItemStatus.getValue());
|
||||||
|
stringBuffer.append(" the following item");
|
||||||
|
if(userMessage!=null && userMessage.length()>0) {
|
||||||
|
stringBuffer.append(" with this accompanying message\n\n");
|
||||||
|
stringBuffer = getMainItemInfo(stringBuffer);
|
||||||
|
stringBuffer.append(userMessage);
|
||||||
|
}else {
|
||||||
|
stringBuffer.append("\n\n");
|
||||||
|
stringBuffer = getMainItemInfo(stringBuffer);
|
||||||
|
}
|
||||||
|
postMessage(stringBuffer.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void postItemRejected(String userMessage) throws Exception {
|
public void postItemRejected(String userMessage) throws Exception {
|
||||||
String fullName = ckanUser.getNameSurname();
|
create = false;
|
||||||
CMItemStatus cmItemStatus = CMItemStatus.REJECTED;
|
cmItemStatus = CMItemStatus.REJECTED;
|
||||||
|
postItemManaged(userMessage);
|
||||||
StringBuffer stringBuffer = getMainItemInfo(cmItemStatus);
|
|
||||||
|
|
||||||
stringBuffer.append("Message:\n");
|
|
||||||
stringBuffer = addUserWithRole(fullName, Moderated.CATALOGUE_MODERATOR, stringBuffer);
|
|
||||||
stringBuffer.append("rejected '");
|
|
||||||
stringBuffer.append(itemTitle);
|
|
||||||
stringBuffer.append("'.");
|
|
||||||
stringBuffer.append(" The author can delete or update it.");
|
|
||||||
|
|
||||||
if(userMessage!=null && userMessage.length()>0) {
|
|
||||||
stringBuffer.append("\n\n");
|
|
||||||
stringBuffer = addUserWithRole(fullName, Moderated.CATALOGUE_MODERATOR, stringBuffer);
|
|
||||||
stringBuffer.append("added the following comment:\n");
|
|
||||||
stringBuffer.append(userMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
postMessage(cmItemStatus, stringBuffer.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postItemApproved(String userMessage) throws Exception{
|
@Override
|
||||||
String fullName = ckanUser.getNameSurname();
|
public void postItemApproved(String userMessage) throws Exception {
|
||||||
CMItemStatus cmItemStatus = CMItemStatus.APPROVED;
|
create = false;
|
||||||
|
cmItemStatus = CMItemStatus.APPROVED;
|
||||||
StringBuffer stringBuffer = getMainItemInfo(cmItemStatus);
|
postItemManaged(userMessage);
|
||||||
|
|
||||||
stringBuffer.append("Message:\n");
|
|
||||||
stringBuffer = addUserWithRole(fullName, Moderated.CATALOGUE_MODERATOR, stringBuffer);
|
|
||||||
stringBuffer.append("approved the '");
|
|
||||||
stringBuffer.append(itemTitle);
|
|
||||||
stringBuffer.append("'.");
|
|
||||||
stringBuffer.append(" It is now available in the catalogue at ");
|
|
||||||
stringBuffer.append(itemURL);
|
|
||||||
|
|
||||||
if(userMessage!=null && userMessage.length()>0) {
|
|
||||||
stringBuffer.append("\n\n");
|
|
||||||
stringBuffer = addUserWithRole(fullName, Moderated.CATALOGUE_MODERATOR, stringBuffer);
|
|
||||||
stringBuffer.append("added the following comment:\n");
|
|
||||||
stringBuffer.append(userMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
postMessage(cmItemStatus, stringBuffer.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getSubject() {
|
||||||
protected String getSubject(CMItemStatus cmItemStatus) {
|
|
||||||
StringWriter stringWriter = new StringWriter();
|
StringWriter stringWriter = new StringWriter();
|
||||||
|
if(!create) {
|
||||||
|
logger.trace("It's a reply");
|
||||||
|
stringWriter.append("Re: [Catalogue Service] ");
|
||||||
|
}
|
||||||
stringWriter.append("[Catalogue Service] ");
|
stringWriter.append("[Catalogue Service] ");
|
||||||
stringWriter.append(itemTitle);
|
stringWriter.append(itemTitle);
|
||||||
stringWriter.append(" (name:");
|
|
||||||
stringWriter.append(itemName);
|
|
||||||
stringWriter.append(" - id:");
|
|
||||||
stringWriter.append(itemID);
|
|
||||||
stringWriter.append(")");
|
|
||||||
return stringWriter.toString();
|
return stringWriter.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Message getMessage(CMItemStatus cmItemStatus, String messageString) throws Exception {
|
protected Message getMessage(String messageString) throws Exception {
|
||||||
Message message = new Message();
|
Message message = new Message();
|
||||||
message.setMessage(messageString);
|
message.setMessage(messageString);
|
||||||
message.setSubject(getSubject(cmItemStatus));
|
message.setSubject(getSubject());
|
||||||
Set<String> moderators = SocialUsers.getUsernamesByRole(Moderated.CATALOGUE_MODERATOR);
|
Set<String> moderators = SocialUsers.getUsernamesByRole(Moderated.CATALOGUE_MODERATOR);
|
||||||
message.setUsers(moderators);
|
message.setUsers(moderators);
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void postMessage(CMItemStatus cmItemStatus, String messageString) throws Exception {
|
protected void postMessage(String messageString) throws Exception {
|
||||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||||
String username = secretManager.getUser().getUsername();
|
String username = secretManager.getUser().getUsername();
|
||||||
Message message = getMessage(cmItemStatus, messageString);
|
Message message = getMessage(messageString);
|
||||||
message.addUser(username);
|
message.addUser(username);
|
||||||
Secret secret = Constants.getCatalogueSecret();
|
Secret secret = Constants.getCatalogueSecret();
|
||||||
secretManager.startSession(secret);
|
secretManager.startSession(secret);
|
||||||
|
@ -170,12 +163,15 @@ public class SocialMessageModerationThread extends ModerationThread {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postUserMessage(CMItemStatus cmItemStatus, String userMessage) throws Exception {
|
public void postUserMessage(CMItemStatus cmItemStatus, String userMessage) throws Exception {
|
||||||
|
this.create = false;
|
||||||
|
this.cmItemStatus = cmItemStatus;
|
||||||
String fullName = ckanUser.getNameSurname();
|
String fullName = ckanUser.getNameSurname();
|
||||||
StringBuffer stringBuffer = getMainItemInfo(cmItemStatus);
|
StringBuffer stringBuffer = new StringBuffer();
|
||||||
stringBuffer = addUserWithRole(fullName, isItemAuthor() ? "Author" : Moderated.CATALOGUE_MODERATOR, stringBuffer);
|
stringBuffer = addUserWithRole(fullName, itemAuthor ? "Author" : Moderated.CATALOGUE_MODERATOR, stringBuffer);
|
||||||
stringBuffer.append("sent the following comment:\n");
|
stringBuffer.append("sent a message regarding the following item\n\n");
|
||||||
|
stringBuffer = getMainItemInfo(stringBuffer);
|
||||||
stringBuffer.append(userMessage);
|
stringBuffer.append(userMessage);
|
||||||
Message message = getMessage(cmItemStatus, stringBuffer.toString());
|
Message message = getMessage(stringBuffer.toString());
|
||||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||||
String username = secretManager.getUser().getUsername();
|
String username = secretManager.getUser().getUsername();
|
||||||
message.addUser(username);
|
message.addUser(username);
|
||||||
|
@ -196,7 +192,8 @@ public class SocialMessageModerationThread extends ModerationThread {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void createModerationThread() throws Exception {
|
protected void createModerationThread() throws Exception {
|
||||||
// Nothing to do
|
create = true;
|
||||||
|
cmItemStatus = CMItemStatus.PENDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,20 +133,21 @@ public class ZulipStream extends ModerationThread {
|
||||||
executeZulipCall(gCatZulipRestExecutor, postCreateStream);
|
executeZulipCall(gCatZulipRestExecutor, postCreateStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void postMessageToStream(ZulipRestExecutor zulipRestExecutor, CMItemStatus cmItemStatus, String message) throws Exception {
|
protected void postMessageToStream(ZulipRestExecutor zulipRestExecutor, String message) throws Exception {
|
||||||
PostMessage postMessage = new PostMessage(getStreamName(), cmItemStatus.getFancyValue(), message);
|
PostMessage postMessage = new PostMessage(getStreamName(), cmItemStatus.getFancyValue(), message);
|
||||||
logger.debug("Going to send the following message: {}", message);
|
logger.debug("Going to send the following message: {}", message);
|
||||||
executeZulipCall(zulipRestExecutor, postMessage);
|
executeZulipCall(zulipRestExecutor, postMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void postMessage(CMItemStatus cmItemStatus, String message) throws Exception {
|
protected void postMessage(String message) throws Exception {
|
||||||
postMessageToStream(getGCatZulipRestExecutor(), cmItemStatus, message);
|
postMessageToStream(getGCatZulipRestExecutor(), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postUserMessage(CMItemStatus cmItemStatus, String message) throws Exception {
|
public void postUserMessage(CMItemStatus cmItemStatus, String message) throws Exception {
|
||||||
postMessageToStream(getUserZulipRestExecutor(), cmItemStatus, message);
|
this.cmItemStatus = cmItemStatus;
|
||||||
|
postMessageToStream(getUserZulipRestExecutor(), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ public class ISProfile {
|
||||||
public boolean createOrUpdate(String name, String xml) throws SAXException {
|
public boolean createOrUpdate(String name, String xml) throws SAXException {
|
||||||
try {
|
try {
|
||||||
CKANUser ckanUser = CKANUserCache.getCurrrentCKANUser();
|
CKANUser ckanUser = CKANUserCache.getCurrrentCKANUser();
|
||||||
if(ckanUser.getRole().ordinal()<Role.ADMIN.ordinal()) {
|
if(ckanUser.getRole().ordinal()<Role.EDITOR.ordinal()) {
|
||||||
throw new NotAuthorizedException("You are not authorized to manage profiles, only Catalogue Editor can manipulate profiles.");
|
throw new NotAuthorizedException("You are not authorized to manage profiles, only Catalogue Editor can manipulate profiles.");
|
||||||
}
|
}
|
||||||
MetadataUtility metadataUtility = new MetadataUtility();
|
MetadataUtility metadataUtility = new MetadataUtility();
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package org.gcube.gcat.moderation;
|
package org.gcube.gcat.moderation;
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import org.gcube.gcat.ContextTest;
|
import org.gcube.gcat.ContextTest;
|
||||||
import org.gcube.gcat.api.moderation.CMItemStatus;
|
import org.gcube.gcat.api.moderation.CMItemStatus;
|
||||||
import org.gcube.gcat.moderation.thread.ModerationThread;
|
import org.gcube.gcat.moderation.thread.ModerationThread;
|
||||||
import org.gcube.gcat.persistence.ckan.CKANUser;
|
import org.gcube.gcat.persistence.ckan.CKANUser;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,7 +13,7 @@ import org.junit.Test;
|
||||||
public class ModerationThreadTest extends ContextTest {
|
public class ModerationThreadTest extends ContextTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// @JsonIgnore
|
@Ignore
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
ModerationThread moderationThread = ModerationThread.getDefaultInstance();
|
ModerationThread moderationThread = ModerationThread.getDefaultInstance();
|
||||||
moderationThread.setItemCoordinates("e31a6ba8-66ef-47b8-b61f-99a1366b4a69", "my_first_restful_transaction_model", "RESTful Transaction Model", "https://data.dev.d4science.org/ctlg/devVRE/my_first_restful_transaction_model");
|
moderationThread.setItemCoordinates("e31a6ba8-66ef-47b8-b61f-99a1366b4a69", "my_first_restful_transaction_model", "RESTful Transaction Model", "https://data.dev.d4science.org/ctlg/devVRE/my_first_restful_transaction_model");
|
||||||
|
@ -23,8 +23,10 @@ public class ModerationThreadTest extends ContextTest {
|
||||||
moderationThread.setCKANUser(ckanUser);
|
moderationThread.setCKANUser(ckanUser);
|
||||||
moderationThread.postItemCreated();
|
moderationThread.postItemCreated();
|
||||||
moderationThread.postItemUpdated();
|
moderationThread.postItemUpdated();
|
||||||
moderationThread.postItemRejected("Non mi garba");
|
moderationThread.postItemRejected(null);
|
||||||
moderationThread.postItemApproved("Ora mi garba");
|
moderationThread.postItemRejected("reject con messaggio: Non mi garba");
|
||||||
|
moderationThread.postItemApproved(null);
|
||||||
|
moderationThread.postItemApproved("approve con messaggio: Ora mi garba");
|
||||||
moderationThread.setItemAuthor(true);
|
moderationThread.setItemAuthor(true);
|
||||||
moderationThread.postUserMessage(CMItemStatus.APPROVED, "Grazie");
|
moderationThread.postUserMessage(CMItemStatus.APPROVED, "Grazie");
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
|
|
Loading…
Reference in New Issue