only added the interface
parent
4606f9719a
commit
143d3bbc4b
@ -0,0 +1,29 @@
|
||||
package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.server.ContentModeratorSystem.ItemStatus;
|
||||
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||
|
||||
/**
|
||||
* The client side stub for the RPC service.
|
||||
*/
|
||||
@RemoteServiceRelativePath("greet")
|
||||
public interface CkanContentModeratorService extends RemoteService {
|
||||
|
||||
public boolean isContentModeratorEnabled();
|
||||
|
||||
public void setStatus(String itemId, ItemStatus theStatus);
|
||||
|
||||
public List<CkanDataset> getListItemsForStatus(ItemStatus theStatus);
|
||||
|
||||
public void approveItem(String itemId);
|
||||
|
||||
public void rejectItem(String itemId, boolean permanentlyDelete, String reasonMsg);
|
||||
|
||||
public void permanentlyDelete(String itemId);
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.server.ContentModeratorSystem.ItemStatus;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
public interface CkanContentModeratorServiceAsync {
|
||||
|
||||
void isContentModeratorEnabled(AsyncCallback<Boolean> callback);
|
||||
|
||||
void approveItem(String itemId, AsyncCallback<Void> callback);
|
||||
|
||||
void getListItemsForStatus(ItemStatus theStatus, AsyncCallback<List<CkanDataset>> callback);
|
||||
|
||||
void permanentlyDelete(String itemId, AsyncCallback<Void> callback);
|
||||
|
||||
void rejectItem(String itemId, boolean permanentlyDelete, String reasonMsg, AsyncCallback<Void> callback);
|
||||
|
||||
void setStatus(String itemId, ItemStatus theStatus, AsyncCallback<Void> callback);
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
||||
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||
|
||||
/**
|
||||
* The client side stub for the RPC service.
|
||||
*/
|
||||
@RemoteServiceRelativePath("greet")
|
||||
public interface GreetingService extends RemoteService {
|
||||
String greetServer(String name) throws IllegalArgumentException;
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
public interface GreetingServiceAsync {
|
||||
|
||||
void greetServer(String name, AsyncCallback<String> callback);
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package org.gcube.portlets.widgets.ckancontentmoderator.server;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.CkanContentModeratorService;
|
||||
|
||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
|
||||
/**
|
||||
* The server side implementation of the RPC service.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class CkanContentModeratorServiceAImpl extends RemoteServiceServlet implements
|
||||
CkanContentModeratorService, ContentModeratorSystem {
|
||||
|
||||
@Override
|
||||
public boolean isContentModeratorEnabled() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatus(String itemId, ItemStatus theStatus) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CkanDataset> getListItemsForStatus(ItemStatus theStatus) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void approveItem(String itemId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rejectItem(String itemId, boolean permanentlyDelete, String reasonMsg) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void permanentlyDelete(String itemId) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
package org.gcube.portlets.widgets.ckancontentmoderator.server;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Interface ContentModeratorSystem.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* May 7, 2021
|
||||
*/
|
||||
public interface ContentModeratorSystem {
|
||||
|
||||
/**
|
||||
* Checks if is content moderator enabled.
|
||||
*
|
||||
* @return true, if is content moderator enabled
|
||||
*/
|
||||
boolean isContentModeratorEnabled();
|
||||
|
||||
/**
|
||||
* Sets the status.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @param theStatus the the status
|
||||
*/
|
||||
void setStatus(String itemId, ItemStatus theStatus);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list items for status.
|
||||
*
|
||||
* @param theStatus the the status
|
||||
* @return the list items for status
|
||||
*/
|
||||
List<CkanDataset> getListItemsForStatus(ItemStatus theStatus);
|
||||
|
||||
/**
|
||||
* Approve item.
|
||||
*
|
||||
* @param itemId the item id
|
||||
*/
|
||||
void approveItem(String itemId);
|
||||
|
||||
/**
|
||||
* Reject item.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @param permanentlyDelete the permanently delete
|
||||
* @param reasonMsg the reason msg
|
||||
*/
|
||||
void rejectItem(String itemId, boolean permanentlyDelete, String reasonMsg);
|
||||
|
||||
/**
|
||||
* Permanently delete.
|
||||
*
|
||||
* @param itemId the item id
|
||||
*/
|
||||
void permanentlyDelete(String itemId);
|
||||
|
||||
/**
|
||||
* The Enum ItemStatus.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* May 7, 2021
|
||||
*/
|
||||
static enum ItemStatus {
|
||||
PENDING("pending", "Pending"), APPROVED("approved", "Approved"), REJECTED("rejected", "Rejected");
|
||||
|
||||
private String id;
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Instantiates a new item status.
|
||||
*
|
||||
* @param id the id
|
||||
* @param label the label
|
||||
*/
|
||||
private ItemStatus(String id, String label) {
|
||||
this.id = id;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the label.
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package org.gcube.portlets.widgets.ckancontentmoderator.server;
|
||||
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.GreetingService;
|
||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.FieldVerifier;
|
||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
|
||||
/**
|
||||
* The server side implementation of the RPC service.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class GreetingServiceImpl extends RemoteServiceServlet implements
|
||||
GreetingService {
|
||||
|
||||
public String greetServer(String input) throws IllegalArgumentException {
|
||||
// Verify that the input is valid.
|
||||
if (!FieldVerifier.isValidName(input)) {
|
||||
// If the input is not valid, throw an IllegalArgumentException back to
|
||||
// the client.
|
||||
throw new IllegalArgumentException(
|
||||
"Name must be at least 4 characters long");
|
||||
}
|
||||
|
||||
String serverInfo = getServletContext().getServerInfo();
|
||||
String userAgent = getThreadLocalRequest().getHeader("User-Agent");
|
||||
|
||||
// Escape data from the client to avoid cross-site script vulnerabilities.
|
||||
input = escapeHtml(input);
|
||||
userAgent = escapeHtml(userAgent);
|
||||
|
||||
return "Hello, " + input + "!<br><br>I am running " + serverInfo
|
||||
+ ".<br><br>It looks like you are using:<br>" + userAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape an html string. Escaping data received from the client helps to
|
||||
* prevent cross-site script vulnerabilities.
|
||||
*
|
||||
* @param html the html string to escape
|
||||
* @return the escaped string
|
||||
*/
|
||||
private String escapeHtml(String html) {
|
||||
if (html == null) {
|
||||
return null;
|
||||
}
|
||||
return html.replaceAll("&", "&").replaceAll("<", "<").replaceAll(
|
||||
">", ">");
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package org.gcube.portlets.widgets.ckancontentmoderator.server;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class CkanContentModeratorServiceAImplTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue