moved the cookie setter before iframe's url is set

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@142216 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2017-02-04 07:50:30 +00:00
parent 5947db3dd8
commit a775694e67
1 changed files with 87 additions and 94 deletions

View File

@ -95,112 +95,105 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
@Override
public void onSuccess(CkanConnectorAccessPoint ckan) {
if(ckan.isOutsideFromPortal()){
// the portlet is outside the portal and no user is logged
// in show only home and statistics
managementPanel.doNotShowUserRelatedInfo();
// set the cookie to hide the banner (expires 3 hours later)
Date now = new Date();
now.setHours(now.getHours() + 3);
Cookies.setCookie("ckan_hide_header", "true", now, ".d4science.org", "/", false);
}
// set the iframe url
ckanAccessPoint = ckan;
instanceCkanFrame(ckan.buildURI());
GCubeCkanDataCatalogPanel.this.rootPanel.remove(loading);
// now perform the other requests
GCubeCkanDataCatalog.service.outsidePortal(new AsyncCallback<Boolean>() {
if(!ckan.isOutsideFromPortal()){
@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();
// MANAGE CKAN MANAGEMENT PANEL ACCORDING TO MY ROLE
GCubeCkanDataCatalog.service.getMyRole(new AsyncCallback<RolesCkanGroupOrOrg>() {
// set the cookie to hide the banner
Date now = new Date();
now.setHours(now.getHours() + 3);
Cookies.setCookie("ckan_hide_header", "true", now, ".d4science.org", "/", false);
@Override
public void onFailure(Throwable caught) {
showEditInsertButtons(false);
}
else {
// MANAGE CKAN MANAGEMENT PANEL ACCORDING TO MY ROLE
GCubeCkanDataCatalog.service.getMyRole(new AsyncCallback<RolesCkanGroupOrOrg>() {
@Override
public void onFailure(Throwable caught) {
showEditInsertButtons(false);
}
@Override
public void onSuccess(RolesCkanGroupOrOrg result) {
switch (result) {
case ADMIN:
showEditInsertButtons(true);
break;
case EDITOR:
showEditInsertButtons(true);
break;
case MEMBER:
showEditInsertButtons(false);
break;
default:
showEditInsertButtons(false);
break;
}
}
});
// retrieve organizations
GCubeCkanDataCatalog.service.getCkanOrganizationsNamesAndUrlsForUser(new AsyncCallback<List<BeanUserInOrgGroupRole>>() {
@Override
public void onSuccess(List<BeanUserInOrgGroupRole> result) {
ckanOrganizationsPanel.setOrganizations(result);
}
@Override
public void onFailure(Throwable caught) {
// an error message will be displayed
ckanOrganizationsPanel.setOrganizations(null);
}
});
// retrieve groups
GCubeCkanDataCatalog.service.getCkanGroupsNamesAndUrlsForUser(new AsyncCallback<List<BeanUserInOrgGroupRole>>() {
@Override
public void onSuccess(List<BeanUserInOrgGroupRole> result) {
ckanGroupsPanel.setGroups(result);
}
@Override
public void onFailure(Throwable caught) {
ckanGroupsPanel.setGroups(null);
}
});
/**
* Just check if it is enabled.. then we need to listen for dom events coming
*/
GCubeCkanDataCatalog.service.isManageProductEnabled(new AsyncCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
isManageProductToShow = result;
managementPanel.showManageProductButton(isManageProductToShow);
}
@Override
public void onFailure(Throwable caught) {
isManageProductToShow = false;
managementPanel.showManageProductButton(isManageProductToShow);
}
});
@Override
public void onSuccess(RolesCkanGroupOrOrg result) {
switch (result) {
case ADMIN:
showEditInsertButtons(true);
break;
case EDITOR:
showEditInsertButtons(true);
break;
case MEMBER:
showEditInsertButtons(false);
break;
default:
showEditInsertButtons(false);
break;
}
}
}
});
// retrieve organizations
GCubeCkanDataCatalog.service.getCkanOrganizationsNamesAndUrlsForUser(new AsyncCallback<List<BeanUserInOrgGroupRole>>() {
@Override
public void onSuccess(List<BeanUserInOrgGroupRole> result) {
ckanOrganizationsPanel.setOrganizations(result);
}
@Override
public void onFailure(Throwable caught) {
// an error message will be displayed
ckanOrganizationsPanel.setOrganizations(null);
}
});
// retrieve groups
GCubeCkanDataCatalog.service.getCkanGroupsNamesAndUrlsForUser(new AsyncCallback<List<BeanUserInOrgGroupRole>>() {
@Override
public void onSuccess(List<BeanUserInOrgGroupRole> result) {
ckanGroupsPanel.setGroups(result);
}
@Override
public void onFailure(Throwable caught) {
ckanGroupsPanel.setGroups(null);
}
});
/**
* Just check if it is enabled.. then we need to listen for dom events coming
*/
GCubeCkanDataCatalog.service.isManageProductEnabled(new AsyncCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
isManageProductToShow = result;
managementPanel.showManageProductButton(isManageProductToShow);
}
@Override
public void onFailure(Throwable caught) {
isManageProductToShow = false;
managementPanel.showManageProductButton(isManageProductToShow);
}
});
}
@Override
public void onFailure(Throwable caught) {
managementPanel.doNotShowUserRelatedInfo();
}
});
}
@Override