minor fix for twin columns widget

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@144202 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2017-02-23 15:25:12 +00:00
parent b891f94b09
commit e666ee4366
6 changed files with 61 additions and 21 deletions

View File

@ -36,10 +36,10 @@ public class CKanMetadataPublisher implements EntryPoint {
public void onModuleLoad() {
// remove comment to the below line for testing the widget
//startExample();
//testMetadata();
//testSelectionPanel();
//testHideOption();
// startExample();
// testMetadata();
// testSelectionPanel();
// testHideOption();
}
@SuppressWarnings("unused")
@ -214,12 +214,10 @@ public class CKanMetadataPublisher implements EntryPoint {
}
@SuppressWarnings("unused")
private void startExample() {
String idFolderWorkspace = "e87bfc7d-4fb0-4795-9c79-0c495500ca9c";
String owner = "costantino.perciante";
String idFolderWorkspace = "1fede4e2-5859-4f19-bddb-aec7dd5b632f";
RootPanel.get("ckan-metadata-publisher-div").add(new CreateDatasetForm(idFolderWorkspace, eventBus));
}

View File

@ -107,6 +107,8 @@ public class TwinColumnSelectionMainPanel extends Composite{
public TwinColumnSelectionMainPanel(ResourceElementBean initialBean) {
initWidget(uiBinder.createAndBindUi(this));
GWT.log(initialBean.toString());
this.initialBean = initialBean;
@ -199,7 +201,9 @@ public class TwinColumnSelectionMainPanel extends Composite{
//breadcrumbsUpdater();
Collections.sort(selectedBean.getChildren());
GWT.log("Children " + selectedBean.getChildren());
dataProviderLeft.setList(selectedBean.getChildren());
cellListLeft.setPageSize(selectedBean.getChildren().size());
dataProviderLeft.refresh();
}
selectionModelLeft.setSelected(selectedBean, false);
@ -234,7 +238,9 @@ public class TwinColumnSelectionMainPanel extends Composite{
// set back the root content list
dataProviderLeft.setList(initialBean.getChildren());
cellListLeft.setPageSize(initialBean.getChildren().size());
dataProviderLeft.refresh();
}
});

View File

@ -213,6 +213,9 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
}
}else{
logger.info("DEV MODE DETECTED");
Utils.getCurrentToken(getThreadLocalRequest(), true);
try{
bean = new DatasetMetadataBean();
bean.setId(folderId);
@ -225,7 +228,8 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
bean.setAuthorEmail("costantino.perciante@isti.cnr.it");
bean.setMaintainer("Costantino Perciante");
bean.setMaintainerEmail("costantino.perciante@isti.cnr.it");
bean.setOrganizationList(getUserOrganizationsListAdmin(userName, Utils.getCurrentContext(getThreadLocalRequest(), true)));
//bean.setOrganizationList(getUserOrganizationsListAdmin(userName, Utils.getCurrentContext(getThreadLocalRequest(), true)));
bean.setOrganizationList(Arrays.asList(new OrganizationBean("preVRE", "prevre")));
bean.setOwnerIdentifier(userName);
if(folderId != null && !folderId.isEmpty()){
@ -236,6 +240,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
}
}
logger.debug("Returning bean " + bean);
return bean;
}
@ -454,16 +459,21 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
String toReturn = null;
if(mapOrganizationScope.containsKey(orgName))
toReturn = mapOrganizationScope.get(orgName);
else{
try{
String evaluatedScope = Utils.retrieveScopeFromOrganizationName(orgName);
mapOrganizationScope.put(orgName, evaluatedScope);
toReturn = evaluatedScope;
}catch(Exception e){
logger.error("Failed to retrieve scope from OrgName for organization " + orgName, e);
if(isWithinPortal()){
if(mapOrganizationScope.containsKey(orgName))
toReturn = mapOrganizationScope.get(orgName);
else{
try{
String evaluatedScope = Utils.retrieveScopeFromOrganizationName(orgName);
mapOrganizationScope.put(orgName, evaluatedScope);
toReturn = evaluatedScope;
}catch(Exception e){
logger.error("Failed to retrieve scope from OrgName for organization " + orgName, e);
}
}
}else{
toReturn = "/gcube/preprod/preVRE";
mapOrganizationScope.put(orgName, toReturn);
}
logger.debug("Returning scope " + toReturn);
return toReturn;
@ -505,7 +515,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
}
}else{
logger.warn("Dev mode detected");
toReturn = Arrays.asList(new GroupBean("Group title", "aaa"));
toReturn = Arrays.asList();
}
return toReturn;
}
@ -519,7 +529,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
if(!isWithinPortal()){
logger.warn("OUT FROM PORTAL DETECTED RETURNING TRUE");
return false;
return true;
}
try{

View File

@ -600,6 +600,26 @@ public class Utils {
return context;
}
/**
* Retrieve the current token by using the portal manager
* @param b
* @return a GcubeUser object
*/
public static String getCurrentToken(HttpServletRequest request, boolean setInThread){
if(request == null)
throw new IllegalArgumentException("HttpServletRequest is null!");
PortalContext pContext = PortalContext.getConfiguration();
String token = pContext.getCurrentUserToken(getCurrentContext(request, false), getCurrentUser(request).getUsername());
logger.debug("Returning token " + token);
if(token != null && setInThread)
SecurityTokenProvider.instance.set(token);
return token;
}
/**
* Retrieve the group given the scope

View File

@ -123,6 +123,8 @@ public class WorkspaceUtils {
.getHome().getWorkspace();
WorkspaceItem originalFolderOrFile = ws.getItem(folderId);
logger.debug("Item retrieved is " + originalFolderOrFile);
if(!originalFolderOrFile.isFolder()){
@ -193,6 +195,8 @@ public class WorkspaceUtils {
logger.error("Failed to build the resource tree", e);
return null;
}
logger.debug("Tree that is going to be returned is " + rootElem);
return rootElem;
}
@ -215,6 +219,7 @@ public class WorkspaceUtils {
elem.setDescription(item.getDescription());
extractEditableNameFromPath(elem, pathSeparator);
childrenInTree.add(elem);
logger.trace("Elem is " + elem);
if(item.isFolder())
visit(elem, item, fullPathBase, pathSeparator);
}

View File

@ -39,7 +39,7 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
return item == null ? null : item.identifierGWT;
}
};
/**
* Copy constructor
* @param another
@ -54,7 +54,7 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
this.url = another.url;
this.description = another.description;
this.organizationNameDatasetParent = another.organizationNameDatasetParent;
}
}
/**
* Default constructor
@ -246,4 +246,5 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
+ organizationNameDatasetParent + ", parent=" + parent
+ ", children number=" + (children == null ? 0 : children.size()) + "]";
}
}