When switching among tabs the ckan-connector is no longer invoked since it is useless.
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@142586 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c4014dfcf2
commit
613228b4af
|
@ -4,9 +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.2.2-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>
|
||||
<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>
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<groupId>org.gcube.portlets.gcubeckan</groupId>
|
||||
<artifactId>gcube-ckan-datacatalog</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>1.2.2-SNAPSHOT</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<name>gCube CKAN Data Catalog</name>
|
||||
<description>The gCube CKAN Data Catalog portlet</description>
|
||||
|
||||
|
|
|
@ -152,7 +152,6 @@ public class CkanEventHandlerManager {
|
|||
|
||||
@Override
|
||||
public void onShowGroups(ShowGroupsEvent showGroupsEvent) {
|
||||
//String request = getCkanRequest("/dashboard/groups", null);
|
||||
//panel.instanceCkanFrame(request);
|
||||
if(showGroupsEvent.isOwnOnly())
|
||||
panel.showGroups();
|
||||
|
@ -213,9 +212,9 @@ public class CkanEventHandlerManager {
|
|||
* @return the ckan request
|
||||
*/
|
||||
private String getCkanRequest(String pathInfo, String query){
|
||||
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(panel.getBaseURLCKANConnector(),"");
|
||||
if(panel.getGcubeTokenValueToCKANConnector() != null)
|
||||
ckan.addGubeToken(panel.getGcubeTokenValueToCKANConnector());
|
||||
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(panel.getCatalogueUrl(),"");
|
||||
/*if(panel.getGcubeTokenValueToCKANConnector() != null)
|
||||
ckan.addGubeToken(panel.getGcubeTokenValueToCKANConnector());*/
|
||||
pathInfo = CkanConnectorAccessPoint.checkNullString(pathInfo);
|
||||
query = CkanConnectorAccessPoint.checkNullString(query);
|
||||
ckan.addPathInfo(pathInfo);
|
||||
|
|
|
@ -60,12 +60,12 @@ public interface GcubeCkanDataCatalogService extends RemoteService {
|
|||
*/
|
||||
String logoutFromCkanURL();
|
||||
|
||||
/**
|
||||
* Remove auth cookie for ckan of this user.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
String logoutURIFromCkan();
|
||||
// /**
|
||||
// * Remove auth cookie for ckan of this user.
|
||||
// *
|
||||
// * @return the string
|
||||
// */
|
||||
// String logoutURIFromCkan();
|
||||
|
||||
/**
|
||||
* Check if the there is a user logged in.
|
||||
|
|
|
@ -38,8 +38,8 @@ public interface GcubeCkanDataCatalogServiceAsync {
|
|||
* @return the c kan connector
|
||||
*/
|
||||
void getCKanConnector(
|
||||
String pathInfoParameters, String queryStringParameters,
|
||||
AsyncCallback<CkanConnectorAccessPoint> callback);
|
||||
String pathInfoParameters, String queryStringParameters,
|
||||
AsyncCallback<CkanConnectorAccessPoint> callback);
|
||||
|
||||
/**
|
||||
* Logout from ckan url.
|
||||
|
@ -48,12 +48,12 @@ public interface GcubeCkanDataCatalogServiceAsync {
|
|||
*/
|
||||
void logoutFromCkanURL(AsyncCallback<String> callback);
|
||||
|
||||
/**
|
||||
* Logout uri from ckan.
|
||||
*
|
||||
* @param callback the callback
|
||||
*/
|
||||
void logoutURIFromCkan(AsyncCallback<String> callback);
|
||||
// /**
|
||||
// * Logout uri from ckan.
|
||||
// *
|
||||
// * @param callback the callback
|
||||
// */
|
||||
// void logoutURIFromCkan(AsyncCallback<String> callback);
|
||||
|
||||
/**
|
||||
* Gets the ckan organizations names and urls for user.
|
||||
|
@ -63,7 +63,7 @@ public interface GcubeCkanDataCatalogServiceAsync {
|
|||
*/
|
||||
void getCkanOrganizationsNamesAndUrlsForUser(
|
||||
AsyncCallback<List<BeanUserInOrgGroupRole>> callback);
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the list of groups to whom the user belongs and their urls.
|
||||
*
|
||||
|
|
|
@ -121,8 +121,8 @@ public class CkanGroupsPanel extends VerticalPanel{
|
|||
* @return
|
||||
*/
|
||||
private String getCkanRequest(String pathInfo, String query){
|
||||
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(father.getBaseURLCKANConnector(), "");
|
||||
ckan.addGubeToken(father.getGcubeTokenValueToCKANConnector());
|
||||
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(father.getCatalogueUrl(), "");
|
||||
//ckan.addGubeToken(father.getGcubeTokenValueToCKANConnector());
|
||||
pathInfo = CkanConnectorAccessPoint.checkNullString(pathInfo);
|
||||
query = CkanConnectorAccessPoint.checkNullString(query);
|
||||
ckan.addPathInfo(pathInfo);
|
||||
|
|
|
@ -121,8 +121,8 @@ public class CkanOrganizationsPanel extends VerticalPanel{
|
|||
* @return
|
||||
*/
|
||||
private String getCkanRequest(String pathInfo, String query){
|
||||
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(father.getBaseURLCKANConnector(), "");
|
||||
ckan.addGubeToken(father.getGcubeTokenValueToCKANConnector());
|
||||
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(father.getCatalogueUrl(), "");
|
||||
//ckan.addGubeToken(father.getGcubeTokenValueToCKANConnector());
|
||||
pathInfo = CkanConnectorAccessPoint.checkNullString(pathInfo);
|
||||
query = CkanConnectorAccessPoint.checkNullString(query);
|
||||
ckan.addPathInfo(pathInfo);
|
||||
|
|
|
@ -112,7 +112,6 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
|
|||
|
||||
if(!ckan.isOutsideFromPortal()){
|
||||
|
||||
|
||||
// MANAGE CKAN MANAGEMENT PANEL ACCORDING TO MY ROLE
|
||||
GCubeCkanDataCatalog.service.getMyRole(new AsyncCallback<RolesCkanGroupOrOrg>() {
|
||||
|
||||
|
@ -326,6 +325,14 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
|
|||
protected native void postMessage(String msg) /*-{
|
||||
$wnd.postMessage(msg, "*");
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Print a message
|
||||
* @param string
|
||||
*/
|
||||
protected native void printString(String string) /*-{
|
||||
console.log(string);
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Listen for post message.
|
||||
|
@ -426,6 +433,16 @@ public class GCubeCkanDataCatalogPanel extends BaseViewTemplate {
|
|||
|
||||
return ckanAccessPoint.getBaseUrlWithContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the catalogue url (e.g. http://ckan-d-d4s.d4science.org:443/)
|
||||
* @return
|
||||
*/
|
||||
public String getCatalogueUrl(){
|
||||
|
||||
printString("Base url for iframe is " + ckanAccessPoint.getCatalogueBaseUrl());
|
||||
return ckanAccessPoint.getCatalogueBaseUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the gcube token value to ckan connector.
|
||||
|
|
|
@ -53,7 +53,6 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
public static String CKANCONNECTORCONTEXT = "CkanConnectorContext";
|
||||
public static String CKANCONNECTORLOGOUT = "CkanConnectorLogout";
|
||||
private static final String GRSF_ADMIN_ROLE = "GRSF-Admin";
|
||||
//private static Logger logger = LoggerFactory.getLogger(GcubeCkanDataCatalogServiceImpl.class);
|
||||
private static final Log logger = LogFactoryUtil.getLog(GcubeCkanDataCatalogServiceImpl.class);
|
||||
|
||||
/**
|
||||
|
@ -293,23 +292,23 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
return toReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String logoutURIFromCkan() {
|
||||
String username = SessionUtil.getCurrentUser(getThreadLocalRequest()).getUsername();
|
||||
|
||||
// get the scope from session
|
||||
String scopePerCurrentUrl = SessionUtil.getScopeFromClientUrl(getThreadLocalRequest());
|
||||
|
||||
CkanConnectorAccessPoint ckanAP = SessionUtil.getCkanAccessPoint(this.getThreadLocalRequest().getSession(), scopePerCurrentUrl);
|
||||
logger.info("Logout from CKAN for: "+username +" by token: "+ckanAP.getGcubeTokenValue());
|
||||
|
||||
String ckanConnectorLogut = getServletContext().getInitParameter(CKANCONNECTORLOGOUT);
|
||||
logger.debug(CKANCONNECTORLOGOUT + " is: "+ckanConnectorLogut);
|
||||
|
||||
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(ckanAP.getBaseUrl(), ckanConnectorLogut);
|
||||
ckan.addGubeToken(ckanAP.getGcubeTokenValue());
|
||||
return ckan.buildURI();
|
||||
}
|
||||
// @Override
|
||||
// public String logoutURIFromCkan() {
|
||||
// String username = SessionUtil.getCurrentUser(getThreadLocalRequest()).getUsername();
|
||||
//
|
||||
// // get the scope from session
|
||||
// String scopePerCurrentUrl = SessionUtil.getScopeFromClientUrl(getThreadLocalRequest());
|
||||
//
|
||||
// CkanConnectorAccessPoint ckanAP = SessionUtil.getCkanAccessPoint(this.getThreadLocalRequest().getSession(), scopePerCurrentUrl);
|
||||
// logger.info("Logout from CKAN for: "+username +" by token: "+ckanAP.getGcubeTokenValue());
|
||||
//
|
||||
// String ckanConnectorLogut = getServletContext().getInitParameter(CKANCONNECTORLOGOUT);
|
||||
// logger.debug(CKANCONNECTORLOGOUT + " is: "+ckanConnectorLogut);
|
||||
//
|
||||
// CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(ckanAP.getBaseUrl(), ckanConnectorLogut);
|
||||
// ckan.addGubeToken(ckanAP.getGcubeTokenValue());
|
||||
// return ckan.buildURI();
|
||||
// }
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -317,7 +316,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
*/
|
||||
@Override
|
||||
public String logoutFromCkanURL() {
|
||||
|
||||
|
||||
// check if the portlet is accessed from outside the portal
|
||||
if(outsidePortal())
|
||||
return null;
|
||||
|
@ -350,63 +349,63 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
|
||||
|
||||
/*HttpSession httpSession = this.getThreadLocalRequest().getSession();
|
||||
ASLSession session = getASLSession(httpSession);
|
||||
String username = session.getUsername();
|
||||
// get the scope from session
|
||||
String scopePerCurrentUrl = (String)this.getThreadLocalRequest().getSession().getAttribute(SessionCatalogueAttributes.SCOPE_CLIENT_PORTLET_URL);
|
||||
CkanConnectorAccessPoint ckanAP = SessionUtil.getCkanAccessPoint(this.getThreadLocalRequest().getSession(), scopePerCurrentUrl);
|
||||
// String token = getGcubeSecurityToken();
|
||||
logger.info("Logout from CKAN for: "+username +" by token: "+ckanAP.getGcubeTokenValue());
|
||||
ASLSession session = getASLSession(httpSession);
|
||||
String username = session.getUsername();
|
||||
// get the scope from session
|
||||
String scopePerCurrentUrl = (String)this.getThreadLocalRequest().getSession().getAttribute(SessionCatalogueAttributes.SCOPE_CLIENT_PORTLET_URL);
|
||||
CkanConnectorAccessPoint ckanAP = SessionUtil.getCkanAccessPoint(this.getThreadLocalRequest().getSession(), scopePerCurrentUrl);
|
||||
// String token = getGcubeSecurityToken();
|
||||
logger.info("Logout from CKAN for: "+username +" by token: "+ckanAP.getGcubeTokenValue());
|
||||
|
||||
String ckanConnectorLogut = getServletContext().getInitParameter(CKANCONNECTORLOGOUT);
|
||||
logger.debug(CKANCONNECTORLOGOUT + " is: "+ckanConnectorLogut);
|
||||
String ckanConnectorLogut = getServletContext().getInitParameter(CKANCONNECTORLOGOUT);
|
||||
logger.debug(CKANCONNECTORLOGOUT + " is: "+ckanConnectorLogut);
|
||||
|
||||
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(ckanAP.getBaseUrl(), ckanConnectorLogut);
|
||||
ckan.addPathInfo(ckanConnectorLogut);
|
||||
ckan.addGubeToken(ckanAP.getGcubeTokenValue());
|
||||
URL url;
|
||||
try {
|
||||
String deleteURI = ckan.buildURI();
|
||||
logger.debug("Perfoming HTTP delete to URI: "+deleteURI);
|
||||
url = new URL(deleteURI);
|
||||
HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
|
||||
httpCon.setDoOutput(true);
|
||||
httpCon.setRequestProperty("Content-Type", "application/x-www-form-urlencoded" );
|
||||
httpCon.setRequestMethod("DELETE");
|
||||
httpCon.connect();
|
||||
CkanConnectorAccessPoint ckan = new CkanConnectorAccessPoint(ckanAP.getBaseUrl(), ckanConnectorLogut);
|
||||
ckan.addPathInfo(ckanConnectorLogut);
|
||||
ckan.addGubeToken(ckanAP.getGcubeTokenValue());
|
||||
URL url;
|
||||
try {
|
||||
String deleteURI = ckan.buildURI();
|
||||
logger.debug("Perfoming HTTP delete to URI: "+deleteURI);
|
||||
url = new URL(deleteURI);
|
||||
HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
|
||||
httpCon.setDoOutput(true);
|
||||
httpCon.setRequestProperty("Content-Type", "application/x-www-form-urlencoded" );
|
||||
httpCon.setRequestMethod("DELETE");
|
||||
httpCon.connect();
|
||||
|
||||
HttpServletResponse response = this.getThreadLocalResponse();
|
||||
HttpServletResponse response = this.getThreadLocalResponse();
|
||||
|
||||
if(httpCon.getResponseCode()==HttpStatus.SC_OK){
|
||||
response.setContentLength(httpCon.getContentLength());
|
||||
Map<String, List<String>> map = httpCon.getHeaderFields();
|
||||
for (String key : map.keySet()) {
|
||||
String hf = httpCon.getHeaderField(key);
|
||||
logger.trace("key: "+key +", value: "+hf);
|
||||
if(key==null){
|
||||
logger.trace("skyp key: "+key +", value: "+hf);
|
||||
}else
|
||||
response.setHeader(key,hf);
|
||||
if(httpCon.getResponseCode()==HttpStatus.SC_OK){
|
||||
response.setContentLength(httpCon.getContentLength());
|
||||
Map<String, List<String>> map = httpCon.getHeaderFields();
|
||||
for (String key : map.keySet()) {
|
||||
String hf = httpCon.getHeaderField(key);
|
||||
logger.trace("key: "+key +", value: "+hf);
|
||||
if(key==null){
|
||||
logger.trace("skyp key: "+key +", value: "+hf);
|
||||
}else
|
||||
response.setHeader(key,hf);
|
||||
}
|
||||
|
||||
response.setContentLength(httpCon.getContentLength());
|
||||
String encoding = httpCon.getContentEncoding();
|
||||
encoding = encoding == null ? UTF_8 : encoding;
|
||||
response.setCharacterEncoding(encoding);
|
||||
response.setStatus(HttpStatus.SC_OK);
|
||||
|
||||
InputStream in = httpCon.getInputStream();
|
||||
ServletOutputStream out = response.getOutputStream();
|
||||
IOUtils.copy(in, out);
|
||||
logger.info("Logout Completed, response code: "+HttpStatus.SC_OK);
|
||||
|
||||
}else{
|
||||
logger.warn("An error occurred during perfoming CKAN logout, Response status is: "+httpCon.getResponseCode());
|
||||
}
|
||||
|
||||
response.setContentLength(httpCon.getContentLength());
|
||||
String encoding = httpCon.getContentEncoding();
|
||||
encoding = encoding == null ? UTF_8 : encoding;
|
||||
response.setCharacterEncoding(encoding);
|
||||
response.setStatus(HttpStatus.SC_OK);
|
||||
|
||||
InputStream in = httpCon.getInputStream();
|
||||
ServletOutputStream out = response.getOutputStream();
|
||||
IOUtils.copy(in, out);
|
||||
logger.info("Logout Completed, response code: "+HttpStatus.SC_OK);
|
||||
|
||||
}else{
|
||||
logger.warn("An error occurred during perfoming CKAN logout, Response status is: "+httpCon.getResponseCode());
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
logger.error("An error occured during performing Logout from CKAN for: "+username +" by token: "+ckanAP.getGcubeTokenValue(), e);
|
||||
}*/
|
||||
catch (IOException e) {
|
||||
logger.error("An error occured during performing Logout from CKAN for: "+username +" by token: "+ckanAP.getGcubeTokenValue(), e);
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,6 +35,7 @@ public class CkanConnectorAccessPoint implements Serializable{
|
|||
private Map<String, String> mapVresRoles;
|
||||
private String serverviceContext;
|
||||
private boolean outsideFromPortal = false;
|
||||
private String catalogueBaseUrl = null;
|
||||
|
||||
/**
|
||||
* Instantiates a new ckan connector access point.
|
||||
|
@ -51,6 +52,7 @@ public class CkanConnectorAccessPoint implements Serializable{
|
|||
*/
|
||||
public CkanConnectorAccessPoint(String baseUrl, String servericeContext){
|
||||
this.baseUrl = baseUrl;
|
||||
this.catalogueBaseUrl = baseUrl.split("ckan-connector")[0];
|
||||
this.serverviceContext = servericeContext;
|
||||
}
|
||||
|
||||
|
@ -261,13 +263,17 @@ public class CkanConnectorAccessPoint implements Serializable{
|
|||
this.outsideFromPortal = outsideFromPortal;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
/**
|
||||
*
|
||||
* @return the catalogue url
|
||||
*/
|
||||
public String getCatalogueBaseUrl() {
|
||||
return catalogueBaseUrl;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("CkanConnectorAccessPoint [baseUrl=");
|
||||
builder.append(baseUrl);
|
||||
|
@ -275,12 +281,16 @@ public class CkanConnectorAccessPoint implements Serializable{
|
|||
builder.append(pathInfoParameter);
|
||||
builder.append(", queryStringParameters=");
|
||||
builder.append(queryStringParameters);
|
||||
builder.append(", gcubeTokenValue=");
|
||||
builder.append(gcubeTokenValue);
|
||||
builder.append(", mapVresRoles=");
|
||||
builder.append(mapVresRoles);
|
||||
builder.append(", serverviceContext=");
|
||||
builder.append(serverviceContext);
|
||||
builder.append(", outsideFromPortal=");
|
||||
builder.append(outsideFromPortal);
|
||||
builder.append(", catalogueBaseUrl=");
|
||||
builder.append(catalogueBaseUrl);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue