refs 5070: TabMan / CSV Import From Workspace / Opn by default the VRE Folder
Task-Url: https://support.d4science.org/issues/5070 Added the recovery of VRE folder id git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@132077 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c29c0b655e
commit
7b18c3abe4
|
@ -148,7 +148,17 @@ public interface TDGWTService extends RemoteService {
|
|||
*/
|
||||
public String getUriFromResolver(UriResolverSession uriResolverSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get VRE Folder Id
|
||||
*
|
||||
* @return VRE Folder Id
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public String getVREFolderIdByScope() throws TDGWTServiceException;
|
||||
|
||||
|
||||
// PeriodDataType
|
||||
/**
|
||||
* Get list of PeriodDataType
|
||||
|
|
|
@ -108,7 +108,9 @@ public interface TDGWTServiceAsync {
|
|||
|
||||
void getUriFromResolver(UriResolverSession uriResolverSession,
|
||||
AsyncCallback<String> callback);
|
||||
|
||||
|
||||
void getVREFolderIdByScope(AsyncCallback<String> callback);
|
||||
|
||||
// PeriodDataType
|
||||
void getPeriodDataTypes(AsyncCallback<ArrayList<PeriodDataType>> callback);
|
||||
|
||||
|
|
|
@ -426,6 +426,35 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVREFolderIdByScope() throws TDGWTServiceException {
|
||||
HttpSession session = null;
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
FilesStorage filesStorage = new FilesStorage();
|
||||
String folderId=filesStorage.getVREFolderIdByScope(aslSession.getUsername(),
|
||||
aslSession.getScope());
|
||||
|
||||
return folderId;
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
throw e;
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
ResourceBundle messages = getResourceBundle(session);
|
||||
throw new TDGWTServiceException(
|
||||
messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
|
||||
} catch (Throwable e) {
|
||||
logger.error("getValueDataFormats(): " + e.getLocalizedMessage(), e);
|
||||
throw new TDGWTServiceException(
|
||||
"Error retrieving value data formats: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
|
@ -3928,7 +3957,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
SessionUtil.setSDMXImportSession(session, sdmxImportSession);
|
||||
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
@ -4260,15 +4289,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
|
||||
|
||||
fileUploadSession = SessionUtil.getCSVFileUploadSession(session);
|
||||
if (fileUploadSession == null) {
|
||||
throw new TDGWTServiceException(
|
||||
"Error retrieving the fileUploadSession: null");
|
||||
}
|
||||
|
||||
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
@ -5293,7 +5320,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
logger.debug("Start JSON Export");
|
||||
|
||||
|
||||
TRId trId = SessionUtil.getTRId(session);
|
||||
if (trId == null) {
|
||||
throw new TDGWTServiceException(
|
||||
|
@ -5435,7 +5462,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
SessionUtil.setAddColumnSession(session, addColumnSession);
|
||||
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
@ -5582,7 +5609,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
SessionUtil.setFilterColumnSession(session, filterColumnSession);
|
||||
|
||||
|
||||
if (filterColumnSession == null) {
|
||||
logger.error("FilterColumnSession is null");
|
||||
throw new TDGWTServiceException(
|
||||
|
@ -5829,7 +5856,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
logger.debug("UserToken: " + token);
|
||||
SessionUtil.setChangeTableTypeSession(session,
|
||||
changeTableTypeSession);
|
||||
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
@ -6007,7 +6034,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
SessionUtil.setDeleteRowsSession(session, deleteRowsSession);
|
||||
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
@ -6974,7 +7001,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
SessionUtil.setReplaceColumnSession(session, replaceColumnSession);
|
||||
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
@ -7043,10 +7070,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
|
||||
|
||||
SessionUtil.setReplaceBatchColumnSession(session,
|
||||
replaceBatchColumnSession);
|
||||
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
@ -7725,9 +7752,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
|
||||
|
||||
SessionUtil.setEditRowSession(session, editRowSession);
|
||||
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
@ -8206,7 +8233,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
SessionUtil.setMergeColumnSession(session, mergeColumnSession);
|
||||
|
||||
|
||||
if (mergeColumnSession == null) {
|
||||
logger.error("MergeColumnSession is null");
|
||||
throw new TDGWTServiceException(
|
||||
|
@ -8300,7 +8327,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
|
||||
|
||||
Workspace w = null;
|
||||
WorkspaceItem wi = null;
|
||||
|
||||
|
@ -8519,7 +8546,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
|
||||
|
||||
SessionUtil.setGroupBySession(session, groupBySession);
|
||||
logger.debug("StartGroupBy: " + groupBySession);
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
|
@ -8788,7 +8815,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
SessionUtil.setUnionSession(session, unionSession);
|
||||
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
@ -8913,7 +8940,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
throws TDGWTServiceException {
|
||||
HttpSession session = null;
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
|
@ -8985,7 +9012,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
|
||||
|
||||
SessionUtil.setStatisticalOperationSession(session,
|
||||
statisticalOperationSession);
|
||||
|
||||
|
|
|
@ -10,9 +10,14 @@ import java.net.URL;
|
|||
import java.net.URLConnection;
|
||||
|
||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||
import org.gcube.common.homelibrary.util.WorkspaceUtil;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
|
@ -138,12 +143,12 @@ public class FilesStorage {
|
|||
try {
|
||||
|
||||
org.gcube.common.homelibrary.home.workspace.folder.items.File gcubeItem = ((org.gcube.common.homelibrary.home.workspace.folder.items.File) wi);
|
||||
//SMPUrl smsHome = new SMPUrl(gcubeItem.getPublicLink());
|
||||
URL url=new URL(gcubeItem.getPublicLink());
|
||||
|
||||
// SMPUrl smsHome = new SMPUrl(gcubeItem.getPublicLink());
|
||||
URL url = new URL(gcubeItem.getPublicLink());
|
||||
|
||||
logger.debug("smsHome: [host:" + url.getHost() + " path:"
|
||||
+ url.getPath() + " ref:" + url.getRef()
|
||||
+ " userinfo:" + url.getUserInfo() + " ]");
|
||||
+ url.getPath() + " ref:" + url.getRef() + " userinfo:"
|
||||
+ url.getUserInfo() + " ]");
|
||||
URLConnection uc = null;
|
||||
uc = (URLConnection) url.openConnection();
|
||||
is = uc.getInputStream();
|
||||
|
@ -193,13 +198,12 @@ public class FilesStorage {
|
|||
try {
|
||||
|
||||
org.gcube.common.homelibrary.home.workspace.folder.items.File gcubeItem = ((org.gcube.common.homelibrary.home.workspace.folder.items.File) wi);
|
||||
//SMPUrl smsHome = new SMPUrl(gcubeItem.getPublicLink());
|
||||
URL url=new URL(gcubeItem.getPublicLink());
|
||||
// SMPUrl smsHome = new SMPUrl(gcubeItem.getPublicLink());
|
||||
URL url = new URL(gcubeItem.getPublicLink());
|
||||
|
||||
|
||||
logger.debug("smsHome: [host:" + url.getHost() + " path:"
|
||||
+ url.getPath() + " ref:" + url.getRef()
|
||||
+ " userinfo:" + url.getUserInfo() + " ]");
|
||||
+ url.getPath() + " ref:" + url.getRef() + " userinfo:"
|
||||
+ url.getUserInfo() + " ]");
|
||||
URLConnection uc = null;
|
||||
uc = (URLConnection) url.openConnection();
|
||||
is = uc.getInputStream();
|
||||
|
@ -230,12 +234,12 @@ public class FilesStorage {
|
|||
InputStream is = null;
|
||||
try {
|
||||
|
||||
//SMPUrl smsHome = new SMPUrl(uri);
|
||||
URL url=new URL(uri);
|
||||
|
||||
// SMPUrl smsHome = new SMPUrl(uri);
|
||||
URL url = new URL(uri);
|
||||
|
||||
logger.debug("smsHome: [host:" + url.getHost() + " path:"
|
||||
+ url.getPath() + " ref:" + url.getRef()
|
||||
+ " userinfo:" + url.getUserInfo() + " ]");
|
||||
+ url.getPath() + " ref:" + url.getRef() + " userinfo:"
|
||||
+ url.getUserInfo() + " ]");
|
||||
URLConnection uc = null;
|
||||
uc = (URLConnection) url.openConnection();
|
||||
is = uc.getInputStream();
|
||||
|
@ -267,12 +271,12 @@ public class FilesStorage {
|
|||
InputStream is = null;
|
||||
try {
|
||||
|
||||
//SMPUrl smsHome = new SMPUrl(uri);
|
||||
URL url=new URL(uri);
|
||||
|
||||
// SMPUrl smsHome = new SMPUrl(uri);
|
||||
URL url = new URL(uri);
|
||||
|
||||
logger.debug("smsHome: [host:" + url.getHost() + " path:"
|
||||
+ url.getPath() + " ref:" + url.getRef()
|
||||
+ " userinfo:" + url.getUserInfo() + " ]");
|
||||
+ url.getPath() + " ref:" + url.getRef() + " userinfo:"
|
||||
+ url.getUserInfo() + " ]");
|
||||
|
||||
URLConnection uc = null;
|
||||
uc = (URLConnection) url.openConnection();
|
||||
|
@ -327,7 +331,8 @@ public class FilesStorage {
|
|||
+ ", uniqueName: " + uniqueName + ", description: "
|
||||
+ item_description + ", mimetype: " + item_mimetype
|
||||
+ ", StorageId: " + storageId + "]");
|
||||
WorkspaceUtil.createExternalFile(folder, uniqueName,item_description, item_mimetype, storageId);
|
||||
WorkspaceUtil.createExternalFile(folder, uniqueName,
|
||||
item_description, item_mimetype, storageId);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error creating item on workspace", e);
|
||||
|
@ -339,4 +344,33 @@ public class FilesStorage {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user
|
||||
* @param scope
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public String getVREFolderIdByScope(String user, String scope)
|
||||
throws TDGWTServiceException {
|
||||
|
||||
try {
|
||||
|
||||
Workspace ws = HomeLibrary.getUserWorkspace(user);
|
||||
WorkspaceSharedFolder folder = ws.getVREFolderByScope(scope);
|
||||
if(folder!=null){
|
||||
return folder.getId();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error retrieving VRE folder by scope!", e);
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException(
|
||||
"Error retrieving VRE folder by scope: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue