Added code and web.xml context parameter in order to hide header from portal

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@129173 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-06-20 10:36:54 +00:00
parent eb2bb850f7
commit 49e08f2333
4 changed files with 16 additions and 13 deletions

View File

@ -4,12 +4,6 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="ckan-metadata-publisher-widget-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-metadata-publisher-widget/ckan-metadata-publisher-widget">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="ckan-util-library-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-util-library/ckan-util-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="gcube-ckan-datacatalog"/>
<property name="java-output-path" value="/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-1.0.0-SNAPSHOT/WEB-INF/classes"/>
</wb-module>

View File

@ -43,6 +43,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
private static final String HTTPS = "https";
private static final String HTTP = "http";
public static String CKANCONNECTORCONTEXT = "CkanConnectorContext";
public static String CKANHIDEHEADER = "CkanHideHeader";
public static final String USERNAME_ATTRIBUTE = ScopeHelper.USERNAME_ATTRIBUTE;
private static Logger logger = LoggerFactory.getLogger(GcubeCkanDataCatalogServiceImpl.class);
private final static String DEFAULT_ROLE = "OrganizationMember";
@ -105,6 +106,9 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
try{
String ckanContext = getServletContext().getInitParameter(CKANCONNECTORCONTEXT);
logger.debug(CKANCONNECTORCONTEXT + " is: "+ckanContext);
String ckanHideHeader = getServletContext().getInitParameter(CKANHIDEHEADER);
logger.debug(CKANHIDEHEADER + " is: "+ckanHideHeader);
ASLSession session = getASLSession(this.getThreadLocalRequest().getSession());
GcoreEndpointReader ckanEndPoint = SessionUtil.getCkanEndPoint(session);
String ckanConnectorUri = ckanEndPoint.getCkanResourceEntyName();
@ -118,8 +122,9 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
ckanConnectorUri+="?"+GCUBE_TOKEN+"="+getGcubeSecurityToken();
}else{
logger.warn("******** Using TEST_USER security token!!!");
ckanConnectorUri+="?"+GCUBE_TOKEN+"="+TEST_SEC_TOKEN;
ckanConnectorUri+="?"+GCUBE_TOKEN+"="+TEST_SEC_TOKEN +"&" +ckanHideHeader;
}
ckanConnectorUri+="&" +ckanHideHeader; //added query string to hide header from portal
logger.info("returning ckanConnectorUri: "+ckanConnectorUri);
return ckanConnectorUri;
// return "http://ckan-d-d4s.d4science.org";
@ -232,7 +237,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
// NOTE: it is supposed that there is just one role for this person correspondent to the one in the catalog
for (RoleModel role : roles) {
logger.debug("User " + username + " has role " + role.getRoleName() + " in " + currentScope);
logger.debug("User " + username + " has role " + role.getRoleName() + " in " + currentScope);
if(role.getRoleName().contains(CkanRolesIntoLiferay.CATALOG_ADMIN.toString())){
mainRole = CkanRolesIntoLiferay.CATALOG_ADMIN;
correspondentRoleToCheck = RolesIntoOrganization.ADMIN;
@ -241,7 +246,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
mainRole = CkanRolesIntoLiferay.CATALOG_EDITOR;
correspondentRoleToCheck = RolesIntoOrganization.EDITOR;
break;
}
}
}
// with this invocation, we check if the role is present in ckan and if it is not it will be added
@ -257,7 +262,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
logger.debug("Unable to check the role into ckan organization, returning MEMBER as role");
// return the base role
return CkanRole.MEMBER;
return CkanRole.MEMBER;
}
/**
@ -270,7 +275,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
case CATALOG_ADMIN: return CkanRole.ADMIN;
case CATALOG_EDITOR: return CkanRole.EDITOR;
case CATALOG_MEMBER: ;
default : return CkanRole.MEMBER;
default : return CkanRole.MEMBER;
}
}

View File

@ -1,2 +0,0 @@
sendButton = Envoyer
nameField = Entrez votre nom

View File

@ -11,6 +11,12 @@
<param-value>/gcube/service/connect</param-value>
</context-param>
<context-param>
<param-name>CkanHideHeader</param-name>
<!-- <param-value>/connect</param-value> -->
<param-value>/hh=true</param-value>
</context-param>
<!-- Servlets -->
<servlet>
<servlet-name>gcubeckandatacatalogservice</servlet-name>