Skip to content

Commit

Permalink
SAK-27170 Make profiles searchable (sakaiproject#4209)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish authored Apr 26, 2017
1 parent f49f939 commit 8e8c6b5
Show file tree
Hide file tree
Showing 7 changed files with 295 additions and 35 deletions.
8 changes: 8 additions & 0 deletions common/common-composite-component/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@
<groupId>org.sakaiproject.common</groupId>
<artifactId>sakai-common-composite-component-data</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.profile2</groupId>
<artifactId>profile2-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.search</groupId>
<artifactId>search-api</artifactId>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.sakaiproject.authz.cover.SecurityService;
import org.sakaiproject.component.api.ServerConfigurationService;
import org.sakaiproject.component.common.manager.PersistableHelper;
import org.sakaiproject.entity.api.Entity;
import org.sakaiproject.event.api.EventTrackingService;
import org.sakaiproject.id.cover.IdManager;
import org.sakaiproject.tool.cover.SessionManager;
Expand Down Expand Up @@ -335,7 +336,7 @@ public void save(SakaiPerson sakaiPerson)



eventTrackingService.post(eventTrackingService.newEvent("profile.update", ref, true));
eventTrackingService.post(eventTrackingService.newEvent(PROFILE_UPDATE, ref, true));


LOG.debug("User record updated for Id :-" + spi.getAgentUuid());
Expand All @@ -362,8 +363,11 @@ public void save(SakaiPerson sakaiPerson)
}

private String getReference(SakaiPerson spi) {
String ref = "/profile/type/" + spi.getTypeUuid() + "/id/" + spi.getAgentUuid();
return ref;
StringBuilder sb = new StringBuilder(Entity.SEPARATOR);
sb.append("profile").append(Entity.SEPARATOR).append("type").append(Entity.SEPARATOR)
.append(spi.getTypeUuid()).append(Entity.SEPARATOR).append("id")
.append(Entity.SEPARATOR).append(spi.getAgentUuid());
return sb.toString();
}

/**
Expand Down Expand Up @@ -600,7 +604,7 @@ public void delete(final SakaiPerson sakaiPerson)

LOG.debug("getHibernateTemplate().delete(sakaiPerson);");
getHibernateTemplate().delete(sakaiPerson);
eventTrackingService.post(eventTrackingService.newEvent("profile.delete", ref, true));
eventTrackingService.post(eventTrackingService.newEvent(PROFILE_DELETE, ref, true));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import java.util.Observable;
import java.util.Observer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sakaiproject.api.common.edu.person.SakaiPerson;
import org.sakaiproject.api.common.edu.person.SakaiPersonManager;
import org.sakaiproject.component.api.ServerConfigurationService;
Expand All @@ -35,36 +33,21 @@
import org.sakaiproject.event.api.EventTrackingService;
import org.sakaiproject.user.api.UserDirectoryService;

import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

/**
* This observer watches for user.del events and removes the profiles associated with the user
* @author dhorwitz
*
*/
@Setter @Slf4j
public class SakaiPersonObserver implements Observer {

private static Logger log = LoggerFactory.getLogger(SakaiPersonObserver.class);

private EventTrackingService eventTrackingService;
public void setEventTrackingService(EventTrackingService eventTrackingService) {
this.eventTrackingService = eventTrackingService;
}


private SakaiPersonManager sakaiPersonManager;
public void setSakaiPersonManager(SakaiPersonManager sakaiPersonManager) {
this.sakaiPersonManager = sakaiPersonManager;
}

private EntityManager entityManager;
public void setEntityManager(EntityManager entityManager) {
this.entityManager = entityManager;
}

private ServerConfigurationService serverConfigurationService;
public void setServerConfigurationService(
ServerConfigurationService serverConfigurationService) {
this.serverConfigurationService = serverConfigurationService;
}

public void init() {
log.info("init()");
Expand Down Expand Up @@ -108,13 +91,6 @@ public void update(Observable o, Object arg) {
if (sp != null) {
sakaiPersonManager.delete(sp);
}


}




}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@
<ref
bean="org.sakaiproject.component.common.manager.PersistableHelper" />
</property>
<property name="serverConfigurationService">
<ref bean="org.sakaiproject.component.api.ServerConfigurationService" />
</property>
<property name="serverConfigurationService" ref="org.sakaiproject.component.api.ServerConfigurationService" />
<property name="userDirectoryService">
<ref bean="org.sakaiproject.user.api.UserDirectoryService"/>
</property>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
*/
public interface SakaiPersonManager
{
public static final String PROFILE_UPDATE = "profile.update";
public static final String PROFILE_DELETE = "profile.delete";

/**
* Creates a persistent SakaiPerson record.
*
Expand Down
Loading

0 comments on commit 8e8c6b5

Please sign in to comment.