enhancement: copy with multi-selection is implemented
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@90435 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
798322bd36
commit
c97cc55b6c
|
@ -524,9 +524,11 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
@Override
|
@Override
|
||||||
public void onRefreshItem(RefreshFolderEvent refreshItemEvent) {
|
public void onRefreshItem(RefreshFolderEvent refreshItemEvent) {
|
||||||
|
|
||||||
|
GWT.log("RefreshFolderEvent: "+refreshItemEvent);
|
||||||
|
|
||||||
if(refreshItemEvent.getFolderTarget()!=null){
|
if(refreshItemEvent.getFolderTarget()!=null){
|
||||||
|
|
||||||
if(!refreshItemEvent.isIfExists()){ //CAlled Tree side
|
if(!refreshItemEvent.isIfExists()){ //Called Tree side
|
||||||
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(refreshItemEvent.getFolderTarget().getIdentifier(), refreshItemEvent.isExpandFolder());
|
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(refreshItemEvent.getFolderTarget().getIdentifier(), refreshItemEvent.isExpandFolder());
|
||||||
notifySubscriber(refreshItemEvent);
|
notifySubscriber(refreshItemEvent);
|
||||||
}
|
}
|
||||||
|
@ -583,15 +585,16 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
@Override
|
@Override
|
||||||
public void onCopyAndPaste(PasteItemEvent pasteItemEvent) {
|
public void onCopyAndPaste(PasteItemEvent pasteItemEvent) {
|
||||||
|
|
||||||
GWT.log("PasteItemEvent is fired on itemId: "+pasteItemEvent.getItemId()+", DestinationId: "+pasteItemEvent.getFolderDestinationId());
|
GWT.log("PasteItemEvent is fired on : "+pasteItemEvent.getIds().size()+ "items, DestinationId: "+pasteItemEvent.getFolderDestinationId());
|
||||||
doCopyAndPaste(pasteItemEvent);
|
doCopyAndPaste(pasteItemEvent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doCopyAndPaste(final PasteItemEvent pasteItemEvent) {
|
private void doCopyAndPaste(final PasteItemEvent pasteItemEvent) {
|
||||||
|
|
||||||
|
Info.display("Info", "Paste working...");
|
||||||
|
|
||||||
rpcWorkspaceService.copyItem(pasteItemEvent.getItemId(), pasteItemEvent.getFolderDestinationId(), new AsyncCallback<Boolean>() {
|
rpcWorkspaceService.copyItems(pasteItemEvent.getIds(), pasteItemEvent.getFolderDestinationId(), new AsyncCallback<Boolean>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
@ -604,13 +607,16 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
new MessageBoxAlert("Error", caught.getMessage(), null);
|
new MessageBoxAlert("Error", caught.getMessage(), null);
|
||||||
|
|
||||||
|
eventBus.fireEvent(new RefreshFolderEvent(explorerPanel.getAsycTreePanel().getFileModelByIdentifier(pasteItemEvent.getFolderDestinationId()), false, true, false));
|
||||||
|
|
||||||
|
notifySubscriber(pasteItemEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Boolean result) {
|
public void onSuccess(Boolean result) {
|
||||||
|
|
||||||
if(result)
|
if(result)
|
||||||
eventBus.fireEvent(new RefreshFolderEvent(explorerPanel.getAsycTreePanel().getFileModelByIdentifier(pasteItemEvent.getFolderDestinationId()), false, true, false));
|
eventBus.fireEvent(new RefreshFolderEvent(explorerPanel.getAsycTreePanel().getFileModelByIdentifier(pasteItemEvent.getFolderDestinationId()), false, false, false));
|
||||||
|
|
||||||
notifySubscriber(pasteItemEvent);
|
notifySubscriber(pasteItemEvent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.gcube.portlets.user.workspace.client.event;
|
package org.gcube.portlets.user.workspace.client.event;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.EventsTypeEnum;
|
import org.gcube.portlets.user.workspace.client.interfaces.EventsTypeEnum;
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface;
|
import org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface;
|
||||||
|
|
||||||
|
@ -8,12 +10,19 @@ import com.google.gwt.event.shared.GwtEvent;
|
||||||
public class CopytemEvent extends GwtEvent<CopytemEventHandler> implements GuiEventInterface{
|
public class CopytemEvent extends GwtEvent<CopytemEventHandler> implements GuiEventInterface{
|
||||||
public static Type<CopytemEventHandler> TYPE = new Type<CopytemEventHandler>();
|
public static Type<CopytemEventHandler> TYPE = new Type<CopytemEventHandler>();
|
||||||
|
|
||||||
private String itemId = null;
|
// private String itemId = null;
|
||||||
|
|
||||||
public CopytemEvent(String itemId) {
|
private List<String> ids;
|
||||||
this.itemId = itemId;
|
|
||||||
|
// public CopytemEvent(String itemId) {
|
||||||
|
// this.itemId = itemId;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public CopytemEvent(List<String> ids) {
|
||||||
|
this.ids = ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type<CopytemEventHandler> getAssociatedType() {
|
public Type<CopytemEventHandler> getAssociatedType() {
|
||||||
return TYPE;
|
return TYPE;
|
||||||
|
@ -25,9 +34,9 @@ public class CopytemEvent extends GwtEvent<CopytemEventHandler> implements GuiEv
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getItemId() {
|
// public String getItemId() {
|
||||||
return itemId;
|
// return itemId;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface#getKey()
|
* @see org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface#getKey()
|
||||||
|
@ -37,4 +46,12 @@ public class CopytemEvent extends GwtEvent<CopytemEventHandler> implements GuiEv
|
||||||
return EventsTypeEnum.COPY_EVENT;
|
return EventsTypeEnum.COPY_EVENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getIds() {
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIds(List<String> ids) {
|
||||||
|
this.ids = ids;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.gcube.portlets.user.workspace.client.event;
|
package org.gcube.portlets.user.workspace.client.event;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.EventsTypeEnum;
|
import org.gcube.portlets.user.workspace.client.interfaces.EventsTypeEnum;
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface;
|
import org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface;
|
||||||
|
|
||||||
|
@ -8,11 +10,18 @@ import com.google.gwt.event.shared.GwtEvent;
|
||||||
public class PasteItemEvent extends GwtEvent<PasteItemEventHandler> implements GuiEventInterface{
|
public class PasteItemEvent extends GwtEvent<PasteItemEventHandler> implements GuiEventInterface{
|
||||||
public static Type<PasteItemEventHandler> TYPE = new Type<PasteItemEventHandler>();
|
public static Type<PasteItemEventHandler> TYPE = new Type<PasteItemEventHandler>();
|
||||||
|
|
||||||
private String itemId = null;
|
// private String itemId = null;
|
||||||
private String folderDestinationId;
|
private String folderDestinationId;
|
||||||
|
|
||||||
public PasteItemEvent(String itemId, String folderDestinationId) {
|
private List<String> ids;
|
||||||
this.itemId = itemId;
|
|
||||||
|
// public PasteItemEvent(String itemId, String folderDestinationId) {
|
||||||
|
// this.itemId = itemId;
|
||||||
|
// this.folderDestinationId = folderDestinationId;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public PasteItemEvent(List<String> ids, String folderDestinationId) {
|
||||||
|
this.ids = ids;
|
||||||
this.folderDestinationId = folderDestinationId;
|
this.folderDestinationId = folderDestinationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,9 +36,9 @@ public class PasteItemEvent extends GwtEvent<PasteItemEventHandler> implements G
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getItemId() {
|
// public String getItemId() {
|
||||||
return itemId;
|
// return itemId;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public String getFolderDestinationId() {
|
public String getFolderDestinationId() {
|
||||||
return folderDestinationId;
|
return folderDestinationId;
|
||||||
|
@ -43,4 +52,12 @@ public class PasteItemEvent extends GwtEvent<PasteItemEventHandler> implements G
|
||||||
return EventsTypeEnum.PASTED_EVENT;
|
return EventsTypeEnum.PASTED_EVENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getIds() {
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIds(List<String> ids) {
|
||||||
|
this.ids = ids;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,13 @@ public class RefreshFolderEvent extends GwtEvent<RefreshItemEventHandler> implem
|
||||||
|
|
||||||
private boolean ifExists = false;
|
private boolean ifExists = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param folderTarget
|
||||||
|
* @param expandFolder - used to expand the folder into tree after refresh
|
||||||
|
* @param forceRefresh - used to force refresh into grid
|
||||||
|
* @param ifExists - refresh only if items exists (into tree)
|
||||||
|
*/
|
||||||
public RefreshFolderEvent(FileModel folderTarget, boolean expandFolder, boolean forceRefresh, boolean ifExists) {
|
public RefreshFolderEvent(FileModel folderTarget, boolean expandFolder, boolean forceRefresh, boolean ifExists) {
|
||||||
this.folderTarget = folderTarget;
|
this.folderTarget = folderTarget;
|
||||||
this.expandFolder = expandFolder;
|
this.expandFolder = expandFolder;
|
||||||
|
@ -69,4 +76,20 @@ public class RefreshFolderEvent extends GwtEvent<RefreshItemEventHandler> implem
|
||||||
public boolean isIfExists() {
|
public boolean isIfExists() {
|
||||||
return ifExists;
|
return ifExists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("RefreshFolderEvent [folderTarget=");
|
||||||
|
builder.append(folderTarget);
|
||||||
|
builder.append(", expandFolder=");
|
||||||
|
builder.append(expandFolder);
|
||||||
|
builder.append(", forceRefresh=");
|
||||||
|
builder.append(forceRefresh);
|
||||||
|
builder.append(", ifExists=");
|
||||||
|
builder.append(ifExists);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,4 +175,13 @@ public interface GWTWorkspaceService extends RemoteService{
|
||||||
|
|
||||||
void deleteListItemsForIds(List<String> ids) throws Exception;
|
void deleteListItemsForIds(List<String> ids) throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param idsItem
|
||||||
|
* @param destinationFolderId
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
boolean copyItems(List<String> idsItem, String destinationFolderId)
|
||||||
|
throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,4 +164,7 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
|
|
||||||
void deleteListItemsForIds(List<String> ids, AsyncCallback<Void> callback);
|
void deleteListItemsForIds(List<String> ids, AsyncCallback<Void> callback);
|
||||||
|
|
||||||
|
void copyItems(List<String> idsItem, String destinationFolderId,
|
||||||
|
AsyncCallback<Boolean> callback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.workspace.client.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* @Jan 23, 2014
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class FileModelUtils {
|
||||||
|
|
||||||
|
|
||||||
|
public static List<String> convertFileModelsToIds(List<FileModel> filesModel){
|
||||||
|
|
||||||
|
if(filesModel==null || filesModel.size()==0)
|
||||||
|
return new ArrayList<String>(1);
|
||||||
|
|
||||||
|
|
||||||
|
List<String> ids = new ArrayList<String>(filesModel.size());
|
||||||
|
for (FileModel target : filesModel) {
|
||||||
|
ids.add(target.getIdentifier());
|
||||||
|
}
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -31,6 +31,7 @@ import org.gcube.portlets.user.workspace.client.event.UnShareFolderEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.WebDavUrlEvent;
|
import org.gcube.portlets.user.workspace.client.event.WebDavUrlEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
||||||
|
import org.gcube.portlets.user.workspace.client.util.FileModelUtils;
|
||||||
|
|
||||||
import com.extjs.gxt.ui.client.event.MenuEvent;
|
import com.extjs.gxt.ui.client.event.MenuEvent;
|
||||||
import com.extjs.gxt.ui.client.event.SelectionListener;
|
import com.extjs.gxt.ui.client.event.SelectionListener;
|
||||||
|
@ -319,11 +320,20 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
copy.addSelectionListener(new SelectionListener<MenuEvent>() {
|
copy.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
for (FileModel target : listSelectedItems) {
|
|
||||||
if(target.getIdentifier()!=null){
|
// //HERE THE MULTI-SELECTION IS NOT ENABLED
|
||||||
CopyAndPaste.copy(target.getIdentifier());
|
// for (FileModel target : listSelectedItems) {
|
||||||
eventBus.fireEvent(new CopytemEvent(target.getIdentifier()));
|
// if(target.getIdentifier()!=null){
|
||||||
}
|
// CopyAndPaste.copy(target.getIdentifier()));
|
||||||
|
// eventBus.fireEvent(new CopytemEvent(target.getIdentifier()));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
List<String> ids = FileModelUtils.convertFileModelsToIds(listSelectedItems);
|
||||||
|
|
||||||
|
if(ids.size()>0){
|
||||||
|
CopyAndPaste.copy(ids);
|
||||||
|
eventBus.fireEvent(new CopytemEvent(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -343,8 +353,8 @@ public class ContextMenuTree {
|
||||||
FileModel parentTarget = getDirectoryOrParent(target);
|
FileModel parentTarget = getDirectoryOrParent(target);
|
||||||
if(parentTarget!=null){
|
if(parentTarget!=null){
|
||||||
|
|
||||||
eventBus.fireEvent(new PasteItemEvent(CopyAndPaste.getCopiedfileModelId(), parentTarget.getIdentifier()));
|
eventBus.fireEvent(new PasteItemEvent(CopyAndPaste.getCopiedIdsFilesModel(), parentTarget.getIdentifier()));
|
||||||
CopyAndPaste.setCopiedfileModelId(null);
|
CopyAndPaste.setCopiedIdsFileModels(null);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -782,8 +792,8 @@ public class ContextMenuTree {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(CopyAndPaste.getCopiedfileModelId()!=null)
|
if(CopyAndPaste.getCopiedIdsFilesModel()!=null)
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(true); //paste
|
contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(true); //enable paste button
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,21 +1,38 @@
|
||||||
package org.gcube.portlets.user.workspace.client.view.tree;
|
package org.gcube.portlets.user.workspace.client.view.tree;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class CopyAndPaste {
|
public class CopyAndPaste {
|
||||||
|
|
||||||
private static String copiedfileModelId = null;
|
// private static String copiedfileModelId = null;
|
||||||
|
|
||||||
public static void copy(String fileModelId){
|
private static List<String> idsFilesModel = null;
|
||||||
|
|
||||||
copiedfileModelId = fileModelId;
|
// public static void copy(String fileModelId){
|
||||||
|
// copiedfileModelId = fileModelId;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public static void copy(List<String> idsFileModel){
|
||||||
|
idsFilesModel = idsFileModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCopiedfileModelId() {
|
|
||||||
return copiedfileModelId;
|
public static List<String> getCopiedIdsFilesModel() {
|
||||||
|
return idsFilesModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setCopiedfileModelId(String copiedfileModelId) {
|
// public static void setCopiedfileModelId(String copiedfileModelId) {
|
||||||
CopyAndPaste.copiedfileModelId = copiedfileModelId;
|
// CopyAndPaste.copiedfileModelId = copiedfileModelId;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// public static String getCopiedfileModelId() {
|
||||||
|
// return copiedfileModelId;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public static void setCopiedIdsFileModels(List<String> idsFileModel) {
|
||||||
|
CopyAndPaste.idsFilesModel = idsFileModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1632,6 +1632,56 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean copyItems(List<String> idsItem, String destinationFolderId) throws Exception {
|
||||||
|
|
||||||
|
if(isSessionExpired())
|
||||||
|
throw new SessionExpiredException();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
Workspace workspace = getWorkspace();
|
||||||
|
boolean error = false;
|
||||||
|
|
||||||
|
for (String itemId : idsItem) {
|
||||||
|
|
||||||
|
WorkspaceItem sourceItem = workspace.getItem(itemId); //GET SOURCE ITEM BEFORE COPY
|
||||||
|
String sourceSharedId = sourceItem.getIdSharedFolder();
|
||||||
|
|
||||||
|
workspaceLogger.trace("copyItem by id: " + itemId);
|
||||||
|
|
||||||
|
WorkspaceItem item = workspace.copy(itemId, destinationFolderId); //copy item
|
||||||
|
|
||||||
|
WorkspaceItem folderDestinationItem = workspace.getItem(destinationFolderId);
|
||||||
|
|
||||||
|
checkNotifyAddItemToShare(sourceItem, sourceSharedId, folderDestinationItem);
|
||||||
|
|
||||||
|
if(item==null){
|
||||||
|
error = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(error)
|
||||||
|
return false; //Copied is false
|
||||||
|
|
||||||
|
return true; //copied is true
|
||||||
|
|
||||||
|
}catch (InsufficientPrivilegesException e) {
|
||||||
|
String error = "An error occurred on copying item, " +e.getMessage() + ". "+ConstantsExplorer.TRY_AGAIN;
|
||||||
|
throw new Exception(error);
|
||||||
|
|
||||||
|
}catch (ItemAlreadyExistException e) {
|
||||||
|
String error = "An error occurred on copying item, " +e.getMessage();
|
||||||
|
throw new Exception(error);
|
||||||
|
} catch (Exception e) {
|
||||||
|
workspaceLogger.error("Error in server copyItem by id", e);
|
||||||
|
String error = ConstantsExplorer.SERVER_ERROR +" copying item " + ConstantsExplorer.TRY_AGAIN;
|
||||||
|
throw new Exception(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean deleteBulk(String bulkId) throws Exception {
|
public boolean deleteBulk(String bulkId) throws Exception {
|
||||||
|
|
||||||
|
|
|
@ -48,10 +48,10 @@ public class HttpRequestUtil {
|
||||||
httpConnection.disconnect();
|
httpConnection.disconnect();
|
||||||
|
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
logger.trace("status code is "+code+" - on url connetction: "+urlConn);
|
logger.trace("status code is "+code+" - on url connection: "+urlConn);
|
||||||
return true;
|
return true;
|
||||||
}else
|
}else
|
||||||
logger.warn("status code is "+code+" - on url connetction: "+urlConn);
|
logger.warn("status code is "+code+" - on url connection: "+urlConn);
|
||||||
|
|
||||||
// logger.trace("result: "+result);
|
// logger.trace("result: "+result);
|
||||||
|
|
||||||
|
@ -62,16 +62,16 @@ public class HttpRequestUtil {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
logger.error("Error SocketTimeoutException with url " +urlConn);
|
logger.error("Error SocketTimeoutException with url " +urlConn, e);
|
||||||
return true;
|
return true;
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
logger.error("Error MalformedURLException with url " +urlConn);
|
logger.error("Error MalformedURLException with url " +urlConn, e);
|
||||||
throw new Exception("Error MalformedURLException");
|
throw new Exception("Error MalformedURLException");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Error IOException with url " +urlConn);
|
logger.error("Error IOException with url " +urlConn, e);
|
||||||
throw new Exception("Error IOException");
|
throw new Exception("Error IOException");
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
logger.error("Error Exception with url " +urlConn);
|
logger.error("Error Exception with url " +urlConn, e);
|
||||||
throw new Exception("Error Exception");
|
throw new Exception("Error Exception");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,10 +74,10 @@ public class WsUtil {
|
||||||
|
|
||||||
/*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING
|
/*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING
|
||||||
* COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/
|
* COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/
|
||||||
user=TEST_USER;
|
// user=TEST_USER;
|
||||||
|
|
||||||
//UNCOMMENT THIS IN DEVELOP ENVIROMENT
|
//UNCOMMENT THIS IN DEVELOP ENVIROMENT
|
||||||
// user = "francesco.mangiacrapa";
|
user = "francesco.mangiacrapa";
|
||||||
|
|
||||||
logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:");
|
logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:");
|
||||||
logger.warn("session id: "+sessionID);
|
logger.warn("session id: "+sessionID);
|
||||||
|
|
|
@ -145,6 +145,7 @@ public class SinglePublicLinkTest {
|
||||||
|
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
logger.error("Error getPublicLinkForFolderItemId for item: "+itemId, e);
|
logger.error("Error getPublicLinkForFolderItemId for item: "+itemId, e);
|
||||||
|
e.printStackTrace();
|
||||||
throw new Exception(e.getMessage());
|
throw new Exception(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@ public class UriResolverReaderRR {
|
||||||
//Query URL parameter
|
//Query URL parameter
|
||||||
String parameter = "";
|
String parameter = "";
|
||||||
private String uriRequest = "";
|
private String uriRequest = "";
|
||||||
|
public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps"; //PRODUCTION
|
||||||
|
// public static String DEFAULT_SCOPE = "/gcube/devsec"; //PRODUCTION
|
||||||
|
|
||||||
public static Logger log = Logger.getLogger(UriResolverReaderRR.class);
|
public static Logger log = Logger.getLogger(UriResolverReaderRR.class);
|
||||||
|
|
||||||
|
@ -146,7 +148,10 @@ public class UriResolverReaderRR {
|
||||||
|
|
||||||
|
|
||||||
// id: 370dc1cc-2e5e-4321-bc6f-ad860414db97, name: testupload.txt, ### Public link: smp://Home/francesco.mangiacrapa/Workspace284ee688-e6fb-4080-bbcb-cc7c8cc5c381?5ezvFfBOLqb3YESyI/kesN4T+ZD0mtmc/4sZ0vGMrl0lgx7k85j8o2Q1vF0ezJi/xIGDhncO9jOkV1T8u6Db7GZ/4ePgMws8Jxu8ierJajHBd20bUotElPG3BVG0ODMHf1ztm6rKJIAeb9R/0FEIDQ==
|
// id: 370dc1cc-2e5e-4321-bc6f-ad860414db97, name: testupload.txt, ### Public link: smp://Home/francesco.mangiacrapa/Workspace284ee688-e6fb-4080-bbcb-cc7c8cc5c381?5ezvFfBOLqb3YESyI/kesN4T+ZD0mtmc/4sZ0vGMrl0lgx7k85j8o2Q1vF0ezJi/xIGDhncO9jOkV1T8u6Db7GZ/4ePgMws8Jxu8ierJajHBd20bUotElPG3BVG0ODMHf1ztm6rKJIAeb9R/0FEIDQ==
|
||||||
System.out.println("uri is: "+getPublicLinkForFolderItemId("f70f01f9-5a06-4123-b6ec-bd121c1af82f"));
|
|
||||||
|
String itemId = "0e875263-f6bc-4945-9435-bfb8774027ca";
|
||||||
|
// itemId = "f70f01f9-5a06-4123-b6ec-bd121c1af82f";
|
||||||
|
System.out.println("uri is: "+getPublicLinkForFolderItemId(itemId));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -161,14 +166,13 @@ public class UriResolverReaderRR {
|
||||||
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
String scope = "/gcube/devsec";
|
|
||||||
|
|
||||||
ScopeProvider.instance.set("/gcube/devsec");
|
ScopeProvider.instance.set(DEFAULT_SCOPE);
|
||||||
|
|
||||||
Workspace workspace = HomeLibrary
|
Workspace workspace = HomeLibrary
|
||||||
.getHomeManagerFactory()
|
.getHomeManagerFactory()
|
||||||
.getHomeManager()
|
.getHomeManager()
|
||||||
.getHome("francesco.mangiacrapa")
|
.getHome("leonardo.candela")
|
||||||
.getWorkspace();
|
.getWorkspace();
|
||||||
|
|
||||||
GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();
|
GWTWorkspaceBuilder builder = new GWTWorkspaceBuilder();
|
||||||
|
@ -184,9 +188,10 @@ public class UriResolverReaderRR {
|
||||||
System.out.println("smpUri "+smpUri);
|
System.out.println("smpUri "+smpUri);
|
||||||
|
|
||||||
System.out.println("get uriResolver...");
|
System.out.println("get uriResolver...");
|
||||||
UriResolverReaderParameter uriResolver = new UriResolverReaderParameter(scope);
|
UriResolverReaderParameter uriResolver = new UriResolverReaderParameter(DEFAULT_SCOPE);
|
||||||
|
|
||||||
String url = uriResolver.resolveAsUriRequest(smpUri, "testResponse!@#$$%^^&&.html", folderItem.getMimeType(), true);
|
// String url = uriResolver.resolveAsUriRequest(smpUri, "testResponse!@#$$%^^&&.html", folderItem.getMimeType(), true);
|
||||||
|
String url = uriResolver.resolveAsUriRequest(smpUri, folderItem.getName(), folderItem.getMimeType(), true);
|
||||||
System.out.println("url econded: "+url);
|
System.out.println("url econded: "+url);
|
||||||
//
|
//
|
||||||
// url = uriResolver.resolveAsUriRequest(smpUri, folderItem.getName(), folderItem.getMimeType(), false);
|
// url = uriResolver.resolveAsUriRequest(smpUri, folderItem.getName(), folderItem.getMimeType(), false);
|
||||||
|
@ -204,7 +209,7 @@ public class UriResolverReaderRR {
|
||||||
// String smpUri = "smp://Home/test.user/Workspace/bla8200ceb0-c525-40e6-bad1-a63f83811d3d?5ezvFfBOLqb3YESyI/kesN4T+ZD0mtmc/4sZ0vGMrl0lgx7k85j8o2Q1vF0ezJi/xIGDhncO9jOkV1T8u6Db7GZ/4ePgMws8Jxu8ierJajHBd20bUotElPG3BVG0ODMHf1ztm6rKJIAeb9R/0FEIDQ==";
|
// String smpUri = "smp://Home/test.user/Workspace/bla8200ceb0-c525-40e6-bad1-a63f83811d3d?5ezvFfBOLqb3YESyI/kesN4T+ZD0mtmc/4sZ0vGMrl0lgx7k85j8o2Q1vF0ezJi/xIGDhncO9jOkV1T8u6Db7GZ/4ePgMws8Jxu8ierJajHBd20bUotElPG3BVG0ODMHf1ztm6rKJIAeb9R/0FEIDQ==";
|
||||||
|
|
||||||
|
|
||||||
UrlShortener urlShortner = new UrlShortener(scope);
|
UrlShortener urlShortner = new UrlShortener(DEFAULT_SCOPE);
|
||||||
|
|
||||||
String shortUrl = urlShortner.shorten(url);
|
String shortUrl = urlShortner.shorten(url);
|
||||||
System.out.println("url shortUrl: "+shortUrl);
|
System.out.println("url shortUrl: "+shortUrl);
|
||||||
|
|
Loading…
Reference in New Issue