only added the interface
This commit is contained in:
parent
4606f9719a
commit
143d3bbc4b
18
pom.xml
18
pom.xml
|
@ -21,7 +21,7 @@
|
|||
The gCube Ckan Content Moderator Widget caters for the approval stage before publishing in the D4Science Catalogue
|
||||
</description>
|
||||
|
||||
<scm>
|
||||
<scm>
|
||||
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection>
|
||||
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection>
|
||||
<url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
|
||||
|
@ -70,6 +70,22 @@
|
|||
<artifactId>gwt-bootstrap</artifactId>
|
||||
<version>2.3.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.datacatalogue</groupId>
|
||||
<artifactId>catalogue-util-library</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
|
|
@ -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,8 +1,12 @@
|
|||
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.core.client.EntryPoint;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
/**
|
||||
|
@ -20,7 +24,7 @@ public class CkanContentModeratorWidget implements EntryPoint {
|
|||
/**
|
||||
* Create a remote service proxy to talk to the server-side Greeting service.
|
||||
*/
|
||||
private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
|
||||
private final CkanContentModeratorServiceAsync greetingService = GWT.create(CkanContentModeratorService.class);
|
||||
|
||||
|
||||
|
||||
|
@ -29,11 +33,12 @@ public class CkanContentModeratorWidget implements EntryPoint {
|
|||
*/
|
||||
public void onModuleLoad() {
|
||||
|
||||
greetingService.greetServer("I'm Francesco", new AsyncCallback<String>() {
|
||||
|
||||
greetingService.getListItemsForStatus(ItemStatus.PENDING, new AsyncCallback<List<CkanDataset>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
Window.alert(result);
|
||||
public void onSuccess(List<CkanDataset> result) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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