Merge remote-tracking branch 'origin/master' into feature/23103
This commit is contained in:
commit
48bf3ec676
|
@ -5,10 +5,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
## [v2.2.0-SNAPSHOT]
|
||||
|
||||
- Switched gcat credentials to new IAM authz [#21628][#22727]
|
||||
- Added support to manage configurations [#22658]
|
||||
- Added support to manage configurations [#22658][#22742]
|
||||
- Migrated service to SecretManagerProvider [#22871]
|
||||
- Migrated to ServiceClass corresponding to Maven groupId
|
||||
- Added Enunciate to automatically create REST APIs documentation [#23096]
|
||||
- Fixed offset behaviuor in item listing [#22999]
|
||||
- Moderation message are sent using gcube messaging system via Social Service [#23117]
|
||||
|
||||
## [v2.1.0]
|
||||
|
||||
|
@ -24,7 +26,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
## [v2.0.0] [r5.2.0] - 2021-05-04
|
||||
|
||||
- Fixed retrieving of filename from content-disposition http header used to persist a resource [#21216]
|
||||
- Fixed author and maintainer name and email [#21059] [#21189]
|
||||
- Fixed author and maintainer name and email [#21059][#21189]
|
||||
- Improved check on controlled vocabulary to match corner cases [#20742]
|
||||
- Added PATCH method on Item collection [#19768]
|
||||
- Switched JSON management to gcube-jackson [#19735]
|
||||
|
|
17
pom.xml
17
pom.xml
|
@ -21,8 +21,6 @@
|
|||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<webappDirectory>${project.basedir}${file.separator}src${file.separator}main${file.separator}webapp${file.separator}WEB-INF</webappDirectory>
|
||||
<serviceClass>data-catalogue</serviceClass>
|
||||
<enunciate.version>2.14.0</enunciate.version>
|
||||
</properties>
|
||||
|
||||
<scm>
|
||||
|
@ -86,22 +84,26 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.information-system</groupId>
|
||||
<artifactId>information-system-model</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.resource-management</groupId>
|
||||
<artifactId>gcube-model</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.information-system</groupId>
|
||||
<artifactId>resource-registry-client</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.information-system</groupId>
|
||||
<artifactId>resource-registry-publisher</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources</groupId>
|
||||
<artifactId>common-gcore-resources</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources</groupId>
|
||||
<artifactId>registry-publisher</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.data-catalogue</groupId>
|
||||
|
@ -250,7 +252,7 @@
|
|||
<plugin>
|
||||
<groupId>com.webcohesion.enunciate</groupId>
|
||||
<artifactId>enunciate-maven-plugin</artifactId>
|
||||
<version>${enunciate.version}</version>
|
||||
<version>2.14.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>assemble</id>
|
||||
|
@ -265,7 +267,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-enunciate-docs</id>
|
||||
|
|
|
@ -7,6 +7,9 @@ import java.lang.annotation.Target;
|
|||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@HttpMethod("PATCH")
|
||||
|
|
|
@ -7,6 +7,9 @@ import java.lang.annotation.Target;
|
|||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@HttpMethod("PURGE")
|
||||
|
|
|
@ -12,8 +12,11 @@ public abstract class ModerationThread {
|
|||
|
||||
protected String itemID;
|
||||
protected String itemName;
|
||||
protected String itemTitle;
|
||||
protected String itemURL;
|
||||
|
||||
protected boolean itemAuthor;
|
||||
|
||||
protected CKANUser ckanUser;
|
||||
protected ObjectMapper objectMapper;
|
||||
|
||||
|
@ -24,14 +27,24 @@ public abstract class ModerationThread {
|
|||
|
||||
public ModerationThread() {
|
||||
this.objectMapper = new ObjectMapper();
|
||||
itemAuthor = false;
|
||||
}
|
||||
|
||||
public void setItemCoordinates(String itemID, String itemName, String itemURL) {
|
||||
public void setItemCoordinates(String itemID, String itemName, String itemTitle, String itemURL) {
|
||||
this.itemID = itemID;
|
||||
this.itemName = itemName;
|
||||
this.itemTitle = itemTitle;
|
||||
this.itemURL = itemURL;
|
||||
}
|
||||
|
||||
public boolean isItemAuthor() {
|
||||
return itemAuthor;
|
||||
}
|
||||
|
||||
public void setItemAuthor(boolean itemAuthor) {
|
||||
this.itemAuthor = itemAuthor;
|
||||
}
|
||||
|
||||
public void setCKANUser(CKANUser ckanUser) {
|
||||
this.ckanUser = ckanUser;
|
||||
}
|
||||
|
@ -58,9 +71,7 @@ public abstract class ModerationThread {
|
|||
createModerationThread();
|
||||
String fullName = ckanUser.getNameSurname();
|
||||
CMItemStatus cmItemStatus = CMItemStatus.PENDING;
|
||||
// String message = String.format("@**%s** has created the item with name '%s' (id='%s'). The item is now in **%s** state and must be moderated.",
|
||||
// username, itemName, itemID, cmItemStatus.getFancyValue());
|
||||
String message = String.format("%s has created the item with name '%s' (id='%s'). The item is now in %s state and must be moderated.",
|
||||
String message = String.format("@**%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());
|
||||
postMessage(cmItemStatus, message);
|
||||
}
|
||||
|
@ -68,19 +79,15 @@ public abstract class ModerationThread {
|
|||
public void postItemUpdated() throws Exception {
|
||||
String fullName = ckanUser.getNameSurname();
|
||||
CMItemStatus cmItemStatus = CMItemStatus.PENDING;
|
||||
// String message = String.format("@**%s** has updated the item with name '%s' (id='%s'). The item is now in **%s** state and must be moderated.",
|
||||
// username, itemName, itemID, cmItemStatus.getFancyValue());
|
||||
String message = String.format("%s has updated the item with name '%s' (id='%s'). The item is now in %s state and must be moderated.",
|
||||
fullName, itemName, itemID, cmItemStatus.getFancyValue(), itemURL);
|
||||
String message = String.format("@**%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());
|
||||
postMessage(cmItemStatus, message);
|
||||
}
|
||||
|
||||
public void postItemRejected(String userMessage) throws Exception {
|
||||
String fullName = ckanUser.getNameSurname();
|
||||
CMItemStatus cmItemStatus = CMItemStatus.REJECTED;
|
||||
// String message = String.format("@**%s** has **%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.",
|
||||
// username, cmItemStatus.getFancyValue(), itemName, itemID,);
|
||||
String message = String.format("%s has %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.",
|
||||
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.",
|
||||
fullName, cmItemStatus.getFancyValue(), itemName, itemID);
|
||||
postMessage(cmItemStatus, message);
|
||||
postUserMessage(cmItemStatus, userMessage);
|
||||
|
@ -89,9 +96,7 @@ public abstract class ModerationThread {
|
|||
public void postItemApproved(String userMessage) throws Exception{
|
||||
String fullName = ckanUser.getNameSurname();
|
||||
CMItemStatus cmItemStatus = CMItemStatus.APPROVED;
|
||||
// String message = String.format("@**%s** has **%s** the item with name '%s' (id='%s'). The item is now available in the catalogue. The item is available at %s",
|
||||
// username, cmItemStatus.getFancyValue(), itemName, itemID, itemURL);
|
||||
String message = String.format("%s has %s the item with name '%s' (id='%s'). The item is now available in the catalogue. The item is available at %s",
|
||||
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",
|
||||
fullName, cmItemStatus.getFancyValue(), itemName, itemID, itemURL);
|
||||
postMessage(cmItemStatus, message);
|
||||
postUserMessage(cmItemStatus, userMessage);
|
||||
|
|
|
@ -23,13 +23,124 @@ public class SocialMessageModerationThread extends ModerationThread {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SocialMessageModerationThread.class);
|
||||
|
||||
protected StringBuffer getMainItemInfo(CMItemStatus cmItemStatus) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("Status: ");
|
||||
stringBuffer.append(cmItemStatus.getFancyValue());
|
||||
stringBuffer.append("\n");
|
||||
stringBuffer.append("Title: ");
|
||||
stringBuffer.append(itemTitle);
|
||||
stringBuffer.append("\n");
|
||||
stringBuffer.append("Name: ");
|
||||
stringBuffer.append(itemName);
|
||||
stringBuffer.append("\n");
|
||||
stringBuffer.append("ID: ");
|
||||
stringBuffer.append(itemID);
|
||||
stringBuffer.append("\n");
|
||||
stringBuffer.append("URL: ");
|
||||
stringBuffer.append(itemURL);
|
||||
stringBuffer.append("\n\n");
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
public void postItemCreated() throws Exception{
|
||||
String fullName = ckanUser.getNameSurname();
|
||||
CMItemStatus cmItemStatus = CMItemStatus.PENDING;
|
||||
StringBuffer stringBuffer = getMainItemInfo(cmItemStatus);
|
||||
|
||||
stringBuffer.append("Message:\n");
|
||||
stringBuffer.append(fullName);
|
||||
stringBuffer.append(" created '");
|
||||
stringBuffer.append(itemTitle);
|
||||
stringBuffer.append("'. It is now in ");
|
||||
stringBuffer.append(cmItemStatus.getFancyValue());
|
||||
stringBuffer.append(" state and must be moderated.");
|
||||
|
||||
postMessage(cmItemStatus, stringBuffer.toString());
|
||||
|
||||
}
|
||||
|
||||
public void postItemUpdated() throws Exception {
|
||||
String fullName = ckanUser.getNameSurname();
|
||||
CMItemStatus cmItemStatus = CMItemStatus.PENDING;
|
||||
StringBuffer stringBuffer = getMainItemInfo(cmItemStatus);
|
||||
|
||||
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) {
|
||||
stringBuffer.append(fullName);
|
||||
stringBuffer.append(" [");
|
||||
stringBuffer.append(role);
|
||||
stringBuffer.append("] ");
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
public void postItemRejected(String userMessage) throws Exception {
|
||||
String fullName = ckanUser.getNameSurname();
|
||||
CMItemStatus cmItemStatus = CMItemStatus.REJECTED;
|
||||
|
||||
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{
|
||||
String fullName = ckanUser.getNameSurname();
|
||||
CMItemStatus cmItemStatus = CMItemStatus.APPROVED;
|
||||
|
||||
StringBuffer stringBuffer = getMainItemInfo(cmItemStatus);
|
||||
|
||||
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(CMItemStatus cmItemStatus) {
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
stringWriter.append("[Catalogue Service] ");
|
||||
stringWriter.append(itemTitle);
|
||||
stringWriter.append(" (name:");
|
||||
stringWriter.append(itemName);
|
||||
stringWriter.append(" (id:");
|
||||
stringWriter.append(" - id:");
|
||||
stringWriter.append(itemID);
|
||||
stringWriter.append(") - status:");
|
||||
stringWriter.append(cmItemStatus.getFancyValue());
|
||||
stringWriter.append(")");
|
||||
return stringWriter.toString();
|
||||
}
|
||||
|
||||
|
@ -59,10 +170,22 @@ public class SocialMessageModerationThread extends ModerationThread {
|
|||
|
||||
@Override
|
||||
public void postUserMessage(CMItemStatus cmItemStatus, String userMessage) throws Exception {
|
||||
Message message = getMessage(cmItemStatus, userMessage);
|
||||
String itemAuthor = ckanUser.getEMail();
|
||||
message.addUser(itemAuthor);
|
||||
sendMessage(message);
|
||||
String fullName = ckanUser.getNameSurname();
|
||||
StringBuffer stringBuffer = getMainItemInfo(cmItemStatus);
|
||||
stringBuffer = addUserWithRole(fullName, isItemAuthor() ? "Author" : Moderated.CATALOGUE_MODERATOR, stringBuffer);
|
||||
stringBuffer.append("sent the following comment:\n");
|
||||
stringBuffer.append(userMessage);
|
||||
Message message = getMessage(cmItemStatus, stringBuffer.toString());
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
String username = secretManager.getUser().getUsername();
|
||||
message.addUser(username);
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
secretManager.startSession(secret);
|
||||
try {
|
||||
sendMessage(message);
|
||||
}finally {
|
||||
secretManager.endSession();
|
||||
}
|
||||
}
|
||||
|
||||
protected void sendMessage(Message message) throws Exception {
|
||||
|
|
|
@ -35,6 +35,7 @@ public abstract class CKAN {
|
|||
private static final Logger logger = LoggerFactory.getLogger(CKAN.class);
|
||||
|
||||
protected static final String ID_KEY = "id";
|
||||
protected static final String TITLE_KEY = "title";
|
||||
protected static final String NAME_KEY = "name";
|
||||
|
||||
protected static final String ERROR_KEY = "error";
|
||||
|
|
|
@ -118,6 +118,7 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
protected final List<CKANResource> managedResources;
|
||||
|
||||
protected String itemID;
|
||||
protected String itemTitle;
|
||||
protected String itemURL;
|
||||
|
||||
protected final CKANUser ckanUser;
|
||||
|
@ -365,7 +366,8 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
if(offset < 0) {
|
||||
offset = 0;
|
||||
}
|
||||
parameters.put(START_KEY, String.valueOf(offset * limit));
|
||||
parameters.put(START_KEY, String.valueOf(offset));
|
||||
// parameters.put(START_KEY, String.valueOf(pageNumber * limit));
|
||||
|
||||
MultivaluedMap<String,String> queryParameters = uriInfo.getQueryParameters();
|
||||
parameters = checkListParameters(queryParameters, parameters);
|
||||
|
@ -382,6 +384,8 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
this.name = null;
|
||||
this.result = null;
|
||||
this.itemID = null;
|
||||
this.itemURL = null;
|
||||
this.itemTitle = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -668,7 +672,7 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
return itemURL;
|
||||
}
|
||||
|
||||
protected void sendSocialPost(String title) {
|
||||
protected void sendSocialPost() {
|
||||
try {
|
||||
boolean makePost = false;
|
||||
try {
|
||||
|
@ -685,8 +689,8 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
SocialPost socialPost = new SocialPost();
|
||||
socialPost.setItemID(itemID);
|
||||
socialPost.setItemURL(itemURL);
|
||||
socialPost.setItemTitle(itemTitle);
|
||||
socialPost.setTags(arrayNode);
|
||||
socialPost.setItemTitle(title);
|
||||
|
||||
Boolean notification = null;
|
||||
try {
|
||||
|
@ -713,15 +717,21 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
return result.get(AUTHOR_EMAIL_KEY).asText().compareTo(ckanUser.getEMail())==0;
|
||||
}
|
||||
|
||||
protected void parseResult() {
|
||||
if(this.itemID == null) {
|
||||
this.itemID = result.get(ID_KEY).asText();
|
||||
}
|
||||
this.itemTitle = result.get(TITLE_KEY).asText();
|
||||
this.itemURL = getExtraField(result, EXTRAS_ITEM_URL_KEY).asText();
|
||||
}
|
||||
|
||||
|
||||
protected void readItem() throws Exception {
|
||||
if(this.result == null) {
|
||||
String ret = super.read();
|
||||
this.result = mapper.readTree(ret);
|
||||
}
|
||||
if(this.itemID == null) {
|
||||
this.itemID = result.get(ID_KEY).asText();
|
||||
}
|
||||
itemURL = getExtraField(result, EXTRAS_ITEM_URL_KEY).asText();
|
||||
parseResult();
|
||||
}
|
||||
|
||||
|
||||
|
@ -771,7 +781,7 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
|
||||
super.create(getAsString(jsonNode));
|
||||
|
||||
this.itemID = result.get(ID_KEY).asText();
|
||||
parseResult();
|
||||
ArrayNode created = createResources(resourcesToBeCreated);
|
||||
((ObjectNode) result).replace(RESOURCES_KEY, created);
|
||||
|
||||
|
@ -780,8 +790,7 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
if(!isModerationEnabled()) {
|
||||
if(configuration.getScopeBean().is(Type.VRE)) {
|
||||
// Actions performed after a package has been correctly created on ckan.
|
||||
String title = result.get(TITLE_KEY).asText();
|
||||
sendSocialPost(title);
|
||||
sendSocialPost();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -921,6 +930,8 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
|
||||
sendPostRequest(ITEM_PATCH, getAsString(jsonNode));
|
||||
|
||||
parseResult();
|
||||
|
||||
for(String resourceId : originalResources.keySet()) {
|
||||
CKANResource ckanResource = originalResources.get(resourceId);
|
||||
ckanResource.deleteFile();
|
||||
|
@ -1292,7 +1303,7 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
private void postItemCreated() throws Exception {
|
||||
try {
|
||||
if(isModerationEnabled()) {
|
||||
moderationThread.setItemCoordinates(itemID, name, itemURL);
|
||||
moderationThread.setItemCoordinates(itemID, name, itemTitle, itemURL);
|
||||
moderationThread.postItemCreated();
|
||||
}
|
||||
} catch(WebApplicationException e) {
|
||||
|
@ -1305,7 +1316,7 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
private void postItemUpdated() {
|
||||
try {
|
||||
if(isModerationEnabled()) {
|
||||
moderationThread.setItemCoordinates(itemID, name, itemURL);
|
||||
moderationThread.setItemCoordinates(itemID, name, itemTitle, itemURL);
|
||||
moderationThread.postItemUpdated();
|
||||
}
|
||||
} catch(WebApplicationException e) {
|
||||
|
@ -1337,14 +1348,13 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
String ret = sendPostRequest(ITEM_UPDATE, getAsString(result));
|
||||
result = mapper.readTree(ret);
|
||||
|
||||
itemURL = getExtraField(result, EXTRAS_ITEM_URL_KEY).asText();
|
||||
moderationThread.setItemCoordinates(itemID, name, itemURL);
|
||||
parseResult();
|
||||
moderationThread.setItemCoordinates(itemID, name, itemTitle, itemURL);
|
||||
moderationThread.postItemApproved(moderatorMessage);
|
||||
|
||||
if(configuration.getScopeBean().is(Type.VRE)) {
|
||||
// Actions performed after a package has been correctly created on ckan.
|
||||
String title = result.get(TITLE_KEY).asText();
|
||||
sendSocialPost(title);
|
||||
sendSocialPost();
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1384,8 +1394,8 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
setToRejected(result);
|
||||
String ret = sendPostRequest(ITEM_PATCH, getAsString(result));
|
||||
result = mapper.readTree(ret);
|
||||
|
||||
moderationThread.setItemCoordinates(itemID, name, itemURL);
|
||||
parseResult();
|
||||
moderationThread.setItemCoordinates(itemID, name, itemTitle, itemURL);
|
||||
moderationThread.postItemRejected(moderatorMessage);
|
||||
break;
|
||||
|
||||
|
@ -1417,11 +1427,13 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
// Users that are not
|
||||
if(!isItemCreator()) {
|
||||
throw new NotAllowedException("Only item creator and " + Moderated.CATALOGUE_MODERATOR + "s are entitled to partecipate to the moderation discussion thread.");
|
||||
}else {
|
||||
moderationThread.setItemAuthor(true);
|
||||
}
|
||||
}
|
||||
|
||||
CMItemStatus cmItemStatus = getCMItemStatus();
|
||||
moderationThread.setItemCoordinates(itemID, name, itemURL);
|
||||
moderationThread.setItemCoordinates(itemID, name, itemTitle, itemURL);
|
||||
moderationThread.postUserMessage(cmItemStatus, message);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ import org.postgresql.core.Utils;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class CKANPackageTrash {
|
||||
|
||||
protected static final Logger logger = LoggerFactory.getLogger(CKANPackageTrash.class);
|
||||
|
|
|
@ -15,6 +15,9 @@ import javax.cache.spi.CachingProvider;
|
|||
import org.gcube.common.authorization.utils.manager.SecretManager;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public abstract class CKANUserCache {
|
||||
|
||||
private static final CacheManager cacheManager;
|
||||
|
|
|
@ -32,6 +32,9 @@ import org.xml.sax.SAXException;
|
|||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class ISProfile {
|
||||
|
||||
public static int PRETTY_PRINT_INDENT_FACTOR = 4;
|
||||
|
|
|
@ -14,6 +14,9 @@ import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataFormat;
|
|||
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.NamespaceCategory;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class MetadataUtility {
|
||||
|
||||
private DataCalogueMetadataFormatReader dataCalogueMetadataFormatReader;
|
||||
|
|
|
@ -46,6 +46,9 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class ResourceRegistryProfile {
|
||||
|
||||
public static int PRETTY_PRINT_INDENT_FACTOR = 4;
|
||||
|
|
|
@ -9,6 +9,9 @@ import org.gcube.gcat.api.GCatConstants;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class BaseREST {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
|
|
@ -9,6 +9,9 @@ import org.gcube.gcat.api.GCatConstants;
|
|||
import org.gcube.gcat.api.interfaces.CRUD;
|
||||
import org.gcube.gcat.persistence.ckan.CKAN;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class REST<C extends CKAN> extends BaseREST implements CRUD<Response,Response> {
|
||||
|
||||
protected final String COLLECTION_PARAMETER;
|
||||
|
|
|
@ -19,6 +19,9 @@ import org.gcube.common.authorization.utils.secret.Secret;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@Provider
|
||||
@PreMatching
|
||||
public class RequestFilter implements ContainerRequestFilter, ContainerResponseFilter {
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
|||
import org.gcube.com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI-CNR)
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class Message {
|
||||
|
||||
|
|
|
@ -13,6 +13,9 @@ import org.gcube.common.authorization.utils.socialservice.SocialService;
|
|||
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
|
||||
import org.gcube.gcat.utils.HTTPUtility;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class SocialUsers {
|
||||
|
||||
protected static final String GET_USERNAMES_BY_ROLE = "2/users/get-usernames-by-role";
|
||||
|
|
|
@ -9,6 +9,9 @@ import javax.ws.rs.InternalServerErrorException;
|
|||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class HTTPCall {
|
||||
|
||||
protected static final String USER_AGENT_KEY = "User-Agent";
|
||||
|
|
|
@ -16,6 +16,9 @@ import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class HTTPUtility {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HTTPUtility.class);
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Random;
|
|||
|
||||
/**
|
||||
* @author Lucio Lelii (ISTI - CNR)
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class RandomString {
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@ import javax.ws.rs.WebApplicationException;
|
|||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public abstract class URIResolver {
|
||||
|
||||
private static final String CATALOGUE_CONTEXT = "gcube_scope";
|
||||
|
|
|
@ -7,6 +7,9 @@ import java.util.Map;
|
|||
import org.gcube.common.storagehub.model.Metadata;
|
||||
import org.gcube.storagehub.MetadataMatcher;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class CatalogueMetadata implements MetadataMatcher {
|
||||
|
||||
public static final String ORIGINAL_URL = "OriginalURL";
|
||||
|
|
|
@ -16,6 +16,9 @@ import org.glassfish.jersey.media.multipart.ContentDisposition;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class CatalogueStorageHubManagement {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CatalogueStorageHubManagement.class);
|
||||
|
|
|
@ -13,10 +13,10 @@ import org.junit.Test;
|
|||
public class ModerationThreadTest extends ContextTest {
|
||||
|
||||
@Test
|
||||
@JsonIgnore
|
||||
// @JsonIgnore
|
||||
public void test() throws Exception {
|
||||
ModerationThread moderationThread = ModerationThread.getDefaultInstance();
|
||||
moderationThread.setItemCoordinates("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");
|
||||
CKANUser ckanUser = new CKANUser();
|
||||
ckanUser.setName(CKANUser.getCKANUsername());
|
||||
ckanUser.read();
|
||||
|
@ -25,7 +25,8 @@ public class ModerationThreadTest extends ContextTest {
|
|||
moderationThread.postItemUpdated();
|
||||
moderationThread.postItemRejected("Non mi garba");
|
||||
moderationThread.postItemApproved("Ora mi garba");
|
||||
moderationThread.postUserMessage(CMItemStatus.APPROVED, "Well Done");
|
||||
moderationThread.setItemAuthor(true);
|
||||
moderationThread.postUserMessage(CMItemStatus.APPROVED, "Grazie");
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue