1925: Uri-Resolver: resolve gCubeStorage smp uri like http uri
Task-Url: https://support.d4science.org/issues/1925 Updated get public link method according to #1959 git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@122319 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7166913ade
commit
981a04d901
|
@ -61,8 +61,6 @@ import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParame
|
||||||
import org.gcube.portlets.user.workspace.server.shortener.UrlShortener;
|
import org.gcube.portlets.user.workspace.server.shortener.UrlShortener;
|
||||||
import org.gcube.portlets.user.workspace.server.util.AclTypeComparator;
|
import org.gcube.portlets.user.workspace.server.util.AclTypeComparator;
|
||||||
import org.gcube.portlets.user.workspace.server.util.DifferenceBetweenInfoContactModel;
|
import org.gcube.portlets.user.workspace.server.util.DifferenceBetweenInfoContactModel;
|
||||||
import org.gcube.portlets.user.workspace.server.util.HttpRequestUtil;
|
|
||||||
import org.gcube.portlets.user.workspace.server.util.StringUtil;
|
|
||||||
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
||||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
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;
|
||||||
|
@ -401,7 +399,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
List<FileGridModel> listFileGridModels = new ArrayList<FileGridModel>();
|
List<FileGridModel> listFileGridModels = new ArrayList<FileGridModel>();
|
||||||
WorkspaceFolder wsFolder = (WorkspaceFolder) workspace.getItem(folder.getIdentifier());
|
WorkspaceFolder wsFolder = (WorkspaceFolder) workspace.getItem(folder.getIdentifier());
|
||||||
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
||||||
List<WorkspaceItem> listItems = (List<WorkspaceItem>) wsFolder.getChildren();
|
List<WorkspaceItem> listItems = wsFolder.getChildren();
|
||||||
listFileGridModels = builder.buildGXTListFileGridModelItem(listItems, folder);
|
listFileGridModels = builder.buildGXTListFileGridModelItem(listItems, folder);
|
||||||
|
|
||||||
//ADDING SPECIAL FOLDER?
|
//ADDING SPECIAL FOLDER?
|
||||||
|
@ -491,7 +489,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
Long startTime = System.currentTimeMillis();
|
Long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
//GET CHILDREN
|
//GET CHILDREN
|
||||||
List<WorkspaceItem> listItems = (List<WorkspaceItem>) parent.getChildren();
|
List<WorkspaceItem> listItems = parent.getChildren();
|
||||||
Long endTime = System.currentTimeMillis() - startTime;
|
Long endTime = System.currentTimeMillis() - startTime;
|
||||||
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
||||||
workspaceLogger.debug("grid getChildren() returning "+listItems.size()+" elements in " + time);
|
workspaceLogger.debug("grid getChildren() returning "+listItems.size()+" elements in " + time);
|
||||||
|
@ -718,7 +716,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
workspaceLogger.trace("checkNotifyAddItemToShare destination item: "+destinationItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName());
|
workspaceLogger.trace("checkNotifyAddItemToShare destination item: "+destinationItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName());
|
||||||
|
|
||||||
//share condition is true if source shared folder is null or not equal to destination shared folder
|
//share condition is true if source shared folder is null or not equal to destination shared folder
|
||||||
boolean shareChangeCondition = (sourceSharedId==null) || (sourceSharedId.compareTo(folderDestinationItem.getIdSharedFolder())!=0);
|
boolean shareChangeCondition = sourceSharedId==null || sourceSharedId.compareTo(folderDestinationItem.getIdSharedFolder())!=0;
|
||||||
|
|
||||||
//System.out.println("shareChangeCondition add item: "+ shareChangeCondition);
|
//System.out.println("shareChangeCondition add item: "+ shareChangeCondition);
|
||||||
|
|
||||||
|
@ -774,7 +772,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
String idSharedFolder = folderDestinationItem.getIdSharedFolder()!=null?folderDestinationItem.getIdSharedFolder():"";
|
String idSharedFolder = folderDestinationItem.getIdSharedFolder()!=null?folderDestinationItem.getIdSharedFolder():"";
|
||||||
|
|
||||||
//share condition is true if source shared folder is not equal to destination shared folder
|
//share condition is true if source shared folder is not equal to destination shared folder
|
||||||
boolean shareChangeCondition = sourceSharedId==null?false:(sourceSharedId.compareTo(idSharedFolder)!=0);
|
boolean shareChangeCondition = sourceSharedId==null?false:sourceSharedId.compareTo(idSharedFolder)!=0;
|
||||||
|
|
||||||
workspaceLogger.trace("checkNotifyMoveItemFromShare source item: "+sourceItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName() +" sourceItemIsShared: "+sourceItemIsShared);
|
workspaceLogger.trace("checkNotifyMoveItemFromShare source item: "+sourceItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName() +" sourceItemIsShared: "+sourceItemIsShared);
|
||||||
|
|
||||||
|
@ -2063,7 +2061,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
listManagers.add(owner);
|
listManagers.add(owner);
|
||||||
WorkspaceItem wsItem = workspace.getItem(folderId);
|
WorkspaceItem wsItem = workspace.getItem(folderId);
|
||||||
|
|
||||||
if(wsItem.isShared() && (wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER))){
|
if(wsItem.isShared() && wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
||||||
WorkspaceSharedFolder ite = (WorkspaceSharedFolder) workspace.getItemByPath(wsItem.getPath());
|
WorkspaceSharedFolder ite = (WorkspaceSharedFolder) workspace.getItemByPath(wsItem.getPath());
|
||||||
|
|
||||||
workspaceLogger.info("Retrieving administrators...");
|
workspaceLogger.info("Retrieving administrators...");
|
||||||
|
@ -2328,16 +2326,20 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
public PublicLink 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();
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
|
||||||
|
if(itemId==null)
|
||||||
|
throw new Exception("Sorry, The Public Link for empty item is unavailable (itemId is null)");
|
||||||
|
|
||||||
Workspace workspace = getWorkspace();
|
Workspace workspace = getWorkspace();
|
||||||
WorkspaceItem wsItem = workspace.getItem(itemId);
|
WorkspaceItem wsItem = workspace.getItem(itemId);
|
||||||
|
|
||||||
|
if(wsItem==null)
|
||||||
|
throw new Exception("Sorry, The Public Link for empty item is unavailable");
|
||||||
|
|
||||||
if(wsItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
if(wsItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
|
||||||
|
|
||||||
FolderItem folderItem = (FolderItem) wsItem;
|
/*FolderItem folderItem = (FolderItem) wsItem;
|
||||||
String storageID = builder.getStorageIDForFolderItem(folderItem);
|
String storageID = builder.getStorageIDForFolderItem(folderItem);
|
||||||
|
|
||||||
if(storageID==null || storageID.isEmpty())
|
if(storageID==null || storageID.isEmpty())
|
||||||
|
@ -2348,26 +2350,39 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
|
|
||||||
if(uriResolver!=null && uriResolver.isAvailable()){
|
if(uriResolver!=null && uriResolver.isAvailable()){
|
||||||
|
|
||||||
/*String itemName = StringUtil.removeSpecialCharacters(folderItem.getName());
|
// String itemName = StringUtil.removeSpecialCharacters(folderItem.getName());
|
||||||
itemName = StringUtil.replaceAllWhiteSpace(itemName, "_");
|
// itemName = StringUtil.replaceAllWhiteSpace(itemName, "_");
|
||||||
uriRequest = uriResolver.resolveAsUriRequest(storageID, itemName, folderItem.getMimeType(), true);*/
|
// uriRequest = uriResolver.resolveAsUriRequest(storageID, itemName, folderItem.getMimeType(), true);
|
||||||
|
|
||||||
uriRequest = uriResolver.resolveAsStorageIdRequest(storageID, true);
|
uriRequest = uriResolver.resolveAsStorageIdRequest(storageID, true);
|
||||||
|
|
||||||
/*
|
|
||||||
//VALIDATE CONNECTION
|
//VALIDATE CONNECTION
|
||||||
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");
|
||||||
*/
|
|
||||||
String shortURL = null;
|
String shortURL = null;
|
||||||
|
|
||||||
if(shortenUrl)
|
if(shortenUrl)
|
||||||
shortURL = getShortUrl(uriRequest);
|
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");*/
|
||||||
|
|
||||||
|
FolderItem folderItem = (FolderItem) wsItem;
|
||||||
|
String uriRequest = folderItem.getPublicLink(false);
|
||||||
|
|
||||||
|
if(uriRequest==null || uriRequest.isEmpty())
|
||||||
|
throw new Exception("Sorry, public link on "+folderItem.getName() +" is not available");
|
||||||
|
|
||||||
|
String shortURL = null;
|
||||||
|
|
||||||
|
if(shortenUrl)
|
||||||
|
shortURL = getShortUrl(uriRequest);
|
||||||
|
|
||||||
|
return new PublicLink(uriRequest, shortURL);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
workspaceLogger.warn("ItemId: "+ itemId +" is not a folder item, sent exception Public Link unavailable");
|
workspaceLogger.warn("ItemId: "+ itemId +" is not a folder item, sent exception Public Link unavailable");
|
||||||
|
@ -2709,7 +2724,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
Workspace workspace = getWorkspace();
|
Workspace workspace = getWorkspace();
|
||||||
WorkspaceItem wsItem = workspace.getItem(folderId);
|
WorkspaceItem wsItem = workspace.getItem(folderId);
|
||||||
|
|
||||||
if(wsItem.isShared() && (wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER))){
|
if(wsItem.isShared() && wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
||||||
WorkspaceSharedFolder ite = (WorkspaceSharedFolder) workspace.getItemByPath(wsItem.getPath());
|
WorkspaceSharedFolder ite = (WorkspaceSharedFolder) workspace.getItemByPath(wsItem.getPath());
|
||||||
//PATCH TODO TEMPORARY SOLUTION
|
//PATCH TODO TEMPORARY SOLUTION
|
||||||
if(ite.isVreFolder()){
|
if(ite.isVreFolder()){
|
||||||
|
|
|
@ -20,8 +20,6 @@ import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
import org.gcube.common.scope.impl.ScopeBean;
|
||||||
|
|
||||||
import com.itextpdf.text.log.SysoCounter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
@ -33,9 +31,9 @@ public class ItemRetrieve {
|
||||||
|
|
||||||
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps"; //PRODUCTION
|
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps"; //PRODUCTION
|
||||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||||
public static String TEST_USER = "francesco.mangiacrapa";
|
public static String TEST_USER = "giancarlo.panichi";
|
||||||
// public static String ITEMID = "63832213-098d-42d1-8774-89b6349764c0"; //Activity T3.4 working drafts/T2-EC-IMAR-HO-14-015 iMarine Sustainability WP - Business Model tools.pdf
|
// public static String ITEMID = "63832213-098d-42d1-8774-89b6349764c0"; //Activity T3.4 working drafts/T2-EC-IMAR-HO-14-015 iMarine Sustainability WP - Business Model tools.pdf
|
||||||
public static String ITEMID = "d81d3a64-603f-4907-ae74-be8353211807";
|
public static String ITEMID = "79b2490b-43aa-40b0-98ec-e073cf7d4887";
|
||||||
// d81d3a64-603f-4907-ae74-be8353211807
|
// d81d3a64-603f-4907-ae74-be8353211807
|
||||||
protected static Logger logger = Logger.getLogger(ItemRetrieve.class);
|
protected static Logger logger = Logger.getLogger(ItemRetrieve.class);
|
||||||
|
|
||||||
|
@ -50,7 +48,7 @@ public class ItemRetrieve {
|
||||||
Workspace ws = getWorkspace();
|
Workspace ws = getWorkspace();
|
||||||
|
|
||||||
|
|
||||||
retrieveFirstLevel(ws, null);
|
// retrieveFirstLevel(ws, null);
|
||||||
|
|
||||||
retrieveFirstLevel(ws, ITEMID);
|
retrieveFirstLevel(ws, ITEMID);
|
||||||
|
|
||||||
|
@ -90,7 +88,7 @@ public class ItemRetrieve {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void retrieveFirstLevel(Workspace ws, String foundID){
|
private static void retrieveFirstLevel(Workspace ws, String foundFolder){
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@ -100,12 +98,12 @@ public class ItemRetrieve {
|
||||||
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
||||||
|
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
System.out.println("Start get root at time: "+startTime);
|
System.out.println("Start foundFolder at time: "+startTime);
|
||||||
// WorkspaceItem root = ws.getItem(ITEMID);
|
// WorkspaceItem root = ws.getItem(ITEMID);
|
||||||
WorkspaceItem root = ws.getRoot();
|
WorkspaceItem fd = ws.getItem(foundFolder);
|
||||||
System.out.println("root id: "+root.getId());
|
System.out.println("foundFolder id: "+foundFolder);
|
||||||
System.out.println("start get children");
|
System.out.println("start get children");
|
||||||
List<? extends WorkspaceItem> children = root.getChildren();
|
List<? extends WorkspaceItem> children = fd.getChildren();
|
||||||
System.out.println("tree getChildren() returning "+children.size()+" elements in " + time);
|
System.out.println("tree getChildren() returning "+children.size()+" elements in " + time);
|
||||||
|
|
||||||
System.out.println("children size: "+children.size());
|
System.out.println("children size: "+children.size());
|
||||||
|
@ -117,12 +115,12 @@ public class ItemRetrieve {
|
||||||
int othersCounter = 0;
|
int othersCounter = 0;
|
||||||
for (WorkspaceItem workspaceItem : children) {
|
for (WorkspaceItem workspaceItem : children) {
|
||||||
|
|
||||||
if(foundID!=null && !foundID.isEmpty()){
|
/*if(foundFolder!=null && !foundFolder.isEmpty()){
|
||||||
if(workspaceItem.getId().compareTo(foundID)==0){
|
if(workspaceItem.getId().compareTo(foundFolder)==0){
|
||||||
System.out.println("ITEM FOUND id: "+workspaceItem.getId()+", name: "+workspaceItem.getName());
|
System.out.println("ITEM FOUND id: "+workspaceItem.getId()+", name: "+workspaceItem.getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
switch (workspaceItem.getType()) {
|
switch (workspaceItem.getType()) {
|
||||||
|
|
Loading…
Reference in New Issue