From 319564e9931255230e04a3a40ffee4cb6550587f Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 1 Jun 2020 17:12:28 +0200 Subject: [PATCH] on going on migration to gCat --- .classpath | 6 +- .gitignore | 1 + pom.xml | 6 + .../ckanutillibrary/db/DBCaller.java | 122 +++- .../ckanutillibrary/server/DataCatalogue.java | 148 +++-- .../server/DataCatalogueImpl.java | 39 +- src/test/java/TestDataCatalogueLib.java | 615 ++++++++++++++++++ src/test/resources/.gitignore | 7 + target/classes/META-INF/MANIFEST.MF | 2 +- .../catalogue-util-library/pom.properties | 2 +- .../catalogue-util-library/pom.xml | 6 + .../ckanutillibrary/db/DBCaller.class | Bin 6228 -> 7308 bytes .../ckanutillibrary/db/DBCaller.java | 122 +++- .../server/DataCatalogue.class | Bin 2450 -> 2655 bytes .../ckanutillibrary/server/DataCatalogue.java | 148 +++-- .../server/DataCatalogueImpl.class | Bin 20700 -> 21813 bytes .../server/DataCatalogueImpl.java | 39 +- 17 files changed, 1054 insertions(+), 209 deletions(-) create mode 100644 .gitignore create mode 100644 src/test/java/TestDataCatalogueLib.java create mode 100644 src/test/resources/.gitignore diff --git a/.classpath b/.classpath index ae19729..afb1550 100644 --- a/.classpath +++ b/.classpath @@ -11,17 +11,17 @@ - + + - - + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/pom.xml b/pom.xml index 668791f..e930208 100644 --- a/pom.xml +++ b/pom.xml @@ -61,6 +61,12 @@ compile + + org.postgresql + postgresql + ${postgresVersion} + + org.gcube.data-publishing gcat-client diff --git a/src/main/java/org/gcube/datacatalogue/ckanutillibrary/db/DBCaller.java b/src/main/java/org/gcube/datacatalogue/ckanutillibrary/db/DBCaller.java index 7be49c9..f989172 100644 --- a/src/main/java/org/gcube/datacatalogue/ckanutillibrary/db/DBCaller.java +++ b/src/main/java/org/gcube/datacatalogue/ckanutillibrary/db/DBCaller.java @@ -15,6 +15,13 @@ import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +// TODO: Auto-generated Javadoc +/** + * The Class DBCaller. + * + * @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy) + * Jun 1, 2020 + */ public class DBCaller { private static final Logger LOG = LoggerFactory.getLogger(DBCaller.class); @@ -25,9 +32,21 @@ public class DBCaller { private String CKAN_DB_USER; private String CKAN_DB_PASSWORD; + /** + * Instantiates a new DB caller. + */ public DBCaller() { } + /** + * Instantiates a new DB caller. + * + * @param cKAN_DB_URL the c KA N D B URL + * @param cKAN_DB_PORT the c KA N D B PORT + * @param cKAN_DB_NAME the c KA N D B NAME + * @param cKAN_DB_USER the c KA N D B USER + * @param cKAN_DB_PASSWORD the c KA N D B PASSWORD + */ public DBCaller(String cKAN_DB_URL, Integer cKAN_DB_PORT, String cKAN_DB_NAME, String cKAN_DB_USER, String cKAN_DB_PASSWORD) { CKAN_DB_URL = cKAN_DB_URL; @@ -39,14 +58,15 @@ public class DBCaller { /** - * Retrieve connection from the pool + * Retrieve connection from the pool. + * * @return a connection available within the pool - * @throws SQLException - * @throws ClassNotFoundException + * @throws SQLException the SQL exception + * @throws ClassNotFoundException the class not found exception */ private Connection getConnection() throws SQLException, ClassNotFoundException{ - LOG.debug("CONNECTION REQUEST"); + LOG.trace("CONNECTION REQUEST"); // create db connection Class.forName("org.postgresql.Driver"); @@ -57,6 +77,8 @@ public class DBCaller { dbBaseConnectionURL+="/" + CKAN_DB_NAME; + LOG.debug("DB CONNECTION URL: "+dbBaseConnectionURL); + Connection connection = DriverManager.getConnection(dbBaseConnectionURL, CKAN_DB_USER, CKAN_DB_PASSWORD); // Connection connection = DriverManager.getConnection( @@ -67,13 +89,13 @@ public class DBCaller { /** * Retrieve the map (groups id, capacity) with the groups to which the user belongs by querying directly the database. - * @param username - * @return - * @throws SQLException - * @throws ClassNotFoundException + * + * @param username the username + * @return the groups by user from DB */ - public Map getGroupsByUserFromDB(String userId){ - checkNotNull(userId); + public Map getGroupsByUserFromDB(String username){ + checkNotNull(username); + LOG.debug("Get groups by user called"); //couples (groups id, capacity) of the user in the group @@ -81,18 +103,20 @@ public class DBCaller { Connection connection = null; try{ - connection = getConnection(); - ResultSet rs; + String userId = getUserIdForUsername(username); + connection = getConnection(); + String joinQuery = "SELECT \"group_id\",\"capacity\" FROM \"public\".\"member\" " + "JOIN \"public\".\"group\" ON \"member\".\"group_id\" = \"group\".\"id\" where \"table_id\"=?" + " and \"table_name\"='user' and \"member\".\"state\"='active' and \"group\".\"state\"='active' and \"group\".\"is_organization\"=?;"; - + + LOG.debug("Performing query: "+joinQuery); PreparedStatement preparedStatement = connection.prepareStatement(joinQuery); preparedStatement.setString(1, userId); preparedStatement.setBoolean(2, false); - rs = preparedStatement.executeQuery(); + ResultSet rs = preparedStatement.executeQuery(); while (rs.next()) { @@ -108,19 +132,62 @@ public class DBCaller { return toReturn; } + /** - * Retrieve the map (organisation id, capacity) with the organisations to which the user belongs by querying directly the database. - * @param username - * @return - * @throws SQLException - * @throws ClassNotFoundException + * Gets the user id for username. + * + * @param username the username + * @return the user id for username */ - public Map getOrganizationsByUserFromDB(String userId){ - checkNotNull(userId); + private String getUserIdForUsername(String username) { + LOG.debug("Get user id for username called"); + + Connection connection = null; + String userId = null; + try{ + + connection = getConnection(); + + String selQuery = "SELECT \"id\" FROM \"public\".\"user\" WHERE \"name\"=?;"; + + LOG.info("Performing query: "+selQuery); + + PreparedStatement preparedStatement = connection.prepareStatement(selQuery); + preparedStatement.setString(1, username); + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + userId = rs.getString("id"); + break; + } + + LOG.debug("For username "+username+" returning the user id: "+userId); + return userId; + + }catch(Exception e){ + LOG.error("Failed to retrieve the user id for username:"+username+". Error is " + e.getMessage()); + return null; + }finally{ + closeConnection(connection); + } + + } + + /** + * Retrieve the map (organisation id, capacity) with the organisations to which the user belongs by querying directly the database. + * + * @param username the username + * @return the organizations by user from DB + */ + public Map getOrganizationsByUserFromDB(String username){ + LOG.debug("Get organisations by user called"); + checkNotNull(username); Map toReturn = new HashMap(); Connection connection = null; try{ + + String userId = getUserIdForUsername(username); connection = getConnection(); ResultSet rs; @@ -150,6 +217,13 @@ public class DBCaller { } + /** + * Gets the api key from username. + * + * @param username the username + * @param state the state + * @return the api key from username + */ public String getApiKeyFromUsername(String username, String state) { LOG.debug("Request api key for user = " + username); @@ -191,14 +265,16 @@ public class DBCaller { /** - * Tries to close a connection - * @param connection + * Tries to close a connection. + * + * @param connection the connection */ private void closeConnection(Connection connection){ if(connection != null){ try{ connection.close(); + LOG.trace("CONNECTION CLOSED"); }catch(Exception e){ LOG.error("Unable to close this connection ", e); } diff --git a/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogue.java b/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogue.java index 800a459..e8b5494 100644 --- a/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogue.java +++ b/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogue.java @@ -11,12 +11,19 @@ import eu.trentorise.opendata.jackan.model.CkanGroup; import eu.trentorise.opendata.jackan.model.CkanLicense; import eu.trentorise.opendata.jackan.model.CkanOrganization; +// TODO: Auto-generated Javadoc +/** + * The Interface DataCatalogue. + * + * @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy) + * Jun 1, 2020 + */ public interface DataCatalogue { /** - * Finds the id associated to the chosen license - * - * @param chosenLicense + * Finds the id associated to the chosen license. + * + * @param chosenLicense the chosen license * @return the id on success, null otherwise */ String findLicenseIdByLicenseTitle(String chosenLicense); @@ -26,8 +33,8 @@ public interface DataCatalogue { * contacting the uri resolver. If no uri resolver is available, an url that is * not guaranteed to be long term valid will be generated. Information are not * encrypted. - * - * @param datasetId + * + * @param datasetIdOrName the dataset id or name * @return The url of the dataset on success, null otherwise */ String getUnencryptedUrlFromDatasetIdOrName(String datasetIdOrName); @@ -37,23 +44,23 @@ public interface DataCatalogue { * values for the same custom field key. NOTE: unfortunately java doesn't * support overload in java interface methods (that's way I cannot use the same * name for the method) - * - * @param title + * + * @param title the title * @param name (unique identifier) - * @param organizationNameOrId - * @param author - * @param authorMail - * @param maintainer - * @param maintainerMail - * @param version - * @param description - * @param licenseId - * @param tags - * @param customFields - * @param resources + * @param organizationNameOrId the organization name or id + * @param author the author + * @param authorMail the author mail + * @param maintainer the maintainer + * @param maintainerMail the maintainer mail + * @param version the version + * @param description the description + * @param licenseId the license id + * @param tags the tags + * @param customFields the custom fields + * @param resources the resources * @param setPublic (manage visibility: Admin role is needed) * @return the id of the dataset on success, null otherwise - * @throws Exception + * @throws Exception the exception */ String createCKanDatasetMultipleCustomFields(String title, String name, String organizationNameOrId, String author, String authorMail, String maintainer, String maintainerMail, long version, String description, @@ -66,11 +73,11 @@ public interface DataCatalogue { * If a custom field with a given key already exists, and removeOld is set to * false, the new values are added at the end of the list. Otherwise they are * lost. - * - * @param productId - * @param customFieldsToChange - * @param removeOld - * @return + * + * @param productId the product id + * @param customFieldsToChange the custom fields to change + * @param removeOld the remove old + * @return true, if successful */ boolean patchProductCustomFields(String productId, Map> customFieldsToChange, boolean removeOld); @@ -78,40 +85,26 @@ public interface DataCatalogue { /** * Add a resource described by the bean to the dataset id into * resource.datasetId - * - * @param resource + * + * @param resource the resource * @return String the id of the resource on success, null otherwise + * @throws Exception the exception */ String addResourceToDataset(ResourceBean resource) throws Exception; /** * Remove the resource with id resourceId from the dataset in which it is. - * - * @param resourceId + * + * @param resourceId the resource id * @return true on success, false otherwise. */ boolean deleteResourceFromDataset(String resourceId); /** * Create a dataset with those information. - * - * @param apiKey - * @param title - * @param name (unique identifier) - * @param organizationNameOrId - * @param author - * @param authorMail - * @param maintainer - * @param maintainerMail - * @param version - * @param description - * @param licenseId - * @param tags - * @param customFields - * @param resources - * @param setPublic (manage visibility: Admin role is needed) + * + * @param nameOrId the name or id * @return the id of the dataset on success, null otherwise - * @throws Exception */ /** @@ -123,16 +116,6 @@ public interface DataCatalogue { */ boolean existProductWithNameOrId(String nameOrId); - /** - * The method returns the role the user has in the groups he/she belongs to (it - * uses the db, so it is much faster) - * - * @param username - * @param apiKey - * @return - */ - Map> getUserRoleByGroup(String username, String apiKey); - /** * Get the list of licenses' titles. * @@ -141,30 +124,30 @@ public interface DataCatalogue { List getLicenseTitles(); /** - * Retrieve ckan licenses - * - * @return + * Retrieve ckan licenses. + * + * @return the licenses */ List getLicenses(); /** - * Retrieve the url of the uri resolver for this catalogue instance/scope - * - * @return + * Retrieve the url of the uri resolver for this catalogue instance/scope. + * + * @return the uri resolver url */ String getUriResolverUrl(); /** - * Return the manage product property - * + * Return the manage product property. + * * @return the manage product property */ boolean isManageProductEnabled(); /** * Return the catalogue portlet for this context(i.e. scope) - * - * @return + * + * @return the portlet url */ String getPortletUrl(); @@ -177,24 +160,45 @@ public interface DataCatalogue { /** - * Returns the list of organizations to whom the user belongs (with any role) - * @param username + * Returns the list of organizations to whom the user belongs (with any role). + * + * @param username the username * @return a list of organizations */ List getOrganizationsByUser(String username); /** - * Returns the list of groups to whom the user belongs (with any role) - * @param username + * Returns the list of groups to whom the user belongs (with any role). + * + * @param username the username * @return a list of groups */ List getGroupsByUser(String username); /** - * Retrieve a ckan dataset given its id - * @param datasetId - * @return + * Retrieve a ckan dataset given its id. + * + * @param datasetId the dataset id + * @param apiKey the api key + * @return the dataset */ CkanDataset getDataset(String datasetId, String apiKey); + + /** + * Gets the user role by group. + * + * @param username the username + * @return the user role by group + */ + Map> getUserRoleByGroup(String username); + + /** + * The method returns the role the user has in the organizations he/she belongs to (it uses the db, so it is much faster) + * @param username + * @param apiKey + * @return + */ + Map> getUserRoleByOrganization(String username); + } diff --git a/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogueImpl.java b/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogueImpl.java index c2f2839..099f1e9 100644 --- a/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogueImpl.java +++ b/src/main/java/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogueImpl.java @@ -280,14 +280,9 @@ public class DataCatalogueImpl implements DataCatalogue { } @Override - public Map> getUserRoleByGroup( - String username, String apiKey) { - + public Map> getUserRoleByGroup(String username) { + LOG.info("Get user role by group called. The username is: "+username); checkNotNull(username); - checkNotNull(apiKey); - - checkNotNull(username); - checkNotNull(apiKey); Map> toReturn = new HashMap>(); @@ -313,6 +308,36 @@ public class DataCatalogueImpl implements DataCatalogue { } + @Override + public Map> getUserRoleByOrganization( + String username) { + LOG.info("Get user role by organization called. The username is: "+username); + + checkNotNull(username); + + Map> toReturn = new HashMap>(); + + try{ + + String ckanUsername = CatalogueUtilMethods.fromUsernameToCKanUsername(username); + Map partialResult = dbCaller.getOrganizationsByUserFromDB(ckanUsername); + + for (String orgID : partialResult.keySet()) { + + CkanOrganization org = ckanCaller.getOrganization(orgID); + HashMap subMap = new HashMap(); + subMap.put(org, partialResult.get(orgID)); + toReturn.put(orgID, subMap); + } + + LOG.debug("Returning map " + toReturn); + }catch(Exception e){ + LOG.error("Failed to retrieve roles of user in his/her own groups",e); + } + + return toReturn; + } + /** * Retrieve an url for the tuple scope, entity, entity name diff --git a/src/test/java/TestDataCatalogueLib.java b/src/test/java/TestDataCatalogueLib.java new file mode 100644 index 0000000..cb00cbe --- /dev/null +++ b/src/test/java/TestDataCatalogueLib.java @@ -0,0 +1,615 @@ + + +import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.datacatalogue.ckanutillibrary.server.ApplicationProfileScopePerUrlReader; +import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueFactory; +import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueImpl; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.LoggerFactory; + +/** + * The Class TestDataCatalogueLib. + * + * @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy) + * Jun 1, 2020 + */ +public class TestDataCatalogueLib { + + private static final org.slf4j.Logger logger = LoggerFactory.getLogger(TestDataCatalogueLib.class); + + private DataCatalogueFactory factory; + private String scope = "/gcube/devsec/devVRE"; + //private String testUser = "costantino_perciante"; + private String testUser = "francesco_mangiacrapa"; + String subjectId = "aa_father4"; + String objectId = "bb_son4"; + + /** + * Before. + * + * @throws Exception the exception + */ + @Before + public void before() throws Exception{ + factory = DataCatalogueFactory.getFactory(); + } + + /** + * Factory test. + * + * @throws Exception the exception + */ + //@Test + public void factoryTest() throws Exception{ + + DataCatalogueFactory factory = DataCatalogueFactory.getFactory(); + + while(true){ + factory.getUtilsPerScope("/gcube"); + Thread.sleep(60* 1000 * 3); + factory.getUtilsPerScope("/gcube"); + break; + } + + for (int i = 0; i < 5; i++) { + Thread.sleep(1000); + factory.getUtilsPerScope("/gcube"); + } + + } + + + /** + * Gets the scope per url. + * + * @return the scope per url + */ + //@Test + public void getScopePerUrl(){ + + ScopeProvider.instance.set("/gcube"); + String url = "https://dev4.d4science.org/group/devvre/ckan"; + String scopeToUse = ApplicationProfileScopePerUrlReader.getScopePerUrl(url); + logger.debug("Retrieved scope is " + scopeToUse); + + ScopeProvider.instance.reset(); // the following sysout should print null + String url2 = "https://dev4.d4science.org/group/devvre/ckan"; + String scopeToUse2 = ApplicationProfileScopePerUrlReader.getScopePerUrl(url2); + logger.debug("Retrieved scope is " + scopeToUse2); + } + + + /** + * Gets the user role by group. + * + * @return the user role by group + * @throws Exception the exception + */ + @Test + public void getUserRoleByGroup() throws Exception{ + DataCatalogueImpl instance = factory.getUtilsPerScope(scope); + String username = testUser; + long init = System.currentTimeMillis(); + instance.getUserRoleByGroup(username); + long end = System.currentTimeMillis(); + logger.debug("Time taken " + (end - init)); + } + + /** + * Gets the user role by organization. + * + * @return the user role by organization + * @throws Exception the exception + */ + //@Test + public void getUserRoleByOrganization() throws Exception{ + DataCatalogueImpl instance = factory.getUtilsPerScope(scope); + String username = testUser; + long init = System.currentTimeMillis(); + instance.getUserRoleByOrganization(username); + long end = System.currentTimeMillis(); + logger.debug("Time taken " + (end - init)); + } + + + +// //@Test +// public void getSysadminEmail() throws Exception{ +// DataCatalogueImpl utils = factory.getUtilsPerScope(scope); +// System.out.println(utils.getCatalogueEmail()); +// } +// +// //@Test +// public void getStatistics() throws Exception{ +// +// DataCatalogueImpl utils = factory.getUtilsPerScope(scope); +// logger.debug("Statistics " + utils.getStatistics()); +// +// } +// +// //@Test +// public void getLandingPages() throws Exception{ +// +// DataCatalogueImpl utils = factory.getUtilsPerScope(scope); +// logger.debug("Landing pages " + utils.getLandingPages()); +// +// } +// +// //@Test +// public void getOrganizationForName() throws Exception{ +// +// String orgName = "nextnext"; +// +// DataCatalogueImpl utils = factory.getUtilsPerScope(scope); +// +// CkanOrganization org = utils.getOrganizationByName(orgName); +// +// logger.debug("The "+CkanOrganization.class.getSimpleName()+" is: "+org.getName()); +// logger.debug("LandingPages of "+CkanOrganization.class.getSimpleName()+" for name " + utils.getLandingPages()); +// if(org.getUsers()!=null) { +// +// for (CkanUser user : org.getUsers()) { +// logger.debug("User: "+user.getName()); +// } +// } +// } +// +// +// //@Test +// public void getRoleOfUserInOrganization() throws Exception{ +// +// String orgName = "nextnext"; +// +// DataCatalogueImpl utils = factory.getUtilsPerScope(scope); +// +// CkanOrganization org = utils.getOrganizationByName(orgName); +// +// String apiKey = utils.getApiKeyFromUsername(testUser); +// +// String role = utils.getRoleOfUserInOrganization(testUser, org.getName(), apiKey); +// +// logger.debug("The user "+testUser+" in the org "+org.getName() + " has the role "+role); +// } +// +// //@Test +// public void getGroupForName() throws Exception{ +// +// String groupName = "ariadne"; +// +// DataCatalogueImpl utils = factory.getUtilsPerScope(scope); +// +// CkanGroup org = utils.getGroupByName(groupName); +// +// logger.debug("The "+CkanGroup.class.getSimpleName()+" is: "+org.getName()); +// logger.debug("LandingPages of "+CkanGroup.class.getSimpleName()+" for name " + utils.getLandingPages()); +// if(org.getUsers()!=null) { +// +// for (CkanUser user : org.getUsers()) { +// logger.debug("User: "+user.getName()); +// } +// } +// } +// +// //@Test +// public void getDatasetIdsFromDB() throws Exception{ +// DataCatalogueImpl utils = factory.getUtilsPerScope(scope); +// List ids = utils.getProductsIdsInGroupOrOrg("aquamaps", true, 0, Integer.MAX_VALUE); +// logger.debug("Size is " + ids.size()); +// } +// +// //@Test +// public void searchInOrganization() throws Exception{ +// DataCatalogueImpl utils = factory.getUtilsPerScope(scope); +// String apiKey = utils.getApiKeyFromUsername(testUser); +// List matches = utils.searchForPackageInOrganization(apiKey, "\"asfis:HMC+eez:AGO;FAO+grsf-org:INT+eez:AGO;RFB+iso3:AGO+isscfg:01.1.1\"", 0, 10, "grsf_admin"); +// logger.debug("Size is " + matches.size()); +// } +// +// //@Test +// public void search() throws Exception{ +// DataCatalogueImpl utils = factory.getUtilsPerScope(scope); +// String apiKey = utils.getApiKeyFromUsername(testUser); +// List matches = utils.searchForPackage(apiKey, "\"asfis:HMC+eez:AGO;FAO+grsf-org:INT+eez:AGO;RFB+iso3:AGO+isscfg:01.1.1\"", 0, 10); +// logger.debug("Size is " + matches.size()); +// } +// +// // @Test +// public void testManageProduct() throws Exception{ +// +// DataCatalogueImpl catalogue = factory.getUtilsPerScope(scope); +// String apiKey = catalogue.getApiKeyFromUsername("costantino_perciante"); +// //Map> map = new HashMap>(); +// //map.put("a new custom field", Arrays.asList("a new custom field 2")); +// //catalogue.patchProductCustomFields("test-searchable-504043", apiKey, map); +// catalogue.removeCustomField("test-searchable-504043", "a new custom field", "a new custom field", apiKey); +// } +// +// //@Test +// public void getRole() throws Exception{ +// +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// instance.getOrganizationsAndRolesByUser(testUser, Arrays.asList(RolesCkanGroupOrOrg.ADMIN, RolesCkanGroupOrOrg.EDITOR, RolesCkanGroupOrOrg.MEMBER +// )); +// +// } +// +// //@Test +// public void datasetsRelationshipCreate() throws Exception{ +// +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// +// DatasetRelationships relation = DatasetRelationships.parent_of; +// +// boolean resC = instance.createDatasetRelationship(subjectId, objectId, relation, "Comment for this relationship", instance.getApiKeyFromUsername(testUser)); +// +// logger.debug("Res is " + resC); +// } +// +// //@Test +// public void datasetsRelationshipDelete() throws Exception{ +// +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// DatasetRelationships relation = DatasetRelationships.child_of; +// +// boolean resD = instance.deleteDatasetRelationship(subjectId, objectId, relation, instance.getApiKeyFromUsername(testUser)); +// +// logger.debug("ResD is " + resD); +// } +// +// //@Test +// public void datasetRelationshipRetrieve() throws Exception{ +// +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// +// List res = instance.getRelationshipDatasets(subjectId, objectId, instance.getApiKeyFromUsername(testUser)); +// +// logger.debug("Relationships " + res); +// +// } +// +// +// //@Test +// public void testgetApiKeyFromUser() throws Exception { +// +// logger.debug("Testing getApiKeyFromUser"); +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// +// String username = "francescomangiacrapa"; +// String key = instance.getApiKeyFromUsername(username); +// +// System.out.println("key for " + username + " is " + key); +// } +// +// //@Test +// public void testgetUserFromApiKey() throws Exception { +// +// logger.debug("Testing getApiKeyFromUser"); +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// +// String key = "put-your-key-here"; +// CKanUserWrapper user = instance.getUserFromApiKey(key); +// +// System.out.println("user for " + key + " is " + user); +// } +// +// //@Test +// public void getOrganizationsByUser() throws Exception { +// +// System.out.println("Testing getOrganizationsByUser"); +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// +// String username = "francescomangiacrapa"; +// List organizations = instance.getOrganizationsByUser(username); +// +// System.out.println("organizations for user " + username + " are: "); +// +// for (CkanOrganization ckanOrganization : organizations) { +// System.out.println("-" + ckanOrganization.getName()); +// } +// } +// +// //@Test +// public void getGroupsAndRolesByUser() throws Exception { +// +// logger.debug("Testing getGroupsAndRolesByUser"); +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// +// String username = "andrea.rossi"; +// instance = new DataCatalogueImpl("/gcube"); +// List rolesToMatch = new ArrayList(); +// rolesToMatch.add(RolesCkanGroupOrOrg.ADMIN); +// rolesToMatch.add(RolesCkanGroupOrOrg.MEMBER); +// rolesToMatch.add(RolesCkanGroupOrOrg.EDITOR); +// Map> map = instance.getOrganizationsAndRolesByUser(username, rolesToMatch); +// +// System.out.println("organizations for user " + username + " are " + map); +// } +// +// //@Test +// public void getUsers() throws Exception{ +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// +// List rolesToMatch = new ArrayList(); +// rolesToMatch.add(RolesCkanGroupOrOrg.ADMIN); +// rolesToMatch.add(RolesCkanGroupOrOrg.EDITOR); +// +// Map> orgs = instance.getOrganizationsAndRolesByUser("costantino_perciante", rolesToMatch); +// +// Iterator>> iterator = orgs.entrySet().iterator(); +// +// while (iterator.hasNext()) { +// Map.Entry> entry = (Map.Entry>) iterator +// .next(); +// +// logger.debug("Org is " + entry.getKey() + " and role is " + entry.getValue().get(0)); +// +// } +// } +// +// +// +// //@Test +// public void createUsers() throws Exception{ +// +// DataCatalogueImpl instance = factory.getUtilsPerScope("/gcube/devsec/devVRE"); +// CheckedCkanClient client = new CheckedCkanClient(instance.getCatalogueUrl(), instance.getApiKeyFromUsername("costantino_perciante")); +// CkanUser editorUser = new CkanUser("user_editor_devvre", "user_editor_devvre@test.it", ""); +// client.createUser(editorUser); +// CkanUser adminUser = new CkanUser("user_admin_devvre", "user_admin_devvre@test.it", ""); +// client.createUser(adminUser); +// CkanUser memberUser = new CkanUser("user_member_devvre", "user_member_devvre@test.it", ""); +// client.createUser(memberUser); +// +// } +// +// //@Test +// public void createAsEditor() throws Exception{ +// DataCatalogueImpl instance = factory.getUtilsPerScope("/gcube/devsec/devVRE"); +// boolean checkedEditor = instance.checkRoleIntoOrganization("user_editor_devvre", "devvre", RolesCkanGroupOrOrg.MEMBER); +// if(checkedEditor){ +// logger.debug("Created editor in devvre? " + checkedEditor); +// } +// boolean checkedAdmin = instance.checkRoleIntoOrganization("user_admin_devvre", "devvre", RolesCkanGroupOrOrg.MEMBER); +// if(checkedAdmin){ +// logger.debug("Created admin in devvre? " + checkedAdmin); +// } +// boolean checkedMember = instance.checkRoleIntoOrganization("user_member_devvre", "devvre", RolesCkanGroupOrOrg.MEMBER); +// if(checkedMember){ +// logger.debug("Created member in devvre? " + checkedMember); +// } +// } +// +// //@Test +// public void editorCreateDataset() throws Exception{ +// +// DataCatalogueImpl instance = factory.getUtilsPerScope("/gcube/devsec/devVRE"); +// instance.createCKanDataset(instance.getApiKeyFromUsername("user_editor_devvre"), "dataset_as_editor_devvre_private", null, "devvre", null, null, null, null, 1, null, null, null, null, null, false); +// +// } +// +// //@Test +// public void adminCreateDataset() throws Exception{ +// +// DataCatalogueImpl instance = factory.getUtilsPerScope("/gcube/devsec/devVRE"); +// //instance.createCKanDataset(instance.getApiKeyFromUsername("user_admin_devvre"), "dataset_as_admin_devvre", "devvre", null, null, null, null, 1, null, null, null, null, null, false); +// instance.createCKanDataset(instance.getApiKeyFromUsername("user_admin_devvre"), "dataset_as_admin_devvre_private", null, "devvre", null, null, null, null, 1, null, null, null, null, null, false); +// } +// +// //@Test +// public void adminChangeVisibility() throws Exception{ +// +// DataCatalogueImpl instance = factory.getUtilsPerScope("/gcube/devsec/devVRE"); +// //instance.createCKanDataset(instance.getApiKeyFromUsername("user_editor_devvre"), "dataset_as_editor_devvre", "devvre", null, null, null, null, 1, null, null, null, null, null, false); +// //instance.setDatasetPrivate(true, "3571cca5-b0ae-4dc6-b791-434a8e062ce5", "dataset_as_admin_devvre_public", instance.getApiKeyFromUsername("user_admin_devvre")); +// +// boolean res = instance.setDatasetPrivate(false, "3571cca5-b0ae-4dc6-b791-434a8e062ce5", "33bbdcb1-929f-441f-8718-a9e5134f517d", instance.getApiKeyFromUsername("user_admin_devvre")); +// logger.debug(""+res); +// +// // CheckedCkanClient client = new CheckedCkanClient(instance.getCatalogueUrl(), instance.getApiKeyFromUsername("user_admin_devvre")); +// // CkanDataset dataset = client.getDataset("dataset_as_admin_devvre_private"); +// // logger.debug("Current value for private: " + dataset.isPriv()); +// // dataset.setPriv(!dataset.isPriv()); +// // CkanDataset datasetUpd = client.updateDataset(dataset); +// // logger.debug("Private value is " + datasetUpd.isPriv()); +// // +// +// } +// +// //@Test +// public void testInvalidOrgRole() throws Exception{ +// +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// boolean res = instance.isRoleAlreadySet("francesco_mangiacrapa", "devvre_group", RolesCkanGroupOrOrg.ADMIN, true); +// logger.debug(""+res); +// +// // set to editor +// instance.checkRoleIntoGroup("francesco_mangiacrapa", "devvre_group", RolesCkanGroupOrOrg.EDITOR); +// +// } +// +// //@Test +// public void existProductWithNameOrId() throws Exception{ +// +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// boolean res = instance.existProductWithNameOrId("notification_portlet_2"); +// logger.debug(""+res); +// +// } +// +// //@Test +// public void testGroupAssociation() throws Exception{ +// +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// String datasetId = "test_grsf_group_stock_groups_sadsad"; +// String groupName = "assessment-unit"; +// instance.assignDatasetToGroup(groupName, datasetId, instance.getApiKeyFromUsername("costantino_perciante")); +// +// } +// +// //@Test +// public void testAddResource() throws Exception{ +// +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// String datasetId = "test_publish_folder_15_44"; +// //instance.assignDatasetToGroup(groupName, datasetId, instance.getApiKeyFromUsername("costantino_perciante")); +// +// String api = instance.getApiKeyFromUsername("costantino_perciante"); +// CheckedCkanClient client = new CheckedCkanClient(instance.getCatalogueUrl(), api); +// List randomName = Arrays.asList("FIRMS", "RAM", "FishSource"); +// for (int i = 0; i < 100; i++) { +// +// CkanResource resource = new CkanResource("https://goo.gl/FH5AQ5", datasetId); +// String name = randomName.get((int)Math.round(Math.ceil(Math.random() * 3))); +// +// resource.setName(name); +// client.createResource(resource); +// +// } +// } +// +// //@Test +// public void checkGroupRole() throws Exception{ +// +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// String role = instance.getRoleOfUserInGroup("francesco.mangiacrapa", "test-by-francesco", instance.getApiKeyFromUsername("francesco.mangiacrapa")); +// logger.debug("Role is " + role); +// } +// +// //@Test +// public void getURL() throws Exception{ +// DataCatalogueImpl util = factory.getUtilsPerScope("/gcube/devNext/NextNext"); +// +// CkanDataset dataset = new CkanDataset(); +// CheckedCkanClient client = new CheckedCkanClient(util.getCatalogueUrl(), util.getApiKeyFromUsername("costantino_perciante")); +// +// dataset.setName("random-test-" + UUID.randomUUID().toString().substring(0, 5)); +// dataset.setOwnerOrg(client.getOrganization("devvre").getId()); +// dataset.setOpen(true); +// dataset.setPriv(true); +// //CkanDataset id = client.createDataset(dataset); +// +// // util.setDatasetPrivate(true, client.getOrganization("devvre").getId(), id.getId(), util.getApiKeyFromUsername("costantino_perciante")); +// +// } +// +// //@Test +// public void deleteAndPurgeDataset() throws Exception{ +// +// DataCatalogueImpl util = factory.getUtilsPerScope("/gcube/devNext/NextNext"); +// boolean deleted = util.deleteProduct("random-test-56sadadsfsdf", util.getApiKeyFromUsername("user_admin_devvre"), true); +// logger.debug("Deleted ? " + deleted); +// +// } +// +// // @Test +// public void testSearchableSet() throws Exception{ +// +// DataCatalogueImpl util = factory.getUtilsPerScope("/gcube/devNext/NextNext"); +// boolean setSearchability = util.setSearchableField("1b261d07-9f9c-414f-ad8d-c5aa429548fc", false); +// logger.debug("Searchability set? " + setSearchability); +// } +// +// //@Test +// public void testNameConversion(){ +// +// logger.debug(CatalogueUtilMethods.fromCKanUsernameToUsername("costantino_perciante")); +// +// } +// +// //@Test +// public void getGroupsRoles() throws Exception{ +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// Map> res = instance.getRolesAndUsersGroup("abundance-level"); +// logger.debug(res.toString()); +// +// } +// +// //@Test +// public void testResourcePatch() throws Exception{ +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// String id = "858f5e77-80c2-4cb2-bcfc-77529693dc9a"; +// instance.patchResource(id, "http://ftp.d4science.org/previews/69cc0769-de6f-45eb-a842-7be2807e8887.jpg", "new_name_for_testing_patch.csv", "description test", "", instance.getApiKeyFromUsername("costantino_perciante")); +// } +// +// //@Test +// public void testPatchProduct() throws Exception{ +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// Map> customFieldsToChange = new HashMap>(); +// customFieldsToChange.put("Status", Arrays.asList("Pending")); +// instance.patchProductCustomFields("a-test-to-ignore", instance.getApiKeyFromUsername("costantino_perciante"), customFieldsToChange, false); +// } +// +// //@Test +// public void addTag()throws Exception{ +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// instance.addTag("test-after-tags-editing", instance.getApiKeyFromUsername("costantino_perciante"), "api add tag to test"); +// } +// +// //@Test +// public void removeTag()throws Exception{ +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// instance.removeTag("test-after-tags-editing", instance.getApiKeyFromUsername("costantino_perciante"), "api add tag to test"); +// +// } +// +// //@Test +// public void removeGroup()throws Exception{ +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// instance.removeDatasetFromGroup("pending", "test-after-tags-editing", instance.getApiKeyFromUsername("costantino_perciante")); +// +// } +// +// //@Test +// public void getGroups() throws Exception{ +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// instance.getParentGroups("abundance-level", instance.getApiKeyFromUsername("costantino_perciante")); +// +// } +// +// // @Test +// public void createGroupsAndSetAsFather() throws Exception{ +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// //CkanGroup childGroup = instance.createGroup("test-group-child", "A child group", null); +// //CkanGroup parentGroup = instance.createGroup("test-group-parent", "A parent group", null); +// instance.setGroupParent("test-group-parent", "test-group-child"); +// } +// +// //@Test +// public void testBelongsToGroup() throws Exception{ +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// boolean checked = instance.isDatasetInGroup("assessment-unit", "test-after-updates-17-1654"); +// logger.debug("Result is " + checked); +// } +// +// // @Test +// public void getDatasetsInGroup() throws Exception{ +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// List result = instance.getProductsInGroup("assessment-unit"); +// for (CkanDataset ckanDataset : result) { +// logger.debug("Dataset name is " + ckanDataset.getName()); +// } +// } +// +// +// //@Test +// public void getHigher(){ +// logger.debug("Max is " + RolesCkanGroupOrOrg.getHigher(RolesCkanGroupOrOrg.ADMIN, RolesCkanGroupOrOrg.ADMIN)); +// } +// +// //@Test +// public void getUrlProduct() throws Exception{ +// DataCatalogueImpl instance = factory.getUtilsPerScope(scope); +// String datasetName = "test_from_andrea_rossi"; +// String url = instance.getUrlFromDatasetIdOrName(datasetName); +// logger.debug("url is " + url); +// } +// +// //@Test +// public void getCatalogueURLs() throws Exception{ +// DataCatalogueImpl util = factory.getUtilsPerScope("/gcube/devNext/NextNext"); +// logger.debug("MAP ACCESS URL TO CATALOGUE:" +util.getMapAccessURLToCatalogue()); +// +// } + +} diff --git a/src/test/resources/.gitignore b/src/test/resources/.gitignore new file mode 100644 index 0000000..8f08e73 --- /dev/null +++ b/src/test/resources/.gitignore @@ -0,0 +1,7 @@ +/devNext.gcubekey +/devsec.gcubekey +/gcube.gcubekey +/howto.txt +/log4j.properties +/pred4s.gcubekey +/preprod.gcubekey diff --git a/target/classes/META-INF/MANIFEST.MF b/target/classes/META-INF/MANIFEST.MF index 0048ac8..e5cf844 100644 --- a/target/classes/META-INF/MANIFEST.MF +++ b/target/classes/META-INF/MANIFEST.MF @@ -6,7 +6,7 @@ Specification-Version: 0.1.0-SNAPSHOT Implementation-Title: CKan utility library Implementation-Version: 0.1.0-SNAPSHOT Implementation-Vendor-Id: org.gcube.datacatalogue -Build-Time: 20200601-134620 +Build-Time: 20200601-145428 Created-By: Maven Integration for Eclipse SCM-Branch: SCM-Revision: diff --git a/target/classes/META-INF/maven/org.gcube.datacatalogue/catalogue-util-library/pom.properties b/target/classes/META-INF/maven/org.gcube.datacatalogue/catalogue-util-library/pom.properties index c1f2a7e..bff563c 100644 --- a/target/classes/META-INF/maven/org.gcube.datacatalogue/catalogue-util-library/pom.properties +++ b/target/classes/META-INF/maven/org.gcube.datacatalogue/catalogue-util-library/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven Integration for Eclipse -#Mon Jun 01 15:46:21 CEST 2020 +#Mon Jun 01 16:54:29 CEST 2020 version=0.1.0-SNAPSHOT groupId=org.gcube.datacatalogue m2e.projectName=catalogue-util-library diff --git a/target/classes/META-INF/maven/org.gcube.datacatalogue/catalogue-util-library/pom.xml b/target/classes/META-INF/maven/org.gcube.datacatalogue/catalogue-util-library/pom.xml index 668791f..e930208 100644 --- a/target/classes/META-INF/maven/org.gcube.datacatalogue/catalogue-util-library/pom.xml +++ b/target/classes/META-INF/maven/org.gcube.datacatalogue/catalogue-util-library/pom.xml @@ -61,6 +61,12 @@ compile + + org.postgresql + postgresql + ${postgresVersion} + + org.gcube.data-publishing gcat-client diff --git a/target/classes/org/gcube/datacatalogue/ckanutillibrary/db/DBCaller.class b/target/classes/org/gcube/datacatalogue/ckanutillibrary/db/DBCaller.class index ab428406cc26cb503652277fc473f8f4816330e5..6147ada7816a6bbeb1435194f9bf016cc98ea7e2 100644 GIT binary patch delta 3583 zcmb_fdwf&n8GgPbC+8$hFSI~OJ0$By>5Z$~gz(czOHmwcwFn452d3?z4YWx~QiL&# zh|aMgj-GlcUJ!>CESoL3wgC$$j5)V4HUSx%?&`)icVRjQ>g=BHBrZpgn@4^{XA zzIr|6!ZZXA9948-UyltczGM`uh1M@)qp?Jtxk5u!z zeT|KJor+BYqfEms5r5;<8-3x13SYAmcVoO00{6ObAHE_mx?Ybg;%oEk<^@A?6Yw=L zqx@E7V%ltZ@T)S6=^DOf^r@F;YuGA~d9xl`84NY~1NELYEqZ9ZOm7>$q2fU%KbTBe zFc8pdBmQ8(h3#lHPHQ(h+VHT7hXitr0WC*y;SoG)%ymqf)P@}{Jch>woMAmu8Vok- zz5pv#Fn?L$;uN&uNf&nFDWlaEv4&k<9Q?M4Ci*^fQtPBs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ZlG$28USkl8r~sT@OiMawOAIZ$U;tPrK{eMJs#S2(06k)@ILdvDyvPjWwsc<7~1I z+{pbS>>d__Y)aD8#H1~+!_ p;(C*P^=%u2^c9nL1cN-gUO^wPT}QfeX;8}9ioA?{n4uK>@+T4YJa+&9 diff --git a/target/classes/org/gcube/datacatalogue/ckanutillibrary/db/DBCaller.java b/target/classes/org/gcube/datacatalogue/ckanutillibrary/db/DBCaller.java index 7be49c9..f989172 100644 --- a/target/classes/org/gcube/datacatalogue/ckanutillibrary/db/DBCaller.java +++ b/target/classes/org/gcube/datacatalogue/ckanutillibrary/db/DBCaller.java @@ -15,6 +15,13 @@ import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +// TODO: Auto-generated Javadoc +/** + * The Class DBCaller. + * + * @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy) + * Jun 1, 2020 + */ public class DBCaller { private static final Logger LOG = LoggerFactory.getLogger(DBCaller.class); @@ -25,9 +32,21 @@ public class DBCaller { private String CKAN_DB_USER; private String CKAN_DB_PASSWORD; + /** + * Instantiates a new DB caller. + */ public DBCaller() { } + /** + * Instantiates a new DB caller. + * + * @param cKAN_DB_URL the c KA N D B URL + * @param cKAN_DB_PORT the c KA N D B PORT + * @param cKAN_DB_NAME the c KA N D B NAME + * @param cKAN_DB_USER the c KA N D B USER + * @param cKAN_DB_PASSWORD the c KA N D B PASSWORD + */ public DBCaller(String cKAN_DB_URL, Integer cKAN_DB_PORT, String cKAN_DB_NAME, String cKAN_DB_USER, String cKAN_DB_PASSWORD) { CKAN_DB_URL = cKAN_DB_URL; @@ -39,14 +58,15 @@ public class DBCaller { /** - * Retrieve connection from the pool + * Retrieve connection from the pool. + * * @return a connection available within the pool - * @throws SQLException - * @throws ClassNotFoundException + * @throws SQLException the SQL exception + * @throws ClassNotFoundException the class not found exception */ private Connection getConnection() throws SQLException, ClassNotFoundException{ - LOG.debug("CONNECTION REQUEST"); + LOG.trace("CONNECTION REQUEST"); // create db connection Class.forName("org.postgresql.Driver"); @@ -57,6 +77,8 @@ public class DBCaller { dbBaseConnectionURL+="/" + CKAN_DB_NAME; + LOG.debug("DB CONNECTION URL: "+dbBaseConnectionURL); + Connection connection = DriverManager.getConnection(dbBaseConnectionURL, CKAN_DB_USER, CKAN_DB_PASSWORD); // Connection connection = DriverManager.getConnection( @@ -67,13 +89,13 @@ public class DBCaller { /** * Retrieve the map (groups id, capacity) with the groups to which the user belongs by querying directly the database. - * @param username - * @return - * @throws SQLException - * @throws ClassNotFoundException + * + * @param username the username + * @return the groups by user from DB */ - public Map getGroupsByUserFromDB(String userId){ - checkNotNull(userId); + public Map getGroupsByUserFromDB(String username){ + checkNotNull(username); + LOG.debug("Get groups by user called"); //couples (groups id, capacity) of the user in the group @@ -81,18 +103,20 @@ public class DBCaller { Connection connection = null; try{ - connection = getConnection(); - ResultSet rs; + String userId = getUserIdForUsername(username); + connection = getConnection(); + String joinQuery = "SELECT \"group_id\",\"capacity\" FROM \"public\".\"member\" " + "JOIN \"public\".\"group\" ON \"member\".\"group_id\" = \"group\".\"id\" where \"table_id\"=?" + " and \"table_name\"='user' and \"member\".\"state\"='active' and \"group\".\"state\"='active' and \"group\".\"is_organization\"=?;"; - + + LOG.debug("Performing query: "+joinQuery); PreparedStatement preparedStatement = connection.prepareStatement(joinQuery); preparedStatement.setString(1, userId); preparedStatement.setBoolean(2, false); - rs = preparedStatement.executeQuery(); + ResultSet rs = preparedStatement.executeQuery(); while (rs.next()) { @@ -108,19 +132,62 @@ public class DBCaller { return toReturn; } + /** - * Retrieve the map (organisation id, capacity) with the organisations to which the user belongs by querying directly the database. - * @param username - * @return - * @throws SQLException - * @throws ClassNotFoundException + * Gets the user id for username. + * + * @param username the username + * @return the user id for username */ - public Map getOrganizationsByUserFromDB(String userId){ - checkNotNull(userId); + private String getUserIdForUsername(String username) { + LOG.debug("Get user id for username called"); + + Connection connection = null; + String userId = null; + try{ + + connection = getConnection(); + + String selQuery = "SELECT \"id\" FROM \"public\".\"user\" WHERE \"name\"=?;"; + + LOG.info("Performing query: "+selQuery); + + PreparedStatement preparedStatement = connection.prepareStatement(selQuery); + preparedStatement.setString(1, username); + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + userId = rs.getString("id"); + break; + } + + LOG.debug("For username "+username+" returning the user id: "+userId); + return userId; + + }catch(Exception e){ + LOG.error("Failed to retrieve the user id for username:"+username+". Error is " + e.getMessage()); + return null; + }finally{ + closeConnection(connection); + } + + } + + /** + * Retrieve the map (organisation id, capacity) with the organisations to which the user belongs by querying directly the database. + * + * @param username the username + * @return the organizations by user from DB + */ + public Map getOrganizationsByUserFromDB(String username){ + LOG.debug("Get organisations by user called"); + checkNotNull(username); Map toReturn = new HashMap(); Connection connection = null; try{ + + String userId = getUserIdForUsername(username); connection = getConnection(); ResultSet rs; @@ -150,6 +217,13 @@ public class DBCaller { } + /** + * Gets the api key from username. + * + * @param username the username + * @param state the state + * @return the api key from username + */ public String getApiKeyFromUsername(String username, String state) { LOG.debug("Request api key for user = " + username); @@ -191,14 +265,16 @@ public class DBCaller { /** - * Tries to close a connection - * @param connection + * Tries to close a connection. + * + * @param connection the connection */ private void closeConnection(Connection connection){ if(connection != null){ try{ connection.close(); + LOG.trace("CONNECTION CLOSED"); }catch(Exception e){ LOG.error("Unable to close this connection ", e); } diff --git a/target/classes/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogue.class b/target/classes/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogue.class index dc5abafb4ec11370216accfc506457120562f55b..8b83f3594d2282cc92399b545f9ed573e9833c60 100644 GIT binary patch delta 272 zcmbOvd|!m?)W2Q(7#J9g84NaZ-DBCz%GS&zE|i{H5?Y*E6qKKn>Qw1olwVrF$e^q- zS&&tQX*Y;cocxwaZgK}}t(+u^Qvag##JtR^#FEVXJVu5?$VzqjkR`2sCJJayPGDxA z{DxI>atDVtqtN6n9EG(K42%rCK<6+qNV709$S}wLE`HIW%R%{>H`25`87KL delta 205 zcmcaFGD(>0)W2Q(7#J9g8T2-C-D43GN>42bElw>8%Fju4s&p^PFD+nXFrD1UE<9O* zQE2i3HlE1~*x4A*qKa_%O%~w@*!+T}nQ5{sr#7SDNJq}nn1o5gEr7?Mg|?Q4Y~mS=puyx diff --git a/target/classes/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogue.java b/target/classes/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogue.java index 800a459..e8b5494 100644 --- a/target/classes/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogue.java +++ b/target/classes/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogue.java @@ -11,12 +11,19 @@ import eu.trentorise.opendata.jackan.model.CkanGroup; import eu.trentorise.opendata.jackan.model.CkanLicense; import eu.trentorise.opendata.jackan.model.CkanOrganization; +// TODO: Auto-generated Javadoc +/** + * The Interface DataCatalogue. + * + * @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy) + * Jun 1, 2020 + */ public interface DataCatalogue { /** - * Finds the id associated to the chosen license - * - * @param chosenLicense + * Finds the id associated to the chosen license. + * + * @param chosenLicense the chosen license * @return the id on success, null otherwise */ String findLicenseIdByLicenseTitle(String chosenLicense); @@ -26,8 +33,8 @@ public interface DataCatalogue { * contacting the uri resolver. If no uri resolver is available, an url that is * not guaranteed to be long term valid will be generated. Information are not * encrypted. - * - * @param datasetId + * + * @param datasetIdOrName the dataset id or name * @return The url of the dataset on success, null otherwise */ String getUnencryptedUrlFromDatasetIdOrName(String datasetIdOrName); @@ -37,23 +44,23 @@ public interface DataCatalogue { * values for the same custom field key. NOTE: unfortunately java doesn't * support overload in java interface methods (that's way I cannot use the same * name for the method) - * - * @param title + * + * @param title the title * @param name (unique identifier) - * @param organizationNameOrId - * @param author - * @param authorMail - * @param maintainer - * @param maintainerMail - * @param version - * @param description - * @param licenseId - * @param tags - * @param customFields - * @param resources + * @param organizationNameOrId the organization name or id + * @param author the author + * @param authorMail the author mail + * @param maintainer the maintainer + * @param maintainerMail the maintainer mail + * @param version the version + * @param description the description + * @param licenseId the license id + * @param tags the tags + * @param customFields the custom fields + * @param resources the resources * @param setPublic (manage visibility: Admin role is needed) * @return the id of the dataset on success, null otherwise - * @throws Exception + * @throws Exception the exception */ String createCKanDatasetMultipleCustomFields(String title, String name, String organizationNameOrId, String author, String authorMail, String maintainer, String maintainerMail, long version, String description, @@ -66,11 +73,11 @@ public interface DataCatalogue { * If a custom field with a given key already exists, and removeOld is set to * false, the new values are added at the end of the list. Otherwise they are * lost. - * - * @param productId - * @param customFieldsToChange - * @param removeOld - * @return + * + * @param productId the product id + * @param customFieldsToChange the custom fields to change + * @param removeOld the remove old + * @return true, if successful */ boolean patchProductCustomFields(String productId, Map> customFieldsToChange, boolean removeOld); @@ -78,40 +85,26 @@ public interface DataCatalogue { /** * Add a resource described by the bean to the dataset id into * resource.datasetId - * - * @param resource + * + * @param resource the resource * @return String the id of the resource on success, null otherwise + * @throws Exception the exception */ String addResourceToDataset(ResourceBean resource) throws Exception; /** * Remove the resource with id resourceId from the dataset in which it is. - * - * @param resourceId + * + * @param resourceId the resource id * @return true on success, false otherwise. */ boolean deleteResourceFromDataset(String resourceId); /** * Create a dataset with those information. - * - * @param apiKey - * @param title - * @param name (unique identifier) - * @param organizationNameOrId - * @param author - * @param authorMail - * @param maintainer - * @param maintainerMail - * @param version - * @param description - * @param licenseId - * @param tags - * @param customFields - * @param resources - * @param setPublic (manage visibility: Admin role is needed) + * + * @param nameOrId the name or id * @return the id of the dataset on success, null otherwise - * @throws Exception */ /** @@ -123,16 +116,6 @@ public interface DataCatalogue { */ boolean existProductWithNameOrId(String nameOrId); - /** - * The method returns the role the user has in the groups he/she belongs to (it - * uses the db, so it is much faster) - * - * @param username - * @param apiKey - * @return - */ - Map> getUserRoleByGroup(String username, String apiKey); - /** * Get the list of licenses' titles. * @@ -141,30 +124,30 @@ public interface DataCatalogue { List getLicenseTitles(); /** - * Retrieve ckan licenses - * - * @return + * Retrieve ckan licenses. + * + * @return the licenses */ List getLicenses(); /** - * Retrieve the url of the uri resolver for this catalogue instance/scope - * - * @return + * Retrieve the url of the uri resolver for this catalogue instance/scope. + * + * @return the uri resolver url */ String getUriResolverUrl(); /** - * Return the manage product property - * + * Return the manage product property. + * * @return the manage product property */ boolean isManageProductEnabled(); /** * Return the catalogue portlet for this context(i.e. scope) - * - * @return + * + * @return the portlet url */ String getPortletUrl(); @@ -177,24 +160,45 @@ public interface DataCatalogue { /** - * Returns the list of organizations to whom the user belongs (with any role) - * @param username + * Returns the list of organizations to whom the user belongs (with any role). + * + * @param username the username * @return a list of organizations */ List getOrganizationsByUser(String username); /** - * Returns the list of groups to whom the user belongs (with any role) - * @param username + * Returns the list of groups to whom the user belongs (with any role). + * + * @param username the username * @return a list of groups */ List getGroupsByUser(String username); /** - * Retrieve a ckan dataset given its id - * @param datasetId - * @return + * Retrieve a ckan dataset given its id. + * + * @param datasetId the dataset id + * @param apiKey the api key + * @return the dataset */ CkanDataset getDataset(String datasetId, String apiKey); + + /** + * Gets the user role by group. + * + * @param username the username + * @return the user role by group + */ + Map> getUserRoleByGroup(String username); + + /** + * The method returns the role the user has in the organizations he/she belongs to (it uses the db, so it is much faster) + * @param username + * @param apiKey + * @return + */ + Map> getUserRoleByOrganization(String username); + } diff --git a/target/classes/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogueImpl.class b/target/classes/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogueImpl.class index 80c093aaf587cada7799c7049c06f52f61597078..8f19b4d0e023f7cca4cffac9bafc6edf7125c77c 100644 GIT binary patch delta 4119 zcmb_f3wV>|6+Y)A?VqH7X)&ecFGy2b+O%nUp)F!8rRCO(ZNV1l>O>4Bl(4j^X`+DB z3^%9K0jnQOan7PsKt-SwQ%dD3U`0{teTbKNo!9B+=50{VpQNQz@o{d?lPCH9?{dEL zzwde9@5{-%@S*!L_UP%|djTMyUXXwgN<>~^hWJ>C?40UK!W8l9s8M2rK0?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_*VcyD|Py2QS5 zg~8u{2=1jC+{?Zr+{-n%S3Q9HN$!IIdg}j%`$-M%r!}~@Gu%5F?p+Lb6T|%)!@ZB; zKEQAvVz>`8+${|E5eBf8;XcH0?_;=+Gu$T_?o;0Z?$!6<{t@@B{|)Xnop7(FHU928f02{4#0u?rMFI$j!bCON}Fr=JU6EGTOpy-eC{L(hwTt;3a2fu zBeZSfb};hmj{RDbcu~7JIP{qHAngj!-T-_apjREXa}c2=Xd_W+<7qAQvjFX{uG5t{FmmJjK)=6gi-C7#iIL}#_^uhTjH@4@+Qz`JyQxI!0T6kQyyd;?`0 BFFpVO diff --git a/target/classes/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogueImpl.java b/target/classes/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogueImpl.java index c2f2839..099f1e9 100644 --- a/target/classes/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogueImpl.java +++ b/target/classes/org/gcube/datacatalogue/ckanutillibrary/server/DataCatalogueImpl.java @@ -280,14 +280,9 @@ public class DataCatalogueImpl implements DataCatalogue { } @Override - public Map> getUserRoleByGroup( - String username, String apiKey) { - + public Map> getUserRoleByGroup(String username) { + LOG.info("Get user role by group called. The username is: "+username); checkNotNull(username); - checkNotNull(apiKey); - - checkNotNull(username); - checkNotNull(apiKey); Map> toReturn = new HashMap>(); @@ -313,6 +308,36 @@ public class DataCatalogueImpl implements DataCatalogue { } + @Override + public Map> getUserRoleByOrganization( + String username) { + LOG.info("Get user role by organization called. The username is: "+username); + + checkNotNull(username); + + Map> toReturn = new HashMap>(); + + try{ + + String ckanUsername = CatalogueUtilMethods.fromUsernameToCKanUsername(username); + Map partialResult = dbCaller.getOrganizationsByUserFromDB(ckanUsername); + + for (String orgID : partialResult.keySet()) { + + CkanOrganization org = ckanCaller.getOrganization(orgID); + HashMap subMap = new HashMap(); + subMap.put(org, partialResult.get(orgID)); + toReturn.put(orgID, subMap); + } + + LOG.debug("Returning map " + toReturn); + }catch(Exception e){ + LOG.error("Failed to retrieve roles of user in his/her own groups",e); + } + + return toReturn; + } + /** * Retrieve an url for the tuple scope, entity, entity name