Fixing the feature
This commit is contained in:
parent
4a7c0f2a70
commit
0ad1df026e
|
@ -27,7 +27,7 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.8
|
||||||
|
|
14
pom.xml
14
pom.xml
|
@ -66,20 +66,6 @@
|
||||||
<version>1.20</version>
|
<version>1.20</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- ehCAChe -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.cache</groupId>
|
|
||||||
<artifactId>cache-api</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.ehcache</groupId>
|
|
||||||
<artifactId>ehcache</artifactId>
|
|
||||||
<version>3.5.2</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- END ehCAChe -->
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
|
|
@ -70,8 +70,9 @@ public class Validator {
|
||||||
public ObjectNode validateAgainstProfile(ObjectNode objectNode, MetadataUtility metadataUtility) throws Exception {
|
public ObjectNode validateAgainstProfile(ObjectNode objectNode, MetadataUtility metadataUtility) throws Exception {
|
||||||
|
|
||||||
ArrayNode extrasArrayOriginal = (ArrayNode) objectNode.get(CKANPackage.EXTRAS_KEY);
|
ArrayNode extrasArrayOriginal = (ArrayNode) objectNode.get(CKANPackage.EXTRAS_KEY);
|
||||||
if(extrasArrayOriginal == null || extrasArrayOriginal.size()==0) {
|
if(extrasArrayOriginal == null || extrasArrayOriginal.size() == 0) {
|
||||||
throw new BadRequestException("'extras' field is missing in context where metadata profile(s) are defined!");
|
throw new BadRequestException(
|
||||||
|
"'extras' field is missing in context where metadata profile(s) are defined!");
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayNode groupsArrayOriginal = (ArrayNode) objectNode.get(CKANPackage.GROUPS_KEY);
|
ArrayNode groupsArrayOriginal = (ArrayNode) objectNode.get(CKANPackage.GROUPS_KEY);
|
||||||
|
@ -184,7 +185,7 @@ public class Validator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there are no tags, throw an exception
|
// if there are no tags, throw an exception
|
||||||
if(tagsArrayOriginal.size()==0) {
|
if(tagsArrayOriginal.size() == 0) {
|
||||||
throw new BadRequestException("Please define at least one tag for this item!");
|
throw new BadRequestException("Please define at least one tag for this item!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,23 +241,23 @@ public class Validator {
|
||||||
String sysAdminAPI = CKANUtility.getSysAdminAPI();
|
String sysAdminAPI = CKANUtility.getSysAdminAPI();
|
||||||
CKANGroup ckanGroup = new CKANGroup();
|
CKANGroup ckanGroup = new CKANGroup();
|
||||||
ckanGroup.setApiKey(sysAdminAPI);
|
ckanGroup.setApiKey(sysAdminAPI);
|
||||||
ckanGroup.setName(CKANGroup.getGroupName(title));
|
ckanGroup.setName(CKANGroup.getCKANGroupName(title));
|
||||||
try {
|
try {
|
||||||
ckanGroup.read();
|
ckanGroup.read();
|
||||||
} catch (WebApplicationException e) {
|
} catch(WebApplicationException e) {
|
||||||
if(e.getResponse().getStatus()==Status.NOT_FOUND.getStatusCode()) {
|
if(e.getResponse().getStatus() == Status.NOT_FOUND.getStatusCode()) {
|
||||||
ckanGroup.create();
|
ckanGroup.create();
|
||||||
}else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}catch (Exception e) {
|
} catch(Exception e) {
|
||||||
throw new InternalServerErrorException(e);
|
throw new InternalServerErrorException(e);
|
||||||
}finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
addUserToGroupAsSysAdmin(title);
|
addUserToGroupAsSysAdmin(title);
|
||||||
}catch (WebApplicationException e) {
|
} catch(WebApplicationException e) {
|
||||||
throw e;
|
throw e;
|
||||||
}catch (Exception e) {
|
} catch(Exception e) {
|
||||||
throw new InternalServerErrorException(e);
|
throw new InternalServerErrorException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,16 +268,14 @@ public class Validator {
|
||||||
addUserToGroupAsSysAdmin(groupName, username);
|
addUserToGroupAsSysAdmin(groupName, username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addUserToGroupAsSysAdmin(String groupName, String username) throws Exception {
|
public void addUserToGroupAsSysAdmin(String groupName, String username) throws Exception {
|
||||||
String sysAdminAPI = CKANUtility.getSysAdminAPI();
|
String sysAdminAPI = CKANUtility.getSysAdminAPI();
|
||||||
CKANUser ckanUser = new CKANUser();
|
CKANUser ckanUser = new CKANUser();
|
||||||
ckanUser.setApiKey(sysAdminAPI);
|
ckanUser.setApiKey(sysAdminAPI);
|
||||||
ckanUser.setName(username);
|
ckanUser.setName(username);
|
||||||
ckanUser.addToGroup(CKANGroup.getGroupName(groupName));
|
ckanUser.addToGroup(CKANGroup.getCKANGroupName(groupName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate this field and generate a new value (or returns the same if there is nothing to update)
|
* Validate this field and generate a new value (or returns the same if there is nothing to update)
|
||||||
* @param metadataIndex
|
* @param metadataIndex
|
||||||
|
@ -353,16 +352,13 @@ public class Validator {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a tag must be generated
|
* Check if a tag must be generated
|
||||||
* @param fieldToValidate
|
* @param fieldToValidate
|
||||||
* @param metadataField
|
* @param metadataField
|
||||||
* @param tagsArrayOriginal
|
* @param tagsArrayOriginal
|
||||||
*/
|
*/
|
||||||
private void checkAsTag(CustomField fieldToValidate, MetadataField metadataField,
|
private void checkAsTag(CustomField fieldToValidate, MetadataField metadataField, ArrayNode tagsArrayOriginal) {
|
||||||
ArrayNode tagsArrayOriginal) {
|
|
||||||
MetadataTagging tagging = metadataField.getTagging();
|
MetadataTagging tagging = metadataField.getTagging();
|
||||||
if(tagging != null) {
|
if(tagging != null) {
|
||||||
|
|
||||||
|
@ -405,8 +401,8 @@ public class Validator {
|
||||||
* @param isApplication
|
* @param isApplication
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private void checkAsGroup(CustomField fieldToValidate, MetadataField metadataField,
|
private void checkAsGroup(CustomField fieldToValidate, MetadataField metadataField, ArrayNode groupsArrayOriginal,
|
||||||
ArrayNode groupsArrayOriginal, List<String> groupToCreate) throws Exception {
|
List<String> groupToCreate) throws Exception {
|
||||||
|
|
||||||
logger.debug("Custom field is " + fieldToValidate);
|
logger.debug("Custom field is " + fieldToValidate);
|
||||||
logger.debug("MetadataField field is " + metadataField);
|
logger.debug("MetadataField field is " + metadataField);
|
||||||
|
@ -437,12 +433,12 @@ public class Validator {
|
||||||
}
|
}
|
||||||
|
|
||||||
for(String title : groupNames) {
|
for(String title : groupNames) {
|
||||||
logger.debug("Adding group to which add this item " + CatalogueUtilMethods.fromGroupTitleToName(title));
|
String groupName = CKANGroup.getCKANGroupName(title);
|
||||||
|
logger.debug("Adding group to which add this item {}", groupName);
|
||||||
ObjectNode group = mapper.createObjectNode();
|
ObjectNode group = mapper.createObjectNode();
|
||||||
group.put("name", CatalogueUtilMethods.fromGroupTitleToName(title));
|
group.put("name", groupName);
|
||||||
if(propagateUp) {
|
if(propagateUp) {
|
||||||
List<String> parents = Validator
|
List<String> parents = Validator.getGroupHierarchyNames(groupName);
|
||||||
.getGroupHierarchyNames(CatalogueUtilMethods.fromGroupTitleToName(title));
|
|
||||||
for(String parent : parents) {
|
for(String parent : parents) {
|
||||||
ObjectNode groupP = mapper.createObjectNode();
|
ObjectNode groupP = mapper.createObjectNode();
|
||||||
groupP.put("name", parent);
|
groupP.put("name", parent);
|
||||||
|
@ -500,8 +496,8 @@ public class Validator {
|
||||||
case Text:
|
case Text:
|
||||||
|
|
||||||
if(regex != null && !value.matches(regex))
|
if(regex != null && !value.matches(regex))
|
||||||
throw new BadRequestException("Field with key '" + key + "' doesn't match the provided regular expression ("
|
throw new BadRequestException("Field with key '" + key
|
||||||
+ regex + ")!");
|
+ "' doesn't match the provided regular expression (" + regex + ")!");
|
||||||
|
|
||||||
if(hasControlledVocabulary) {
|
if(hasControlledVocabulary) {
|
||||||
|
|
||||||
|
@ -536,7 +532,8 @@ public class Validator {
|
||||||
for(int i = 0; i < timeValues.length; i++) {
|
for(int i = 0; i < timeValues.length; i++) {
|
||||||
String time = timeValues[i];
|
String time = timeValues[i];
|
||||||
if(!isValidDate(time))
|
if(!isValidDate(time))
|
||||||
throw new BadRequestException("Field with key '" + key + "' doesn't seem a valid time interval!");
|
throw new BadRequestException(
|
||||||
|
"Field with key '" + key + "' doesn't seem a valid time interval!");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -546,11 +543,13 @@ public class Validator {
|
||||||
for(int i = 0; i < timeIntervals.length; i++) {
|
for(int i = 0; i < timeIntervals.length; i++) {
|
||||||
String[] timeIntervalValues = timeIntervals[i].split("/");
|
String[] timeIntervalValues = timeIntervals[i].split("/");
|
||||||
if(timeIntervalValues.length > 2)
|
if(timeIntervalValues.length > 2)
|
||||||
throw new BadRequestException("Field with key '" + key + "' doesn't seem a valid list of times!");
|
throw new BadRequestException(
|
||||||
|
"Field with key '" + key + "' doesn't seem a valid list of times!");
|
||||||
for(i = 0; i < timeIntervalValues.length; i++) {
|
for(i = 0; i < timeIntervalValues.length; i++) {
|
||||||
String time = timeIntervalValues[i];
|
String time = timeIntervalValues[i];
|
||||||
if(!isValidDate(time))
|
if(!isValidDate(time))
|
||||||
throw new BadRequestException("Field with key '" + key + "' doesn't seem a valid list of times!");
|
throw new BadRequestException(
|
||||||
|
"Field with key '" + key + "' doesn't seem a valid list of times!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@ package org.gcube.gcat.persistence.ckan;
|
||||||
import javax.ws.rs.InternalServerErrorException;
|
import javax.ws.rs.InternalServerErrorException;
|
||||||
import javax.ws.rs.WebApplicationException;
|
import javax.ws.rs.WebApplicationException;
|
||||||
|
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.server.utils.CatalogueUtilMethods;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,15 +36,30 @@ public class CKANGroup extends CKAN {
|
||||||
PURGE = GROUP_PURGE;
|
PURGE = GROUP_PURGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getGroupName(String name) {
|
private static String fromGroupTitleToName(String groupName){
|
||||||
return CatalogueUtilMethods.fromGroupTitleToName(name);
|
if(groupName == null)
|
||||||
// return name.trim().toLowerCase().replaceAll(" ", "_");
|
return null;
|
||||||
|
|
||||||
|
String regexGroupNameTransform = "[^A-Za-z0-9-]";
|
||||||
|
String modified = groupName.trim().replaceAll(regexGroupNameTransform, "-").replaceAll("-+", "-").toLowerCase();
|
||||||
|
|
||||||
|
if(modified.startsWith("-"))
|
||||||
|
modified = modified.substring(1);
|
||||||
|
if(modified.endsWith("-"))
|
||||||
|
modified = modified.substring(0, modified.length() -1);
|
||||||
|
|
||||||
|
return modified;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getCKANGroupName(String name) {
|
||||||
|
return CKANGroup.fromGroupTitleToName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String create() throws WebApplicationException {
|
public String create() throws WebApplicationException {
|
||||||
try {
|
try {
|
||||||
ObjectNode objectNode = mapper.createObjectNode();
|
ObjectNode objectNode = mapper.createObjectNode();
|
||||||
objectNode.put(NAME_KEY, CKANGroup.getGroupName(name));
|
objectNode.put(NAME_KEY, CKANGroup.getCKANGroupName(name));
|
||||||
objectNode.put("title", name);
|
objectNode.put("title", name);
|
||||||
objectNode.put("display_name", name);
|
objectNode.put("display_name", name);
|
||||||
objectNode.put("description", "");
|
objectNode.put("description", "");
|
||||||
|
|
|
@ -38,9 +38,13 @@ public class CKANUser extends CKAN {
|
||||||
public static final String ADD_USER_TO_GROUP = CKAN.CKAN_API_PATH + "member_create";
|
public static final String ADD_USER_TO_GROUP = CKAN.CKAN_API_PATH + "member_create";
|
||||||
|
|
||||||
public static final String NAME = "name";
|
public static final String NAME = "name";
|
||||||
|
public static final String DISPLAY_NAME = "display_name";
|
||||||
|
public static final String FULL_NAME = "fullname";
|
||||||
|
public static final String ABOUT = "about";
|
||||||
public static final String EMAIL = "email";
|
public static final String EMAIL = "email";
|
||||||
public static final String PASSWORD = "password";
|
public static final String PASSWORD = "password";
|
||||||
|
|
||||||
|
|
||||||
private static final String API_KEY = "apikey";
|
private static final String API_KEY = "apikey";
|
||||||
|
|
||||||
public enum Role {
|
public enum Role {
|
||||||
|
@ -134,8 +138,10 @@ public class CKANUser extends CKAN {
|
||||||
RandomString randomString = new RandomString(12);
|
RandomString randomString = new RandomString(12);
|
||||||
ObjectNode objectNode = mapper.createObjectNode();
|
ObjectNode objectNode = mapper.createObjectNode();
|
||||||
objectNode.put(NAME, name);
|
objectNode.put(NAME, name);
|
||||||
objectNode.put(EMAIL, getPortalUser().getEMail());
|
|
||||||
objectNode.put(PASSWORD, randomString.nextString());
|
objectNode.put(PASSWORD, randomString.nextString());
|
||||||
|
checkAndSetEMail(objectNode);
|
||||||
|
checkAndSetFullName(objectNode);
|
||||||
|
checkAndSetJobTitle(objectNode);
|
||||||
return create(getAsString(objectNode));
|
return create(getAsString(objectNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +150,84 @@ public class CKANUser extends CKAN {
|
||||||
this.delete();
|
this.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param objectNode
|
||||||
|
* @return true if the display name and the full name has been updated in objectNode
|
||||||
|
*/
|
||||||
|
private boolean checkAndSetJobTitle(ObjectNode objectNode) {
|
||||||
|
String portalJobTitle = getPortalUser().getJobTitle();
|
||||||
|
|
||||||
|
String ckanJobTitle = "";
|
||||||
|
if(objectNode.has(ABOUT)) {
|
||||||
|
ckanJobTitle = objectNode.get(ABOUT).asText();
|
||||||
|
}
|
||||||
|
if(portalJobTitle.compareTo(ckanJobTitle)!=0){
|
||||||
|
objectNode = (ObjectNode) result;
|
||||||
|
objectNode.put(ABOUT, portalJobTitle);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param objectNode
|
||||||
|
* @return true if the display name and the full name has been updated in objectNode
|
||||||
|
*/
|
||||||
|
private boolean checkAndSetFullName(ObjectNode objectNode) {
|
||||||
|
String portalFullname = getPortalUser().getFullName();
|
||||||
|
|
||||||
|
String ckanFullname = "";
|
||||||
|
if(objectNode.has(FULL_NAME)) {
|
||||||
|
ckanFullname = objectNode.get(FULL_NAME).asText();
|
||||||
|
}
|
||||||
|
if(portalFullname.compareTo(ckanFullname)!=0){
|
||||||
|
objectNode = (ObjectNode) result;
|
||||||
|
objectNode.put(FULL_NAME, portalFullname);
|
||||||
|
objectNode.put(DISPLAY_NAME, portalFullname);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param objectNode
|
||||||
|
* @return true if the display name and the full name has been updated
|
||||||
|
*/
|
||||||
|
private boolean checkAndSetEMail(ObjectNode objectNode) {
|
||||||
|
String portalEmail = getPortalUser().getEMail();
|
||||||
|
|
||||||
|
String ckanEmail = "";
|
||||||
|
if(objectNode.has(EMAIL)) {
|
||||||
|
ckanEmail = objectNode.get(EMAIL).asText();
|
||||||
|
}
|
||||||
|
if(portalEmail.compareTo(ckanEmail)!=0){
|
||||||
|
objectNode = (ObjectNode) result;
|
||||||
|
objectNode.put(EMAIL, portalEmail);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the user profile on CKAN if the got got informations differs from the portal information
|
||||||
|
* @return true if the profile information has been updated
|
||||||
|
*/
|
||||||
|
protected boolean updateProfileIfNeeded() {
|
||||||
|
ObjectNode objectNode = (ObjectNode) result;
|
||||||
|
boolean toBeUpdated = false;
|
||||||
|
|
||||||
|
toBeUpdated = checkAndSetEMail(objectNode) || toBeUpdated;
|
||||||
|
toBeUpdated = checkAndSetFullName(objectNode) || toBeUpdated;
|
||||||
|
toBeUpdated = checkAndSetJobTitle(objectNode) || toBeUpdated;
|
||||||
|
|
||||||
|
if(toBeUpdated) {
|
||||||
|
update(getAsString(objectNode));
|
||||||
|
}
|
||||||
|
return toBeUpdated;
|
||||||
|
}
|
||||||
|
|
||||||
private void retrieve() {
|
private void retrieve() {
|
||||||
setApiKey(CKANUtility.getSysAdminAPI());
|
setApiKey(CKANUtility.getSysAdminAPI());
|
||||||
|
@ -152,6 +236,7 @@ public class CKANUser extends CKAN {
|
||||||
setName(getCKANUsername());
|
setName(getCKANUsername());
|
||||||
}
|
}
|
||||||
read();
|
read();
|
||||||
|
updateProfileIfNeeded();
|
||||||
} catch(WebApplicationException e) {
|
} catch(WebApplicationException e) {
|
||||||
if(e.getResponse().getStatusInfo() == Status.NOT_FOUND) {
|
if(e.getResponse().getStatusInfo() == Status.NOT_FOUND) {
|
||||||
create();
|
create();
|
||||||
|
@ -217,7 +302,7 @@ public class CKANUser extends CKAN {
|
||||||
public void addToGroup(String groupName) throws WebApplicationException {
|
public void addToGroup(String groupName) throws WebApplicationException {
|
||||||
try {
|
try {
|
||||||
ObjectNode objectNode = mapper.createObjectNode();
|
ObjectNode objectNode = mapper.createObjectNode();
|
||||||
objectNode.put(ID_KEY, CKANGroup.getGroupName(groupName));
|
objectNode.put(ID_KEY, CKANGroup.getCKANGroupName(groupName));
|
||||||
objectNode.put("object", name);
|
objectNode.put("object", name);
|
||||||
objectNode.put("object_type", "user");
|
objectNode.put("object_type", "user");
|
||||||
objectNode.put("capacity", "member");
|
objectNode.put("capacity", "member");
|
||||||
|
|
|
@ -25,11 +25,10 @@ public class PortalUser {
|
||||||
|
|
||||||
protected static final String SOCIAL_SERVICE_GET_OAUTH_USER_PROFILE_PATH = "2/users/get-oauth-profile";
|
protected static final String SOCIAL_SERVICE_GET_OAUTH_USER_PROFILE_PATH = "2/users/get-oauth-profile";
|
||||||
|
|
||||||
// This key cotnains the fullname
|
// This key contains the fullname
|
||||||
protected static final String OAUTH_USER_PROFILE_NAME_KEY = "name";
|
protected static final String OAUTH_USER_PROFILE_NAME_KEY = "name";
|
||||||
|
|
||||||
protected static final String OAUTH_USER_PROFILE_EMAIL_KEY = "email";
|
protected static final String OAUTH_USER_PROFILE_EMAIL_KEY = "email";
|
||||||
|
protected static final String OAUTH_USER_PROFILE_JOB_TITLE_KEY = "job_title";
|
||||||
protected static final String OAUTH_USER_PROFILE_ROLES_KEY = "roles";
|
protected static final String OAUTH_USER_PROFILE_ROLES_KEY = "roles";
|
||||||
|
|
||||||
protected final ObjectMapper objectMapper;
|
protected final ObjectMapper objectMapper;
|
||||||
|
@ -39,6 +38,7 @@ public class PortalUser {
|
||||||
|
|
||||||
protected String fullName;
|
protected String fullName;
|
||||||
protected String eMail;
|
protected String eMail;
|
||||||
|
protected String jobTitle;
|
||||||
|
|
||||||
protected List<String> roles;
|
protected List<String> roles;
|
||||||
|
|
||||||
|
@ -120,6 +120,12 @@ public class PortalUser {
|
||||||
}
|
}
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getJobTitle() {
|
||||||
|
if(jobTitle == null) {
|
||||||
|
jobTitle = getOAuthUserProfile().get(OAUTH_USER_PROFILE_JOB_TITLE_KEY).asText();
|
||||||
|
}
|
||||||
|
return jobTitle;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,6 @@ public class SocialServiceDiscovery {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the base path of the service
|
* @return the base path of the service
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class CKANUserTest extends ContextTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(CKANUserTest.class);
|
private static Logger logger = LoggerFactory.getLogger(CKANUserTest.class);
|
||||||
|
|
||||||
private static final String USERNAME = "pippo";
|
private static final String USERNAME = "lucio_lelii";
|
||||||
|
|
||||||
private CKANUser getCKANUser() {
|
private CKANUser getCKANUser() {
|
||||||
CKANUser user = new CKANUser();
|
CKANUser user = new CKANUser();
|
||||||
|
@ -72,4 +72,10 @@ public class CKANUserTest extends ContextTest {
|
||||||
ckanUser.addUserToOrganization();
|
ckanUser.addUserToOrganization();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void checkAndUpdateInformation() throws Exception {
|
||||||
|
CKANUser ckanUser = CKANUser.getCurrentCKANUser();
|
||||||
|
logger.debug("{}", ckanUser.result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
/*.gcubekey
|
||||||
|
/*.properties
|
Loading…
Reference in New Issue