fixed login for groups

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@97873 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-06-26 16:27:00 +00:00
parent 46aac8bbec
commit 3516aa2426
3 changed files with 38 additions and 16 deletions

View File

@ -17,4 +17,6 @@ public interface ConstantsSharing {
public static int WIDTH_DIALOG = 530;
public static int HEIGHT_DIALOG = 430;
public static final String PATH_SEPARATOR = "/";
}

View File

@ -19,6 +19,7 @@ import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalPDFFile;
import org.gcube.common.homelibrary.home.workspace.folder.items.gcube.Document;
import org.gcube.common.homelibrary.home.workspace.folder.items.gcube.ImageDocument;
import org.gcube.common.homelibrary.home.workspace.usermanager.GCubeGroup;
import org.gcube.portlets.widgets.workspacesharingwidget.client.ConstantsSharing;
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.UserUtil;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ACL_TYPE;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel;
@ -40,8 +41,12 @@ import org.slf4j.LoggerFactory;
*/
public class GWTWorkspaceSharingBuilder {
protected Logger logger = LoggerFactory
.getLogger(GWTWorkspaceSharingBuilder.class);
/**
*
*/
protected Logger logger = LoggerFactory.getLogger(GWTWorkspaceSharingBuilder.class);
private InfoContactModel userLogged;
@ -162,14 +167,23 @@ public class GWTWorkspaceSharingBuilder {
/**
*
* @param vrePath
* @param list
* @return
* @throws InternalErrorException
*/
public List<InfoContactModel> buildGXTListContactsModelFromVOs(List<VO> listVO) throws InternalErrorException {
public List<InfoContactModel> buildGXTListContactsModelFromVOs(List<VO> listVO, String vrePath) throws InternalErrorException {
List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>();
if(vrePath==null){
vrePath=ConstantsSharing.PATH_SEPARATOR;
}
if(vrePath!=null && !vrePath.endsWith(ConstantsSharing.PATH_SEPARATOR)){
vrePath+=ConstantsSharing.PATH_SEPARATOR;
}
if (listVO == null){
logger.warn("List<VO> is null, returning");
return listContactsModel;
@ -181,12 +195,17 @@ public class GWTWorkspaceSharingBuilder {
for (VO vo : listVO) {
List<VRE> vres = vo.getVres();
logger.trace("vo getGroupName: "+ vo.getGroupName());
logger.trace("vo getName: "+ vo.getName());
logger.trace("Building list contact model...");
if(vres!=null){
logger.trace("vres from VO "+vo.getName() +" having size :" +vres.size() +", converting");
for (VRE vre : vres) {
if(vre.getName()!=null || !vre.getName().isEmpty()){
InfoContactModel contact = new InfoContactModel(vre.getName(), vre.getName(), vre.getName(), true);
String groupId = vrePath+vre.getName();
InfoContactModel contact = new InfoContactModel(groupId, groupId, vre.getName(), true);
logger.trace("Adding VRE " + contact);
listContactsModel.add(contact);
}

View File

@ -137,7 +137,8 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
logger.info("context.getInfrastructureName(): "+context.getInfrastructureName());
logger.info("aslSession.getGroupName(): "+ aslSession.getGroupName());
List<VO> lsVOs = WsUtil.getVresFromInfrastructure(context.getInfrastructureName(), aslSession.getGroupName());
listContactsModel.addAll(builder.buildGXTListContactsModelFromVOs(lsVOs));
String vrePath = ConstantsSharing.PATH_SEPARATOR+context.getInfrastructureName() + ConstantsSharing.PATH_SEPARATOR + aslSession.getGroupName() + ConstantsSharing.PATH_SEPARATOR;
listContactsModel.addAll(builder.buildGXTListContactsModelFromVOs(lsVOs, vrePath));
}
logger.info("Get all contacts returning a list having size: "+listContactsModel.size());
@ -491,16 +492,15 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
WorkspaceSharingServiceImpl impl = new WorkspaceSharingServiceImpl();
PortalContext context = PortalContext.getConfiguration();
logger.info("context.getInfrastructureName(): "+context.getInfrastructureName());
String user = "pippo";
String sessionID = "123";
ASLSession aslSession = SessionManager.getInstance().getASLSession(sessionID, user);
aslSession.setScope("/gcube/devsec");
// aslSession.set
logger.info("aslSession.getGroupName(): "+ aslSession.getGroupName());
try {
List<VO> lsVOs = WsUtil.getVresFromInfrastructure(context.getInfrastructureName(), "devsec");
String nameVO = "devsec";
String vrePath = ConstantsSharing.PATH_SEPARATOR+context.getInfrastructureName() + ConstantsSharing.PATH_SEPARATOR + nameVO + ConstantsSharing.PATH_SEPARATOR;
List<VO> lsVOs = WsUtil.getVresFromInfrastructure(context.getInfrastructureName(), nameVO);
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
List<InfoContactModel> groups = builder.buildGXTListContactsModelFromVOs(lsVOs, vrePath);
for (VO vo : lsVOs) {
System.out.println(vo.getName());
@ -509,9 +509,10 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
System.out.println("VRE: "+vre.getName());
}
}
// for (InfoContactModel infoContactModel : groups) {
// System.out.println(infoContactModel);
// }
for (InfoContactModel infoContactModel : groups) {
System.out.println(infoContactModel);
}
} catch (Exception e) {
// TODO Auto-generated catch block