To set visible/private a product the sysadmin api key is used

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@131291 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-09-12 13:00:30 +00:00
parent 6ed9d7eeff
commit 78f8494381
4 changed files with 17 additions and 5 deletions

View File

@ -230,4 +230,5 @@ public interface CKanUtils {
* @return list of CkanDatasetRelationship objects or null if an error occurs
*/
List<CkanDatasetRelationship> getRelationshipDatasets(String datasetIdSubject, String datasetIdObject, String apiKey);
}

View File

@ -164,10 +164,10 @@ public class CKanUtilsImpl implements CKanUtils{
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
apiToReturn = rs.getString("apikey");
logger.debug("Api key retrieved for user " + ckanUsername);
break;
}
logger.debug("Api key retrieved for user " + ckanUsername);
}catch(Exception e){
logger.error("Unable to retrieve key for user " + ckanUsername, e);
}finally{
@ -712,9 +712,9 @@ public class CKanUtilsImpl implements CKanUtils{
!setPublic, // swap to private
res.getOrganization().getId(),
res.getId(),
apiKey);
CKAN_TOKEN_SYS); // use sysadmin api key to be sure it will be set
logger.debug("Is visibility set to " + (setPublic ? "public" : "private") + "? " + visibilitySet);
logger.debug("Was visibility set to " + (setPublic ? "public" : "private") + "? " + visibilitySet);
return res.getId();
}

View File

@ -125,7 +125,7 @@ public class CKanUserWrapper implements Serializable{
@Override
public String toString() {
return "CKanUserExtended [id=" + id + ", name=" + name + ", apiKey=" + apiKey
return "CKanUserExtended [id=" + id + ", name=" + name + ", apiKey=" + apiKey.substring(0, 5) + "****************"
+ ", creationTimestamp=" + creationTimestamp + ", about="
+ about + ", openId=" + openId + ", fullName=" + fullName
+ ", email=" + email + ", isAdmin=" + isAdmin + "]";

View File

@ -66,5 +66,16 @@ public class UtilMethods {
return false;
}
}
/**
* Given the orgName, returns "orgName_admin" string.
* @return
*/
public static String getUserAdminFromOrganizationName(String orgName){
logger.debug("Going to return " + orgName + "_admin");
return orgName + "_admin";
}
}