Package org.dspace.content
Class CommunityServiceImpl
- All Implemented Interfaces:
CommunityService,DSpaceObjectLegacySupportService<Community>,DSpaceObjectService<Community>
public class CommunityServiceImpl
extends DSpaceObjectServiceImpl<Community>
implements CommunityService
Service implementation for the Community object.
This class is responsible for all business logic calls for the Community object and is autowired by spring.
This class should never be accessed directly.
- Author:
- kevinvandevelde at atmire.com
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AuthorizeServiceprotected BitstreamServiceprotected CollectionServiceprotected CommunityDAOprotected GroupServiceprotected IdentifierServiceprotected ItemCounterprotected ItemServiceprotected SiteServiceprotected SubscribeServiceFields inherited from class org.dspace.content.DSpaceObjectServiceImpl
choiceAuthorityService, handleService, metadataAuthorityService, metadataFieldService, metadataValueService, relationshipServiceFields inherited from interface org.dspace.content.service.DSpaceObjectService
MD_COPYRIGHT_TEXT, MD_INTRODUCTORY_TEXT, MD_LICENSE, MD_NAME, MD_PROVENANCE_DESCRIPTION, MD_SHORT_DESCRIPTION, MD_SIDEBAR_TEXT, MD_SOURCE, MD_USER_FORMAT_DESCRIPTION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCollection(Context context, Community community, Collection collection) Add an existing collection to the communityprotected voidaddCollectionList(Community community, List<Collection> collectionList) Internal method to process subcommunities recursivelyvoidaddSubcommunity(Context context, Community parentCommunity, Community childCommunity) Add an existing community as a subcommunity to the communityvoidbooleancanEditBoolean(Context context, Community community) return TRUE if context's user can edit community, false otherwiseintcountArchivedItems(Context context, Community community) Returns total community archived itemsintcountTotal(Context context) Create a new top-level community, with a new ID.Create a new top-level community, with a new ID.Create a new top-level community, with a new ID.createAdministrators(Context context, Community community) Create a default administrators group if one does not already exist.createSubcommunity(Context context, Community parentCommunity) Create a new sub-community within this community.createSubcommunity(Context context, Community parentCommunity, String handle) Create a new sub-community within this community.createSubcommunity(Context context, Community parentCommunity, String handle, UUID uuid) Create a new sub-community within this community.voidGeneric find for when the precise type of an Entity is not knownGet a list of all communities in the system.Get all communities in the system.findAllTop(Context context) Get a list of all top-level communities in the system.findAuthorized(Context context, List<Integer> actions) findAuthorizedGroupMapped(Context context, List<Integer> actions) findByAdminGroup(Context context, Group group) findByIdOrLegacyId(Context context, String id) findByLegacyId(Context context, int id) Generic find for when the precise type of a DSO is not known, just the a pair of type number and database ID.getAdminObject(Context context, Community community, int action) Return the dspace object where an ADMIN action right is sufficient to grant the initial authorize check.getAllCollections(Context context, Community community) Return an array of collections of this community and its subcommunitiesgetAllParents(Context context, Collection collection) Return an array of parent communities of this collection.getAllParents(Context context, Community community) Return an array of parent communities of this community, in ascending order.getParentObject(Context context, Community community) Return the dspace object that "own" the current object in the hierarchy.intReturns the Constants which this service supportsprotected voidInternal method to remove the community and all its children from the database, and perform any pre/post-cleanupvoidremoveAdministrators(Context context, Community community) Remove the administrators group, if no group has already been created then return without error.voidremoveCollection(Context context, Community community, Collection collection) Remove a collection.voidremoveSubcommunity(Context context, Community parentCommunity, Community childCommunity) Remove a subcommunity.setLogo(Context context, Community community, InputStream is) Give the community a logo.voidsetMetadataSingleValue(Context context, Community community, MetadataFieldName field, String language, String value) Set first metadata field valuevoidvoidupdateLastModified(Context context, Community community) Methods inherited from class org.dspace.content.DSpaceObjectServiceImpl
addAndShiftRightMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, clearMetadata, getAuthoritiesAndConfidences, getElements, getElementsFilled, getIdentifiers, getMDValueByField, getMDValueByLegacyField, getMetadata, getMetadata, getMetadata, getMetadata, getMetadataByMetadataString, getMetadataFirstValue, getMetadataFirstValue, getMetadataValuePlace, getName, getTypeText, match, moveMetadata, moveSingleMetadataValue, removeMetadataValues, replaceMetadata, setMetadataModified, setMetadataSingleValueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.dspace.content.service.DSpaceObjectService
addAndShiftRightMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, clearMetadata, getIdentifiers, getMetadata, getMetadata, getMetadata, getMetadata, getMetadataByMetadataString, getMetadataFirstValue, getMetadataFirstValue, getName, getTypeText, moveMetadata, removeMetadataValues, replaceMetadata, setMetadataModified, setMetadataSingleValue
-
Field Details
-
communityDAO
-
collectionService
-
groupService
-
authorizeService
-
itemService
-
bitstreamService
-
siteService
-
identifierService
-
subscribeService
-
itemCounter
-
-
Constructor Details
-
CommunityServiceImpl
protected CommunityServiceImpl()
-
-
Method Details
-
create
Description copied from interface:CommunityServiceCreate a new top-level community, with a new ID.- Specified by:
createin interfaceCommunityService- Parameters:
parent- parent communitycontext- DSpace context object- Returns:
- the newly created community
- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
create
public Community create(Community parent, Context context, String handle) throws SQLException, AuthorizeException Description copied from interface:CommunityServiceCreate a new top-level community, with a new ID.- Specified by:
createin interfaceCommunityService- Parameters:
parent- parent communitycontext- DSpace context objecthandle- the pre-determined Handle to assign to the new community- Returns:
- the newly created community
- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
create
public Community create(Community parent, Context context, String handle, UUID uuid) throws SQLException, AuthorizeException Description copied from interface:CommunityServiceCreate a new top-level community, with a new ID.- Specified by:
createin interfaceCommunityService- Parameters:
parent- parent communitycontext- DSpace context objecthandle- the pre-determined Handle to assign to the new communityuuid- the pre-determined uuid to assign to the new community- Returns:
- the newly created community
- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
find
Description copied from interface:DSpaceObjectServiceGeneric find for when the precise type of an Entity is not known- Specified by:
findin interfaceDSpaceObjectService<Community>- Parameters:
context- - the contextid- - uuid within table of typed dspace objects- Returns:
- the dspace object found, or null if it does not exist.
- Throws:
SQLException- only upon failure accessing the database.
-
findAll
Description copied from interface:CommunityServiceGet a list of all communities in the system. These are alphabetically sorted by community name.- Specified by:
findAllin interfaceCommunityService- Parameters:
context- DSpace context object- Returns:
- the communities in the system
- Throws:
SQLException- if database error
-
findAll
Description copied from interface:CommunityServiceGet all communities in the system. Adds support for limit and offset.- Specified by:
findAllin interfaceCommunityService- Parameters:
context- contextlimit- limitoffset- offset- Returns:
- list of communities
- Throws:
SQLException- if database error
-
findAllTop
Description copied from interface:CommunityServiceGet a list of all top-level communities in the system. These are alphabetically sorted by community name. A top-level community is one without a parent community.- Specified by:
findAllTopin interfaceCommunityService- Parameters:
context- DSpace context object- Returns:
- the top-level communities in the system
- Throws:
SQLException- if database error
-
setMetadataSingleValue
public void setMetadataSingleValue(Context context, Community community, MetadataFieldName field, String language, String value) throws MissingResourceException, SQLException Description copied from interface:DSpaceObjectServiceSet first metadata field value- Specified by:
setMetadataSingleValuein interfaceDSpaceObjectService<Community>- Overrides:
setMetadataSingleValuein classDSpaceObjectServiceImpl<Community>- Parameters:
context- DSpace contextcommunity- DSpaceObjectfield- {schema, element, qualifier} for the desired field.language- the ISO639 language code, optionally followed by an underscore and the ISO3166 country code.nullmeans only values with no language are removed, andItem.ANYmeans values with any country code or no country code are removed.value- metadata value- Throws:
SQLException- if database errorMissingResourceException
-
setLogo
public Bitstream setLogo(Context context, Community community, InputStream is) throws AuthorizeException, IOException, SQLException Description copied from interface:CommunityServiceGive the community a logo. Passing innullremoves any existing logo. You will need to set the format of the new logo bitstream before it will work, for example to "JPEG". Note thatupdatewill need to be called for the change to take effect. Setting a logo and not callingupdatelater may result in a previous logo lying around as an "orphaned" bitstream.- Specified by:
setLogoin interfaceCommunityService- Parameters:
context- contextcommunity- communityis- the stream to use as the new logo- Returns:
- the new logo bitstream, or
nullif there is no logo (nullwas passed in) - Throws:
AuthorizeException- if authorization errorIOException- if IO errorSQLException- if database error
-
update
- Specified by:
updatein interfaceDSpaceObjectService<Community>- Overrides:
updatein classDSpaceObjectServiceImpl<Community>- Throws:
SQLExceptionAuthorizeException
-
createAdministrators
public Group createAdministrators(Context context, Community community) throws SQLException, AuthorizeException Description copied from interface:CommunityServiceCreate a default administrators group if one does not already exist. Returns either the newly created group or the previously existing one. Note that other groups may also be administrators.- Specified by:
createAdministratorsin interfaceCommunityService- Parameters:
context- contextcommunity- community- Returns:
- the default group of editors associated with this community
- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
removeAdministrators
public void removeAdministrators(Context context, Community community) throws SQLException, AuthorizeException Description copied from interface:CommunityServiceRemove the administrators group, if no group has already been created then return without error. This will merely dereference the current administrators group from the community so that it may be deleted without violating database constraints.- Specified by:
removeAdministratorsin interfaceCommunityService- Parameters:
context- contextcommunity- community- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
getAllParents
Description copied from interface:CommunityServiceReturn an array of parent communities of this community, in ascending order. If community is top-level, return an empty array.- Specified by:
getAllParentsin interfaceCommunityService- Parameters:
context- contextcommunity- community- Returns:
- an array of parent communities, empty if top-level
- Throws:
SQLException- if database error
-
getAllParents
Description copied from interface:CommunityServiceReturn an array of parent communities of this collection.- Specified by:
getAllParentsin interfaceCommunityService- Parameters:
context- The relevant DSpace Context.collection- collection to check- Returns:
- an array of parent communities
- Throws:
SQLException- if database error
-
getAllCollections
Description copied from interface:CommunityServiceReturn an array of collections of this community and its subcommunities- Specified by:
getAllCollectionsin interfaceCommunityService- Parameters:
context- contextcommunity- community- Returns:
- an array of collections
- Throws:
SQLException- if database error
-
addCollectionList
protected void addCollectionList(Community community, List<Collection> collectionList) throws SQLException Internal method to process subcommunities recursively- Parameters:
community- communitycollectionList- list of collections- Throws:
SQLException- if database error
-
addCollection
public void addCollection(Context context, Community community, Collection collection) throws SQLException, AuthorizeException Description copied from interface:CommunityServiceAdd an existing collection to the community- Specified by:
addCollectionin interfaceCommunityService- Parameters:
context- contextcommunity- communitycollection- collection to add- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
createSubcommunity
public Community createSubcommunity(Context context, Community parentCommunity) throws SQLException, AuthorizeException Description copied from interface:CommunityServiceCreate a new sub-community within this community.- Specified by:
createSubcommunityin interfaceCommunityService- Parameters:
context- contextparentCommunity- parent community- Returns:
- the new community
- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
createSubcommunity
public Community createSubcommunity(Context context, Community parentCommunity, String handle) throws SQLException, AuthorizeException Description copied from interface:CommunityServiceCreate a new sub-community within this community.- Specified by:
createSubcommunityin interfaceCommunityService- Parameters:
context- contextparentCommunity- parent communityhandle- the pre-determined Handle to assign to the new community- Returns:
- the new community
- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
createSubcommunity
public Community createSubcommunity(Context context, Community parentCommunity, String handle, UUID uuid) throws SQLException, AuthorizeException Description copied from interface:CommunityServiceCreate a new sub-community within this community.- Specified by:
createSubcommunityin interfaceCommunityService- Parameters:
context- contextparentCommunity- parent communityhandle- the pre-determined Handle to assign to the new communityuuid- the pre-determined UUID to assign to the new community- Returns:
- the new community
- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
addSubcommunity
public void addSubcommunity(Context context, Community parentCommunity, Community childCommunity) throws SQLException, AuthorizeException Description copied from interface:CommunityServiceAdd an existing community as a subcommunity to the community- Specified by:
addSubcommunityin interfaceCommunityService- Parameters:
context- contextparentCommunity- parent community to add our subcommunity tochildCommunity- subcommunity to add- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
removeCollection
public void removeCollection(Context context, Community community, Collection collection) throws SQLException, AuthorizeException, IOException Description copied from interface:CommunityServiceRemove a collection. If it only belongs to one parent community, then it is permanently deleted. If it has more than one parent community, it is simply unmapped from the current community.- Specified by:
removeCollectionin interfaceCommunityService- Parameters:
context- contextcommunity- communitycollection- collection to remove- Throws:
SQLException- if database errorAuthorizeException- if authorization errorIOException- if IO error
-
removeSubcommunity
public void removeSubcommunity(Context context, Community parentCommunity, Community childCommunity) throws SQLException, AuthorizeException, IOException Description copied from interface:CommunityServiceRemove a subcommunity. If it only belongs to one parent community, then it is permanently deleted. If it has more than one parent community, it is simply unmapped from the current community.- Specified by:
removeSubcommunityin interfaceCommunityService- Parameters:
context- contextparentCommunity- parent communitychildCommunity- subcommunity to remove- Throws:
SQLException- if database errorAuthorizeException- if authorization errorIOException- if IO error
-
delete
public void delete(Context context, Community community) throws SQLException, AuthorizeException, IOException - Specified by:
deletein interfaceDSpaceObjectService<Community>- Throws:
SQLExceptionAuthorizeExceptionIOException
-
getSupportsTypeConstant
public int getSupportsTypeConstant()Description copied from interface:DSpaceObjectServiceReturns the Constants which this service supports- Specified by:
getSupportsTypeConstantin interfaceDSpaceObjectLegacySupportService<Community>- Specified by:
getSupportsTypeConstantin interfaceDSpaceObjectService<Community>- Returns:
- a org.dspace.core.Constants that represents a IndexableObject type
-
rawDelete
protected void rawDelete(Context context, Community community) throws SQLException, AuthorizeException, IOException Internal method to remove the community and all its children from the database, and perform any pre/post-cleanup- Parameters:
context- contextcommunity- community- Throws:
SQLException- if database errorAuthorizeException- if authorization errorIOException- if IO error
-
canEditBoolean
Description copied from interface:CommunityServicereturn TRUE if context's user can edit community, false otherwise- Specified by:
canEditBooleanin interfaceCommunityService- Parameters:
context- contextcommunity- community- Returns:
- boolean true = current user can edit community
- Throws:
SQLException- if database error
-
canEdit
- Specified by:
canEditin interfaceCommunityService- Throws:
AuthorizeExceptionSQLException
-
findByAdminGroup
- Specified by:
findByAdminGroupin interfaceCommunityService- Throws:
SQLException
-
findAuthorized
- Specified by:
findAuthorizedin interfaceCommunityService- Throws:
SQLException
-
findAuthorizedGroupMapped
public List<Community> findAuthorizedGroupMapped(Context context, List<Integer> actions) throws SQLException - Specified by:
findAuthorizedGroupMappedin interfaceCommunityService- Throws:
SQLException
-
getAdminObject
public DSpaceObject getAdminObject(Context context, Community community, int action) throws SQLException Description copied from interface:DSpaceObjectServiceReturn the dspace object where an ADMIN action right is sufficient to grant the initial authorize check.Default behaviour is ADMIN right on the object grant right on all other action on the object itself. Subclass should override this method as needed.
- Specified by:
getAdminObjectin interfaceDSpaceObjectService<Community>- Overrides:
getAdminObjectin classDSpaceObjectServiceImpl<Community>- Parameters:
context- DSpace contextcommunity- DSpaceObjectaction- ID of action being attempted, fromorg.dspace.core.Constants. The ADMIN action is not a valid parameter for this method, an IllegalArgumentException should be thrown- Returns:
- the dspace object, if any, where an ADMIN action is sufficient to grant the original action
- Throws:
SQLException- if database error
-
getParentObject
Description copied from interface:DSpaceObjectServiceReturn the dspace object that "own" the current object in the hierarchy. Note that this method has a meaning slightly different from the getAdminObject because it is independent of the action but it is in a way related to it. It defines the "first" dspace object OTHER then the current one, where allowed ADMIN actions imply allowed ADMIN actions on the object self.- Specified by:
getParentObjectin interfaceDSpaceObjectService<Community>- Overrides:
getParentObjectin classDSpaceObjectServiceImpl<Community>- Parameters:
context- DSpace contextcommunity- DSpaceObject- Returns:
- the dspace object that "own" the current object in the hierarchy
- Throws:
SQLException- if database error
-
updateLastModified
- Specified by:
updateLastModifiedin interfaceDSpaceObjectService<Community>
-
findByIdOrLegacyId
- Specified by:
findByIdOrLegacyIdin interfaceDSpaceObjectLegacySupportService<Community>- Throws:
SQLException
-
findByLegacyId
Description copied from interface:DSpaceObjectLegacySupportServiceGeneric find for when the precise type of a DSO is not known, just the a pair of type number and database ID.- Specified by:
findByLegacyIdin interfaceDSpaceObjectLegacySupportService<Community>- Parameters:
context- - the contextid- - the legacy id within table of type'd objects- Returns:
- the object found, or null if it does not exist.
- Throws:
SQLException- only upon failure accessing the database.
-
countTotal
- Specified by:
countTotalin interfaceCommunityService- Throws:
SQLException
-
countArchivedItems
Returns total community archived items- Specified by:
countArchivedItemsin interfaceCommunityService- Parameters:
context- DSpace contextcommunity- Community- Returns:
- total community archived items
-