Added Share
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@92866 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
bb43f44878
commit
745a22a457
|
@ -18,6 +18,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportMonitor;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.share.ShareInfo;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||
|
@ -158,7 +159,26 @@ public interface TDGWTService extends RemoteService {
|
|||
*/
|
||||
public ArrayList<TRMetadata> getTRMetadata(TRId trId)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
|
||||
//Share
|
||||
/**
|
||||
* Retrieves information sharing on the tabular resource
|
||||
*
|
||||
* @param trId
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public ShareInfo getShareInfo(TRId trId) throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Share sabular resource
|
||||
*
|
||||
* @param shareInfo
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public void setShare(ShareInfo shareInfo) throws TDGWTServiceException;
|
||||
|
||||
// Open
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportMonitor;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.share.ShareInfo;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||
|
@ -62,7 +63,6 @@ public interface TDGWTServiceAsync {
|
|||
void hello(AsyncCallback<String> callback);
|
||||
|
||||
void createTabularResource(TabResource tabResource,AsyncCallback<TabResource> callback);
|
||||
|
||||
|
||||
void getTabResourceInformation(AsyncCallback<TabResource> callback);
|
||||
|
||||
|
@ -93,6 +93,11 @@ public interface TDGWTServiceAsync {
|
|||
void removeTabularResource(TRId trId, AsyncCallback<Void> callback);
|
||||
|
||||
|
||||
//Share
|
||||
void getShareInfo(TRId trId, AsyncCallback<ShareInfo> callback);
|
||||
|
||||
void setShare(ShareInfo shareInfo, AsyncCallback<Void> callback);
|
||||
|
||||
//CodelistPagingLoaded
|
||||
void setCodelistsPagingLoader(AsyncCallback<Void> callback);
|
||||
|
||||
|
|
|
@ -96,6 +96,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportMonitor;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.share.Contacts;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.share.ShareInfo;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||
|
@ -2753,7 +2755,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
return invocation;
|
||||
}
|
||||
|
||||
|
||||
protected OperationExecution retrieveOperationExecution(
|
||||
TabularDataService service, DuplicatesSession duplicatesSession)
|
||||
throws TDGWTServiceException {
|
||||
|
@ -2764,12 +2765,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
logger.debug(duplicatesSession.toString());
|
||||
OperationDefinition operationDefinition;
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
|
||||
ArrayList<ColumnData> cols = duplicatesSession.getColumns();
|
||||
logger.debug("ReferenceColumn To Set: " + cols);
|
||||
ArrayList<ColumnReference> columnReferences=new ArrayList<ColumnReference>();
|
||||
|
||||
for(ColumnData col:cols){
|
||||
ArrayList<ColumnReference> columnReferences = new ArrayList<ColumnReference>();
|
||||
|
||||
for (ColumnData col : cols) {
|
||||
ColumnLocalId cId = new ColumnLocalId(col.getColumnId());
|
||||
TRId trId = col.getTrId();
|
||||
logger.debug("trID: " + trId);
|
||||
|
@ -2778,31 +2779,35 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
ColumnReference columnReference = new ColumnReference(tId, cId);
|
||||
columnReferences.add(columnReference);
|
||||
}
|
||||
|
||||
|
||||
switch (duplicatesSession.getDuplicateOp()) {
|
||||
case VALIDATE:
|
||||
operationDefinition = OperationDefinitionMap.map(
|
||||
OperationsId.DuplicateTupleValidation.toString(), capabilities);
|
||||
OperationsId.DuplicateTupleValidation.toString(),
|
||||
capabilities);
|
||||
|
||||
map.put(Constants.PARAMETER_KEY, columnReferences);
|
||||
|
||||
invocation = new OperationExecution(operationDefinition.getOperationId(), map);
|
||||
invocation = new OperationExecution(
|
||||
operationDefinition.getOperationId(), map);
|
||||
|
||||
break;
|
||||
case DELETE:
|
||||
operationDefinition = OperationDefinitionMap.map(
|
||||
OperationsId.RemoveDuplicateTuples.toString(), capabilities);
|
||||
operationDefinition = OperationDefinitionMap
|
||||
.map(OperationsId.RemoveDuplicateTuples.toString(),
|
||||
capabilities);
|
||||
|
||||
map.put(Constants.PARAMETER_KEY, columnReferences);
|
||||
|
||||
invocation = new OperationExecution(operationDefinition.getOperationId(), map);
|
||||
invocation = new OperationExecution(
|
||||
operationDefinition.getOperationId(), map);
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
return invocation;
|
||||
}
|
||||
|
||||
|
@ -3853,4 +3858,63 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShareInfo getShareInfo(TRId trId) throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
TabResource tabResource = getTabResourceInformation(trId);
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
TabularResourceId serviceTR = new TabularResourceId(
|
||||
Long.valueOf(tabResource.getTrId().getId()));
|
||||
|
||||
TabularResource tr = service.getTabularResource(serviceTR);
|
||||
List<String> sharedWith = tr.getSharedWith();
|
||||
ArrayList<Contacts> contacts = new ArrayList<Contacts>();
|
||||
for (String user : sharedWith) {
|
||||
Contacts cont = new Contacts(null, user, false);
|
||||
contacts.add(cont);
|
||||
}
|
||||
|
||||
ShareInfo shareInfo = new ShareInfo(tabResource, contacts);
|
||||
return shareInfo;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error in getShareInfo: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShare(ShareInfo shareInfo) throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
TabularResourceId serviceTR = new TabularResourceId(
|
||||
Long.valueOf(shareInfo.getTabResource().getTrId().getId()));
|
||||
|
||||
List<String> users = new ArrayList<String>();
|
||||
for (Contacts cont : shareInfo.getContacts()) {
|
||||
String user = cont.getLogin();
|
||||
users.add(user);
|
||||
}
|
||||
service.share(serviceTR, (String[]) users.toArray());
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error in setShare: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.shared.share;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Contacts implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 8727398755200080050L;
|
||||
|
||||
private String id;
|
||||
private String login;
|
||||
private boolean isGroup;
|
||||
|
||||
public Contacts(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param login
|
||||
* @param isGroup
|
||||
*/
|
||||
public Contacts(String id, String login, boolean isGroup) {
|
||||
this.id = id;
|
||||
this.login = login;
|
||||
this.isGroup = isGroup;
|
||||
}
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
|
||||
public void setLogin(String login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
|
||||
public boolean isGroup() {
|
||||
return isGroup;
|
||||
}
|
||||
|
||||
|
||||
public void setGroup(boolean isGroup) {
|
||||
this.isGroup = isGroup;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Contacts [id=" + id + ", login=" + login + ", isGroup="
|
||||
+ isGroup + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.shared.share;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||
|
||||
|
||||
public class ShareInfo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4803711252511329006L;
|
||||
|
||||
protected TabResource tabResource;
|
||||
protected ArrayList<Contacts> contacts;
|
||||
|
||||
public ShareInfo() {
|
||||
|
||||
}
|
||||
|
||||
public ShareInfo(TabResource tabResource, ArrayList<Contacts> contacts) {
|
||||
this.tabResource = tabResource;
|
||||
this.contacts = contacts;
|
||||
|
||||
}
|
||||
|
||||
public TabResource getTabResource() {
|
||||
return tabResource;
|
||||
}
|
||||
|
||||
public void setTabResource(TabResource tabResource) {
|
||||
this.tabResource = tabResource;
|
||||
}
|
||||
|
||||
public ArrayList<Contacts> getContacts() {
|
||||
return contacts;
|
||||
}
|
||||
|
||||
public void setContacts(ArrayList<Contacts> contacts) {
|
||||
this.contacts = contacts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ShareInfo [tabResource=" + tabResource + ", contacts="
|
||||
+ contacts + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue