Create Multi Tab Management
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@100720 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
13316a1efa
commit
7185351ccc
|
@ -63,6 +63,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.union.UnionSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.user.UserInfo;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
|
@ -94,7 +95,7 @@ public interface TDGWTService extends RemoteService {
|
|||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public String hello() throws TDGWTServiceException;
|
||||
public UserInfo hello() throws TDGWTServiceException;
|
||||
|
||||
// TabularResource
|
||||
/**
|
||||
|
@ -106,7 +107,17 @@ public interface TDGWTService extends RemoteService {
|
|||
public TRId getCurrentTRId() throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Get informations on the current tabular resource
|
||||
* Get information on the current tabular resource don't call service
|
||||
*
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public TabResource getInSessionTabResourceInfo() throws TDGWTServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* Get informations on the current tabular resource call service
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
|
@ -216,15 +227,6 @@ public interface TDGWTService extends RemoteService {
|
|||
public ColumnData getConnection(RefColumn refColumn)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Close current tabular resource
|
||||
*
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public TRId closeTabularResource() throws TDGWTServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* Close All Tabular Resources
|
||||
*
|
||||
|
@ -233,6 +235,34 @@ public interface TDGWTService extends RemoteService {
|
|||
*/
|
||||
public void closeAllTabularResources() throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Close Tabular Resource with TRId equals to closeTRId
|
||||
* and open if not null that with TRId equals to openTRId
|
||||
*
|
||||
* @param openTRId
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public void closeTabularResourceAndOpen(TRId openTRId, TRId closeTRId)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Close Tabular Resource with TRId equals to closeTRId
|
||||
*
|
||||
* @param closeTRId
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public void closeTabularResource(TRId closeTRId)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Set Current Tabular Resource that passed as parameter if not null
|
||||
*
|
||||
*
|
||||
* @param activeTRId
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public void setActiveTabularResource(TRId activeTRId)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
// Task
|
||||
/**
|
||||
|
@ -315,7 +345,7 @@ public interface TDGWTService extends RemoteService {
|
|||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public ShareInfo getShareInfo(TRId trId) throws TDGWTServiceException;
|
||||
//public ShareInfo getShareInfo(TRId trId) throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Share sabular resource
|
||||
|
|
|
@ -62,6 +62,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.union.UnionSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.user.UserInfo;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -79,7 +80,7 @@ public interface TDGWTServiceAsync {
|
|||
public static TDGWTServiceAsync INSTANCE = (TDGWTServiceAsync) GWT
|
||||
.create(TDGWTService.class);
|
||||
|
||||
void hello(AsyncCallback<String> callback);
|
||||
void hello(AsyncCallback<UserInfo> callback);
|
||||
|
||||
// TabularResource
|
||||
void getCurrentTRId(AsyncCallback<TRId> callback);
|
||||
|
@ -91,6 +92,8 @@ public interface TDGWTServiceAsync {
|
|||
|
||||
void isTabularResourceValid(TRId trId, AsyncCallback<Boolean> callback);
|
||||
|
||||
void getInSessionTabResourceInfo(AsyncCallback<TabResource> callback);
|
||||
|
||||
void getTabResourceInformation(AsyncCallback<TabResource> callback);
|
||||
|
||||
void getTabResourceInformation(TRId trId,
|
||||
|
@ -132,10 +135,15 @@ public interface TDGWTServiceAsync {
|
|||
|
||||
void getConnection(RefColumn refColumn, AsyncCallback<ColumnData> callback);
|
||||
|
||||
void closeTabularResource(AsyncCallback<TRId> callback);
|
||||
|
||||
void closeAllTabularResources(AsyncCallback<Void> callback);
|
||||
|
||||
void closeTabularResourceAndOpen(TRId openTRId, TRId closeTRId, AsyncCallback<Void> callback);
|
||||
|
||||
void closeTabularResource(TRId closeTRId, AsyncCallback<Void> callback);
|
||||
|
||||
void setActiveTabularResource(TRId activeTRId,AsyncCallback<Void> callback);
|
||||
|
||||
// Task
|
||||
void startTaskResubmit(TaskResubmitSession taskResubmitSession,
|
||||
AsyncCallback<String> callback);
|
||||
|
@ -160,7 +168,7 @@ public interface TDGWTServiceAsync {
|
|||
void startDiscard(TRId trId, AsyncCallback<String> callback);
|
||||
|
||||
// Share
|
||||
void getShareInfo(TRId trId, AsyncCallback<ShareInfo> callback);
|
||||
//void getShareInfo(TRId trId, AsyncCallback<ShareInfo> callback);
|
||||
|
||||
void setShare(ShareInfo shareInfo, AsyncCallback<Void> callback);
|
||||
|
||||
|
|
|
@ -180,7 +180,8 @@ public class SessionUtil {
|
|||
}
|
||||
|
||||
//
|
||||
public static ArrayList<TabResource> getCurrentTabularResourcesOpen(HttpSession httpSession) {
|
||||
public static ArrayList<TabResource> getCurrentTabularResourcesOpen(
|
||||
HttpSession httpSession) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<TabResource> currentTROpen = (ArrayList<TabResource>) httpSession
|
||||
.getAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN);
|
||||
|
@ -198,46 +199,67 @@ public class SessionUtil {
|
|||
if (t != null)
|
||||
httpSession
|
||||
.removeAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN);
|
||||
httpSession.setAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN,
|
||||
currentTROpen);
|
||||
httpSession.setAttribute(
|
||||
SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN, currentTROpen);
|
||||
|
||||
}
|
||||
|
||||
public static void addToCurrentTabularResourcesOpen(HttpSession httpSession,
|
||||
TabResource tabResource){
|
||||
public static void addToCurrentTabularResourcesOpen(
|
||||
HttpSession httpSession, TabResource tabResource) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<TabResource> t = (ArrayList<TabResource>) httpSession
|
||||
.getAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN);
|
||||
if (t != null) {
|
||||
for (TabResource tr : t) {
|
||||
if (tr.getTrId().getId()
|
||||
.compareTo(tabResource.getTrId().getId()) == 0) {
|
||||
t.remove(tr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
t.add(tabResource);
|
||||
httpSession.setAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN,
|
||||
t);
|
||||
httpSession
|
||||
.removeAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN);
|
||||
} else {
|
||||
t = new ArrayList<TabResource>();
|
||||
t.add(tabResource);
|
||||
httpSession.setAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN,
|
||||
t);
|
||||
}
|
||||
httpSession.setAttribute(
|
||||
SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN, t);
|
||||
}
|
||||
|
||||
public static void removeFromCurrentTabularResourcesOpen(HttpSession httpSession,
|
||||
TabResource tabResource){
|
||||
public static void removeFromCurrentTabularResourcesOpen(
|
||||
HttpSession httpSession, TRId trId) {
|
||||
if (trId != null && trId.getId() != null & !trId.getId().isEmpty()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<TabResource> t = (ArrayList<TabResource>) httpSession
|
||||
.getAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN);
|
||||
if (t != null && !t.isEmpty()) {
|
||||
t.remove(tabResource);
|
||||
httpSession.setAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN,
|
||||
for (TabResource tabR : t) {
|
||||
if (tabR.getTrId().getId().compareTo(trId.getId()) == 0) {
|
||||
|
||||
t.remove(tabR);
|
||||
httpSession
|
||||
.removeAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN);
|
||||
httpSession
|
||||
.setAttribute(
|
||||
SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN,
|
||||
t);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeAllFromCurrentTabularResourcesOpen(HttpSession httpSession){
|
||||
httpSession.removeAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN);
|
||||
public static void removeAllFromCurrentTabularResourcesOpen(
|
||||
HttpSession httpSession) {
|
||||
httpSession
|
||||
.removeAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN);
|
||||
}
|
||||
|
||||
public static TabResource getFirstFromCurrentTabularResourcesOpen(HttpSession httpSession) {
|
||||
public static TabResource getFirstFromCurrentTabularResourcesOpen(
|
||||
HttpSession httpSession) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<TabResource> currentTROpen = (ArrayList<TabResource>) httpSession
|
||||
.getAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN);
|
||||
|
@ -249,6 +271,26 @@ public class SessionUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static TabResource getFromCurrentTabularResourcesOpen(
|
||||
HttpSession httpSession, TRId trId) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<TabResource> currentTROpen = (ArrayList<TabResource>) httpSession
|
||||
.getAttribute(SessionConstants.CURRENT_TABULAR_RESOURCES_OPEN);
|
||||
if (currentTROpen == null || currentTROpen.isEmpty()) {
|
||||
logger.error("No CURRENT_TABULAR_RESOURCES_OPEN");
|
||||
} else {
|
||||
for (TabResource tabResource : currentTROpen) {
|
||||
if (tabResource != null
|
||||
&& tabResource.getTrId() != null
|
||||
&& tabResource.getTrId().getId()
|
||||
.compareTo(trId.getId()) == 0) {
|
||||
return tabResource;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//
|
||||
public static TabResource getSDMXImportTabResource(HttpSession httpSession) {
|
||||
|
|
|
@ -242,6 +242,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.union.UnionSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.user.UserInfo;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.RelationshipData;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
|
@ -278,11 +279,14 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String hello() throws TDGWTServiceException {
|
||||
public UserInfo hello() throws TDGWTServiceException {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String user = aslSession.getUsername();
|
||||
return user;
|
||||
UserInfo userInfo = new UserInfo(aslSession.getUsername(),
|
||||
aslSession.getGroupId(), aslSession.getGroupName(),
|
||||
aslSession.getScope(), aslSession.getScopeName(),
|
||||
aslSession.getUserEmailAddress(), aslSession.getUserFullName());
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -384,24 +388,39 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public TRId closeTabularResource() throws TDGWTServiceException {
|
||||
public void closeTabularResourceAndOpen(TRId openTRId, TRId closeTRId)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
logger.debug("closeTabularResourceAndOpen(): Open[" + openTRId
|
||||
+ "], Close[" + closeTRId + "]");
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getAslSession(session);
|
||||
TabResource currentTR=SessionUtil.getTabResource(session);
|
||||
SessionUtil.removeFromCurrentTabularResourcesOpen(session, currentTR);
|
||||
TabResource firstTR=SessionUtil.getFirstFromCurrentTabularResourcesOpen(session);
|
||||
if(firstTR==null){
|
||||
SessionUtil.removeFromCurrentTabularResourcesOpen(session,
|
||||
closeTRId);
|
||||
|
||||
if (openTRId != null) {
|
||||
TabResource tabResource = SessionUtil
|
||||
.getFromCurrentTabularResourcesOpen(session, openTRId);
|
||||
if (tabResource != null) {
|
||||
SessionUtil.setTabResource(session, tabResource);
|
||||
SessionUtil.setTRId(session, tabResource.getTrId());
|
||||
} else {
|
||||
logger.error("Set Active Tabular Resource failed, no valid id!: Open["
|
||||
+ openTRId + ", " + tabResource);
|
||||
throw new TDGWTServiceException(
|
||||
"Set Active Tabular Resource failed, no valid id!: Open["
|
||||
+ openTRId + ", " + tabResource);
|
||||
}
|
||||
} else {
|
||||
SessionUtil.setTabResource(session, null);
|
||||
SessionUtil.setTRId(session, null);
|
||||
return null;
|
||||
} else {
|
||||
SessionUtil.setTabResource(session, firstTR);
|
||||
SessionUtil.setTRId(session, firstTR.getTrId());
|
||||
return firstTR.getTrId();
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
throw e;
|
||||
|
@ -417,6 +436,100 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeTabularResource(TRId closeTRId)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
logger.debug("closeTabularResource(): " + closeTRId);
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getAslSession(session);
|
||||
|
||||
SessionUtil.removeFromCurrentTabularResourcesOpen(session,
|
||||
closeTRId);
|
||||
|
||||
SessionUtil.setTabResource(session, null);
|
||||
SessionUtil.setTRId(session, null);
|
||||
|
||||
return;
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
throw e;
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException(
|
||||
"Security exception, you haven't rights!");
|
||||
} catch (Throwable e) {
|
||||
logger.error("getCurrentTRID(): " + e.getLocalizedMessage(), e);
|
||||
throw new TDGWTServiceException("Error retrieving TR id: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setActiveTabularResource(TRId activeTRId)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
logger.debug("setActiveTabularResource(): " + activeTRId);
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getAslSession(session);
|
||||
TabResource tabResource = SessionUtil
|
||||
.getFromCurrentTabularResourcesOpen(session, activeTRId);
|
||||
if (tabResource != null) {
|
||||
SessionUtil.setTabResource(session, tabResource);
|
||||
SessionUtil.setTRId(session, tabResource.getTrId());
|
||||
} else {
|
||||
logger.error("Set Active Tabular Resource failed, no valid id!: "
|
||||
+ activeTRId);
|
||||
throw new TDGWTServiceException(
|
||||
"Set Active Tabular Resource failed, no valid id!");
|
||||
}
|
||||
return;
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
throw e;
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException(
|
||||
"Security exception, you haven't rights!");
|
||||
} catch (Throwable e) {
|
||||
logger.error("getCurrentTRID(): " + e.getLocalizedMessage(), e);
|
||||
throw new TDGWTServiceException("Error retrieving TR id: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabResource getInSessionTabResourceInfo()
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
|
||||
SessionUtil.getAslSession(session);
|
||||
|
||||
TabResource currentTR = SessionUtil.getTabResource(session);
|
||||
|
||||
return currentTR;
|
||||
} catch (TDGWTServiceException e) {
|
||||
throw e;
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException(
|
||||
"Security exception, you haven't rights!");
|
||||
} catch (Throwable e) {
|
||||
logger.error(
|
||||
"Error setting TabResource parameter: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
throw new TDGWTServiceException(
|
||||
"Error setting TabResource parameter: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -444,10 +557,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
logger.debug("Current TRId: " + currentTR.getTrId());
|
||||
|
||||
ArrayList<TRMetadata> trMetadatas = getTRMetadata(currentTR
|
||||
.getTrId());
|
||||
updateTabResourceInformation(currentTR, trMetadatas);
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
@ -456,12 +565,17 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
.getTabularResource(new TabularResourceId(Long
|
||||
.valueOf(currentTR.getTrId().getId())));
|
||||
|
||||
ArrayList<TRMetadata> trMetadatas = getTRMetadata(tr);
|
||||
updateTabResourceInformation(currentTR, trMetadatas);
|
||||
|
||||
currentTR.setDate(sdf.format(tr.getCreationDate().getTime()));
|
||||
currentTR.setValid(tr.isValid());
|
||||
currentTR.setFinalized(tr.isFinalized());
|
||||
currentTR.setLocked(tr.isLocked());
|
||||
Contacts owner = new Contacts("", tr.getOwner(), false);
|
||||
currentTR.setOwner(owner);
|
||||
currentTR.setContacts(retrieveShareInfo(tr));
|
||||
|
||||
SessionUtil.setTabResource(session, currentTR);
|
||||
logger.debug("GetTabResourceInformation() updated information:"
|
||||
+ currentTR.toString());
|
||||
|
@ -504,10 +618,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
TabResource currentTR = new TabResource();
|
||||
currentTR.setTrId(trId);
|
||||
|
||||
ArrayList<TRMetadata> trMetadatas = getTRMetadata(currentTR
|
||||
.getTrId());
|
||||
updateTabResourceInformation(currentTR, trMetadatas);
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
@ -517,12 +627,17 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
.valueOf(currentTR.getTrId().getId())));
|
||||
logger.debug("GetTabResourceInformation() TR on service: " + tr);
|
||||
|
||||
ArrayList<TRMetadata> trMetadatas = getTRMetadata(tr);
|
||||
updateTabResourceInformation(currentTR, trMetadatas);
|
||||
|
||||
currentTR.setDate(sdf.format(tr.getCreationDate().getTime()));
|
||||
currentTR.setValid(tr.isValid());
|
||||
currentTR.setFinalized(tr.isFinalized());
|
||||
currentTR.setLocked(tr.isLocked());
|
||||
Contacts owner = new Contacts("", tr.getOwner(), false);
|
||||
currentTR.setOwner(owner);
|
||||
currentTR.setContacts(retrieveShareInfo(tr));
|
||||
|
||||
logger.debug("GetTabResourceInformation() updated information:"
|
||||
+ currentTR);
|
||||
return currentTR;
|
||||
|
@ -3193,10 +3308,101 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
protected ArrayList<TRMetadata> getTRMetadata(TabularResource tr)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
|
||||
Collection<TabularResourceMetadata<?>> trMetas = tr
|
||||
.getAllMetadata();
|
||||
|
||||
logger.debug("GetTRMetadata size: " + trMetas.size());
|
||||
ArrayList<TRMetadata> listTRMetadata = new ArrayList<TRMetadata>();
|
||||
|
||||
for (TabularResourceMetadata<?> trMetadata : trMetas) {
|
||||
if (trMetadata instanceof org.gcube.data.analysis.tabulardata.service.tabular.metadata.DescriptionMetadata) {
|
||||
TRDescriptionMetadata trDescriptionMetadata = new TRDescriptionMetadata();
|
||||
trDescriptionMetadata
|
||||
.setValue(((org.gcube.data.analysis.tabulardata.service.tabular.metadata.DescriptionMetadata) trMetadata)
|
||||
.getValue());
|
||||
listTRMetadata.add(trDescriptionMetadata);
|
||||
} else {
|
||||
if (trMetadata instanceof org.gcube.data.analysis.tabulardata.service.tabular.metadata.NameMetadata) {
|
||||
TRNameMetadata trNameMetadata = new TRNameMetadata();
|
||||
trNameMetadata
|
||||
.setValue(((org.gcube.data.analysis.tabulardata.service.tabular.metadata.NameMetadata) trMetadata)
|
||||
.getValue());
|
||||
listTRMetadata.add(trNameMetadata);
|
||||
} else {
|
||||
if (trMetadata instanceof AgencyMetadata) {
|
||||
TRAgencyMetadata trAgencyMetadata = new TRAgencyMetadata();
|
||||
trAgencyMetadata
|
||||
.setValue(((AgencyMetadata) trMetadata)
|
||||
.getValue());
|
||||
listTRMetadata.add(trAgencyMetadata);
|
||||
} else {
|
||||
if (trMetadata instanceof RightsMetadata) {
|
||||
TRRightsMetadata trRightsMetadata = new TRRightsMetadata();
|
||||
trRightsMetadata
|
||||
.setValue(((RightsMetadata) trMetadata)
|
||||
.getValue());
|
||||
listTRMetadata.add(trRightsMetadata);
|
||||
} else {
|
||||
if (trMetadata instanceof ValidSinceMetadata) {
|
||||
TRValidSinceMetadata validSinceMetadata = new TRValidSinceMetadata();
|
||||
Calendar cal = ((ValidSinceMetadata) trMetadata)
|
||||
.getValue();
|
||||
validSinceMetadata.setValue(sdfDate
|
||||
.format(cal.getTime()));
|
||||
listTRMetadata.add(validSinceMetadata);
|
||||
} else {
|
||||
if (trMetadata instanceof ValidUntilMetadata) {
|
||||
TRValidUntilMetadata validUntilMetadata = new TRValidUntilMetadata();
|
||||
Calendar cal = ((ValidUntilMetadata) trMetadata)
|
||||
.getValue();
|
||||
validUntilMetadata.setValue(sdfDate
|
||||
.format(cal.getTime()));
|
||||
listTRMetadata.add(validUntilMetadata);
|
||||
} else {
|
||||
if (trMetadata instanceof LicenceMetadata) {
|
||||
TRLicenceMetadata licenceMetadata = new TRLicenceMetadata();
|
||||
licenceMetadata
|
||||
.setValue(((LicenceMetadata) trMetadata)
|
||||
.getValue()
|
||||
.toString());
|
||||
listTRMetadata.add(licenceMetadata);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug("GetTRMetadata retrived: " + listTRMetadata.size());
|
||||
logger.debug("GetTRMetadata: [" + listTRMetadata + "]");
|
||||
return listTRMetadata;
|
||||
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException(
|
||||
"Security exception, you haven't rights!");
|
||||
} catch (Throwable e) {
|
||||
logger.error(
|
||||
"Error in getTRMetadata(): " + e.getLocalizedMessage(), e);
|
||||
throw new TDGWTServiceException("Error in getTRMetadata(): "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<TRMetadata> getTRMetadata(TRId trId)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
|
@ -4588,10 +4794,46 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
protected ArrayList<Contacts> retrieveShareInfo(TabularResource tr)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
|
||||
ArrayList<Contacts> contacts = new ArrayList<Contacts>();
|
||||
List<String> sharedWithUsers = tr.getSharedWithUsers();
|
||||
logger.debug("Shared with Users: " + sharedWithUsers);
|
||||
if (sharedWithUsers != null) {
|
||||
for (String user : sharedWithUsers) {
|
||||
Contacts cont = new Contacts(user, user, false);
|
||||
contacts.add(cont);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> sharedWithGroups = tr.getSharedWithGroup();
|
||||
logger.debug("Shared with Groups: " + sharedWithUsers);
|
||||
if (sharedWithGroups != null) {
|
||||
for (String group : sharedWithGroups) {
|
||||
Contacts cont = new Contacts(group, group, true);
|
||||
contacts.add(cont);
|
||||
}
|
||||
}
|
||||
return contacts;
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException(
|
||||
"Security exception, you haven't rights!");
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error in retrieveShareInfo: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
/*
|
||||
@Override
|
||||
public ShareInfo getShareInfo(TRId trId) throws TDGWTServiceException {
|
||||
try {
|
||||
|
@ -4640,7 +4882,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
throw new TDGWTServiceException("Error in getShareInfo: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -6747,12 +6989,15 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
checkTabularResourceLocked(service, trId);
|
||||
TabularResourceId tabularResourceId=new TabularResourceId(Long.parseLong(trId.getId()));
|
||||
TabularResourceId tabularResourceId = new TabularResourceId(
|
||||
Long.parseLong(trId.getId()));
|
||||
|
||||
List<ResourceDescriptor> resources=service.getResources(tabularResourceId);
|
||||
List<ResourceDescriptor> resources = service
|
||||
.getResources(tabularResourceId);
|
||||
ResourceTDCreator resourceTDCreator = new ResourceTDCreator();
|
||||
|
||||
ArrayList<ResourceTDDescriptor> resourcesTD=resourceTDCreator.createResourcesDescriptorTD(resources);
|
||||
ArrayList<ResourceTDDescriptor> resourcesTD = resourceTDCreator
|
||||
.createResourcesDescriptorTD(resources);
|
||||
|
||||
return resourcesTD;
|
||||
} catch (TDGWTServiceException e) {
|
||||
|
@ -6762,16 +7007,16 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
throw new TDGWTServiceException(
|
||||
"Security exception, you haven't rights!");
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error retrieving resources: " + e.getLocalizedMessage(),
|
||||
e);
|
||||
logger.error(
|
||||
"Error retrieving resources: " + e.getLocalizedMessage(), e);
|
||||
throw new TDGWTServiceException("Error retrieving resources: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ResourceTDDescriptor> getResourcesTDByType(TRId trId, ResourceTDType resourceTDType)
|
||||
throws TDGWTServiceException {
|
||||
public ArrayList<ResourceTDDescriptor> getResourcesTDByType(TRId trId,
|
||||
ResourceTDType resourceTDType) throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
@ -6780,13 +7025,17 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
checkTabularResourceLocked(service, trId);
|
||||
TabularResourceId tabularResourceId=new TabularResourceId(Long.parseLong(trId.getId()));
|
||||
ResourceType resourceType=ResourceTDTypeMap.getResourceType(resourceTDType);
|
||||
TabularResourceId tabularResourceId = new TabularResourceId(
|
||||
Long.parseLong(trId.getId()));
|
||||
ResourceType resourceType = ResourceTDTypeMap
|
||||
.getResourceType(resourceTDType);
|
||||
|
||||
List<ResourceDescriptor> resources=service.getResourcesByType(tabularResourceId,resourceType);
|
||||
List<ResourceDescriptor> resources = service.getResourcesByType(
|
||||
tabularResourceId, resourceType);
|
||||
ResourceTDCreator resourceTDCreator = new ResourceTDCreator();
|
||||
|
||||
ArrayList<ResourceTDDescriptor> resourcesTD=resourceTDCreator.createResourcesDescriptorTD(resources);
|
||||
ArrayList<ResourceTDDescriptor> resourcesTD = resourceTDCreator
|
||||
.createResourcesDescriptorTD(resources);
|
||||
|
||||
return resourcesTD;
|
||||
} catch (TDGWTServiceException e) {
|
||||
|
@ -6796,9 +7045,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
throw new TDGWTServiceException(
|
||||
"Security exception, you haven't rights!");
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error retrieving resources by type: " + e.getLocalizedMessage(),
|
||||
e);
|
||||
throw new TDGWTServiceException("Error retrieving resources by type: "
|
||||
logger.error(
|
||||
"Error retrieving resources by type: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
throw new TDGWTServiceException(
|
||||
"Error retrieving resources by type: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
@ -6816,7 +7067,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
checkTabularResourceLocked(service, mapCreationSession.getTrId());
|
||||
|
||||
|
||||
OpExecution4MapCreation opEx = new OpExecution4MapCreation(service,
|
||||
mapCreationSession);
|
||||
OpExecutionDirector director = new OpExecutionDirector();
|
||||
|
@ -6854,6 +7104,4 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.shared.tr;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.share.Contacts;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
@ -26,6 +27,7 @@ public class TabResource implements Serializable {
|
|||
protected String validUntilTo;
|
||||
protected String licence;
|
||||
protected Contacts owner;
|
||||
protected ArrayList<Contacts> contacts;
|
||||
protected boolean valid;
|
||||
protected boolean finalized;
|
||||
protected boolean locked;
|
||||
|
@ -175,15 +177,25 @@ public class TabResource implements Serializable {
|
|||
this.locked = locked;
|
||||
}
|
||||
|
||||
public ArrayList<Contacts> getContacts() {
|
||||
return contacts;
|
||||
}
|
||||
|
||||
public void setContacts(ArrayList<Contacts> contacts) {
|
||||
this.contacts = contacts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TabResource [trId=" + trId + ", id=" + id + ", name=" + name
|
||||
+ ", description=" + description + ", agency=" + agency
|
||||
+ ", date=" + date + ", right=" + right + ", validFrom="
|
||||
+ validFrom + ", validUntilTo=" + validUntilTo + ", licence="
|
||||
+ licence + ", owner=" + owner + ", valid=" + valid
|
||||
+ ", finalized=" + finalized + ", locked=" + locked + "]";
|
||||
+ licence + ", owner=" + owner + ", contacts=" + contacts
|
||||
+ ", valid=" + valid + ", finalized=" + finalized + ", locked="
|
||||
+ locked + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ public class UserInfo implements Serializable {
|
|||
private static final long serialVersionUID = -2826549639677017234L;
|
||||
|
||||
private String username;
|
||||
private int groupId;
|
||||
private long groupId;
|
||||
private String groupName;
|
||||
private String scope;
|
||||
private String scopeName;
|
||||
|
@ -34,7 +34,7 @@ public class UserInfo implements Serializable {
|
|||
* @param userEmailAddress
|
||||
* @param userFullName
|
||||
*/
|
||||
public UserInfo(String username, int groupId, String groupName,
|
||||
public UserInfo(String username, long groupId, String groupName,
|
||||
String scope, String scopeName, String userEmailAddress,
|
||||
String userFullName) {
|
||||
super();
|
||||
|
@ -55,11 +55,11 @@ public class UserInfo implements Serializable {
|
|||
this.username = username;
|
||||
}
|
||||
|
||||
public int getGroupId() {
|
||||
public long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(int groupId) {
|
||||
public void setGroupId(long groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue