331: WS: Get Public Link enhancements
Task-Url: https://support.d4science.org/issues/331 Updated Dialog Get Public Link to show complete and short URL git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@115822 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3b09a96e09
commit
055305905f
|
@ -18,6 +18,7 @@ import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.SubTree;
|
import org.gcube.portlets.user.workspace.client.model.SubTree;
|
||||||
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
||||||
import org.gcube.portlets.user.workspace.shared.ExtendedWorkspaceACL;
|
import org.gcube.portlets.user.workspace.shared.ExtendedWorkspaceACL;
|
||||||
|
import org.gcube.portlets.user.workspace.shared.PublicLink;
|
||||||
import org.gcube.portlets.user.workspace.shared.ReportAssignmentACL;
|
import org.gcube.portlets.user.workspace.shared.ReportAssignmentACL;
|
||||||
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
||||||
import org.gcube.portlets.user.workspace.shared.TrashContent;
|
import org.gcube.portlets.user.workspace.shared.TrashContent;
|
||||||
|
@ -178,7 +179,7 @@ public interface GWTWorkspaceService extends RemoteService{
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
String getPublicLinkForFolderItemId(String itemId, boolean shortenUrl)
|
PublicLink getPublicLinkForFolderItemId(String itemId, boolean shortenUrl)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
boolean isSessionExpired() throws Exception;
|
boolean isSessionExpired() throws Exception;
|
||||||
|
|
|
@ -18,6 +18,7 @@ import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.SubTree;
|
import org.gcube.portlets.user.workspace.client.model.SubTree;
|
||||||
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
||||||
import org.gcube.portlets.user.workspace.shared.ExtendedWorkspaceACL;
|
import org.gcube.portlets.user.workspace.shared.ExtendedWorkspaceACL;
|
||||||
|
import org.gcube.portlets.user.workspace.shared.PublicLink;
|
||||||
import org.gcube.portlets.user.workspace.shared.ReportAssignmentACL;
|
import org.gcube.portlets.user.workspace.shared.ReportAssignmentACL;
|
||||||
import org.gcube.portlets.user.workspace.shared.TrashContent;
|
import org.gcube.portlets.user.workspace.shared.TrashContent;
|
||||||
import org.gcube.portlets.user.workspace.shared.TrashOperationContent;
|
import org.gcube.portlets.user.workspace.shared.TrashOperationContent;
|
||||||
|
@ -167,7 +168,7 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
void getShortUrl(String longUrl, AsyncCallback<String> callback);
|
void getShortUrl(String longUrl, AsyncCallback<String> callback);
|
||||||
|
|
||||||
void getPublicLinkForFolderItemId(String itemId, boolean shortenUrl,
|
void getPublicLinkForFolderItemId(String itemId, boolean shortenUrl,
|
||||||
AsyncCallback<String> callback);
|
AsyncCallback<PublicLink> callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -2,14 +2,15 @@ package org.gcube.portlets.user.workspace.client.view.windows;
|
||||||
|
|
||||||
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
||||||
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
||||||
|
import org.gcube.portlets.user.workspace.shared.PublicLink;
|
||||||
|
|
||||||
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||||
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
|
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
|
||||||
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
||||||
import com.extjs.gxt.ui.client.event.SelectionListener;
|
import com.extjs.gxt.ui.client.event.SelectionListener;
|
||||||
import com.extjs.gxt.ui.client.widget.Dialog;
|
import com.extjs.gxt.ui.client.widget.Dialog;
|
||||||
|
import com.extjs.gxt.ui.client.widget.Label;
|
||||||
import com.extjs.gxt.ui.client.widget.VerticalPanel;
|
import com.extjs.gxt.ui.client.widget.VerticalPanel;
|
||||||
import com.extjs.gxt.ui.client.widget.form.TextArea;
|
|
||||||
import com.extjs.gxt.ui.client.widget.form.TextField;
|
import com.extjs.gxt.ui.client.widget.form.TextField;
|
||||||
import com.google.gwt.dom.client.Style.Unit;
|
import com.google.gwt.dom.client.Style.Unit;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
@ -20,9 +21,10 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
*/
|
*/
|
||||||
public class DialogPublicLink extends Dialog {
|
public class DialogPublicLink extends Dialog {
|
||||||
|
|
||||||
private TextField<String> txt;
|
private TextField<String> txtCompleteURL;
|
||||||
|
private TextField<String> txtShortURL;
|
||||||
private int widht = 450;
|
private int widht = 450;
|
||||||
private int height = 150;
|
private int height = 170;
|
||||||
private VerticalPanel vp = new VerticalPanel();
|
private VerticalPanel vp = new VerticalPanel();
|
||||||
// private Label label = new Label();
|
// private Label label = new Label();
|
||||||
|
|
||||||
|
@ -42,38 +44,47 @@ public class DialogPublicLink extends Dialog {
|
||||||
|
|
||||||
// label.setText(msgTitle);
|
// label.setText(msgTitle);
|
||||||
// label.setStyleName("myWebDavStyle");
|
// label.setStyleName("myWebDavStyle");
|
||||||
|
VerticalPanel vp1 = new VerticalPanel();
|
||||||
|
vp1.setStyleAttribute("margin-top", "8px");
|
||||||
|
txtCompleteURL = new TextField<String>();
|
||||||
|
txtCompleteURL.setStyleAttribute("margin-top", "1px");
|
||||||
|
txtCompleteURL.setWidth(widht-20);
|
||||||
|
txtCompleteURL.setReadOnly(true);
|
||||||
|
txtCompleteURL.mask("Getting Link...");
|
||||||
|
vp1.add(new Label("Link"));
|
||||||
|
vp1.add(txtCompleteURL);
|
||||||
|
|
||||||
txt = new TextArea();
|
VerticalPanel vp2 = new VerticalPanel();
|
||||||
// txt.setStyleAttribute("padding-top", "3px");
|
vp2.setStyleAttribute("margin-top", "8px");
|
||||||
txt.setWidth(widht-20);
|
txtShortURL = new TextField<String>();
|
||||||
txt.setHeight(height-74);
|
txtShortURL.setStyleAttribute("margin-top", "1px");
|
||||||
// txt.setFieldLabel(msgTitle);
|
txtShortURL.setWidth(widht-20);
|
||||||
|
txtShortURL.mask("Getting Link...");
|
||||||
txt.setReadOnly(true);
|
vp2.add(new Label("Short Link"));
|
||||||
|
vp2.add(txtShortURL);
|
||||||
|
|
||||||
txt.mask("Shortening link...");
|
|
||||||
|
|
||||||
if(itemId!=null && !itemId.isEmpty()){
|
if(itemId!=null && !itemId.isEmpty()){
|
||||||
AppControllerExplorer.rpcWorkspaceService.getPublicLinkForFolderItemId(itemId, true, new AsyncCallback<String>() {
|
AppControllerExplorer.rpcWorkspaceService.getPublicLinkForFolderItemId(itemId, true, new AsyncCallback<PublicLink>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String url) {
|
public void onSuccess(PublicLink publicLink) {
|
||||||
txt.unmask();
|
txtCompleteURL.unmask();
|
||||||
txt.setValue(url);
|
txtShortURL.unmask();
|
||||||
|
txtCompleteURL.setValue(publicLink.getCompleteURL());
|
||||||
|
txtShortURL.setValue(publicLink.getShortURL());
|
||||||
selectTxt();
|
selectTxt();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
txt.unmask();
|
txtCompleteURL.unmask();
|
||||||
|
txtShortURL.unmask();
|
||||||
new MessageBoxAlert("Error", caught.getMessage(), null);
|
new MessageBoxAlert("Error", caught.getMessage(), null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
txt.unmask();
|
txtCompleteURL.unmask();
|
||||||
new MessageBoxAlert("Error", "The item identifier is null", null);
|
new MessageBoxAlert("Error", "The item identifier is null", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,20 +99,22 @@ public class DialogPublicLink extends Dialog {
|
||||||
|
|
||||||
|
|
||||||
// vp.add(label);
|
// vp.add(label);
|
||||||
vp.add(txt);
|
vp.add(vp1);
|
||||||
|
vp.add(vp2);
|
||||||
|
|
||||||
|
setFocusWidget(txtCompleteURL);
|
||||||
|
|
||||||
setFocusWidget(txt);
|
|
||||||
add(vp);
|
add(vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTxtValue() {
|
public String getTxtValue() {
|
||||||
|
|
||||||
return txt.getValue();
|
return txtCompleteURL.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectTxt(){
|
public void selectTxt(){
|
||||||
|
|
||||||
if(txt.getValue()!=null)
|
if(txtCompleteURL.getValue()!=null)
|
||||||
txt.select(0, txt.getValue().length());
|
txtCompleteURL.select(0, txtCompleteURL.getValue().length());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -71,6 +71,7 @@ import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||||
import org.gcube.portlets.user.workspace.server.util.resource.PropertySpecialFolderReader;
|
import org.gcube.portlets.user.workspace.server.util.resource.PropertySpecialFolderReader;
|
||||||
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
|
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
|
||||||
import org.gcube.portlets.user.workspace.shared.ExtendedWorkspaceACL;
|
import org.gcube.portlets.user.workspace.shared.ExtendedWorkspaceACL;
|
||||||
|
import org.gcube.portlets.user.workspace.shared.PublicLink;
|
||||||
import org.gcube.portlets.user.workspace.shared.ReportAssignmentACL;
|
import org.gcube.portlets.user.workspace.shared.ReportAssignmentACL;
|
||||||
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
||||||
import org.gcube.portlets.user.workspace.shared.TrashContent;
|
import org.gcube.portlets.user.workspace.shared.TrashContent;
|
||||||
|
@ -2576,7 +2577,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getPublicLinkForFolderItemId(String itemId, boolean shortenUrl) throws Exception{
|
public PublicLink getPublicLinkForFolderItemId(String itemId, boolean shortenUrl) throws Exception{
|
||||||
|
|
||||||
workspaceLogger.trace("get Public Link For ItemId: "+ itemId);
|
workspaceLogger.trace("get Public Link For ItemId: "+ itemId);
|
||||||
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
||||||
|
@ -2607,10 +2608,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
if(!HttpRequestUtil.urlExists(uriRequest+"&validation=true"))
|
if(!HttpRequestUtil.urlExists(uriRequest+"&validation=true"))
|
||||||
throw new Exception("Sorry, The Public Link for selected file is unavailable");
|
throw new Exception("Sorry, The Public Link for selected file is unavailable");
|
||||||
|
|
||||||
if(shortenUrl)
|
String shortURL = null;
|
||||||
uriRequest = getShortUrl(uriRequest);
|
|
||||||
|
|
||||||
return uriRequest;
|
if(shortenUrl)
|
||||||
|
shortURL = getShortUrl(uriRequest);
|
||||||
|
|
||||||
|
return new PublicLink(uriRequest, shortURL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw new Exception("Sorry, The Uri resolver service is temporarily unavailable. Please try again later");
|
throw new Exception("Sorry, The Uri resolver service is temporarily unavailable. Please try again later");
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.workspace.shared;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jul 3, 2015
|
||||||
|
*/
|
||||||
|
public class PublicLink implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -8157172818802297440L;
|
||||||
|
|
||||||
|
private String completeURL;
|
||||||
|
private String shortURL;
|
||||||
|
|
||||||
|
public PublicLink() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param completeURL
|
||||||
|
* @param shortURL
|
||||||
|
*/
|
||||||
|
public PublicLink(String completeURL, String shortURL) {
|
||||||
|
super();
|
||||||
|
this.completeURL = completeURL;
|
||||||
|
this.shortURL = shortURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the completeURL
|
||||||
|
*/
|
||||||
|
public String getCompleteURL() {
|
||||||
|
return completeURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the shortURL
|
||||||
|
*/
|
||||||
|
public String getShortURL() {
|
||||||
|
return shortURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param completeURL
|
||||||
|
* the completeURL to set
|
||||||
|
*/
|
||||||
|
public void setCompleteURL(String completeURL) {
|
||||||
|
this.completeURL = completeURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param shortURL
|
||||||
|
* the shortURL to set
|
||||||
|
*/
|
||||||
|
public void setShortURL(String shortURL) {
|
||||||
|
this.shortURL = shortURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("PublicLink [completeURL=");
|
||||||
|
builder.append(completeURL);
|
||||||
|
builder.append(", shortURL=");
|
||||||
|
builder.append(shortURL);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue