@GET @Path("contacts/incoming") public Response getIncoming(@Context SecurityContext sc, @Context UriInfo uriInfo) { try { String userId = getUserId(sc, uriInfo); if (userId == null) { return Response.status(HTTPStatus.INTERNAL_ERROR).cacheControl(cacheControl).build(); } Identity identity = identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, userId); List<Relationship> relations = relationshipManager.getIncoming(identity); JSONArray jsonArray = new JSONArray(); for (Relationship relation : relations) { Identity senderId = relation.getSender(); String avatar = senderId.getProfile().getAvatarImageSource(); if (avatar == null) { avatar = "/eXoSkin/skin/images/system/Avatar.gif"; } JSONObject json = new JSONObject(); json.put("senderName", senderId.getProfile().getFullName()); json.put("relationId", relation.getId()); json.put("avatar", avatar); json.put("profile", senderId.getProfile().getUrl()); jsonArray.put(json); } return Response.ok(jsonArray.toString(), MediaType.APPLICATION_JSON).cacheControl(cacheControl).build(); } catch (Exception e) { log.error("Error in people incoming rest service: " + e.getMessage(), e); return Response.status(HTTPStatus.INTERNAL_ERROR).cacheControl(cacheControl).build(); } }
@GET @Path("contacts/pending") public Response getPending(@Context SecurityContext sc, @Context UriInfo uriInfo) { try { String userId = getUserId(sc, uriInfo); if (userId == null) { return Response.status(HTTPStatus.INTERNAL_ERROR).cacheControl(cacheControl).build(); } Identity identity = identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, userId); List<Relationship> relations = relationshipManager.getPending(identity); JSONArray jsonArray = new JSONArray(); for (Relationship relation : relations) { Identity senderId = relation.getSender(); Profile senderProfile = senderId.getProfile(); Identity receiverId = relation.getReceiver(); Profile receiverProfile = receiverId.getProfile(); JSONObject json = new JSONObject(); json.put("senderName", senderProfile.getFullName()); json.put("senderId", senderId.getId()); json.put("receiverName", receiverProfile.getFullName()); json.put("receiverId", receiverId.getId()); json.put("status", relation.getStatus()); jsonArray.put(json); } return Response.ok(jsonArray.toString(), MediaType.APPLICATION_JSON).cacheControl(cacheControl).build(); } catch (Exception e) { log.error("Error in people pending rest service: " + e.getMessage(), e); return Response.ok("error").cacheControl(cacheControl).build(); } }
JSONObject json = new JSONObject(); Identity userIdentity = identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, user,false); Profile userProfile = userIdentity.getProfile(); json.put("id", userProfile.getId()); json.put("profileUrl", LinkProvider.getUserProfileUri(userIdentity.getRemoteId()));
String avatar = sender.getProfile().getAvatarImageSource(); JSONObject json = new JSONObject(); json.put(INVITATION_TYPE, PEOPLE_INVITATION_TYPE); json.put(SENDER_NAME, sender.getProfile().getFullName()); json.put(RELATION_ID, relationshipManager.get(identity, sender).getId()); json.put(SENDER_AVATAR_URL, avatar); json.put(SENDER_POSITION, sender.getProfile().getPosition()); json.put(SENDER_PROFILE_URL, sender.getProfile().getUrl()); jsonArray.put(json);
@SuppressWarnings("deprecation") private boolean hasAvatar(String userId) { try { IdentityManager identityManager = (IdentityManager) ExoContainerContext.getCurrentContainer() .getComponentInstanceOfType(IdentityManager.class); Identity identity = identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, userId); Profile profile = identity.getProfile(); if (profile.getAvatarUrl() != null) return true; else return false; } catch (Exception e) { LOG.debug("Error in gettingStarted REST service: " + e.getMessage(), e); return false; } }
@SuppressWarnings("deprecation") public boolean hasAvatar(String userId) { try { IdentityManager identityManager = (IdentityManager) ExoContainerContext.getCurrentContainer() .getComponentInstanceOfType(IdentityManager.class); Identity identity = identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, userId); Profile profile = identity.getProfile(); if (profile.getAvatarUrl() != null) return true; else return false; } catch (Exception e) { LOG.debug("Error in gettingStarted REST service: " + e.getMessage(), e); return false; } }
Profile socialProfile = id.getProfile(); String avatar = socialProfile.getAvatarUrl(); if (avatar == null) {
IdentityManager iManager = (IdentityManager) portalContainer.getComponentInstanceOfType(IdentityManager.class); Identity spaceIdentity = iManager.getOrCreateIdentity(SpaceIdentityProvider.NAME, spaceNode.getProperty("soc:name").getString(), true); Profile profile = spaceIdentity.getProfile(); avartarUrl =profile.getAvatarUrl(); space.setAvatarURL(avartarUrl);
@GET @Path("contacts/{identityId}/pending") public Response contactsPendingRequests(@PathParam("identityId") String identityId) { IdentityManager identityManager = (IdentityManager) ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(IdentityManager.class); Identity identity = identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, identityId); if (identity == null){ return Response.ok("identity null for "+identityId, MediaType.APPLICATION_JSON).cacheControl(cacheControl).build(); } RelationshipManager relationshipManager = (RelationshipManager) ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(RelationshipManager.class); List<Relationship> relations = relationshipManager.getIncoming(identity); ArrayList<Object> liste = new ArrayList<Object>(); for (Relationship relation : relations) { Relation rel = new Relation(); Identity contactIdentity = relation.getSender(); Profile profile = contactIdentity.getProfile(); rel.setRelationshipId(contactIdentity.getRemoteId()); rel.setRequesterName(profile.getFullName()); rel.setPosition(profile.getPosition()); rel.setAvatarUrl(profile.getAvatarUrl()); liste.add(rel); } return renderJSON(liste); }
Profile profile = identity.getProfile(); ListAccess<Identity> confirmedContacts = relationshipManager.getConnections(identity); for(Identity contact : myConnections){ profile = contact.getProfile();
Profile p = identity.getProfile();