task_21363 #1
26
.classpath
26
.classpath
|
@ -11,19 +11,6 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="test" value="true"/>
|
|
||||||
<attribute name="optional" value="true"/>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="test" value="true"/>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
@ -34,6 +21,19 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
<classpathentry kind="lib" path="/home/francescomangiacrapa/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar"/>
|
<classpathentry kind="lib" path="/home/francescomangiacrapa/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar"/>
|
||||||
<classpathentry kind="output" path="target/ckan-content-moderator-widget-0.1.0-SNAPSHOT/WEB-INF/classes"/>
|
<classpathentry kind="output" path="target/ckan-content-moderator-widget-0.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
|
|
@ -1,31 +1,54 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-module deploy-name="ckan-content-moderator-widget-0.1.0-SNAPSHOT">
|
<wb-module deploy-name="ckan-content-moderator-widget-0.1.0-SNAPSHOT">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||||
|
<dependent-module archiveName="catalogue-util-library-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/catalogue-util-library/catalogue-util-library">
|
||||||
|
<dependency-type>uses</dependency-type>
|
||||||
|
</dependent-module>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<property name="context-root" value="ckan-content-moderator-widget"/>
|
<property name="context-root" value="ckan-content-moderator-widget"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<property name="java-output-path" value="/ckan-content-moderator-widget/target/ckan-content-moderator-widget-0.1.0-SNAPSHOT/WEB-INF/classes"/>
|
<property name="java-output-path" value="/ckan-content-moderator-widget/target/ckan-content-moderator-widget-0.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</wb-module>
|
</wb-module>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</project-modules>
|
</project-modules>
|
||||||
|
|
11
pom.xml
11
pom.xml
|
@ -131,6 +131,17 @@
|
||||||
<version>${gwt-material.version}</version>
|
<version>${gwt-material.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.core</groupId>
|
||||||
|
<artifactId>common-encryption</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.core</groupId>
|
||||||
|
<artifactId>common-configuration-scanner</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- FWS -->
|
<!-- FWS -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.resources.discovery</groupId>
|
<groupId>org.gcube.resources.discovery</groupId>
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
<inherits name="gwt.material.design.themes.ThemeBlue" />
|
<inherits name="gwt.material.design.themes.ThemeBlue" />
|
||||||
<inherits name="gwt.material.design.GwtMaterialTable" />
|
<inherits name="gwt.material.design.GwtMaterialTable" />
|
||||||
|
|
||||||
|
<inherits
|
||||||
|
name="org.gcube.datacatalogue.utillibrary.CkanUtilLibrary" />
|
||||||
|
|
||||||
<!-- Other module inherits -->
|
<!-- Other module inherits -->
|
||||||
|
|
||||||
<!-- Specify the app entry point class. -->
|
<!-- Specify the app entry point class. -->
|
||||||
|
|
|
@ -2,28 +2,69 @@ package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.ItemStatus;
|
|
||||||
|
|
||||||
import com.google.gwt.user.client.rpc.RemoteService;
|
import com.google.gwt.user.client.rpc.RemoteService;
|
||||||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The client side stub for the RPC service.
|
* The client side stub for the RPC service.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Jun 14, 2021
|
||||||
*/
|
*/
|
||||||
@RemoteServiceRelativePath("greet")
|
@RemoteServiceRelativePath("greet")
|
||||||
public interface CkanContentModeratorService extends RemoteService {
|
public interface CkanContentModeratorService extends RemoteService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is content moderator enabled.
|
||||||
|
*
|
||||||
|
* @return true, if is content moderator enabled
|
||||||
|
*/
|
||||||
public boolean isContentModeratorEnabled();
|
public boolean isContentModeratorEnabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the status.
|
||||||
|
*
|
||||||
|
* @param itemId the item id
|
||||||
|
* @param theStatus the the status
|
||||||
|
*/
|
||||||
public void setStatus(String itemId, ItemStatus theStatus);
|
public void setStatus(String itemId, ItemStatus theStatus);
|
||||||
|
|
||||||
public List<CatalogueDataset> getListItemsForStatus(ItemStatus theStatus);
|
/**
|
||||||
|
* Approve item.
|
||||||
|
*
|
||||||
|
* @param itemId the item id
|
||||||
|
*/
|
||||||
public void approveItem(String itemId);
|
public void approveItem(String itemId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reject item.
|
||||||
|
*
|
||||||
|
* @param itemId the item id
|
||||||
|
* @param permanentlyDelete the permanently delete
|
||||||
|
* @param reasonMsg the reason msg
|
||||||
|
*/
|
||||||
public void rejectItem(String itemId, boolean permanentlyDelete, String reasonMsg);
|
public void rejectItem(String itemId, boolean permanentlyDelete, String reasonMsg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permanently delete.
|
||||||
|
*
|
||||||
|
* @param itemId the item id
|
||||||
|
*/
|
||||||
public void permanentlyDelete(String itemId);
|
public void permanentlyDelete(String itemId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the list items for status.
|
||||||
|
*
|
||||||
|
* @param theStatus the the status
|
||||||
|
* @param limit the limit
|
||||||
|
* @param offset the offset
|
||||||
|
* @return the list items for status
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public List<CatalogueDataset> getListItemsForStatus(ItemStatus theStatus, int limit, int offset) throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,23 +2,72 @@ package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.ItemStatus;
|
|
||||||
|
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface CkanContentModeratorServiceAsync.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Jun 14, 2021
|
||||||
|
*/
|
||||||
public interface CkanContentModeratorServiceAsync {
|
public interface CkanContentModeratorServiceAsync {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is content moderator enabled.
|
||||||
|
*
|
||||||
|
* @param callback the callback
|
||||||
|
*/
|
||||||
void isContentModeratorEnabled(AsyncCallback<Boolean> callback);
|
void isContentModeratorEnabled(AsyncCallback<Boolean> callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Approve item.
|
||||||
|
*
|
||||||
|
* @param itemId the item id
|
||||||
|
* @param callback the callback
|
||||||
|
*/
|
||||||
void approveItem(String itemId, AsyncCallback<Void> callback);
|
void approveItem(String itemId, AsyncCallback<Void> callback);
|
||||||
|
|
||||||
void getListItemsForStatus(ItemStatus theStatus, AsyncCallback<List<CatalogueDataset>> callback);
|
/**
|
||||||
|
* Permanently delete.
|
||||||
|
*
|
||||||
|
* @param itemId the item id
|
||||||
|
* @param callback the callback
|
||||||
|
*/
|
||||||
void permanentlyDelete(String itemId, AsyncCallback<Void> callback);
|
void permanentlyDelete(String itemId, AsyncCallback<Void> callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reject item.
|
||||||
|
*
|
||||||
|
* @param itemId the item id
|
||||||
|
* @param permanentlyDelete the permanently delete
|
||||||
|
* @param reasonMsg the reason msg
|
||||||
|
* @param callback the callback
|
||||||
|
*/
|
||||||
void rejectItem(String itemId, boolean permanentlyDelete, String reasonMsg, AsyncCallback<Void> callback);
|
void rejectItem(String itemId, boolean permanentlyDelete, String reasonMsg, AsyncCallback<Void> callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the status.
|
||||||
|
*
|
||||||
|
* @param itemId the item id
|
||||||
|
* @param theStatus the the status
|
||||||
|
* @param callback the callback
|
||||||
|
*/
|
||||||
void setStatus(String itemId, ItemStatus theStatus, AsyncCallback<Void> callback);
|
void setStatus(String itemId, ItemStatus theStatus, AsyncCallback<Void> callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the list items for status.
|
||||||
|
*
|
||||||
|
* @param theStatus the the status
|
||||||
|
* @param limit the limit
|
||||||
|
* @param offset the offset
|
||||||
|
* @param callback the callback
|
||||||
|
* @return the list items for status
|
||||||
|
*/
|
||||||
|
void getListItemsForStatus(ItemStatus theStatus, int limit, int offset,
|
||||||
|
AsyncCallback<List<CatalogueDataset>> callback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,15 @@ package org.gcube.portlets.widgets.ckancontentmoderator.client;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.material.table.CustomizedView;
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.material.table.CustomizedView;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.resources.DataTableClientBundle;
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.resources.DataTableClientBundle;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.ItemStatus;
|
|
||||||
|
|
||||||
import com.google.gwt.core.client.EntryPoint;
|
import com.google.gwt.core.client.EntryPoint;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.dom.client.StyleInjector;
|
import com.google.gwt.dom.client.StyleInjector;
|
||||||
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.RootPanel;
|
import com.google.gwt.user.client.ui.RootPanel;
|
||||||
|
|
||||||
|
@ -45,7 +46,7 @@ public class CkanContentModeratorWidget implements EntryPoint {
|
||||||
RootPanel.get().add(cvTable);
|
RootPanel.get().add(cvTable);
|
||||||
// table.getView().refresh();
|
// table.getView().refresh();
|
||||||
|
|
||||||
greetingService.getListItemsForStatus(ItemStatus.PENDING, new AsyncCallback<List<CatalogueDataset>>() {
|
greetingService.getListItemsForStatus(ItemStatus.PENDING, 20, 0, new AsyncCallback<List<CatalogueDataset>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<CatalogueDataset> result) {
|
public void onSuccess(List<CatalogueDataset> result) {
|
||||||
|
@ -55,23 +56,7 @@ public class CkanContentModeratorWidget implements EntryPoint {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
// TODO Auto-generated method stub
|
Window.alert(caught.getMessage());
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
greetingService.approveItem("ciao", new AsyncCallback<Void>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Void result) {
|
|
||||||
GWT.log("OK");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
package org.gcube.portlets.widgets.ckancontentmoderator.server;
|
||||||
|
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.gcube.datacatalogue.utillibrary.server.DataCatalogueImpl;
|
||||||
|
import org.gcube.datacatalogue.utillibrary.server.cms.CatalogueContentModeratorSystem;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A factory for getting CatalogueContentModeratorSystem objects.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Jun 14, 2021
|
||||||
|
*/
|
||||||
|
public class CatalogueCMSFactory {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(CatalogueCMSFactory.class);
|
||||||
|
private static final long MAX_LIFETIME = 1000 * 60 * 30; // 30 MINUTES
|
||||||
|
private static CatalogueCMSFactory instance = new CatalogueCMSFactory();
|
||||||
|
private static ConcurrentHashMap<String, CacheBean> cache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class CacheBean.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Jun 14, 2021
|
||||||
|
*/
|
||||||
|
private class CacheBean {
|
||||||
|
CatalogueContentModeratorSystem cmsInstance;
|
||||||
|
long ttl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new cache bean.
|
||||||
|
*
|
||||||
|
* @param ttl the ttl
|
||||||
|
* @param cmsInstance the cms instance
|
||||||
|
*/
|
||||||
|
public CacheBean(long ttl, CatalogueContentModeratorSystem cmsInstance) {
|
||||||
|
this.ttl = ttl;
|
||||||
|
this.cmsInstance = cmsInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private constructor.
|
||||||
|
*/
|
||||||
|
private CatalogueCMSFactory() {
|
||||||
|
|
||||||
|
logger.debug(CatalogueCMSFactory.class.getSimpleName() + " object build");
|
||||||
|
cache = new ConcurrentHashMap<String, CacheBean>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the factory instance.
|
||||||
|
*
|
||||||
|
* @return the factory
|
||||||
|
*/
|
||||||
|
public static CatalogueCMSFactory getFactory() {
|
||||||
|
logger.debug(CatalogueCMSFactory.class.getSimpleName() + " requested");
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the CMS per scope.
|
||||||
|
*
|
||||||
|
* @param scope the scope
|
||||||
|
* @return the CMS per scope
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
public CatalogueContentModeratorSystem getCMSPerScope(String scope) throws Exception {
|
||||||
|
|
||||||
|
if (scope == null || scope.isEmpty())
|
||||||
|
throw new IllegalArgumentException("Invalid scope given!");
|
||||||
|
|
||||||
|
if (cache.containsKey(scope) && !expired(cache.get(scope))) {
|
||||||
|
return cache.get(scope).cmsInstance;
|
||||||
|
} else {
|
||||||
|
logger.info("Creating "+CatalogueCMSFactory.class.getSimpleName()+" for scope " + scope);
|
||||||
|
DataCatalogueImpl dci = new DataCatalogueImpl(scope);
|
||||||
|
CatalogueContentModeratorSystem cmsInstance = dci.getCatalogueContentModerator();
|
||||||
|
cache.put(scope, new CacheBean(System.currentTimeMillis(), cmsInstance));
|
||||||
|
return cmsInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the ckan information must be retrieved again.
|
||||||
|
*
|
||||||
|
* @param cacheBean the cache bean
|
||||||
|
* @return true, if successful
|
||||||
|
*/
|
||||||
|
private boolean expired(CacheBean cacheBean) {
|
||||||
|
return (cacheBean.ttl + MAX_LIFETIME < System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,15 @@
|
||||||
package org.gcube.portlets.widgets.ckancontentmoderator.server;
|
package org.gcube.portlets.widgets.ckancontentmoderator.server;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.gcat.client.Item;
|
import org.gcube.datacatalogue.utillibrary.server.cms.CatalogueContentModeratorSystem;
|
||||||
|
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||||
|
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.client.CkanContentModeratorService;
|
import org.gcube.portlets.widgets.ckancontentmoderator.client.CkanContentModeratorService;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.ItemStatus;
|
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -18,8 +20,7 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||||
* The server side implementation of the RPC service.
|
* The server side implementation of the RPC service.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implements
|
public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implements CkanContentModeratorService {
|
||||||
CkanContentModeratorService, ContentModeratorSystem {
|
|
||||||
|
|
||||||
private static Logger LOG = LoggerFactory.getLogger(CkanContentModeratorServiceImpl.class);
|
private static Logger LOG = LoggerFactory.getLogger(CkanContentModeratorServiceImpl.class);
|
||||||
|
|
||||||
|
@ -36,34 +37,43 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CatalogueDataset> getListItemsForStatus(ItemStatus theStatus) {
|
public List<CatalogueDataset> getListItemsForStatus(ItemStatus theStatus, int limit, int offset) throws Exception {
|
||||||
LOG.info("Called getListItemsForStatus: "+theStatus);
|
LOG.info("called getListItemsForStatus with [status: " + theStatus + "], [limit: " + limit + "], [offset: "
|
||||||
|
+ offset + "]");
|
||||||
|
List<CatalogueDataset> datasetList = null;
|
||||||
try {
|
try {
|
||||||
//DataCatalogueImpl catalogue = DataCatalogueFactory.getFactory().getUtilsPerScope(scope);
|
|
||||||
String scope = WsUtil.getCurrentScope(getThreadLocalRequest());
|
|
||||||
GCubeUser user = WsUtil.getCurrentUser(getThreadLocalRequest());
|
|
||||||
|
|
||||||
|
String scope = WsUtil.getCurrentScope(this.getThreadLocalRequest());
|
||||||
|
GCubeUser user = WsUtil.getCurrentUser(this.getThreadLocalRequest());
|
||||||
String token = WsUtil.getCurrentToken(scope, user.getUsername());
|
String token = WsUtil.getCurrentToken(scope, user.getUsername());
|
||||||
LOG.info("Setting scope: "+scope);
|
|
||||||
ScopeProvider.instance.set(scope);
|
ScopeProvider.instance.set(scope);
|
||||||
LOG.info("Setting token: "+token);
|
|
||||||
SecurityTokenProvider.instance.set(token);
|
SecurityTokenProvider.instance.set(token);
|
||||||
String datasetId = new Item().list(10, 0);
|
CatalogueContentModeratorSystem cmsInstance = CatalogueCMSFactory.getFactory().getCMSPerScope(scope);
|
||||||
System.out.println("the datasetId: " +datasetId);
|
List<CkanDataset> datasets = cmsInstance.getListItemsForStatus(theStatus, limit, offset);
|
||||||
|
if (datasets != null) {
|
||||||
|
int size = datasets.size();
|
||||||
|
datasetList = new ArrayList<CatalogueDataset>(size);
|
||||||
|
LOG.info("datasetList for input parameters returned by CMS has size: " + size);
|
||||||
|
for (CkanDataset ckanDataset : datasets) {
|
||||||
|
CatalogueDataset ds = CatalogueBeansConverter.toCatalogueDataset.apply(ckanDataset);
|
||||||
|
LOG.debug("converted dataset is: " + ds);
|
||||||
|
datasetList.add(ds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
LOG.error(e.getMessage(), e);
|
||||||
e.printStackTrace();
|
throw new Exception(
|
||||||
LOG.error(e.getMessage(),e);
|
"Error occurrend on reading items for status: " + theStatus + ". Caused by: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
LOG.info("returning "+datasetList.size()+ " dataset");
|
||||||
|
return datasetList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void approveItem(String itemId) {
|
public void approveItem(String itemId) {
|
||||||
LOG.info("Called approve Item: "+itemId);
|
LOG.info("Called approve Item: " + itemId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,5 +88,4 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
package org.gcube.portlets.widgets.ckancontentmoderator.server;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.CatalogueDataset;
|
|
||||||
import org.gcube.portlets.widgets.ckancontentmoderator.shared.ItemStatus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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<CatalogueDataset> 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);
|
|
||||||
|
|
||||||
}
|
|
|
@ -2,6 +2,8 @@ package org.gcube.portlets.widgets.ckancontentmoderator.shared;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||||
|
|
||||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||||
|
|
||||||
// TODO: Auto-generated Javadoc
|
// TODO: Auto-generated Javadoc
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
package org.gcube.portlets.widgets.ckancontentmoderator.shared;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Enum ItemStatus.
|
|
||||||
*
|
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
|
||||||
*
|
|
||||||
* May 7, 2021
|
|
||||||
*/
|
|
||||||
public 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -11,6 +11,9 @@
|
||||||
<inherits name="gwt.material.design.themes.ThemeBlue" />
|
<inherits name="gwt.material.design.themes.ThemeBlue" />
|
||||||
<inherits name="gwt.material.design.GwtMaterialTable" />
|
<inherits name="gwt.material.design.GwtMaterialTable" />
|
||||||
|
|
||||||
|
<inherits
|
||||||
|
name="org.gcube.datacatalogue.utillibrary.CkanUtilLibrary" />
|
||||||
|
|
||||||
<!-- Other module inherits -->
|
<!-- Other module inherits -->
|
||||||
|
|
||||||
<!-- Specify the app entry point class. -->
|
<!-- Specify the app entry point class. -->
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>greetServlet</servlet-name>
|
<servlet-name>greetServlet</servlet-name>
|
||||||
<servlet-class>org.gcube.portlets.widgets.ckancontentmoderator.server.CkanContentModeratorServiceAImpl</servlet-class>
|
<servlet-class>org.gcube.portlets.widgets.ckancontentmoderator.server.CkanContentModeratorServiceImpl</servlet-class>
|
||||||
</servlet>
|
</servlet>
|
||||||
|
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
package org.gcube.portlets.widgets.ckancontentmoderator.server;
|
||||||
|
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.datacatalogue.utillibrary.server.cms.CatalogueContentModeratorSystem;
|
||||||
|
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
|
||||||
|
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class CkanContentModeratorServiceTest {
|
||||||
|
|
||||||
|
private String scope = "/gcube/devsec/devVRE";
|
||||||
|
private String testUser = "francesco.mangiacrapa";
|
||||||
|
private String authorizationToken = "8e74a17c-92f1-405a-b591-3a6090066248-98187548";
|
||||||
|
|
||||||
|
private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(CkanContentModeratorServiceTest.class);
|
||||||
|
|
||||||
|
//@Test
|
||||||
|
public void test() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void loadItemsForStatus() {
|
||||||
|
ScopeProvider.instance.set(scope);
|
||||||
|
SecurityTokenProvider.instance.set(authorizationToken);
|
||||||
|
try {
|
||||||
|
CatalogueContentModeratorSystem cms = CatalogueCMSFactory.getFactory().getCMSPerScope(scope);
|
||||||
|
List<CkanDataset> items = cms.getListItemsForStatus(ItemStatus.PENDING, 20, 0);
|
||||||
|
int i = 0;
|
||||||
|
for (CkanDataset ckanDataset : items) {
|
||||||
|
System.out.println(i++ +")Read dataset: "+ckanDataset);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue