mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 18:14:26 +00:00
[DS-2729] Ensure SiteService extends DSpaceObjectService
This commit is contained in:
@@ -7,11 +7,14 @@
|
||||
*/
|
||||
package org.dspace.content;
|
||||
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.SiteService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
/**
|
||||
* Represents the root of the DSpace Archive.
|
||||
@@ -22,6 +25,9 @@ import javax.persistence.Table;
|
||||
public class Site extends DSpaceObject
|
||||
{
|
||||
|
||||
@Transient
|
||||
private SiteService siteService;
|
||||
|
||||
/**
|
||||
* Get the type of this object, found in Constants
|
||||
*
|
||||
@@ -36,11 +42,20 @@ public class Site extends DSpaceObject
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return ConfigurationManager.getProperty("dspace.name");
|
||||
return getSiteService().getName(this);
|
||||
}
|
||||
|
||||
public String getURL()
|
||||
{
|
||||
return ConfigurationManager.getProperty("dspace.url");
|
||||
}
|
||||
|
||||
private SiteService getSiteService() {
|
||||
if(siteService == null)
|
||||
{
|
||||
siteService = ContentServiceFactory.getInstance().getSiteService();
|
||||
}
|
||||
return siteService;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -11,8 +11,10 @@ import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.content.dao.SiteDAO;
|
||||
import org.dspace.content.service.SiteService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.event.Event;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -70,12 +72,27 @@ public class SiteServiceImpl extends DSpaceObjectServiceImpl<Site> implements Si
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Context context, Site dso) throws SQLException, AuthorizeException {
|
||||
public void update(Context context, Site site) throws SQLException, AuthorizeException {
|
||||
if(!authorizeService.isAdmin(context)){
|
||||
throw new AuthorizeException();
|
||||
}
|
||||
siteDAO.save(context, dso);
|
||||
if(site.isMetadataModified())
|
||||
{
|
||||
context.addEvent(new Event(Event.MODIFY_METADATA, site.getType(), site.getID(), site.getDetails(), getIdentifiers(context, site)));
|
||||
}
|
||||
if(site.isModified()) {
|
||||
context.addEvent(new Event(Event.MODIFY, site.getType(), site.getID(), site.getDetails(), getIdentifiers(context, site)));
|
||||
}
|
||||
site.clearModified();
|
||||
site.clearDetails();
|
||||
|
||||
siteDAO.save(context, site);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(Site dso)
|
||||
{
|
||||
return ConfigurationManager.getProperty("dspace.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -134,6 +134,7 @@ public class SiteTest extends AbstractUnitTest
|
||||
public void testGetName()
|
||||
{
|
||||
assertThat("testGetName 0",s.getName(), equalTo(ConfigurationManager.getProperty("dspace.name")));
|
||||
assertThat("testGetName 1",siteService.getName(s), equalTo(ConfigurationManager.getProperty("dspace.name")));
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user