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:
parent
7fda2a764e
commit
f75a291489
|
@ -70,9 +70,11 @@ public interface CKanPublisherService extends RemoteService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the list of groups the user can choose to associate this product with.
|
* 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
|
* @return a list of groups' beans
|
||||||
*/
|
*/
|
||||||
List<GroupBean> getUserGroups();
|
List<GroupBean> getUserGroups(String orgName);
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Return a tree object representing the whole folder hierarchy
|
// * Return a tree object representing the whole folder hierarchy
|
||||||
|
|
|
@ -78,7 +78,9 @@ public interface CKanPublisherServiceAsync {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the list of groups the user can choose to associate this product with.
|
* 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
|
* @return a list of groups' beans
|
||||||
*/
|
*/
|
||||||
void getUserGroups(AsyncCallback<List<GroupBean>> callback);
|
void getUserGroups(String orgName, AsyncCallback<List<GroupBean>> callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -418,7 +418,7 @@ public class CreateDatasetForm extends Composite{
|
||||||
setAlertBlock("Retrieving groups, please wait...", AlertType.INFO, true);
|
setAlertBlock("Retrieving groups, please wait...", AlertType.INFO, true);
|
||||||
|
|
||||||
// request groups
|
// request groups
|
||||||
ckanServices.getUserGroups(new AsyncCallback<List<GroupBean>>() {
|
ckanServices.getUserGroups(null, new AsyncCallback<List<GroupBean>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<GroupBean> groups) {
|
public void onSuccess(List<GroupBean> groups) {
|
||||||
|
@ -483,7 +483,7 @@ public class CreateDatasetForm extends Composite{
|
||||||
|
|
||||||
// get the name of the organization from the title
|
// get the name of the organization from the title
|
||||||
String selectedOrganizationTitle = organizationsListbox.getSelectedItemText();
|
String selectedOrganizationTitle = organizationsListbox.getSelectedItemText();
|
||||||
String orgName = nameTitleOrganizationMap.get(selectedOrganizationTitle);
|
final String orgName = nameTitleOrganizationMap.get(selectedOrganizationTitle);
|
||||||
|
|
||||||
// try to retrieve the profiles
|
// try to retrieve the profiles
|
||||||
setAlertBlock("Retrieving profiles, please wait...", AlertType.INFO, true);
|
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);
|
setAlertBlock("Retrieving groups, please wait...", AlertType.INFO, true);
|
||||||
|
|
||||||
// request groups
|
// request groups
|
||||||
ckanServices.getUserGroups(new AsyncCallback<List<GroupBean>>() {
|
ckanServices.getUserGroups(orgName, new AsyncCallback<List<GroupBean>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<GroupBean> groups) {
|
public void onSuccess(List<GroupBean> groups) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ import eu.trentorise.opendata.jackan.model.CkanLicense;
|
||||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
*/
|
*/
|
||||||
public class CKANPublisherServicesImpl extends RemoteServiceServlet implements CKanPublisherService{
|
public class CKANPublisherServicesImpl extends RemoteServiceServlet implements CKanPublisherService{
|
||||||
|
|
||||||
private static final long serialVersionUID = 7252248774050361697L;
|
private static final long serialVersionUID = 7252248774050361697L;
|
||||||
|
|
||||||
// Logger
|
// Logger
|
||||||
|
@ -272,7 +272,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
|
|
||||||
String datasetId = utils.createCKanDatasetMultipleCustomFields
|
String datasetId = utils.createCKanDatasetMultipleCustomFields
|
||||||
(userApiKey, title, null, organizationNameOrId, author, authorMail, maintainer,
|
(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){
|
if(datasetId != null){
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
// retrieve the url
|
// retrieve the url
|
||||||
String datasetUrl = utils.getUrlFromDatasetIdOrName(datasetId);
|
String datasetUrl = utils.getUrlFromDatasetIdOrName(datasetId);
|
||||||
toCreate.setSource(datasetUrl);
|
toCreate.setSource(datasetUrl);
|
||||||
|
|
||||||
// add also this information as custom field
|
// add also this information as custom field
|
||||||
Map<String, List<String>> addField = new HashMap<String, List<String>>();
|
Map<String, List<String>> addField = new HashMap<String, List<String>>();
|
||||||
addField.put(PRODUCT_URL_FIELD, Arrays.asList(datasetUrl));
|
addField.put(PRODUCT_URL_FIELD, Arrays.asList(datasetUrl));
|
||||||
|
@ -505,7 +505,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GroupBean> getUserGroups() {
|
public List<GroupBean> getUserGroups(String orgName) {
|
||||||
|
|
||||||
List<GroupBean> toReturn = new ArrayList<GroupBean>();
|
List<GroupBean> toReturn = new ArrayList<GroupBean>();
|
||||||
|
|
||||||
|
@ -516,7 +516,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
|
|
||||||
// get http session
|
// get http session
|
||||||
HttpSession httpSession = getThreadLocalRequest().getSession();
|
HttpSession httpSession = getThreadLocalRequest().getSession();
|
||||||
String scope = Utils.getScopeFromClientUrl(getThreadLocalRequest());
|
String scope = orgName != null ? getScopeFromOrgName(orgName) : Utils.getScopeFromClientUrl(getThreadLocalRequest());
|
||||||
|
|
||||||
// check if they are in session
|
// check if they are in session
|
||||||
String keyPerScopeGroups = UtilMethods.concatenateSessionKeyScope(SessionCatalogueAttributes.CKAN_GROUPS_MEMBER, scope);
|
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);
|
String apiKey = catalogue.getApiKeyFromUsername(username);
|
||||||
|
|
||||||
// Members/Admin of the group
|
|
||||||
for (CkanGroup ckanGroup : ckanGroups) {
|
for (CkanGroup ckanGroup : ckanGroups) {
|
||||||
String role = catalogue.getRoleOfUserInGroup(username, ckanGroup.getName(), apiKey);
|
String role = catalogue.getRoleOfUserInGroup(username, ckanGroup.getName(), apiKey);
|
||||||
if(role == null)
|
if(role == null)
|
||||||
|
|
Loading…
Reference in New Issue