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:
parent
6ed9d7eeff
commit
78f8494381
|
@ -230,4 +230,5 @@ public interface CKanUtils {
|
||||||
* @return list of CkanDatasetRelationship objects or null if an error occurs
|
* @return list of CkanDatasetRelationship objects or null if an error occurs
|
||||||
*/
|
*/
|
||||||
List<CkanDatasetRelationship> getRelationshipDatasets(String datasetIdSubject, String datasetIdObject, String apiKey);
|
List<CkanDatasetRelationship> getRelationshipDatasets(String datasetIdSubject, String datasetIdObject, String apiKey);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,10 +164,10 @@ public class CKanUtilsImpl implements CKanUtils{
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
apiToReturn = rs.getString("apikey");
|
apiToReturn = rs.getString("apikey");
|
||||||
|
logger.debug("Api key retrieved for user " + ckanUsername);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("Api key retrieved for user " + ckanUsername);
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Unable to retrieve key for user " + ckanUsername, e);
|
logger.error("Unable to retrieve key for user " + ckanUsername, e);
|
||||||
}finally{
|
}finally{
|
||||||
|
@ -712,9 +712,9 @@ public class CKanUtilsImpl implements CKanUtils{
|
||||||
!setPublic, // swap to private
|
!setPublic, // swap to private
|
||||||
res.getOrganization().getId(),
|
res.getOrganization().getId(),
|
||||||
res.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();
|
return res.getId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class CKanUserWrapper implements Serializable{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
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="
|
+ ", creationTimestamp=" + creationTimestamp + ", about="
|
||||||
+ about + ", openId=" + openId + ", fullName=" + fullName
|
+ about + ", openId=" + openId + ", fullName=" + fullName
|
||||||
+ ", email=" + email + ", isAdmin=" + isAdmin + "]";
|
+ ", email=" + email + ", isAdmin=" + isAdmin + "]";
|
||||||
|
|
|
@ -66,5 +66,16 @@ public class UtilMethods {
|
||||||
return false;
|
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";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue