getOrgName fixed: now it retrieves the groups per scope

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@141391 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-12-22 22:53:30 +00:00
parent 7fda2a764e
commit f75a291489
4 changed files with 14 additions and 11 deletions

View File

@ -70,9 +70,11 @@ public interface CKanPublisherService extends RemoteService {
/**
* Retrieve the list of groups the user can choose to associate this product with.
* @param orgName retrieve the groups in the context linked to this name. If null, returns
* the one in the current context.
* @return a list of groups' beans
*/
List<GroupBean> getUserGroups();
List<GroupBean> getUserGroups(String orgName);
// /**
// * Return a tree object representing the whole folder hierarchy

View File

@ -78,7 +78,9 @@ public interface CKanPublisherServiceAsync {
/**
* Retrieve the list of groups the user can choose to associate this product with.
* @param orgName retrieve the groups in the context linked to this name. If null, returns
* the one in the current context.
* @return a list of groups' beans
*/
void getUserGroups(AsyncCallback<List<GroupBean>> callback);
void getUserGroups(String orgName, AsyncCallback<List<GroupBean>> callback);
}

View File

@ -418,7 +418,7 @@ public class CreateDatasetForm extends Composite{
setAlertBlock("Retrieving groups, please wait...", AlertType.INFO, true);
// request groups
ckanServices.getUserGroups(new AsyncCallback<List<GroupBean>>() {
ckanServices.getUserGroups(null, new AsyncCallback<List<GroupBean>>() {
@Override
public void onSuccess(List<GroupBean> groups) {
@ -483,7 +483,7 @@ public class CreateDatasetForm extends Composite{
// get the name of the organization from the title
String selectedOrganizationTitle = organizationsListbox.getSelectedItemText();
String orgName = nameTitleOrganizationMap.get(selectedOrganizationTitle);
final String orgName = nameTitleOrganizationMap.get(selectedOrganizationTitle);
// try to retrieve the profiles
setAlertBlock("Retrieving profiles, please wait...", AlertType.INFO, true);
@ -513,7 +513,7 @@ public class CreateDatasetForm extends Composite{
setAlertBlock("Retrieving groups, please wait...", AlertType.INFO, true);
// request groups
ckanServices.getUserGroups(new AsyncCallback<List<GroupBean>>() {
ckanServices.getUserGroups(orgName, new AsyncCallback<List<GroupBean>>() {
@Override
public void onSuccess(List<GroupBean> groups) {

View File

@ -44,7 +44,7 @@ import eu.trentorise.opendata.jackan.model.CkanLicense;
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class CKANPublisherServicesImpl extends RemoteServiceServlet implements CKanPublisherService{
private static final long serialVersionUID = 7252248774050361697L;
// Logger
@ -272,7 +272,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
String datasetId = utils.createCKanDatasetMultipleCustomFields
(userApiKey, title, null, organizationNameOrId, author, authorMail, maintainer,
maintainerMail, version, description, licenseId, listOfTags, customFields, resources, setPublic);
maintainerMail, version, description, licenseId, listOfTags, customFields, resources, setPublic);
if(datasetId != null){
@ -282,7 +282,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
// retrieve the url
String datasetUrl = utils.getUrlFromDatasetIdOrName(datasetId);
toCreate.setSource(datasetUrl);
// add also this information as custom field
Map<String, List<String>> addField = new HashMap<String, List<String>>();
addField.put(PRODUCT_URL_FIELD, Arrays.asList(datasetUrl));
@ -505,7 +505,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
// }
@Override
public List<GroupBean> getUserGroups() {
public List<GroupBean> getUserGroups(String orgName) {
List<GroupBean> toReturn = new ArrayList<GroupBean>();
@ -516,7 +516,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
// get http session
HttpSession httpSession = getThreadLocalRequest().getSession();
String scope = Utils.getScopeFromClientUrl(getThreadLocalRequest());
String scope = orgName != null ? getScopeFromOrgName(orgName) : Utils.getScopeFromClientUrl(getThreadLocalRequest());
// check if they are in session
String keyPerScopeGroups = UtilMethods.concatenateSessionKeyScope(SessionCatalogueAttributes.CKAN_GROUPS_MEMBER, scope);
@ -531,7 +531,6 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
String apiKey = catalogue.getApiKeyFromUsername(username);
// Members/Admin of the group
for (CkanGroup ckanGroup : ckanGroups) {
String role = catalogue.getRoleOfUserInGroup(username, ckanGroup.getName(), apiKey);
if(role == null)