Added code to manage error during read ckan-connenctor runtime resource
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@130473 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e11eb818aa
commit
1c996a7904
|
@ -29,10 +29,14 @@ public class GcoreEndpointReader {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(GcoreEndpointReader.class);
|
||||
private String ckanResourceEntyName;
|
||||
|
||||
/**
|
||||
* Instantiates a new gcore endpoint reader.
|
||||
*
|
||||
* @param scope the scope
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public GcoreEndpointReader(String scope) {
|
||||
public GcoreEndpointReader(String scope) throws Exception {
|
||||
|
||||
try{
|
||||
|
||||
|
@ -68,7 +72,9 @@ public class GcoreEndpointReader {
|
|||
System.out.println(epName);*/
|
||||
|
||||
}catch(Exception e){
|
||||
logger.error("An error occurred during GCoreEndpoint discovery, serviceName: "+serviceName +", serviceClass: " +serviceClass +", in scope: "+scope +" not found", e);
|
||||
String error = "An error occurred during GCoreEndpoint discovery, serviceName: "+serviceName +", serviceClass: " +serviceClass +", in scope: "+scope +".";
|
||||
logger.error(error, e);
|
||||
throw new Exception(error);
|
||||
}finally{
|
||||
logger.info("scope provider reset");
|
||||
ScopeProvider.instance.reset();
|
||||
|
|
|
@ -128,8 +128,9 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
* @param pathInfoParameter the path info parameter
|
||||
* @param queryStringParameters the query string parameters
|
||||
* @return the ckan connector access point
|
||||
* @throws Exception
|
||||
*/
|
||||
private CkanConnectorAccessPoint getCkanConnectorAccessPoint(String pathInfoParameter, String queryStringParameters) {
|
||||
private CkanConnectorAccessPoint getCkanConnectorAccessPoint(String pathInfoParameter, String queryStringParameters) throws Exception {
|
||||
|
||||
if(outsidePortal()){
|
||||
|
||||
|
@ -140,7 +141,13 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
|
||||
//CKAN BASE URL
|
||||
ASLSession session = getASLSession(this.getThreadLocalRequest().getSession());
|
||||
GcoreEndpointReader ckanEndPoint = SessionUtil.getCkanEndPoint(this.getThreadLocalRequest().getSession(), session.getScope());
|
||||
GcoreEndpointReader ckanEndPoint = null;
|
||||
try{
|
||||
ckanEndPoint = SessionUtil.getCkanEndPoint(this.getThreadLocalRequest().getSession(), session.getScope());
|
||||
}catch(Exception e){
|
||||
logger.error("CkanConnectorAccessPoint error: "+e.getMessage());
|
||||
throw new Exception("Sorry, an error occurred during contacting d4Science Data Catalogue, try again later");
|
||||
}
|
||||
String ckanConnectorBaseUrl = ckanEndPoint.getCkanResourceEntyName();
|
||||
ckanConnectorBaseUrl = ckanConnectorBaseUrl.startsWith(HTTP) && !ckanConnectorBaseUrl.startsWith(HTTPS)?ckanConnectorBaseUrl.replaceFirst(HTTP, HTTPS):ckanConnectorBaseUrl;
|
||||
ckanConnectorBaseUrl = ckanConnectorBaseUrl.contains(PORT_HTTP)?ckanConnectorBaseUrl.replace(PORT_HTTP, PORT_HTTPS):ckanConnectorBaseUrl;
|
||||
|
|
|
@ -31,7 +31,7 @@ public class SessionUtil {
|
|||
* @param session the session
|
||||
* @return the ckan end point
|
||||
*/
|
||||
public static GcoreEndpointReader getCkanEndPoint(HttpSession session, String scope){
|
||||
public static GcoreEndpointReader getCkanEndPoint(HttpSession session, String scope) throws Exception{
|
||||
|
||||
GcoreEndpointReader ckanEndPoint = (GcoreEndpointReader) session.getAttribute(CKAN_END_POINT);
|
||||
|
||||
|
|
Loading…
Reference in New Issue