Updated the GUI
This commit is contained in:
parent
68970848a5
commit
b7904782f8
|
@ -1,9 +1,9 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
|
29
pom.xml
29
pom.xml
|
@ -31,10 +31,10 @@
|
|||
|
||||
<properties>
|
||||
<!-- Convenience property to set the GWT version -->
|
||||
<gwtVersion>2.7.0</gwtVersion>
|
||||
<gwtVersion>2.8.2</gwtVersion>
|
||||
|
||||
<!-- GWT needs at least java 1.6 -->
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
@ -80,6 +80,31 @@
|
|||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>portal-service</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.dvos</groupId>
|
||||
<artifactId>usermanagement-core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common.portal</groupId>
|
||||
<artifactId>portal-manager</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>social-networking-library</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>custom-portal-handler</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
|
|
@ -1,9 +1,21 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
|
||||
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.BasicTabPanel;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.Ckan2ZenodoViewManager;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.LoaderIcon;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Alert;
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.Label;
|
||||
import com.github.gwtbootstrap.client.ui.Modal;
|
||||
import com.github.gwtbootstrap.client.ui.ModalFooter;
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
import com.github.gwtbootstrap.client.ui.constants.LabelType;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
/**
|
||||
|
@ -18,6 +30,7 @@ public class CkanToZendoPublisherWidget {
|
|||
private final CkanToZenodoPublisherServiceAsync ckanToZenodoService = CkanToZenodoPublisherServiceAsync.Util
|
||||
.getInstance();
|
||||
|
||||
private Button buttonPublish = new Button("Publish on Zenodo");
|
||||
/**
|
||||
* Instantiates a new ckan to zendo publisher widget.
|
||||
*/
|
||||
|
@ -32,19 +45,57 @@ public class CkanToZendoPublisherWidget {
|
|||
*/
|
||||
public void publishOnZenodo(final CatalogueItem item) {
|
||||
|
||||
final Modal modal = new Modal(true);
|
||||
modal.setTitle("Publishing on Zenodo...");
|
||||
modal.addStyleName("ckan2zenodo-modal-style");
|
||||
modal.setCloseVisible(true);
|
||||
buttonPublish.setEnabled(false);
|
||||
final LoaderIcon loader = new LoaderIcon("Loading data from service...");
|
||||
modal.add(loader);
|
||||
ckanToZenodoService.convertToZenodoItem(item, new AsyncCallback<ZenodoItem>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
loader.setVisible(false);
|
||||
modal.remove(loader);
|
||||
Alert erroLabel = new Alert();
|
||||
erroLabel.setClose(false);
|
||||
erroLabel.setType(AlertType.ERROR);
|
||||
erroLabel.setText(caught.getLocalizedMessage());
|
||||
modal.add(erroLabel);
|
||||
Button close = new Button("Close");
|
||||
close.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
modal.hide();
|
||||
}
|
||||
});
|
||||
modal.add(close);
|
||||
//Window.alert(caught.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ZenodoItem result) {
|
||||
|
||||
loader.setVisible(false);
|
||||
modal.remove(loader);
|
||||
Ckan2ZenodoViewManager manager = new Ckan2ZenodoViewManager();
|
||||
manager.viewForPublishing(result);
|
||||
BasicTabPanel basicTabPanel = manager.viewForPublishing(result);
|
||||
modal.add(basicTabPanel);
|
||||
buttonPublish.setEnabled(true);
|
||||
}
|
||||
});
|
||||
|
||||
buttonPublish.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
}
|
||||
});
|
||||
|
||||
ModalFooter modalFooter = new ModalFooter(buttonPublish);
|
||||
modal.add(modalFooter);
|
||||
modal.show();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.resource;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.resources.client.ClientBundle;
|
||||
import com.google.gwt.resources.client.ImageResource;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Interface Icons.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 7, 2018
|
||||
*/
|
||||
public interface Icons extends ClientBundle {
|
||||
|
||||
/** The Constant ICONS. */
|
||||
public static final Icons ICONS = GWT.create(Icons.class);
|
||||
|
||||
/**
|
||||
* Loading.
|
||||
*
|
||||
* @return the image resource
|
||||
*/
|
||||
@Source("loading.gif")
|
||||
ImageResource loading();
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
|
@ -6,10 +6,6 @@ import java.util.List;
|
|||
import com.github.gwtbootstrap.client.ui.Pager;
|
||||
import com.github.gwtbootstrap.client.ui.Tab;
|
||||
import com.github.gwtbootstrap.client.ui.TabPanel;
|
||||
import com.github.gwtbootstrap.client.ui.TabPanel.ShownEvent.Handler;
|
||||
import com.github.gwtbootstrap.client.ui.event.ShowEvent;
|
||||
import com.github.gwtbootstrap.client.ui.event.ShowHandler;
|
||||
import com.github.gwtbootstrap.client.ui.event.ShownEvent;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.core.client.Scheduler;
|
||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||
|
|
|
@ -4,11 +4,6 @@ import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.BasicTabPanel;
|
|||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.basicinformation.BasicInformationView;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.Modal;
|
||||
import com.github.gwtbootstrap.client.ui.ModalFooter;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
|
||||
/**
|
||||
|
@ -22,7 +17,7 @@ public class Ckan2ZenodoViewManager {
|
|||
|
||||
|
||||
private BasicTabPanel basicTabPanel;
|
||||
private Button buttonPublish = new Button("Publish on Zenodo");
|
||||
|
||||
|
||||
public final static HandlerManager eventBus = new HandlerManager(null);
|
||||
|
||||
|
@ -37,10 +32,9 @@ public class Ckan2ZenodoViewManager {
|
|||
* View for publishing.
|
||||
*
|
||||
* @param zenodoItem the zenodo item
|
||||
* @return
|
||||
*/
|
||||
public void viewForPublishing(final ZenodoItem zenodoItem){
|
||||
|
||||
Modal modal = new Modal(true);
|
||||
public BasicTabPanel viewForPublishing(final ZenodoItem zenodoItem){
|
||||
|
||||
basicTabPanel = new BasicTabPanel();
|
||||
|
||||
|
@ -74,28 +68,12 @@ public class Ckan2ZenodoViewManager {
|
|||
PublishFileViewManager vm = new PublishFileViewManager(zenodoItem.getFiles(), tabIndex);
|
||||
basicTabPanel.getAcc_files().add(vm.getView());
|
||||
|
||||
return basicTabPanel;
|
||||
|
||||
//return basePanel;
|
||||
|
||||
modal.setTitle("Publishing on Zenodo...");
|
||||
modal.addStyleName("ckan2zenodo-modal-style");
|
||||
modal.setCloseVisible(true);
|
||||
modal.add(basicTabPanel);
|
||||
|
||||
|
||||
//buttonPublish.setEnabled(false);
|
||||
|
||||
buttonPublish.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
}
|
||||
});
|
||||
|
||||
ModalFooter modalFooter = new ModalFooter(buttonPublish);
|
||||
modal.add(modalFooter);
|
||||
|
||||
modal.show();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view;
|
||||
|
||||
|
||||
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.resource.Icons;
|
||||
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
|
||||
/**
|
||||
* The Class LoaderIcon.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 19, 2015
|
||||
*/
|
||||
public class LoaderIcon extends HorizontalPanel{
|
||||
|
||||
|
||||
private Image imgLoading = new Image(Icons.ICONS.loading());
|
||||
private HTML txtLoading = new HTML("");
|
||||
|
||||
/**
|
||||
* Instantiates a new loader icon.
|
||||
*
|
||||
* @param txtHTML the txt html
|
||||
*/
|
||||
public LoaderIcon(String txtHTML) {
|
||||
this();
|
||||
setText(txtHTML);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new loader icon.
|
||||
*/
|
||||
public LoaderIcon() {
|
||||
setStyleName("marginTop20");
|
||||
add(imgLoading);
|
||||
add(txtLoading);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text.
|
||||
*
|
||||
* @param txtHTML the new text
|
||||
*/
|
||||
public void setText(String txtHTML){
|
||||
txtLoading.setHTML("<span style=\"margin-left:5px; vertical-align:middle;\">"+txtHTML+"</span>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Show.
|
||||
*
|
||||
* @param bool the bool
|
||||
*/
|
||||
public void show(boolean bool){
|
||||
this.setVisible(bool);
|
||||
}
|
||||
|
||||
}
|
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.data.publishing.ckan2zenodo.Ckan2Zenodo;
|
||||
import org.gcube.data.publishing.ckan2zenodo.model.CkanItemDescriptor;
|
||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.Creator;
|
||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata;
|
||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata.AccessRights;
|
||||
|
@ -21,6 +23,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
|
||||
/**
|
||||
* The server side implementation of the RPC service.
|
||||
|
@ -53,7 +56,26 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
|
||||
try {
|
||||
|
||||
//TO TEST
|
||||
if(isOutFromPortal()) {
|
||||
PortalUtils.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
PortalUtils.getCurrentToken(this.getThreadLocalRequest(), true);
|
||||
}
|
||||
|
||||
// Ckan2Zenodo client= Ckan2Zenodo.get();
|
||||
//
|
||||
// // Get the item representation
|
||||
// CkanItemDescriptor itemDescr=client.read(item.getItemName());
|
||||
//
|
||||
// //Get a preview of the deposition to be published
|
||||
// ZenodoDeposition zdPreview=client.translate(itemDescr);
|
||||
//
|
||||
// //Filter resources according to VRE policies
|
||||
// //List<CkanResource> toFilterFiles=client.filterResources(itemDescr);
|
||||
//
|
||||
// //zdPreview.setFiles(toFilterFiles);
|
||||
// return ItemToZenodoConverter.toZenodoItem(zdPreview);
|
||||
|
||||
// //TO TEST
|
||||
ZenodoDeposition zd = new ZenodoDeposition();
|
||||
zd.setTitle("My beautiful title");
|
||||
ArrayList<FileDeposition> files = new ArrayList<FileDeposition>();
|
||||
|
@ -70,14 +92,29 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
related_identifiers.add(new RelatedIdentifier("12345", Relation.cites));
|
||||
metadata.setRelated_identifiers(related_identifiers);
|
||||
zd.setMetadata(metadata);
|
||||
|
||||
return ItemToZenodoConverter.toZenodoItem(zd);
|
||||
|
||||
} catch (Exception e) {
|
||||
String error = "Error on converting the catalogue item: "+item.getItemName();
|
||||
LOG.error(error, e);
|
||||
String clientError = String.format("%s. %s", error, CkanToZendoPublisherWidgetConstant.MSG_OF_ERROR_REFRESH_AND_TRY_AGAIN_OR_CONTACT_THE_SUPPORT);
|
||||
String clientError = String.format("%s. %s", error, e.getMessage());
|
||||
throw new Exception(clientError);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Online or in development mode?
|
||||
* @return true if you're running into the portal, false if in development
|
||||
*/
|
||||
private boolean isOutFromPortal() {
|
||||
try {
|
||||
UserLocalServiceUtil.getService();
|
||||
return false;
|
||||
}
|
||||
catch (com.liferay.portal.kernel.bean.BeanLocatorException ex) {
|
||||
LOG.debug("Development Mode ON");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.server;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class PortalUtils {
|
||||
|
||||
private static Logger LOG = LoggerFactory.getLogger(PortalUtils.class);
|
||||
|
||||
/**
|
||||
* Retrieve the current scope by using the portal manager.
|
||||
*
|
||||
* @param request the request
|
||||
* @param setInThread the set in thread
|
||||
* @return a GcubeUser object
|
||||
*/
|
||||
public static String getCurrentContext(HttpServletRequest request, boolean setInThread) {
|
||||
|
||||
if (request == null)
|
||||
throw new IllegalArgumentException("HttpServletRequest is null!");
|
||||
|
||||
PortalContext pContext = PortalContext.getConfiguration();
|
||||
String context = pContext.getCurrentScope(request);
|
||||
LOG.debug("Returning context " + context);
|
||||
|
||||
if (context != null && setInThread)
|
||||
ScopeProvider.instance.set(context);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the current token by using the portal manager.
|
||||
*
|
||||
* @param request the request
|
||||
* @param setInThread the set in thread
|
||||
* @return a GcubeUser object
|
||||
*/
|
||||
public static String getCurrentToken(HttpServletRequest request, boolean setInThread) {
|
||||
|
||||
if (request == null)
|
||||
throw new IllegalArgumentException("HttpServletRequest is null!");
|
||||
|
||||
PortalContext pContext = PortalContext.getConfiguration();
|
||||
String token = pContext.getCurrentUserToken(getCurrentContext(request, false),
|
||||
getCurrentUser(request).getUsername());
|
||||
LOG.debug("Returning token " + token.substring(0, token.length() - 7) + "XXXXX");
|
||||
|
||||
if (token != null && setInThread)
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the current user by using the portal manager.
|
||||
*
|
||||
* @param request the request
|
||||
* @return a GcubeUser object
|
||||
*/
|
||||
public static GCubeUser getCurrentUser(HttpServletRequest request) {
|
||||
|
||||
if (request == null)
|
||||
throw new IllegalArgumentException("HttpServletRequest is null!");
|
||||
|
||||
PortalContext pContext = PortalContext.getConfiguration();
|
||||
GCubeUser user = pContext.getCurrentUser(request);
|
||||
LOG.debug("Returning user " + user);
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue