Task #12909: Provide public links for versioned files
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@176389 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
371882be82
commit
de65a96c72
|
@ -3,7 +3,10 @@
|
||||||
date="${buildDate}">
|
date="${buildDate}">
|
||||||
<Change>Updated regular expression to validate Folder and File names
|
<Change>Updated regular expression to validate Folder and File names
|
||||||
</Change>
|
</Change>
|
||||||
<Change>[Task #12911] Called getFullName for any user other than logged user
|
<Change>[Task #12911] Called getFullName for any user other than
|
||||||
|
logged user
|
||||||
|
</Change>
|
||||||
|
<Change>[Task #12909:] Provide public links for versioned files
|
||||||
</Change>
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-23-0"
|
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-23-0"
|
||||||
|
|
|
@ -439,13 +439,13 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
eventBus.addHandler(VersioningHistoryShowEvent.TYPE, new VersioningHistoryShowEventHandler() {
|
eventBus.addHandler(VersioningHistoryShowEvent.TYPE, new VersioningHistoryShowEventHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFileVersioning(VersioningHistoryShowEvent fileVersioningEvent) {
|
public void onFileVersioning(VersioningHistoryShowEvent versioningHistoryEvent) {
|
||||||
|
|
||||||
FileModel file = fileVersioningEvent.getTargetFileModel();
|
FileModel file = versioningHistoryEvent.getTargetFileModel();
|
||||||
if(file==null)
|
if(file==null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
notifySubscriber(fileVersioningEvent);
|
notifySubscriber(versioningHistoryEvent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -497,7 +497,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
if(getFolderLinkEvent.getSourceFile()!=null){
|
if(getFolderLinkEvent.getSourceFile()!=null){
|
||||||
GWT.log("getFolderLinkEvent.getSourceFile() "+getFolderLinkEvent.getSourceFile());
|
GWT.log("getFolderLinkEvent.getSourceFile() "+getFolderLinkEvent.getSourceFile());
|
||||||
DialogGetLink dialog = new DialogGetLink("Copy to clipboard Folder Link: Ctrl+C", getFolderLinkEvent.getSourceFile(), Link_Type.FOLDER_LINK, getFolderLinkEvent.isSetPublic());
|
DialogGetLink dialog = new DialogGetLink("Copy to clipboard Folder Link: Ctrl+C", getFolderLinkEvent.getSourceFile(), null, Link_Type.FOLDER_LINK, getFolderLinkEvent.isSetPublic());
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -882,7 +882,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
public void onGetPublicLink(GetPublicLinkEvent getPublicLinkEvent) {
|
public void onGetPublicLink(GetPublicLinkEvent getPublicLinkEvent) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
if(getPublicLinkEvent.getSourceFile()!=null){
|
if(getPublicLinkEvent.getSourceFile()!=null){
|
||||||
DialogGetLink dialog = new DialogGetLink("Copy to clipboard Public Link: Ctrl+C", getPublicLinkEvent.getSourceFile(), Link_Type.PUBLIC_LINK, false);
|
DialogGetLink dialog = new DialogGetLink("Copy to clipboard Public Link: Ctrl+C", getPublicLinkEvent.getSourceFile(), getPublicLinkEvent.getVersion(), Link_Type.PUBLIC_LINK, false);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,32 +4,64 @@ import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
|
|
||||||
import com.google.gwt.event.shared.GwtEvent;
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The Class GetPublicLinkEvent.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
*
|
* Jan 8, 2019
|
||||||
*/
|
*/
|
||||||
public class GetPublicLinkEvent extends GwtEvent<GetPublicLinkEventHandler> {
|
public class GetPublicLinkEvent extends GwtEvent<GetPublicLinkEventHandler> {
|
||||||
public static Type<GetPublicLinkEventHandler> TYPE = new Type<GetPublicLinkEventHandler>();
|
public static Type<GetPublicLinkEventHandler> TYPE = new Type<GetPublicLinkEventHandler>();
|
||||||
|
|
||||||
private FileModel targetFile = null;
|
private FileModel targetFile = null;
|
||||||
|
private String version;
|
||||||
|
|
||||||
public GetPublicLinkEvent(FileModel target) {
|
/**
|
||||||
|
* Instantiates a new gets the public link event.
|
||||||
|
*
|
||||||
|
* @param target the target
|
||||||
|
* @param version the version
|
||||||
|
*/
|
||||||
|
public GetPublicLinkEvent(FileModel target, String version) {
|
||||||
this.targetFile = target;
|
this.targetFile = target;
|
||||||
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Type<GetPublicLinkEventHandler> getAssociatedType() {
|
public Type<GetPublicLinkEventHandler> getAssociatedType() {
|
||||||
return TYPE;
|
return TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void dispatch(GetPublicLinkEventHandler handler) {
|
protected void dispatch(GetPublicLinkEventHandler handler) {
|
||||||
handler.onGetPublicLink(this);
|
handler.onGetPublicLink(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the source file.
|
||||||
|
*
|
||||||
|
* @return the source file
|
||||||
|
*/
|
||||||
public FileModel getSourceFile() {
|
public FileModel getSourceFile() {
|
||||||
return targetFile;
|
return targetFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the version.
|
||||||
|
*
|
||||||
|
* @return the version
|
||||||
|
*/
|
||||||
|
public String getVersion() {
|
||||||
|
|
||||||
|
return version;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -80,7 +80,6 @@ public interface GWTWorkspaceService extends RemoteService{
|
||||||
/**
|
/**
|
||||||
* Gets the root for tree.
|
* Gets the root for tree.
|
||||||
*
|
*
|
||||||
* @param scopeId the scope id
|
|
||||||
* @return the root for tree
|
* @return the root for tree
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
|
@ -780,6 +779,7 @@ public interface GWTWorkspaceService extends RemoteService{
|
||||||
List<GcubeVRE> getListOfVREsForLoggedUser()
|
List<GcubeVRE> getListOfVREsForLoggedUser()
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is item under sync.
|
* Checks if is item under sync.
|
||||||
*
|
*
|
||||||
|
@ -791,5 +791,18 @@ public interface GWTWorkspaceService extends RemoteService{
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the public link for file item id to version.
|
||||||
|
*
|
||||||
|
* @param itemId the item id
|
||||||
|
* @param version the version
|
||||||
|
* @param shortenUrl the shorten url
|
||||||
|
* @return the public link for file item id to version
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
PublicLink getPublicLinkForFileItemIdToVersion(
|
||||||
|
String itemId, String version, boolean shortenUrl) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
/**
|
/**
|
||||||
* Gets the root for tree.
|
* Gets the root for tree.
|
||||||
*
|
*
|
||||||
* @param scopeId the scope id
|
* @param folder the folder
|
||||||
* @param callback the callback
|
* @param callback the callback
|
||||||
* @return the root for tree
|
* @return the root for tree
|
||||||
*/
|
*/
|
||||||
|
@ -473,6 +473,21 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
void getPublicLinkForFileItemId(String itemId, boolean shortenUrl,
|
void getPublicLinkForFileItemId(String itemId, boolean shortenUrl,
|
||||||
AsyncCallback<PublicLink> callback);
|
AsyncCallback<PublicLink> callback);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the public link for file item id to version.
|
||||||
|
*
|
||||||
|
* @param itemId the item id
|
||||||
|
* @param version the version
|
||||||
|
* @param shortenUrl the shorten url
|
||||||
|
* @param callback the callback
|
||||||
|
* @return the public link for file item id to version
|
||||||
|
*/
|
||||||
|
void getPublicLinkForFileItemIdToVersion(String itemId, String version, boolean shortenUrl,
|
||||||
|
AsyncCallback<PublicLink> callback);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is session expired.
|
* Checks if is session expired.
|
||||||
*
|
*
|
||||||
|
@ -489,10 +504,24 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
void deleteListItemsForIds(List<String> ids,
|
void deleteListItemsForIds(List<String> ids,
|
||||||
AsyncCallback<List<GarbageItem>> callback);
|
AsyncCallback<List<GarbageItem>> callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy items.
|
||||||
|
*
|
||||||
|
* @param idsItem the ids item
|
||||||
|
* @param destinationFolderId the destination folder id
|
||||||
|
* @param callback the callback
|
||||||
|
*/
|
||||||
void copyItems(
|
void copyItems(
|
||||||
List<String> idsItem, String destinationFolderId,
|
List<String> idsItem, String destinationFolderId,
|
||||||
AsyncCallback<WorkspaceOperationResult> callback);
|
AsyncCallback<WorkspaceOperationResult> callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move items.
|
||||||
|
*
|
||||||
|
* @param ids the ids
|
||||||
|
* @param destinationId the destination id
|
||||||
|
* @param callback the callback
|
||||||
|
*/
|
||||||
void moveItems(
|
void moveItems(
|
||||||
List<String> ids, String destinationId,
|
List<String> ids, String destinationId,
|
||||||
AsyncCallback<WorkspaceOperationResult> callback);
|
AsyncCallback<WorkspaceOperationResult> callback);
|
||||||
|
@ -768,6 +797,13 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
*/
|
*/
|
||||||
void isItemUnderSync(String itemId, AsyncCallback<Boolean> callback);
|
void isItemUnderSync(String itemId, AsyncCallback<Boolean> callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the link for send to switch board.
|
||||||
|
*
|
||||||
|
* @param itemId the item id
|
||||||
|
* @param callback the callback
|
||||||
|
* @return the link for send to switch board
|
||||||
|
*/
|
||||||
void getLinkForSendToSwitchBoard(String itemId, AsyncCallback<String> callback);
|
void getLinkForSendToSwitchBoard(String itemId, AsyncCallback<String> callback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ public class ContextMenuTree {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
for (FileModel sel : listSelectedItems) {
|
for (FileModel sel : listSelectedItems) {
|
||||||
eventBus.fireEvent(new GetPublicLinkEvent(sel));
|
eventBus.fireEvent(new GetPublicLinkEvent(sel, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -48,15 +48,17 @@ public class DialogGetLink extends Dialog {
|
||||||
*/
|
*/
|
||||||
public enum Link_Type {PUBLIC_LINK, FOLDER_LINK};
|
public enum Link_Type {PUBLIC_LINK, FOLDER_LINK};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new dialog get link.
|
* Instantiates a new dialog get link.
|
||||||
*
|
*
|
||||||
* @param headingTxt the heading txt
|
* @param headingTxt the heading txt
|
||||||
* @param item the item
|
* @param item the item
|
||||||
|
* @param version the version
|
||||||
* @param type the type
|
* @param type the type
|
||||||
* @param setAsPublic the set as public
|
* @param setAsPublic the set as public
|
||||||
*/
|
*/
|
||||||
public DialogGetLink(String headingTxt, final FileModel item, Link_Type type, boolean setAsPublic) {
|
public DialogGetLink(String headingTxt, final FileModel item, String version, Link_Type type, boolean setAsPublic) {
|
||||||
this.item = item;
|
this.item = item;
|
||||||
this.setAsPublic = setAsPublic;
|
this.setAsPublic = setAsPublic;
|
||||||
setButtonAlign(HorizontalAlignment.CENTER);
|
setButtonAlign(HorizontalAlignment.CENTER);
|
||||||
|
@ -101,27 +103,54 @@ public class DialogGetLink extends Dialog {
|
||||||
setIcon(Resources.getIconPublicLink());
|
setIcon(Resources.getIconPublicLink());
|
||||||
|
|
||||||
if(item.getIdentifier()!=null && !item.getIdentifier().isEmpty()){
|
if(item.getIdentifier()!=null && !item.getIdentifier().isEmpty()){
|
||||||
AppControllerExplorer.rpcWorkspaceService.getPublicLinkForFileItemId(item.getIdentifier(), true, new AsyncCallback<PublicLink>() {
|
|
||||||
|
|
||||||
@Override
|
if(version==null || version.isEmpty()){
|
||||||
public void onSuccess(PublicLink publicLink) {
|
|
||||||
vp.unmask();
|
|
||||||
txtCompleteURL.setValue(publicLink.getCompleteURL());
|
|
||||||
txtShortURL.setValue(publicLink.getShortURL());
|
|
||||||
selectTxt();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
AppControllerExplorer.rpcWorkspaceService.getPublicLinkForFileItemId(item.getIdentifier(), true, new AsyncCallback<PublicLink>() {
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
vp.unmask();
|
@Override
|
||||||
if(caught instanceof SessionExpiredException){
|
public void onSuccess(PublicLink publicLink) {
|
||||||
GWT.log("Session expired");
|
vp.unmask();
|
||||||
AppControllerExplorer.getEventBus().fireEvent(new SessionExpiredEvent());
|
txtCompleteURL.setValue(publicLink.getCompleteURL());
|
||||||
return;
|
txtShortURL.setValue(publicLink.getShortURL());
|
||||||
|
selectTxt();
|
||||||
}
|
}
|
||||||
new MessageBoxAlert("Error", caught.getMessage(), null);
|
|
||||||
}
|
@Override
|
||||||
});
|
public void onFailure(Throwable caught) {
|
||||||
|
vp.unmask();
|
||||||
|
if(caught instanceof SessionExpiredException){
|
||||||
|
GWT.log("Session expired");
|
||||||
|
AppControllerExplorer.getEventBus().fireEvent(new SessionExpiredEvent());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
new MessageBoxAlert("Error", caught.getMessage(), null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
|
||||||
|
AppControllerExplorer.rpcWorkspaceService.getPublicLinkForFileItemIdToVersion(item.getIdentifier(), version, true, new AsyncCallback<PublicLink>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(PublicLink publicLink) {
|
||||||
|
vp.unmask();
|
||||||
|
txtCompleteURL.setValue(publicLink.getCompleteURL());
|
||||||
|
txtShortURL.setValue(publicLink.getShortURL());
|
||||||
|
selectTxt();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
vp.unmask();
|
||||||
|
if(caught instanceof SessionExpiredException){
|
||||||
|
GWT.log("Session expired");
|
||||||
|
AppControllerExplorer.getEventBus().fireEvent(new SessionExpiredEvent());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
new MessageBoxAlert("Error", caught.getMessage(), null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
txtCompleteURL.unmask();
|
txtCompleteURL.unmask();
|
||||||
|
|
|
@ -4532,6 +4532,54 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getPublicLinkForFileItemIdToVersion(java.lang.String, java.lang.String, boolean)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PublicLink getPublicLinkForFileItemIdToVersion(
|
||||||
|
String itemId, String version, boolean shortenUrl) throws Exception {
|
||||||
|
|
||||||
|
workspaceLogger.trace("get Public Link For ItemId: "+ itemId + " at the version: "+version);
|
||||||
|
try{
|
||||||
|
|
||||||
|
if(itemId==null)
|
||||||
|
throw new Exception("Sorry, The Public Link for empty item is unavailable (itemId is null)");
|
||||||
|
|
||||||
|
org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub();
|
||||||
|
org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(itemId);
|
||||||
|
|
||||||
|
if(wsItem==null)
|
||||||
|
throw new Exception("Sorry, The Public Link for empty item is unavailable");
|
||||||
|
|
||||||
|
if(wsItem.getType().equals(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItemType.FILE_ITEM)){
|
||||||
|
|
||||||
|
URL publicLink = workspace.getPublicLinkForFile(itemId, version);
|
||||||
|
|
||||||
|
if(publicLink==null || publicLink.toString()==null)
|
||||||
|
throw new Exception("Sorry, public link on "+wsItem.getName() +" is not available");
|
||||||
|
|
||||||
|
String shortURL = null;
|
||||||
|
String httpURL = publicLink.toString();
|
||||||
|
|
||||||
|
if(shortenUrl){
|
||||||
|
shortURL = getShortUrl(httpURL);
|
||||||
|
shortURL = shortURL!=null?shortURL:"not available";
|
||||||
|
}
|
||||||
|
|
||||||
|
return new PublicLink(httpURL, shortURL);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
workspaceLogger.warn("ItemId: "+ itemId +" is not a file, sent exception Public Link unavailable");
|
||||||
|
throw new Exception("Sorry, The Public Link for selected item is unavailable");
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (Exception e) {
|
||||||
|
workspaceLogger.error("Error getPublicLinkForFileItemIdToVersion for item: "+itemId+" at the version: "+version, e);
|
||||||
|
throw new Exception(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ public enum WorkspaceVersioningOperation {
|
||||||
REFRESH("Refresh", "Refresh history of versioning"),
|
REFRESH("Refresh", "Refresh history of versioning"),
|
||||||
//RESTORE("Restore", "Restore the file to the selected version"),
|
//RESTORE("Restore", "Restore the file to the selected version"),
|
||||||
DOWNLOAD("Download", "Download the version of the selected file"),
|
DOWNLOAD("Download", "Download the version of the selected file"),
|
||||||
|
PUBLIC_LINK("Public Link", "Get the public link of the file at the selected version"),
|
||||||
DELETE_PERMANENTLY("Delete Permanently", "Delete Permanently the version for the selected file"),
|
DELETE_PERMANENTLY("Delete Permanently", "Delete Permanently the version for the selected file"),
|
||||||
DELETE_ALL_OLDER_VERSIONS("Delete all versions permanently", "Delete definitively all versions of the file");
|
DELETE_ALL_OLDER_VERSIONS("Delete all versions permanently", "Delete definitively all versions of the file");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue