Skip to content

Commit

Permalink
KNL-1374 Remove references to AliasService cover
Browse files Browse the repository at this point in the history
This updates everthing that uses the AliasService cover directly to either use the ComponentManager to get the service or Spring injection.
This allows the cover to be removed so we don't have 2 copies of the API and makes testing easier for services.
  • Loading branch information
buckett committed Aug 3, 2015
1 parent 584a5f7 commit 8a84768
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 69 deletions.
4 changes: 4 additions & 0 deletions alias/alias-tool/tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
<groupId>org.sakaiproject.kernel</groupId>
<artifactId>sakai-kernel-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.kernel</groupId>
<artifactId>sakai-component-manager</artifactId>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.List;

import org.sakaiproject.alias.api.AliasEdit;
import org.sakaiproject.alias.cover.AliasService;
import org.sakaiproject.alias.api.AliasService;
import org.sakaiproject.authz.cover.SecurityService;
import org.sakaiproject.cheftool.Context;
import org.sakaiproject.cheftool.JetspeedRunData;
Expand All @@ -39,6 +39,7 @@
import org.sakaiproject.cheftool.api.MenuItem;
import org.sakaiproject.cheftool.menu.MenuEntry;
import org.sakaiproject.cheftool.menu.MenuImpl;
import org.sakaiproject.component.cover.ComponentManager;
import org.sakaiproject.courier.api.ObservingCourier;
import org.sakaiproject.event.api.SessionState;
import org.sakaiproject.exception.IdInvalidException;
Expand Down Expand Up @@ -70,6 +71,13 @@ public class AliasesAction extends PagedResourceActionII
/** Resource bundle using current language locale */
private static ResourceLoader rb = new ResourceLoader("admin");

private AliasService aliasService;

public AliasesAction() {
super();
aliasService = ComponentManager.get(AliasService.class);
}

protected void initState(SessionState state, VelocityPortlet portlet, JetspeedRunData rundata)
{
super.initState(state, portlet, rundata);
Expand Down Expand Up @@ -149,14 +157,14 @@ else if (mode.equals("confirm"))
private String buildListContext(SessionState state, Context context)
{
// put the service in the context
context.put("service", AliasService.getInstance());
context.put("service", aliasService);

// put all aliases into the context
context.put("aliases", prepPage(state));

// build the menu
Menu bar = new MenuImpl();
if (AliasService.allowAdd())
if (aliasService.allowAdd())
{
bar.add(new MenuEntry(rb.getString("alias.new"), null, true, MenuItem.CHECKED_NA, "doNew"));
}
Expand Down Expand Up @@ -230,7 +238,7 @@ private String buildEditContext(SessionState state, Context context)
// we need the form fields for the remove...
boolean menuPopulated = false;
Menu bar = new MenuImpl();
if (AliasService.allowRemoveAlias(alias.getId()))
if (aliasService.allowRemoveAlias(alias.getId()))
{
bar.add(new MenuEntry(rb.getString("alias.remove"), null, true, MenuItem.CHECKED_NA, "doRemove", "alias-form"));
menuPopulated = true;
Expand Down Expand Up @@ -286,7 +294,7 @@ public void doEdit(RunData data, Context context)
// get the alias
try
{
AliasEdit alias = AliasService.edit(id);
AliasEdit alias = aliasService.edit(id);
state.setAttribute("alias", alias);
state.setAttribute("mode", "edit");

Expand Down Expand Up @@ -342,7 +350,7 @@ public void doSave(RunData data, Context context)
AliasEdit alias = (AliasEdit) state.getAttribute("alias");
if (alias != null)
{
AliasService.commit(alias);
aliasService.commit(alias);
}

// cleanup
Expand Down Expand Up @@ -375,7 +383,7 @@ public void doCancel(RunData data, Context context)
// remove
try
{
AliasService.remove(alias);
aliasService.remove(alias);
}
catch (PermissionException e)
{
Expand All @@ -384,7 +392,7 @@ public void doCancel(RunData data, Context context)
}
else
{
AliasService.cancel(alias);
aliasService.cancel(alias);
}
}

Expand Down Expand Up @@ -432,7 +440,7 @@ public void doRemove_confirmed(RunData data, Context context)
// remove
try
{
AliasService.remove(alias);
aliasService.remove(alias);
}
catch (PermissionException e)
{
Expand Down Expand Up @@ -484,7 +492,7 @@ private boolean readAliasForm(RunData data, SessionState state)
try
{
// add the alias, getting an edit clone to it
alias = AliasService.add(id);
alias = aliasService.add(id);

// put the alias in the state
state.setAttribute("alias", alias);
Expand Down Expand Up @@ -526,10 +534,10 @@ protected List readResourcesPage(SessionState state, int first, int last)

if (search != null)
{
return AliasService.searchAliases(search, first, last);
return aliasService.searchAliases(search, first, last);
}

return AliasService.getAliases(first, last);
return aliasService.getAliases(first, last);
}

/**
Expand All @@ -542,10 +550,10 @@ protected int sizeResources(SessionState state)

if (search != null)
{
return AliasService.countSearchAliases(search);
return aliasService.countSearchAliases(search);
}

return AliasService.countAliases();
return aliasService.countAliases();
}

} // AliasesAction
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import org.sakaiproject.announcement.api.AnnouncementMessageHeaderEdit;
import org.sakaiproject.announcement.cover.AnnouncementService;
import org.sakaiproject.announcement.tool.AnnouncementActionState.DisplayOptions;
import org.sakaiproject.alias.cover.AliasService;
import org.sakaiproject.alias.api.AliasService;
import org.sakaiproject.alias.api.Alias;
import org.sakaiproject.authz.api.PermissionsHelper;
import org.sakaiproject.authz.api.SecurityAdvisor;
Expand Down Expand Up @@ -251,12 +251,19 @@ public class AnnouncementAction extends PagedResourceActionII

private EntityBroker entityBroker;

private AliasService aliasService;

private RuleBasedCollator collator_ini = (RuleBasedCollator)Collator.getInstance();

private Collator collator = Collator.getInstance();

private static final String DEFAULT_TEMPLATE="announcement/chef_announcements";



public AnnouncementAction() {
super();
aliasService = ComponentManager.get(AliasService.class);
}
/*
* Returns the current order
*
Expand Down Expand Up @@ -1380,7 +1387,7 @@ public String buildOptionsPanelContext(VelocityPortlet portlet, Context context,
+ SiteService.getSiteDisplay(channelRef.getContext()));

Reference anncRef = AnnouncementService.getAnnouncementReference(ToolManager.getCurrentPlacement().getContext());
List aliasList = AliasService.getAliases( anncRef.getReference() );
List aliasList = aliasService.getAliases( anncRef.getReference() );
if ( ! aliasList.isEmpty() )
{
String alias[] = ((Alias)aliasList.get(0)).getId().split("\\.");
Expand Down Expand Up @@ -4913,7 +4920,7 @@ public void doOptionsUpdate(RunData runData, Context context)

Reference anncRef = AnnouncementService.getAnnouncementReference(ToolManager.getCurrentPlacement().getContext());

List aliasList = AliasService.getAliases( anncRef.getReference() );
List aliasList = aliasService.getAliases( anncRef.getReference() );
String oldAlias = null;
if ( ! aliasList.isEmpty() )
{
Expand All @@ -4925,10 +4932,10 @@ public void doOptionsUpdate(RunData runData, Context context)
if ( alias != null && (oldAlias == null || !oldAlias.equals(alias)) )
{
// first, clear any alias set to this channel
AliasService.removeTargetAliases(anncRef.getReference());
aliasService.removeTargetAliases(anncRef.getReference());

alias += ".rss";
AliasService.setAlias(alias, anncRef.getReference());
aliasService.setAlias(alias, anncRef.getReference());
}
}
catch (IdUsedException ue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.sakaiproject.alias.api.Alias;
import org.sakaiproject.alias.cover.AliasService;
import org.sakaiproject.alias.api.AliasService;
import org.sakaiproject.authz.api.PermissionsHelper;
import org.sakaiproject.authz.cover.AuthzGroupService;
import org.sakaiproject.authz.cover.SecurityService;
Expand Down Expand Up @@ -207,13 +207,20 @@ public class CalendarAction

// Dependency: setup in init
private OpaqueUrlDao opaqueUrlDao;

private AliasService aliasService;

// tbd fix shared definition from org.sakaiproject.assignment.api.AssignmentEntityProvider
private final static String ASSN_ENTITY_ID = "assignment";
private final static String ASSN_ENTITY_ACTION = "deepLink";
private final static String ASSN_ENTITY_PREFIX = EntityReference.SEPARATOR+ASSN_ENTITY_ID+EntityReference.SEPARATOR+ASSN_ENTITY_ACTION+EntityReference.SEPARATOR;

private NumberFormat monthFormat = null;

public CalendarAction() {
super();
aliasService = ComponentManager.get(AliasService.class);
}

/**
* Converts a string that is used to store additional attribute fields to an array of strings.
Expand Down Expand Up @@ -4023,7 +4030,7 @@ public String buildIcalExportPanelContext(VelocityPortlet portlet, Context conte

if ( calendarObj != null )
{
List aliasList = AliasService.getAliases( calendarObj.getReference() );
List aliasList = aliasService.getAliases( calendarObj.getReference() );
if ( ! aliasList.isEmpty() )
{
String alias[] = ((Alias)aliasList.get(0)).getId().split("\\.");
Expand Down Expand Up @@ -5751,7 +5758,7 @@ public void doIcalExport(RunData data, Context context)
{
calendarObj = CalendarService.getCalendar(calId);

List aliasList = AliasService.getAliases( calendarObj.getReference() );
List aliasList = aliasService.getAliases( calendarObj.getReference() );
String oldAlias = null;
if ( ! aliasList.isEmpty() )
{
Expand All @@ -5763,10 +5770,10 @@ public void doIcalExport(RunData data, Context context)
if ( alias != null && (oldAlias == null || !oldAlias.equals(alias)) )
{
// first, clear any alias set to this calendar
AliasService.removeTargetAliases(calendarObj.getReference());
aliasService.removeTargetAliases(calendarObj.getReference());

alias += ICAL_EXTENSION;
AliasService.setAlias(alias, calendarObj.getReference());
aliasService.setAlias(alias, calendarObj.getReference());
}
}
catch (IdUnusedException ie)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.sakaiproject.alias.api.AliasEdit;
import org.sakaiproject.alias.cover.AliasService;
import org.sakaiproject.alias.api.AliasService;
import org.sakaiproject.antivirus.api.VirusFoundException;
import org.sakaiproject.authz.api.PermissionsHelper;
import org.sakaiproject.authz.cover.AuthzGroupService;
Expand Down Expand Up @@ -163,6 +163,7 @@ public class ResourcesAction
private static ContentPrintService contentPrintService = (ContentPrintService) ComponentManager.get("org.sakaiproject.content.api.ContentPrintService");

private static SchedulerManager schedulerManager = (SchedulerManager) ComponentManager.get("org.sakaiproject.api.app.scheduler.SchedulerManager");

/** state variable name for the content print service call result */
private static String CONTENT_PRINT_CALL_RESPONSE = "content_print_call_response";

Expand Down Expand Up @@ -904,6 +905,13 @@ public void setParent(String parent)
CREATION_ACTIONS.add(ActionType.PASTE_COPIED);
}

private AliasService aliasService;

public ResourcesAction() {
super();
aliasService = ComponentManager.get(AliasService.class);
}

/**
* Add additional resource pattern to the observer
*@param pattern The pattern value to be added
Expand Down Expand Up @@ -5693,7 +5701,7 @@ else if(parts.length >= 3)
if (!inMyWorkspace && !dropboxMode && m_siteAlias)
{
// find site alias first
List target = AliasService.getAliases("/site/" + siteId);
List target = aliasService.getAliases("/site/" + siteId);

if (!target.isEmpty()) {
// take the first alias only
Expand All @@ -5707,7 +5715,7 @@ else if(parts.length >= 3)
}
} else {
// use mail archive alias
target = AliasService.getAliases("/mailarchive/channel/" + siteId + "/main");
target = aliasService.getAliases("/mailarchive/channel/" + siteId + "/main");

if (!target.isEmpty()) {
// take the first alias only
Expand Down
7 changes: 5 additions & 2 deletions dav/dav/src/java/org/sakaiproject/dav/DavServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
import org.apache.catalina.util.XMLWriter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.sakaiproject.alias.cover.AliasService;
import org.sakaiproject.alias.api.AliasService;
import org.sakaiproject.component.cover.ComponentManager;
import org.sakaiproject.component.cover.ServerConfigurationService;
import org.sakaiproject.content.api.*;
Expand Down Expand Up @@ -378,7 +378,7 @@ else if (parts[1].equals("group"))
{
try
{
String target = AliasService.getTarget(context);
String target = aliasService.getTarget(context);
Reference targetRef = EntityManager.newReference(target);
boolean changed = false;

Expand Down Expand Up @@ -547,6 +547,8 @@ private SimpleDateFormat[] dateFormats()

private ContentHostingService contentHostingService;

private AliasService aliasService;

// --------------------------------------------------------- Public Methods

/**
Expand All @@ -555,6 +557,7 @@ private SimpleDateFormat[] dateFormats()
public void init() throws ServletException
{
contentHostingService = (ContentHostingService) ComponentManager.get(ContentHostingService.class.getName());
aliasService = ComponentManager.get(AliasService.class);

// Set our properties from the initialization parameters
String value = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
import java.util.Vector;

import org.sakaiproject.alias.api.Alias;
import org.sakaiproject.alias.cover.AliasService;
import org.sakaiproject.alias.api.AliasService;
import org.sakaiproject.authz.cover.SecurityService;
import org.sakaiproject.authz.api.Member;
import org.sakaiproject.component.cover.ComponentManager;
import org.sakaiproject.component.cover.ServerConfigurationService;
import org.sakaiproject.entity.api.Reference;
import org.sakaiproject.entity.cover.EntityManager;
Expand Down Expand Up @@ -59,11 +60,19 @@
*/
public class SiteEmailNotification extends EmailNotification
{
private AliasService aliasService;

/**
* Construct.
*/
public SiteEmailNotification()
{
this(ComponentManager.get(AliasService.class));
}

public SiteEmailNotification(AliasService aliasService)
{
this.aliasService = aliasService;
}

/**
Expand Down Expand Up @@ -234,7 +243,7 @@ protected String getToSite(Event event)
EntityManager.newReference(channel);

// find the alias for this site's mail channel
List<Alias> all = AliasService.getAliases(channel);
List<Alias> all = aliasService.getAliases(channel);
if (!all.isEmpty()) email = ((Alias) all.get(0)).getId();
}
catch (Exception ignore)
Expand Down
Loading

0 comments on commit 8a84768

Please sign in to comment.