minor fixes
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@134160 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
fbf1c03595
commit
a23fc3291d
|
@ -167,12 +167,16 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
|
||||
// check in the hashmap first
|
||||
if(apiKeysMap.containsKey(ckanUsername)){
|
||||
logger.debug("Api was in cache");
|
||||
CKANTokenBean bean = apiKeysMap.get(ckanUsername);
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if(bean.timestamp + EXPIRE_KEY_TIME < currentTime) // it's still ok
|
||||
if((bean.timestamp + EXPIRE_KEY_TIME) > System.currentTimeMillis()){ // it's still ok
|
||||
logger.debug("Api is not expired yet");
|
||||
return bean.apiKey;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
logger.debug("Api key was not in cache or it expired");
|
||||
|
||||
// the connection
|
||||
Connection connection = null;
|
||||
String apiToReturn = null;
|
||||
|
@ -197,13 +201,14 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
if(apiToReturn != null)
|
||||
apiKeysMap.put(ckanUsername, new CKANTokenBean(apiToReturn, System.currentTimeMillis()));
|
||||
|
||||
return apiToReturn;
|
||||
|
||||
}catch(Exception e){
|
||||
logger.error("Unable to retrieve key for user " + ckanUsername, e);
|
||||
return null;
|
||||
}finally{
|
||||
closeConnection(connection);
|
||||
}
|
||||
|
||||
return apiToReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue