Skip to content

Commit

Permalink
SAK-50536 profile Remove little used features
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish committed Oct 7, 2024
1 parent fb2764f commit 74d692e
Show file tree
Hide file tree
Showing 256 changed files with 461 additions and 33,529 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.sakaiproject.commons.api;

import java.util.Map;
import java.util.Observer;
import java.util.Set;

import org.apache.commons.fileupload.FileItem;
Expand Down Expand Up @@ -90,7 +89,5 @@ public interface SakaiProxy {

public boolean isUserSite(String siteId);

public void addObserver(Observer observer);

public String storeFile(FileItem fileItem, String siteId);
}
4 changes: 0 additions & 4 deletions commons/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@
<groupId>org.sakaiproject.entitybroker</groupId>
<artifactId>entitybroker-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.profile2</groupId>
<artifactId>profile2-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.delegatedaccess</groupId>
<artifactId>delegatedaccess-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,20 @@
import org.sakaiproject.commons.api.datamodel.Post;
import org.sakaiproject.commons.api.datamodel.PostLike;
import org.sakaiproject.entity.api.Entity;
import org.sakaiproject.entity.api.HttpAccess;
import org.sakaiproject.entity.api.Reference;
import org.sakaiproject.entity.api.ResourceProperties;
import org.sakaiproject.event.api.Event;
import org.sakaiproject.memory.api.Cache;
import org.sakaiproject.profile2.logic.ProfileConnectionsLogic;
import org.sakaiproject.profile2.model.BasicConnection;
import org.sakaiproject.profile2.util.ProfileConstants;
import org.sakaiproject.util.api.FormattedText;


