ensure that the ckan connector add the user to the organizations first, then call the utility library

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@130672 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-07-22 07:55:35 +00:00
parent 1409810969
commit 5e0467a79a
1 changed files with 71 additions and 66 deletions

View File

@ -63,6 +63,7 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
Window.Location.getParameter(GCubeCkanDataCatalog.GET_PATH_PARAMETER);
String queryParameter =
Window.Location.getParameter(GCubeCkanDataCatalog.GET_QUERY_PARAMETER);
GCubeCkanDataCatalog.service.getCKanConnector(
pathParameter, queryParameter,
new AsyncCallback<CkanConnectorAccessPoint>() {
@ -73,6 +74,76 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
ckanAccessPoint = ckan;
instanceCkanFrame(ckan.buildURI());
GCubeCkanDataCatalogPanel.this.rootPanel.remove(loading);
// now perform the other requests
GCubeCkanDataCatalog.service.outsidePortal(new AsyncCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
if (result) {
// the portlet is outside the portal and no user is logged
// in
// show only home and statistics
managementPanel.doNotShowUserRelatedInfo();
}
else {
// polling for session expired check
CheckSession.getInstance().startPolling();
// RETRIEVE USER'S ORGANIZATIONS
GCubeCkanDataCatalog.service.getCkanOrganizationsNamesAndUrlsForUser(new AsyncCallback<Map<String, String>>() {
@Override
public void onSuccess(Map<String, String> result) {
if (result != null)
ckanOrganizationsPanel.setOrganizations(result);
}
@Override
public void onFailure(Throwable caught) {
}
});
// MANAGE CKAN MANAGEMENT PANEL ACCORDING TO MY ROLE
GCubeCkanDataCatalog.service.getMyRole(new AsyncCallback<CkanRole>() {
@Override
public void onFailure(Throwable caught) {
showEditInsertButtons(false);
}
@Override
public void onSuccess(CkanRole result) {
switch (result) {
case ADMIN:
showEditInsertButtons(true);
break;
case EDITOR:
showEditInsertButtons(false); // because the editor has some limitations TODO
break;
case MEMBER:
showEditInsertButtons(false);
break;
default:
showEditInsertButtons(false);
break;
}
}
});
}
}
@Override
public void onFailure(Throwable caught) {
// the portlet is outside the portal and no user is logged in
// show only home and statistics
managementPanel.doNotShowUserRelatedInfo();
}
});
}
@Override
@ -82,72 +153,6 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
Window.alert("Sorry, An error occurred during contacting Gcube Ckan Data Catalogue!");
}
});
GCubeCkanDataCatalog.service.outsidePortal(new AsyncCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
if (result) {
// the portlet is outside the portal and no user is logged
// in
// show only home and statistics
managementPanel.doNotShowUserRelatedInfo();
}
else {
// polling for session expired check
CheckSession.getInstance().startPolling();
// RETRIEVE USER'S ORGANIZATIONS
GCubeCkanDataCatalog.service.getCkanOrganizationsNamesAndUrlsForUser(new AsyncCallback<Map<String, String>>() {
@Override
public void onSuccess(Map<String, String> result) {
if (result != null)
ckanOrganizationsPanel.setOrganizations(result);
}
@Override
public void onFailure(Throwable caught) {
}
});
// MANAGE CKAN MANAGEMENT PANEL ACCORDING TO MY ROLE
GCubeCkanDataCatalog.service.getMyRole(new AsyncCallback<CkanRole>() {
@Override
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(CkanRole result) {
switch (result) {
case ADMIN:
showEditInsertButtons(true);
break;
case EDITOR:
showEditInsertButtons(false); // because the editor has some limitations TODO
break;
case MEMBER:
showEditInsertButtons(false);
break;
default:
showEditInsertButtons(false);
break;
}
}
});
}
}
@Override
public void onFailure(Throwable caught) {
// the portlet is outside the portal and no user is logged in
// show only home and statistics
managementPanel.doNotShowUserRelatedInfo();
}
});
Window.addResizeHandler(new ResizeHandler() {
@Override