Package org.gbif.api.service.collections
Interface DescriptorChangeSuggestionService
public interface DescriptorChangeSuggestionService
Service interface for managing descriptor change suggestions in collections.
This service handles the creation, updating, and management of descriptor change suggestions,
including file handling and status management.
Note: File storage is handled internally using unique identifiers. The provided filename
is used only for display and metadata purposes.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
applySuggestion
(long key) Applies a pending descriptor change suggestion.long
Counts the total number of descriptor change suggestions based on filters.createSuggestion
(InputStream fileStream, String filename, DescriptorChangeSuggestionRequest request) Creates a new descriptor change suggestion.void
discardSuggestion
(long key) Discards a pending descriptor change suggestion.getSuggestion
(long key) Retrieves a descriptor change suggestion by its key.getSuggestionFile
(long key) Retrieves the file associated with a descriptor change suggestion.Lists descriptor change suggestions with optional filters.updateSuggestion
(long key, DescriptorChangeSuggestionRequest request, InputStream fileStream, String filename) Updates an existing descriptor change suggestion.
-
Method Details
-
createSuggestion
DescriptorChangeSuggestion createSuggestion(InputStream fileStream, String filename, DescriptorChangeSuggestionRequest request) throws IOException Creates a new descriptor change suggestion.- Parameters:
fileStream
- The input stream containing the descriptor datafilename
- The original filename (used for display and metadata only)request
- The suggestion request containing metadata- Returns:
- The created DescriptorChangeSuggestion
- Throws:
IOException
- If there's an error processing the fileIllegalArgumentException
- If the request is invalid
-
updateSuggestion
DescriptorChangeSuggestion updateSuggestion(long key, DescriptorChangeSuggestionRequest request, InputStream fileStream, String filename) throws IOException Updates an existing descriptor change suggestion. Only pending suggestions can be updated.- Parameters:
key
- The key of the suggestion to updaterequest
- The updated suggestion requestfileStream
- Optional new file stream to replace the existing onefilename
- The original filename if fileStream is provided (used for display and metadata only)- Returns:
- The updated DescriptorChangeSuggestion
- Throws:
IOException
- If there's an error processing the fileIllegalArgumentException
- If the suggestion is not in PENDING stateIllegalStateException
- If the suggestion cannot be updated
-
getSuggestion
Retrieves a descriptor change suggestion by its key.- Parameters:
key
- The key of the suggestion to retrieve- Returns:
- The DescriptorChangeSuggestion or null if not found
-
getSuggestionFile
Retrieves the file associated with a descriptor change suggestion.- Parameters:
key
- The key of the suggestion- Returns:
- InputStream containing the suggestion file data
- Throws:
IllegalArgumentException
- If the suggestion is not foundIOException
- If there's an error reading the file
-
applySuggestion
Applies a pending descriptor change suggestion. This will create or update the descriptor group based on the suggestion.- Parameters:
key
- The key of the suggestion to apply- Throws:
IOException
- If there's an error processing the fileIllegalArgumentException
- If the suggestion is not in PENDING stateIllegalStateException
- If the suggestion cannot be applied
-
discardSuggestion
Discards a pending descriptor change suggestion.- Parameters:
key
- The key of the suggestion to discard- Throws:
IllegalArgumentException
- If the suggestion is not in PENDING stateIllegalStateException
- If the suggestion cannot be discarded
-
list
PagingResponse<DescriptorChangeSuggestion> list(Pageable pageable, Status status, Type type, String proposerEmail, UUID collectionKey) Lists descriptor change suggestions with optional filters.- Parameters:
pageable
- Pagination detailsstatus
- Filter by status (PENDING, APPROVED, DISCARDED)type
- Filter by type (CREATE, UPDATE, DELETE)proposerEmail
- Filter by proposer's emailcollectionKey
- Filter by collection key- Returns:
- PagingResponse containing the filtered suggestions
-
count
Counts the total number of descriptor change suggestions based on filters.- Parameters:
status
- Filter by statustype
- Filter by typeproposerEmail
- Filter by proposer's emailcollectionKey
- Filter by collection key- Returns:
- Total number of matching suggestions
-