/**
* @author Adrian Fish ([email protected])
*/
@Setter @Slf4j
public class CommonsManagerImpl implements CommonsManager, Observer {
public class CommonsManagerImpl implements CommonsManager {

private CommonsSecurityManager commonsSecurityManager;
private PersistenceManager persistenceManager;
private ProfileConnectionsLogic profileConnectionsLogic;
private SakaiProxy sakaiProxy;
private FormattedText formattedText;

Expand All @@ -73,7 +67,6 @@ public void init() {
log.info("Registered Commons functions.");

sakaiProxy.registerEntityProducer(this);
sakaiProxy.addObserver(this);
}

private List<Post> getPosts(String siteId) throws Exception {
Expand All @@ -99,7 +92,6 @@ public List<Post> getPosts(QueryBean query) throws Exception {
if (query.isUserSite()) {
log.debug("Getting posts for a user site ...");
query.getFromIds().add(query.getCallerId());
query.getFromIds().addAll(getConnectionUserIds(sakaiProxy.getCurrentUserId()));
}
List<Post> unfilteredPosts = persistenceManager.getAllPost(query, true);
cache.put(key, unfilteredPosts);
Expand All @@ -119,11 +111,7 @@ public Post savePost(Post post) {
if (newOrUpdatedPost != null) {
String commonsId = post.getCommonsId();
List<String> contextIds = new ArrayList();
if (persistenceManager.getCommons(commonsId).isSocial()) {
contextIds = getConnectionUserIds(sakaiProxy.getCurrentUserId());
} else {
contextIds.add(post.getCommonsId());
}
contextIds.add(post.getCommonsId());
removeContextIdsFromCache(contextIds);
return newOrUpdatedPost;
} else {
Expand All @@ -147,13 +135,7 @@ public boolean deletePost(String postId) {
if (persistenceManager.deletePost(post)) {
List<String> contextIds = new ArrayList();
String commonsId = post.getCommonsId();
if (persistenceManager.getCommons(commonsId).isSocial()) {
String userId = post.getCreatorId();
// This is a social post. We need to invalidate the social caches of all this user's connections
contextIds = getConnectionUserIds(userId);
} else {
contextIds.add(post.getCommonsId());
}
contextIds.add(post.getCommonsId());
// Invalidate all caches for this site
removeContextIdsFromCache(contextIds);
return true;
Expand Down Expand Up @@ -201,11 +183,7 @@ public Comment saveComment(String commonsId, Comment comment) {
Comment savedComment = persistenceManager.saveComment(comment);
if (savedComment != null) {
List<String> contextIds = new ArrayList();
if (persistenceManager.getCommons(commonsId).isSocial()) {
contextIds = getConnectionUserIds(post.getCreatorId());
} else {
contextIds.add(commonsId);
}
contextIds.add(commonsId);
removeContextIdsFromCache(contextIds);
return savedComment;
}
Expand All @@ -223,12 +201,7 @@ public boolean deleteComment(String siteId, String commonsId, String embedder, S
if (commonsSecurityManager.canCurrentUserDeleteComment(siteId, embedder, commentCreatorId, postCreatorId)
&& persistenceManager.deleteComment(commentId)) {
List<String> contextIds = new ArrayList();
if (embedder.equals(CommonsConstants.SOCIAL)) {
//Post post = persistenceManager.getPost(postId, false);
contextIds = getConnectionUserIds(postCreatorId);
} else {
contextIds.add(commonsId);
}
contextIds.add(commonsId);
removeContextIdsFromCache(contextIds);
return true;
}
Expand Down Expand Up @@ -412,12 +385,6 @@ public boolean parseEntityReference(String referenceString, Reference reference)

String siteId = parts[2];
String subType = parts[3];
/*String entityId = parts[4];
if ("posts".equals(subType)) {
reference.set("commons", "posts", entityId, null, siteId);
return true;
}*/

return false;
}
Expand Down Expand Up @@ -449,33 +416,4 @@ private void removeContextIdsFromCache(List<String> contextIds) {
Cache cache = sakaiProxy.getCache(POST_CACHE);
contextIds.forEach(contextId -> cache.remove(contextId));
}

private List<String> getConnectionUserIds(String userId) {

List<String> userIds = new ArrayList();
List<BasicConnection> conns
= profileConnectionsLogic.getBasicConnectionsForUser(userId);
conns.forEach(conn -> userIds.add(conn.getUuid()));
userIds.add(userId);
return userIds;
}

public void update(Observable o, final Object arg) {

if (arg instanceof Event) {
Event e = (Event) arg;
String event = e.getEvent();
if (ProfileConstants.EVENT_FRIEND_CONFIRM.equals(event)
|| ProfileConstants.EVENT_FRIEND_REMOVE.equals(event)) {
String ref = e.getResource();
String[] pathParts = ref.split("/");
String from = e.getUserId();
String to = pathParts[2];
List<String> contextIds = new ArrayList();
contextIds.add(from);
contextIds.add(to);
removeContextIdsFromCache(contextIds);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Observer;
import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;
Expand Down Expand Up @@ -493,10 +492,6 @@ public boolean isUserSite(String siteId) {
return siteService.isUserSite(siteId);
}

public void addObserver(Observer observer) {
eventTrackingService.addObserver(observer);
}

public String storeFile(FileItem fileItem, String siteId) {

SecurityAdvisor advisor = new SecurityAdvisor() {
Expand Down
1 change: 0 additions & 1 deletion commons/impl/src/webapp/WEB-INF/components.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
<property name="sakaiProxy"><ref bean="org.sakaiproject.commons.api.SakaiProxy"/></property>
<property name="commonsSecurityManager"><ref bean="org.sakaiproject.commons.api.CommonsSecurityManager"/></property>
<property name="persistenceManager"><ref bean="org.sakaiproject.commons.api.PersistenceManager"/></property>
<property name="profileConnectionsLogic"><ref bean="org.sakaiproject.profile2.logic.ProfileConnectionsLogic"/></property>
<property name="formattedText" ref="org.sakaiproject.util.api.FormattedText" />
</bean>

Expand Down
1 change: 0 additions & 1 deletion commons/tool/src/webapp/WEB-INF/bootstrap.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
</script>
${sakaiHtmlHead}
<link href="/profile2-tool/css/profile2-profile-entity.css${portalCDNQuery}" type="text/css" rel="stylesheet" media="all" />
</head>
<body>

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 74d692e

Please sign in to comment.