fixed itemExistsInWorkpaceFolder
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@169460 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
907f69c5da
commit
7f6d0f35d8
10
pom.xml
10
pom.xml
|
@ -119,11 +119,15 @@
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- HOME LIBRARY -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.portal</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
|
<artifactId>storagehub-client-library</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>storagehub-client-wrapper</artifactId>
|
<artifactId>storagehub-client-wrapper</artifactId>
|
||||||
<version>[0.0.1-SNAPSHOT, 1.0.0-SNAPSHOT]</version>
|
<version>[0.0.1-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- JSON PARSER -->
|
<!-- JSON PARSER -->
|
||||||
|
|
|
@ -8,7 +8,6 @@ import java.util.Arrays;
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.DialogResult;
|
import org.gcube.portlets.widgets.workspaceuploader.client.DialogResult;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploaderServiceAsync;
|
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload;
|
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.shared.HandlerResultMessage;
|
import org.gcube.portlets.widgets.workspaceuploader.shared.HandlerResultMessage;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploadFile;
|
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploadFile;
|
||||||
|
@ -22,7 +21,6 @@ import com.google.gwt.json.client.JSONArray;
|
||||||
import com.google.gwt.json.client.JSONObject;
|
import com.google.gwt.json.client.JSONObject;
|
||||||
import com.google.gwt.json.client.JSONString;
|
import com.google.gwt.json.client.JSONString;
|
||||||
import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
||||||
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
|
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
|
||||||
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler;
|
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler;
|
||||||
import com.google.gwt.user.client.ui.FormPanel.SubmitEvent;
|
import com.google.gwt.user.client.ui.FormPanel.SubmitEvent;
|
||||||
|
@ -226,44 +224,44 @@ public class MultipleDilaogUpload extends DialogUpload {
|
||||||
// initJsonClientKeys();
|
// initJsonClientKeys();
|
||||||
jsonClientKeys.setValue(jsonKeys);
|
jsonClientKeys.setValue(jsonKeys);
|
||||||
|
|
||||||
// CASE 1 FILE
|
// // CASE 1 FILE
|
||||||
if (files.length == 1) {
|
// if (files.length == 1) {
|
||||||
|
//
|
||||||
// recall: Some browser would write in
|
// // recall: Some browser would write in
|
||||||
// fileUploadField.getValue() C:\fakepath\$fileName
|
// // fileUploadField.getValue() C:\fakepath\$fileName
|
||||||
final String label = files[0];
|
// final String label = files[0];
|
||||||
WorkspaceUploaderServiceAsync.Util.getInstance()
|
// WorkspaceUploaderServiceAsync.Util.getInstance()
|
||||||
.itemExistsInWorkpaceFolder(parentIdentifier,
|
// .itemExistsInWorkpaceFolder(parentIdentifier,
|
||||||
label, new AsyncCallback<String>() {
|
// label, new AsyncCallback<String>() {
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void onSuccess(
|
// public void onSuccess(
|
||||||
final String itemId) {
|
// final String itemId) {
|
||||||
GWT.log("itemExistsInWorkpaceFolder: "
|
// GWT.log("itemExistsInWorkpaceFolder: "
|
||||||
+ itemId);
|
// + itemId);
|
||||||
if (itemId != null) {
|
// if (itemId != null) {
|
||||||
removeItemAndSubmitForm(itemId);
|
// removeItemAndSubmitForm(itemId);
|
||||||
updateItemSubmitForm(itemId);
|
// updateItemSubmitForm(itemId);
|
||||||
// if (Window.confirm(label+ " exists in folder. If you continue, a new version will be created")) {
|
//// if (Window.confirm(label+ " exists in folder. If you continue, a new version will be created")) {
|
||||||
// removeItemAndSubmitForm(itemId);
|
//// removeItemAndSubmitForm(itemId);
|
||||||
// updateItemSubmitForm(itemId);
|
//// updateItemSubmitForm(itemId);
|
||||||
// }
|
//// }
|
||||||
} else
|
// } else
|
||||||
submitForm(); // ITEM does NOT
|
// submitForm(); // ITEM does NOT
|
||||||
// EXIST SO
|
// // EXIST SO
|
||||||
// SUBMIT FORM;
|
// // SUBMIT FORM;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void onFailure(Throwable caught) {
|
// public void onFailure(Throwable caught) {
|
||||||
GWT.log("Sorry an error occurred on the server "
|
// GWT.log("Sorry an error occurred on the server "
|
||||||
+ caught.getLocalizedMessage()
|
// + caught.getLocalizedMessage()
|
||||||
+ ". Please try again later");
|
// + ". Please try again later");
|
||||||
Window.alert(caught.getMessage());
|
// Window.alert(caught.getMessage());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
});
|
// });
|
||||||
} else
|
// } else
|
||||||
submitForm();
|
submitForm();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,15 +28,16 @@ import org.apache.commons.fileupload.util.Streams;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.common.storagehub.model.items.Item;
|
import org.gcube.common.storagehub.model.items.Item;
|
||||||
import org.gcube.portal.storagehubwrapper.server.StorageHubWrapper;
|
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.WorkspaceFolder;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.WorkspaceItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.WorkspaceItemType;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItemType;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.exceptions.InsufficientPrivilegesException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InsufficientPrivilegesException;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.exceptions.ItemAlreadyExistException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemAlreadyExistException;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
||||||
|
import org.gcube.portlets.widgets.workspaceuploader.server.notification.NotificationsWorkspaceUploader;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.server.notification.NotificationsWorkspaceUploaderProducer;
|
import org.gcube.portlets.widgets.workspaceuploader.server.notification.NotificationsWorkspaceUploaderProducer;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.server.upload.AbstractUploadProgressListener;
|
import org.gcube.portlets.widgets.workspaceuploader.server.upload.AbstractUploadProgressListener;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.server.upload.MemoryUploadListener;
|
import org.gcube.portlets.widgets.workspaceuploader.server.upload.MemoryUploadListener;
|
||||||
|
@ -433,7 +434,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
final WorkspaceFolder destinationFolder = (WorkspaceFolder) item;
|
final WorkspaceFolder destinationFolder = (WorkspaceFolder) item;
|
||||||
try {
|
try {
|
||||||
//we calculate an unique name for the current destination
|
//we calculate an unique name for the current destination
|
||||||
String itemName = "";
|
String itemName = fileName;
|
||||||
|
|
||||||
logger.debug("getItemName from HL");
|
logger.debug("getItemName from HL");
|
||||||
/*if(!isOverwrite){
|
/*if(!isOverwrite){
|
||||||
|
@ -694,11 +695,10 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
Item sourceItem = storageWrapper.getStorageHubClientService().getItem(itemId);
|
Item sourceItem = storageWrapper.getStorageHubClientService().getItem(itemId);
|
||||||
|
|
||||||
//TODO sourceItem.getIdSharedFolder();
|
//TODO sourceItem.getIdSharedFolder();
|
||||||
/*String sourceSharedId = sourceItem.getIdSharedFolder();
|
String sourceSharedId = null;
|
||||||
Item folderDestinationItem = storageWrapper.getStorageHubClientService().getItem(destinationFolderId);
|
Item folderDestinationItem = storageWrapper.getStorageHubClientService().getItem(destinationFolderId);
|
||||||
logger.trace("[3] HttpServletRequest is: URI: "+request.getRequestURI() +", ServerName: "+request.getServerName());
|
logger.trace("[3] HttpServletRequest is: URI: "+request.getRequestURI() +", ServerName: "+request.getServerName());
|
||||||
NotificationsWorkspaceUploader.checkSendNotifyChangedItemToShare(storageWrapper, request, currUser, scopeGroupId, np, httpSession, sourceItem, sourceSharedId, folderDestinationItem,isOverwrite);
|
NotificationsWorkspaceUploader.checkSendNotifyChangedItemToShare(storageWrapper, request, currUser, scopeGroupId, np, httpSession, sourceItem, sourceSharedId, folderDestinationItem,isOverwrite);
|
||||||
*/
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error in notifyUploadInSharedFolder", e);
|
logger.error("Error in notifyUploadInSharedFolder", e);
|
||||||
|
|
|
@ -5,8 +5,10 @@ import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.common.storagehub.model.types.WorkspaceItemType;
|
import org.gcube.common.storagehub.model.types.WorkspaceItemType;
|
||||||
import org.gcube.portal.storagehubwrapper.server.StorageHubWrapper;
|
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.WorkspaceItem;
|
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploaderService;
|
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploaderService;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.server.util.WsUtil;
|
import org.gcube.portlets.widgets.workspaceuploader.server.util.WsUtil;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.shared.UploadProgress;
|
import org.gcube.portlets.widgets.workspaceuploader.shared.UploadProgress;
|
||||||
|
@ -106,20 +108,23 @@ public class WorkspaceUploaderServiceImpl extends RemoteServiceServlet implement
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getWorkspaceId() throws Exception {
|
public String getWorkspaceId() throws Exception {
|
||||||
logger.trace("getWorkspaceId");
|
logger.debug("Getting the workspaceId");
|
||||||
try {
|
try {
|
||||||
String scopeGroupId = ""+PortalContext.getConfiguration().getCurrentGroupId(getThreadLocalRequest());
|
String scopeGroupId = ""+PortalContext.getConfiguration().getCurrentGroupId(getThreadLocalRequest());
|
||||||
GCubeUser currUser = PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest());
|
GCubeUser currUser = PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest());
|
||||||
StorageHubWrapper stHubWrapper = WsUtil.getStorageHubWrapper(getThreadLocalRequest(), scopeGroupId, currUser);
|
StorageHubWrapper stHubWrapper = WsUtil.getStorageHubWrapper(getThreadLocalRequest(), scopeGroupId, currUser);
|
||||||
if(stHubWrapper.getWorkspace()!=null)
|
Workspace workspace = stHubWrapper.getWorkspace();
|
||||||
return stHubWrapper.getWorkspace().getRoot().getId();
|
if(workspace!=null){
|
||||||
|
WorkspaceFolder root = workspace.getRoot();
|
||||||
|
logger.debug("Retrieve the root "+root+" correctly");
|
||||||
|
return root.getId();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Get workspace id error", e);
|
logger.error("Get workspace id error", e);
|
||||||
String error = "An error occurred getting root id";
|
String error = "An error occurred getting root id";
|
||||||
throw new Exception(error);
|
throw new Exception(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
package org.gcube.portlets.widgets.workspaceuploader.server;
|
package org.gcube.portlets.widgets.workspaceuploader.server;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.common.storagehub.model.types.WorkspaceItemType;
|
import org.gcube.common.storagehub.model.types.WorkspaceItemType;
|
||||||
import org.gcube.portal.storagehubwrapper.server.StorageHubWrapper;
|
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
||||||
import org.gcube.portal.storagehubwrapper.server.tohl.Workspace;
|
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
||||||
import org.gcube.portal.storagehubwrapper.server.util.PortalContextUtil;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.WorkspaceItem;
|
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.server.util.WsUtil;
|
import org.gcube.portlets.widgets.workspaceuploader.server.util.WsUtil;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
@ -51,7 +52,7 @@ public class WorkspaceUploaderWsUtil extends HttpServlet {
|
||||||
Workspace wa = null;
|
Workspace wa = null;
|
||||||
//GCubeUser currUser;
|
//GCubeUser currUser;
|
||||||
try {
|
try {
|
||||||
GCubeUser user = PortalContextUtil.getCurrentUser(request);
|
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(request);
|
||||||
StorageHubWrapper storageWrapper = WsUtil.getStorageHubWrapper(request, currGroupId, user);
|
StorageHubWrapper storageWrapper = WsUtil.getStorageHubWrapper(request, currGroupId, user);
|
||||||
wa = storageWrapper.getWorkspace();
|
wa = storageWrapper.getWorkspace();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -89,16 +90,14 @@ public class WorkspaceUploaderWsUtil extends HttpServlet {
|
||||||
WorkspaceItem wsItem = workspace.getItem(parentId); //GET PARENT
|
WorkspaceItem wsItem = workspace.getItem(parentId); //GET PARENT
|
||||||
|
|
||||||
if(wsItem.getType().equals(WorkspaceItemType.FOLDER) || wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
if(wsItem.getType().equals(WorkspaceItemType.FOLDER) || wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
||||||
WorkspaceItem itemFound = workspace.find(itemName, parentId);
|
List<WorkspaceItem> foundItems = workspace.find(itemName, parentId);
|
||||||
if(itemFound==null){
|
logger.debug("Is item: "+itemName+", existing in parentId: "+parentId +"? "+foundItems);
|
||||||
logger.trace("item: "+itemName+", not exists in parentId: "+parentId);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("item: "+itemName+", exists in parentId: "+parentId +", returning id:" +itemFound.getId());
|
if(foundItems!=null && foundItems.size()>0)
|
||||||
return itemFound.getId();
|
return foundItems.get(0).getId();
|
||||||
}
|
else
|
||||||
else
|
return null;
|
||||||
|
}else
|
||||||
throw new Exception("Invalid Folder parent");
|
throw new Exception("Invalid Folder parent");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -11,10 +11,12 @@ import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.gcube.common.storagehub.model.items.Item;
|
import org.gcube.common.storagehub.model.items.Item;
|
||||||
|
import org.gcube.common.storagehub.model.items.SharedFolder;
|
||||||
import org.gcube.common.storagehub.model.types.WorkspaceItemType;
|
import org.gcube.common.storagehub.model.types.WorkspaceItemType;
|
||||||
import org.gcube.portal.storagehubwrapper.server.StorageHubWrapper;
|
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
||||||
import org.gcube.portal.storagehubwrapper.server.tohl.Workspace;
|
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.WorkspaceItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.shared.ContactModel;
|
import org.gcube.portlets.widgets.workspaceuploader.shared.ContactModel;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
|
||||||
|
@ -52,7 +54,7 @@ public class NotificationsWorkspaceUploader {
|
||||||
try{
|
try{
|
||||||
if(folderDestinationItem.isShared()){ //Notify Added Item To Sharing?
|
if(folderDestinationItem.isShared()){ //Notify Added Item To Sharing?
|
||||||
|
|
||||||
/* TODO folderDestinationItem.getIdSharedFolder()
|
//TODO folderDestinationItem.getIdSharedFolder()
|
||||||
logger.trace("checkNotifyAddItemToShare source item: "+sourceItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName() + " folder destination shared folder id: "+folderDestinationItem.getIdSharedFolder());
|
logger.trace("checkNotifyAddItemToShare source item: "+sourceItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName() + " folder destination shared folder id: "+folderDestinationItem.getIdSharedFolder());
|
||||||
|
|
||||||
//share condition is true if source shared folder is not null
|
//share condition is true if source shared folder is not null
|
||||||
|
@ -68,10 +70,11 @@ public class NotificationsWorkspaceUploader {
|
||||||
//Workspace workspace = WsUtil.getWorkspace(request, scopeGroupId, currUser);
|
//Workspace workspace = WsUtil.getWorkspace(request, scopeGroupId, currUser);
|
||||||
//Workspace workspace = storageWrapper.getWorkspace();
|
//Workspace workspace = storageWrapper.getWorkspace();
|
||||||
|
|
||||||
|
SharedFolder folderDest = (SharedFolder) folderDestinationItem;
|
||||||
//TODO
|
//TODO
|
||||||
List<ContactModel> listContacts = getListUserSharedByFolderSharedId(storageWrapper.getWorkspace(), folderDestinationItem.getIdSharedFolder());
|
List<ContactModel> listContacts = getListUserSharedByFolderSharedId(storageWrapper.getWorkspace(), folderDest.getIdSharedFolder());
|
||||||
|
|
||||||
Item destinationSharedFolder = storageWrapper.getStorageHubClientService().getItem(folderDestinationItem.getIdSharedFolder());
|
Item destinationSharedFolder = storageWrapper.getStorageHubClientService().getItem(folderDest.getIdSharedFolder());
|
||||||
|
|
||||||
if(destinationSharedFolder instanceof WorkspaceSharedFolder){
|
if(destinationSharedFolder instanceof WorkspaceSharedFolder){
|
||||||
|
|
||||||
|
@ -86,7 +89,7 @@ public class NotificationsWorkspaceUploader {
|
||||||
}else
|
}else
|
||||||
logger.trace("The notifies doesn't sent because "+destinationSharedFolder+ " is not instance of WorkspaceSharedFolder");
|
logger.trace("The notifies doesn't sent because "+destinationSharedFolder+ " is not instance of WorkspaceSharedFolder");
|
||||||
// np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem);
|
// np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem);
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
logger.trace("folder destination is not shared");
|
logger.trace("folder destination is not shared");
|
||||||
|
|
|
@ -9,16 +9,16 @@ import java.io.InputStream;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.gcube.portal.storagehubwrapper.server.StorageHubWrapper;
|
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.WorkspaceFolder;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.WorkspaceItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.exceptions.InsufficientPrivilegesException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InsufficientPrivilegesException;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.exceptions.ItemAlreadyExistException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemAlreadyExistException;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.exceptions.WorkspaceFolderNotFoundException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WorkspaceFolderNotFoundException;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.exceptions.WrongDestinationException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WrongDestinationException;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.folder.items.WorkspaceVersion;
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.impl.FileItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.WorkspaceVersion;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.server.WorkspaceUploadServletStream;
|
import org.gcube.portlets.widgets.workspaceuploader.server.WorkspaceUploadServletStream;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.server.util.WsUtil;
|
import org.gcube.portlets.widgets.workspaceuploader.server.util.WsUtil;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem;
|
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem;
|
||||||
|
@ -67,7 +67,7 @@ public class WorkspaceUploaderMng {
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
private static WorkspaceUploaderItem createWorkspaceUploaderFile(StorageHubWrapper storageWrapper, final GCubeUser currUser, final String scopeGroupId, final HttpServletRequest request, final WorkspaceUploaderItem workspaceUploader, final HttpSession httpSession, final boolean isOvewrite, final InputStream uploadFile, final String itemName, final WorkspaceFolder destinationFolder, final String contentType, final long totalBytes) throws InternalErrorException, IOException{
|
private static WorkspaceUploaderItem createWorkspaceUploaderFile(StorageHubWrapper storageWrapper, final GCubeUser currUser, final String scopeGroupId, final HttpServletRequest request, final WorkspaceUploaderItem workspaceUploader, final HttpSession httpSession, final boolean isOvewrite, final InputStream uploadFile, final String itemName, final WorkspaceFolder destinationFolder, final String contentType, final long totalBytes) throws InternalErrorException, IOException{
|
||||||
logger.debug("Creating WorkspaceUploaderFile... isOvewrite: " +isOvewrite);
|
logger.debug("Creating WorkspaceUploaderFile to user: " +currUser.getUsername()+ ", filename: "+itemName+", destinationFolder: "+destinationFolder);
|
||||||
|
|
||||||
workspaceUploader.setUploadStatus(UPLOAD_STATUS.IN_PROGRESS);
|
workspaceUploader.setUploadStatus(UPLOAD_STATUS.IN_PROGRESS);
|
||||||
workspaceUploader.setStatusDescription("Uploading "+itemName);
|
workspaceUploader.setStatusDescription("Uploading "+itemName);
|
||||||
|
@ -100,8 +100,9 @@ public class WorkspaceUploaderMng {
|
||||||
logger.debug("StorageHub file: "+createdItem.getName() + " has version: "+currVersion.getName());
|
logger.debug("StorageHub file: "+createdItem.getName() + " has version: "+currVersion.getName());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
logger.debug("StorageHub file: "+createdItem.getName() + " has no current version");
|
//TODO NO VERSION
|
||||||
workspaceUploader.getFile().setVersionName(file.getName());
|
//logger.debug("StorageHub file: "+createdItem.getName() + " has no current version");
|
||||||
|
//workspaceUploader.getFile().setVersionName(file.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
}else
|
}else
|
||||||
|
|
|
@ -8,10 +8,9 @@ import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.portal.storagehubwrapper.server.StorageHubWrapper;
|
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
||||||
import org.gcube.portal.storagehubwrapper.server.util.PortalContextUtil;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WorkspaceFolderNotFoundException;
|
||||||
import org.gcube.portal.storagehubwrapper.shared.tohl.exceptions.WorkspaceFolderNotFoundException;
|
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem;
|
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
|
||||||
|
@ -78,15 +77,17 @@ public class WsUtil {
|
||||||
throw new Exception("Session expired");
|
throw new Exception("Session expired");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.debug("getWorkspace from HL scopeGroupId="+scopeGroupId +", userId="+user);
|
|
||||||
String scope;
|
String scope;
|
||||||
PortalContext pContext = PortalContextUtil.getPortalContext(request);
|
PortalContext pContext = PortalContext.getConfiguration();
|
||||||
if(WsUtil.isWithinPortal() && scopeGroupId!=null)
|
if(WsUtil.isWithinPortal() && scopeGroupId!=null){
|
||||||
scope = pContext.getCurrentScope(scopeGroupId);
|
scope = pContext.getCurrentScope(scopeGroupId);
|
||||||
|
logger.debug(scope+" has retrieved by using the scopeGroupId="+scopeGroupId);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
scope = pContext.getCurrentScope(request);
|
scope = pContext.getCurrentScope(request);
|
||||||
|
|
||||||
String token = PortalContextUtil.getContextUserToken(request);
|
logger.debug("Instancing "+StorageHubWrapper.class.getSimpleName()+" for user: "+user.getUsername() +", by using the scope: "+scope);
|
||||||
|
String token = pContext.getCurrentUserToken(scope, user.getUsername());
|
||||||
return new StorageHubWrapper(scope, token);
|
return new StorageHubWrapper(scope, token);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error during getting storageHub wrapper", e);
|
logger.error("Error during getting storageHub wrapper", e);
|
||||||
|
|
Loading…
Reference in New Issue