|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package org.gcube.gcat.client;
|
|
|
|
|
|
|
|
|
|
import java.net.HttpURLConnection;
|
|
|
|
|
import java.net.MalformedURLException;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
@ -11,12 +12,13 @@ import javax.xml.ws.WebServiceException;
|
|
|
|
|
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
|
|
|
|
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import org.gcube.gcat.api.GCatConstants;
|
|
|
|
|
import org.gcube.gcat.api.moderation.Moderated;
|
|
|
|
|
import org.gcube.gcat.api.moderation.CMItemStatus;
|
|
|
|
|
import org.gcube.gcat.api.moderation.ModerationContent;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
|
|
|
*/
|
|
|
|
|
public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.Item<String,Void>, Moderated {
|
|
|
|
|
public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.Item<String,Void> {
|
|
|
|
|
|
|
|
|
|
public Item() throws MalformedURLException {
|
|
|
|
|
super(ITEMS);
|
|
|
|
@ -123,22 +125,39 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String approve(String moderatorMessage) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
return null;
|
|
|
|
|
protected String moderate(String name, ModerationContent moderationContent) {
|
|
|
|
|
try {
|
|
|
|
|
initRequest();
|
|
|
|
|
gxhttpStringRequest.path(name);
|
|
|
|
|
String moderationContentString = (new ObjectMapper()).writeValueAsString(moderationContent);
|
|
|
|
|
gxhttpStringRequest.withBody(moderationContentString);
|
|
|
|
|
HttpURLConnection httpURLConnection = gxhttpStringRequest.post();
|
|
|
|
|
return parseHttpURLConnection(httpURLConnection);
|
|
|
|
|
}catch (WebApplicationException e) {
|
|
|
|
|
throw e;
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
throw new WebApplicationException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String approve(String name, String moderatorMessage) {
|
|
|
|
|
ModerationContent moderationContent = new ModerationContent();
|
|
|
|
|
moderationContent.setCMItemStatus(CMItemStatus.APPROVED);
|
|
|
|
|
moderationContent.setMessage(moderatorMessage);
|
|
|
|
|
return moderate(name, moderationContent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String reject(String moderatorMessage) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
return null;
|
|
|
|
|
public String reject(String name, String moderatorMessage) {
|
|
|
|
|
ModerationContent moderationContent = new ModerationContent();
|
|
|
|
|
moderationContent.setCMItemStatus(CMItemStatus.REJECTED);
|
|
|
|
|
moderationContent.setMessage(moderatorMessage);
|
|
|
|
|
return moderate(name, moderationContent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void message(String message) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
|
|
public void message(String name, String message) {
|
|
|
|
|
ModerationContent moderationContent = new ModerationContent();
|
|
|
|
|
moderationContent.setMessage(message);
|
|
|
|
|
moderate(name, moderationContent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|