added the method 'checkValidUser'
This commit is contained in:
parent
2db8bd6a2c
commit
9bd907427e
|
@ -296,5 +296,13 @@ public interface DataCatalogue {
|
|||
*/
|
||||
CkanGroup createGroup(String nameOrId, String title, String description) throws Exception;
|
||||
|
||||
/**
|
||||
* Check if the user is valid by checking if its API_KEY is present into DB.
|
||||
*
|
||||
* @param username the username
|
||||
* @return true, if successful
|
||||
*/
|
||||
boolean checkValidUser(String username);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -53,10 +53,11 @@ import net.htmlparser.jericho.Source;
|
|||
|
||||
/**
|
||||
* This is the Ckan Utils implementation class.
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*
|
||||
* revisited by
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR
|
||||
*
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public class DataCatalogueImpl implements DataCatalogue {
|
||||
|
||||
|
@ -324,6 +325,7 @@ public class DataCatalogueImpl implements DataCatalogue {
|
|||
}
|
||||
|
||||
LOG.debug("Returning map " + toReturn);
|
||||
LOG.info("Found " + toReturn.size() +" group/s with the user "+username);
|
||||
}catch(Exception e){
|
||||
LOG.error("Failed to retrieve roles of user in his/her own groups",e);
|
||||
}
|
||||
|
@ -356,6 +358,7 @@ public class DataCatalogueImpl implements DataCatalogue {
|
|||
}
|
||||
|
||||
LOG.debug("Returning map " + toReturn);
|
||||
LOG.info("Found " + toReturn.size() +" organization/s with the user "+username);
|
||||
}catch(Exception e){
|
||||
LOG.error("Failed to retrieve roles of user in his/her own groups",e);
|
||||
}
|
||||
|
@ -582,6 +585,20 @@ public class DataCatalogueImpl implements DataCatalogue {
|
|||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the user is valid by checking if its API_KEY is present into DB.
|
||||
*
|
||||
* @param username the username
|
||||
* @return true, if successful
|
||||
*/
|
||||
@Override
|
||||
public boolean checkValidUser(String username) {
|
||||
|
||||
String apiKey = getApiKeyFromUsername(username);
|
||||
return apiKey != null;
|
||||
|
||||
}
|
||||
|
||||
private String getApiKeyFromUsername(String username) {
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class TestDataCatalogueLib {
|
|||
//private String scope = "/d4science.research-infrastructures.eu/SoBigData/Catalogue-TerritoriAperti";
|
||||
//private String scope = "/d4science.research-infrastructures.eu/gCubeApps/BiodiversityLab";
|
||||
//private String testUser = "costantino_perciante";
|
||||
private String testUser = "francesco.mangiacrapa";
|
||||
private String testUser = "francescomangiacrapa";
|
||||
private String authorizationToken = "";
|
||||
String subjectId = "aa_father4";
|
||||
String objectId = "bb_son4";
|
||||
|
@ -103,7 +103,7 @@ public class TestDataCatalogueLib {
|
|||
* @return the user role by group
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void getUserRoleByGroup() throws Exception{
|
||||
DataCatalogueImpl instance = factory.getUtilsPerScope(scope);
|
||||
String username = testUser;
|
||||
|
@ -184,7 +184,7 @@ public class TestDataCatalogueLib {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void createDataset() throws Exception{
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue