mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-14 21:43:11 +00:00
[DS-2729] Ensure SiteService extends DSpaceObjectService
This commit is contained in:
@@ -268,6 +268,11 @@ public class BitstreamServiceImpl extends DSpaceObjectServiceImpl<Bitstream> imp
|
|||||||
update(context, bitstream);
|
update(context, bitstream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSupportsTypeConstant() {
|
||||||
|
return Constants.BITSTREAM;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream retrieve(Context context, Bitstream bitstream) throws IOException, SQLException, AuthorizeException {
|
public InputStream retrieve(Context context, Bitstream bitstream) throws IOException, SQLException, AuthorizeException {
|
||||||
// Maybe should return AuthorizeException??
|
// Maybe should return AuthorizeException??
|
||||||
|
@@ -439,6 +439,11 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
|
|||||||
bundleDAO.delete(context, bundle);
|
bundleDAO.delete(context, bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSupportsTypeConstant() {
|
||||||
|
return Constants.BUNDLE;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Bundle findByIdOrLegacyId(Context context, String id) throws SQLException {
|
public Bundle findByIdOrLegacyId(Context context, String id) throws SQLException {
|
||||||
if(StringUtils.isNumeric(id))
|
if(StringUtils.isNumeric(id))
|
||||||
|
@@ -729,6 +729,11 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
|||||||
collectionDAO.delete(context, collection);
|
collectionDAO.delete(context, collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSupportsTypeConstant() {
|
||||||
|
return Constants.COLLECTION;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Collection> findAuthorized(Context context, Community community, int actionID) throws SQLException {
|
public List<Collection> findAuthorized(Context context, Community community, int actionID) throws SQLException {
|
||||||
List<Collection> myResults = new ArrayList<Collection>();
|
List<Collection> myResults = new ArrayList<Collection>();
|
||||||
|
@@ -466,6 +466,11 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSupportsTypeConstant() {
|
||||||
|
return Constants.COMMUNITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal method to remove the community and all its children from the
|
* Internal method to remove the community and all its children from the
|
||||||
|
@@ -578,6 +578,11 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
rawDelete(context, item);
|
rawDelete(context, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSupportsTypeConstant() {
|
||||||
|
return Constants.ITEM;
|
||||||
|
}
|
||||||
|
|
||||||
protected void rawDelete(Context context, Item item) throws AuthorizeException, SQLException, IOException {
|
protected void rawDelete(Context context, Item item) throws AuthorizeException, SQLException, IOException {
|
||||||
authorizeService.authorizeAction(context, item, Constants.REMOVE);
|
authorizeService.authorizeAction(context, item, Constants.REMOVE);
|
||||||
|
|
||||||
|
@@ -7,14 +7,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.content;
|
package org.dspace.content;
|
||||||
|
|
||||||
|
import org.dspace.authorize.AuthorizeException;
|
||||||
|
import org.dspace.authorize.service.AuthorizeService;
|
||||||
import org.dspace.content.dao.SiteDAO;
|
import org.dspace.content.dao.SiteDAO;
|
||||||
import org.dspace.content.service.SiteService;
|
import org.dspace.content.service.SiteService;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.handle.service.HandleService;
|
import org.dspace.handle.service.HandleService;
|
||||||
import org.dspace.services.ConfigurationService;
|
import org.dspace.services.ConfigurationService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service implementation for the Site object.
|
* Service implementation for the Site object.
|
||||||
@@ -23,7 +28,10 @@ import java.sql.SQLException;
|
|||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public class SiteServiceImpl implements SiteService {
|
public class SiteServiceImpl extends DSpaceObjectServiceImpl<Site> implements SiteService {
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected AuthorizeService authorizeService;
|
||||||
|
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
protected HandleService handleService;
|
protected HandleService handleService;
|
||||||
@@ -50,4 +58,33 @@ public class SiteServiceImpl implements SiteService {
|
|||||||
public Site findSite(Context context) throws SQLException {
|
public Site findSite(Context context) throws SQLException {
|
||||||
return siteDAO.findSite(context);
|
return siteDAO.findSite(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Site find(Context context, UUID id) throws SQLException {
|
||||||
|
return siteDAO.findByID(context, Site.class, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateLastModified(Context context, Site dso) throws SQLException, AuthorizeException {
|
||||||
|
//Not used at the moment
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Context context, Site dso) throws SQLException, AuthorizeException {
|
||||||
|
if(!authorizeService.isAdmin(context)){
|
||||||
|
throw new AuthorizeException();
|
||||||
|
}
|
||||||
|
siteDAO.save(context, dso);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(Context context, Site dso) throws SQLException, AuthorizeException, IOException {
|
||||||
|
throw new AuthorizeException("Site object cannot be deleted");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSupportsTypeConstant() {
|
||||||
|
return Constants.SITE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,7 @@ import java.sql.SQLException;
|
|||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface SiteDAO extends GenericDAO<Site> {
|
public interface SiteDAO extends DSpaceObjectDAO<Site> {
|
||||||
|
|
||||||
public Site findSite(Context context) throws SQLException;
|
public Site findSite(Context context) throws SQLException;
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,8 @@ import org.dspace.eperson.factory.EPersonServiceFactory;
|
|||||||
import org.dspace.utils.DSpace;
|
import org.dspace.utils.DSpace;
|
||||||
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract factory to get services for the content package, use ContentServiceFactory.getInstance() to retrieve an implementation
|
* Abstract factory to get services for the content package, use ContentServiceFactory.getInstance() to retrieve an implementation
|
||||||
*
|
*
|
||||||
@@ -23,6 +25,10 @@ import org.dspace.workflow.factory.WorkflowServiceFactory;
|
|||||||
*/
|
*/
|
||||||
public abstract class ContentServiceFactory {
|
public abstract class ContentServiceFactory {
|
||||||
|
|
||||||
|
public abstract List<DSpaceObjectService<? extends DSpaceObject>> getDSpaceObjectServices();
|
||||||
|
|
||||||
|
public abstract List<DSpaceObjectLegacySupportService<? extends DSpaceObject>> getDSpaceObjectLegacySupportServices();
|
||||||
|
|
||||||
public abstract BitstreamFormatService getBitstreamFormatService();
|
public abstract BitstreamFormatService getBitstreamFormatService();
|
||||||
|
|
||||||
public abstract BitstreamService getBitstreamService();
|
public abstract BitstreamService getBitstreamService();
|
||||||
@@ -71,48 +77,27 @@ public abstract class ContentServiceFactory {
|
|||||||
|
|
||||||
public DSpaceObjectService getDSpaceObjectService(int type)
|
public DSpaceObjectService getDSpaceObjectService(int type)
|
||||||
{
|
{
|
||||||
switch (type)
|
for (int i = 0; i < getDSpaceObjectServices().size(); i++) {
|
||||||
{
|
DSpaceObjectService objectService = getDSpaceObjectServices().get(i);
|
||||||
case Constants.BITSTREAM:
|
if(objectService.getSupportsTypeConstant() == type)
|
||||||
return getBitstreamService();
|
{
|
||||||
case Constants.BUNDLE:
|
return objectService;
|
||||||
return getBundleService();
|
}
|
||||||
case Constants.ITEM:
|
|
||||||
return getItemService();
|
|
||||||
case Constants.COLLECTION:
|
|
||||||
return getCollectionService();
|
|
||||||
case Constants.COMMUNITY:
|
|
||||||
return getCommunityService();
|
|
||||||
case Constants.GROUP:
|
|
||||||
return EPersonServiceFactory.getInstance().getGroupService();
|
|
||||||
case Constants.EPERSON:
|
|
||||||
return EPersonServiceFactory.getInstance().getEPersonService();
|
|
||||||
default:
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
}
|
||||||
|
throw new UnsupportedOperationException("Unknown DSpace type: " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DSpaceObjectLegacySupportService<? extends DSpaceObject> getDSpaceLegacyObjectService(int type)
|
public DSpaceObjectLegacySupportService<? extends DSpaceObject> getDSpaceLegacyObjectService(int type)
|
||||||
{
|
{
|
||||||
switch (type)
|
for (int i = 0; i < getDSpaceObjectLegacySupportServices().size(); i++) {
|
||||||
{
|
DSpaceObjectLegacySupportService<? extends DSpaceObject> objectLegacySupportService = getDSpaceObjectLegacySupportServices().get(i);
|
||||||
case Constants.BITSTREAM:
|
if(objectLegacySupportService.getSupportsTypeConstant() == type)
|
||||||
return getBitstreamService();
|
{
|
||||||
case Constants.BUNDLE:
|
return objectLegacySupportService;
|
||||||
return getBundleService();
|
}
|
||||||
case Constants.ITEM:
|
|
||||||
return getItemService();
|
|
||||||
case Constants.COLLECTION:
|
|
||||||
return getCollectionService();
|
|
||||||
case Constants.COMMUNITY:
|
|
||||||
return getCommunityService();
|
|
||||||
case Constants.GROUP:
|
|
||||||
return EPersonServiceFactory.getInstance().getGroupService();
|
|
||||||
case Constants.EPERSON:
|
|
||||||
return EPersonServiceFactory.getInstance().getEPersonService();
|
|
||||||
default:
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
}
|
||||||
|
throw new UnsupportedOperationException("Unknown DSpace type: " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ContentServiceFactory getInstance(){
|
public static ContentServiceFactory getInstance(){
|
||||||
|
@@ -7,9 +7,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.content.factory;
|
package org.dspace.content.factory;
|
||||||
|
|
||||||
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.service.*;
|
import org.dspace.content.service.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory implementation to get services for the content package, use ContentServiceFactory.getInstance() to retrieve an implementation
|
* Factory implementation to get services for the content package, use ContentServiceFactory.getInstance() to retrieve an implementation
|
||||||
*
|
*
|
||||||
@@ -17,6 +20,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
*/
|
*/
|
||||||
public class ContentServiceFactoryImpl extends ContentServiceFactory {
|
public class ContentServiceFactoryImpl extends ContentServiceFactory {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
private List<DSpaceObjectService<? extends DSpaceObject>> dSpaceObjectServices;
|
||||||
|
@Autowired(required = true)
|
||||||
|
private List<DSpaceObjectLegacySupportService<? extends DSpaceObject>> dSpaceObjectLegacySupportServices;
|
||||||
|
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
private BitstreamFormatService bitstreamFormatService;
|
private BitstreamFormatService bitstreamFormatService;
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
@@ -45,6 +54,16 @@ public class ContentServiceFactoryImpl extends ContentServiceFactory {
|
|||||||
private SiteService siteService;
|
private SiteService siteService;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DSpaceObjectService<? extends DSpaceObject>> getDSpaceObjectServices() {
|
||||||
|
return dSpaceObjectServices;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DSpaceObjectLegacySupportService<? extends DSpaceObject>> getDSpaceObjectLegacySupportServices() {
|
||||||
|
return dSpaceObjectLegacySupportServices;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BitstreamFormatService getBitstreamFormatService()
|
public BitstreamFormatService getBitstreamFormatService()
|
||||||
{
|
{
|
||||||
|
@@ -33,4 +33,11 @@ public interface DSpaceObjectLegacySupportService<T extends DSpaceObject> {
|
|||||||
* @throws java.sql.SQLException only upon failure accessing the database.
|
* @throws java.sql.SQLException only upon failure accessing the database.
|
||||||
*/
|
*/
|
||||||
public T findByLegacyId(Context context, int id) throws SQLException;
|
public T findByLegacyId(Context context, int id) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Constants which this service supports
|
||||||
|
*
|
||||||
|
* @return a org.dspace.core.Constants that represents a DSpaceObjct type
|
||||||
|
*/
|
||||||
|
public int getSupportsTypeConstant();
|
||||||
}
|
}
|
||||||
|
@@ -337,4 +337,13 @@ public interface DSpaceObjectService<T extends DSpaceObject> {
|
|||||||
public void update(Context context, T dso) throws SQLException, AuthorizeException;
|
public void update(Context context, T dso) throws SQLException, AuthorizeException;
|
||||||
|
|
||||||
public void delete(Context context, T dso) throws SQLException, AuthorizeException, IOException;
|
public void delete(Context context, T dso) throws SQLException, AuthorizeException, IOException;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Constants which this service supports
|
||||||
|
*
|
||||||
|
* @return a org.dspace.core.Constants that represents a DSpaceObjct type
|
||||||
|
*/
|
||||||
|
public int getSupportsTypeConstant();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -18,7 +18,8 @@ import java.sql.SQLException;
|
|||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface SiteService {
|
public interface SiteService extends DSpaceObjectService<Site>
|
||||||
|
{
|
||||||
|
|
||||||
public Site createSite(Context context) throws SQLException;
|
public Site createSite(Context context) throws SQLException;
|
||||||
|
|
||||||
|
@@ -224,6 +224,11 @@ public class EPersonServiceImpl extends DSpaceObjectServiceImpl<EPerson> impleme
|
|||||||
"eperson_id=" + ePerson.getID()));
|
"eperson_id=" + ePerson.getID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSupportsTypeConstant() {
|
||||||
|
return Constants.EPERSON;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPassword(EPerson ePerson, String password) {
|
public void setPassword(EPerson ePerson, String password) {
|
||||||
PasswordHash hash = new PasswordHash(password);
|
PasswordHash hash = new PasswordHash(password);
|
||||||
|
@@ -323,6 +323,11 @@ public class GroupServiceImpl extends DSpaceObjectServiceImpl<Group> implements
|
|||||||
+ group.getID()));
|
+ group.getID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSupportsTypeConstant() {
|
||||||
|
return Constants.GROUP;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if group has no direct or indirect members
|
* Return true if group has no direct or indirect members
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user