Skip to content

Commit

Permalink
SFDCENG-888:
Browse files Browse the repository at this point in the history
- added support for getting the Contact account name to which a User belongs
- extended properties list for the Community
  • Loading branch information
flv22 committed Apr 19, 2021
1 parent cc6f2e0 commit 4546d1f
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 1 deletion.
140 changes: 140 additions & 0 deletions src/main/java/org/springframework/social/salesforce/api/Community.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,34 @@ public class Community {

private boolean sendWelcomeEmail;

private boolean allowChatterAccessWithoutLogin;

private boolean allowMembersToFlag;

private boolean guestMemberVisibilityEnabled;

private boolean knowledgeableEnabled;

private String loginUrl;

private boolean memberVisibilityEnabled;

private boolean nicknameDisplayEnabled;

private boolean privateMessagesEnabled;

private boolean reputationEnabled;

private boolean siteAsContainerEnabled;

private String siteUrl;

private String status;

private String templateName;

private String urlPathPrefix;

public String getDescription() {
return description;
}
Expand Down Expand Up @@ -79,4 +107,116 @@ public boolean isSendWelcomeEmail() {
public void setSendWelcomeEmail(boolean sendWelcomeEmail) {
this.sendWelcomeEmail = sendWelcomeEmail;
}

public boolean isAllowChatterAccessWithoutLogin() {
return allowChatterAccessWithoutLogin;
}

public void setAllowChatterAccessWithoutLogin(boolean allowChatterAccessWithoutLogin) {
this.allowChatterAccessWithoutLogin = allowChatterAccessWithoutLogin;
}

public boolean isAllowMembersToFlag() {
return allowMembersToFlag;
}

public void setAllowMembersToFlag(boolean allowMembersToFlag) {
this.allowMembersToFlag = allowMembersToFlag;
}

public boolean isGuestMemberVisibilityEnabled() {
return guestMemberVisibilityEnabled;
}

public void setGuestMemberVisibilityEnabled(boolean guestMemberVisibilityEnabled) {
this.guestMemberVisibilityEnabled = guestMemberVisibilityEnabled;
}

public boolean isKnowledgeableEnabled() {
return knowledgeableEnabled;
}

public void setKnowledgeableEnabled(boolean knowledgeableEnabled) {
this.knowledgeableEnabled = knowledgeableEnabled;
}

public String getLoginUrl() {
return loginUrl;
}

public void setLoginUrl(String loginUrl) {
this.loginUrl = loginUrl;
}

public boolean isMemberVisibilityEnabled() {
return memberVisibilityEnabled;
}

public void setMemberVisibilityEnabled(boolean memberVisibilityEnabled) {
this.memberVisibilityEnabled = memberVisibilityEnabled;
}

public boolean isNicknameDisplayEnabled() {
return nicknameDisplayEnabled;
}

public void setNicknameDisplayEnabled(boolean nicknameDisplayEnabled) {
this.nicknameDisplayEnabled = nicknameDisplayEnabled;
}

public boolean isPrivateMessagesEnabled() {
return privateMessagesEnabled;
}

public void setPrivateMessagesEnabled(boolean privateMessagesEnabled) {
this.privateMessagesEnabled = privateMessagesEnabled;
}

public boolean isReputationEnabled() {
return reputationEnabled;
}

public void setReputationEnabled(boolean reputationEnabled) {
this.reputationEnabled = reputationEnabled;
}

public boolean isSiteAsContainerEnabled() {
return siteAsContainerEnabled;
}

public void setSiteAsContainerEnabled(boolean siteAsContainerEnabled) {
this.siteAsContainerEnabled = siteAsContainerEnabled;
}

public String getSiteUrl() {
return siteUrl;
}

public void setSiteUrl(String siteUrl) {
this.siteUrl = siteUrl;
}

public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}

public String getTemplateName() {
return templateName;
}

public void setTemplateName(String templateName) {
this.templateName = templateName;
}

public String getUrlPathPrefix() {
return urlPathPrefix;
}

public void setUrlPathPrefix(String urlPathPrefix) {
this.urlPathPrefix = urlPathPrefix;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class CommunityUser {

private String aboutMe;

private String contactName;

public String getCommunityNickname() {
return communityNickname;
}
Expand Down Expand Up @@ -139,4 +141,12 @@ public String getAboutMe() {
public void setAboutMe(String aboutMe) {
this.aboutMe = aboutMe;
}

public String getContactName() {
return contactName;
}

public void setContactName(String contactName) {
this.contactName = contactName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.springframework.social.salesforce.api.CommunityUser;
import org.springframework.social.salesforce.api.ConnectOperations;
import org.springframework.social.salesforce.api.Salesforce;
import org.springframework.social.salesforce.api.QueryResult;
import org.springframework.social.salesforce.api.ResultItem;
import org.springframework.web.client.RestTemplate;

import java.util.List;
Expand Down Expand Up @@ -54,7 +56,29 @@ public List<CommunityUser> getCommunityUsers(String communityId) {

JsonNode dataNode = restTemplate.getForObject(api.getBaseUrl() + "/" + getVersion() + CONNECT_URI + communityId + CHATTER_USERS, JsonNode.class, getVersion());

return api.readList(dataNode.get("users"), CommunityUser.class);
List<CommunityUser> users = api.readList(dataNode.get("users"), CommunityUser.class);;

for(int i=0; i<users.size(); i++) {

/* Extract the contact account name by using a query*/
QueryResult queryResult = this.api.queryOperations().query("SELECT Contact.Account.Name FROM User WHERE id='" + users.get(i).getId() + "'");

for(ResultItem resultItem: queryResult.getRecords()) {

ResultItem contact = (ResultItem) resultItem.getAttributes().get("Contact");

/* If the User has an Account attached, then set it */
if(contact != null) {

ResultItem account = (ResultItem) contact.getAttributes().get("Account");
String accountName = account.getAttributes().get("Name").toString();

users.get(i).setContactName(accountName);
}
}
}

return users;
}

}

0 comments on commit 4546d1f

Please sign in to comment.