use of org.apache.shindig.social.core.model.PersonImpl in project liferay-ide by liferay.
the class LiferayPersonService method getGroupPerson.
protected Person getGroupPerson(String groupId) throws Exception {
Person person = null;
long groupIdLong = GetterUtil.getLong(groupId);
Group group = GroupLocalServiceUtil.getGroup(groupIdLong);
if (group.isOrganization()) {
Organization organization = OrganizationLocalServiceUtil.getOrganization(group.getClassPK());
Name name = new NameImpl(organization.getName() + " (Organization)");
person = new PersonImpl(groupId, name.getFormatted(), name);
List<ListField> phoneNumbers = getPhoneNumbers(Organization.class.getName(), organization.getOrganizationId());
person.setPhoneNumbers(phoneNumbers);
} else if (group.isRegularSite()) {
Name name = new NameImpl(group.getName() + " (Site)");
person = new PersonImpl(groupId, name.getFormatted(), name);
}
person.setGender(Gender.male);
return person;
}
use of org.apache.shindig.social.core.model.PersonImpl in project liferay-ide by liferay.
the class LiferayPersonService method getUserPerson.
protected Person getUserPerson(User user, Set<String> fields, SecurityToken securityToken) throws Exception {
Name name = new NameImpl(user.getFullName());
Person person = new PersonImpl(String.valueOf(user.getUserId()), user.getScreenName(), name);
StringBundler sb = new StringBundler(4);
sb.append(securityToken.getDomain());
sb.append(PortalUtil.getPathFriendlyURLPublic());
sb.append(StringPool.SLASH);
sb.append(user.getScreenName());
person.setProfileUrl(sb.toString());
sb.setIndex(0);
sb.append(securityToken.getDomain());
sb.append(PortalUtil.getPathImage());
sb.append("/user_");
sb.append(user.isFemale() ? "female" : "male");
sb.append("_portrait?img_id=");
sb.append(user.getPortraitId());
sb.append("&t=");
sb.append(WebServerServletTokenUtil.getToken(user.getPortraitId()));
person.setThumbnailUrl(sb.toString());
if (fields.contains(Person.Field.ABOUT_ME.toString())) {
person.setAboutMe(user.getComments());
}
if (fields.contains(Person.Field.AGE.toString())) {
Calendar birthday = new GregorianCalendar();
birthday.setTime(user.getBirthday());
Calendar today = Calendar.getInstance();
int age = today.get(Calendar.YEAR) - birthday.get(Calendar.YEAR);
birthday.add(Calendar.YEAR, age);
if (today.before(birthday)) {
age--;
}
person.setAge(age);
}
if (fields.contains(Person.Field.BIRTHDAY.toString())) {
person.setBirthday(user.getBirthday());
}
if (fields.contains(Person.Field.EMAILS)) {
person.setEmails(getEmails(user));
}
if (fields.contains(Person.Field.GENDER.toString())) {
if (user.isFemale()) {
person.setGender(Gender.female);
} else {
person.setGender(Gender.male);
}
}
if (fields.contains(Person.Field.NICKNAME.toString())) {
person.setNickname(user.getScreenName());
}
if (fields.contains(Person.Field.PHONE_NUMBERS.toString())) {
List<ListField> phoneNumbers = getPhoneNumbers(Contact.class.getName(), user.getContactId());
person.setPhoneNumbers(phoneNumbers);
}
if (fields.contains(Person.Field.UTC_OFFSET.toString())) {
person.setUtcOffset(new Long(user.getTimeZone().getRawOffset()));
}
if (securityToken.getOwnerId().equals(person.getId())) {
person.setIsOwner(true);
}
if (securityToken.getViewerId().equals(person.getId())) {
person.setIsViewer(true);
}
return person;
}
Aggregations