Browse Source

only added the interface

master
parent
commit
143d3bbc4b
  1. 18
      pom.xml
  2. 29
      src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorService.java
  3. 24
      src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorServiceAsync.java
  4. 15
      src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorWidget.java
  5. 12
      src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/GreetingService.java
  6. 9
      src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/GreetingServiceAsync.java
  7. 52
      src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorServiceAImpl.java
  8. 108
      src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/ContentModeratorSystem.java
  9. 48
      src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/GreetingServiceImpl.java
  10. 14
      src/test/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorServiceAImplTest.java

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>

29
src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorService.java

@ -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);
}

24
src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorServiceAsync.java

@ -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);
}

15
src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorWidget.java

@ -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
}

12
src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/GreetingService.java

@ -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;
}

9
src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/GreetingServiceAsync.java

@ -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);
}

52
src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorServiceAImpl.java

@ -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
}
}

108
src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/ContentModeratorSystem.java

@ -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;
}
}
}

48
src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/GreetingServiceImpl.java

@ -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("&", "&amp;").replaceAll("<", "&lt;").replaceAll(
">", "&gt;");
}
}

14
src/test/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorServiceAImplTest.java

@ -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…
Cancel
Save