Class DSpaceObjectMetadataPatchUtils
- java.lang.Object
-
- org.dspace.app.rest.repository.patch.operation.DSpaceObjectMetadataPatchUtils
-
@Component public final class DSpaceObjectMetadataPatchUtils extends Object
Util class for shared methods between the Metadata Operations- Author:
- Maria Verdonck (Atmire) on 18/11/2019
-
-
Field Summary
Fields Modifier and Type Field Description static StringOPERATION_METADATA_PATHPath in json body of patch that uses these metadata operations
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckMetadataFieldNotNull(MetadataField metadataField)protected MetadataValueRestconvertMdValueToRest(MetadataValue md)Converts a metadataValue (database entity) to a REST equivalent of itprotected StringextractMdFieldStringFromOperation(Operation operation)Extracts the mdField String (schema.element.qualifier) from the operation and returns itprotected MetadataValueRestextractMetadataValueFromOperation(Operation operation)Extract metadataValue from Operation by parsing the json and mapping it to a MetadataValueRestprotected StringextractNewValueOfMd(Operation operation)Extracts the new value of the metadata from the operation for the replace patch operationprotected StringextractPropertyOfMdFromPath(String[] partsOfPath)Extracts which property of the metadata is being changed in the replace patch operationprotected StringgetIndexFromPath(String path)Retrieved the index from the path of the patch operation, if one can be foundprotected MetadataFieldgetMetadataField(Context context, Operation operation)Retrieves metadataField based on the metadata element found in the operation
-
-
-
Field Detail
-
OPERATION_METADATA_PATH
public static final String OPERATION_METADATA_PATH
Path in json body of patch that uses these metadata operations- See Also:
- Constant Field Values
-
-
Method Detail
-
extractMetadataValueFromOperation
protected MetadataValueRest extractMetadataValueFromOperation(Operation operation)
Extract metadataValue from Operation by parsing the json and mapping it to a MetadataValueRest- Parameters:
operation- Operation whose value is begin parsed- Returns:
- MetadataValueRest extracted from json in operation value
-
extractMdFieldStringFromOperation
protected String extractMdFieldStringFromOperation(Operation operation)
Extracts the mdField String (schema.element.qualifier) from the operation and returns it- Parameters:
operation- The patch operation- Returns:
- The mdField (schema.element.qualifier) patch is being performed on
-
convertMdValueToRest
protected MetadataValueRest convertMdValueToRest(MetadataValue md)
Converts a metadataValue (database entity) to a REST equivalent of it- Parameters:
md- Original metadataValue- Returns:
- The REST equivalent
-
extractPropertyOfMdFromPath
protected String extractPropertyOfMdFromPath(String[] partsOfPath)
Extracts which property of the metadata is being changed in the replace patch operation- Parameters:
partsOfPath- Parts of the path of the operation, separated with /- Returns:
- The property that is begin replaced of the metadata
-
extractNewValueOfMd
protected String extractNewValueOfMd(Operation operation)
Extracts the new value of the metadata from the operation for the replace patch operation- Parameters:
operation- The patch operation- Returns:
- The new value of the metadata being replaced in the patch operation
-
getMetadataField
protected MetadataField getMetadataField(Context context, Operation operation) throws SQLException
Retrieves metadataField based on the metadata element found in the operation- Parameters:
context- Context the retrieve metadataField from service with stringoperation- Operation of the patch- Returns:
- The metadataField corresponding to the md element string of the operation
- Throws:
SQLException
-
getIndexFromPath
protected String getIndexFromPath(String path)
Retrieved the index from the path of the patch operation, if one can be found- Parameters:
path- The string from the operation- Returns:
- The index in the path if there is one (path ex: /metadata/dc.title/1 (1 being the index))
-
checkMetadataFieldNotNull
protected void checkMetadataFieldNotNull(MetadataField metadataField)
-
-