Skip to content

Commit

Permalink
Updates based on code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian committed Nov 28, 2024
1 parent 16b666b commit 0c35dbf
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public class JCloudStore extends AbstractStore {
}

// For azure Blob ADSL hdi_isfolder property name used to identify folders
private final static String AZURE_BLOB_IS_FOLDER_PROPERTY_NAME="hdi_isfolder";
private static final String AZURE_BLOB_IS_FOLDER_PROPERTY_NAME="hdi_isfolder";

private Path baseMetadataDir = null;

Expand Down Expand Up @@ -147,15 +147,16 @@ private MetadataResource createResourceDescription(final ServiceContext context,
StorageMetadata storageMetadata, int metadataId, boolean approved) {
String filename = getFilename(metadataUuid, resourceId);

Date changedDate = null;
Date changedDate;
String changedDatePropertyName = jCloudConfiguration.getExternalResourceManagementChangedDatePropertyName();
if (storageMetadata.getUserMetadata().containsKey(changedDatePropertyName)) {
String changedDateValue = storageMetadata.getUserMetadata().get(changedDatePropertyName);
try {
changedDate = DATE_FORMATTER.parse(changedDateValue);
} catch (ParseException e) {
Log.warning(Geonet.RESOURCES, String.format("Unable to parse date '%s' into format pattern '%s' on resource '%s' for metadata %d(%s)",
Log.warning(Geonet.RESOURCES, String.format("Unable to parse date '%s' into format pattern '%s' on resource '%s' for metadata %d(%s). Will use resource last modified date",
changedDateValue, DATE_FORMATTER.toPattern(), resourceId, metadataId, metadataUuid), e);
changedDate = storageMetadata.getLastModified();
}
} else {
changedDate = storageMetadata.getLastModified();
Expand All @@ -169,9 +170,9 @@ private MetadataResource createResourceDescription(final ServiceContext context,
if (storageMetadata.getUserMetadata().containsKey(versionPropertyName)) {
versionValue = storageMetadata.getUserMetadata().get(versionPropertyName);
} else {
versionValue = "";
Log.warning(Geonet.RESOURCES, String.format("Expecting property '%s' on resource '%s' for metadata %d(%s) but the property was not found.",
versionPropertyName, resourceId, metadataId, metadataUuid));
versionValue = "";
}
} else {
versionValue = storageMetadata.getETag();
Expand Down Expand Up @@ -353,11 +354,11 @@ protected void setExternalResourceManagementDates(Map<String, String> properties
// JCloud does not allow created date to be set so we may supply the value we want as a property so assign the value.
// Only assign the value if we currently don't have a creation date, and we don't have a version assigned either because if either of these exists then
// it will indicate that this is not the first version.
String CreatedDatePropertyName = jCloudConfiguration.getExternalResourceManagementCreatedDatePropertyName();
String VersionPropertyName = jCloudConfiguration.getExternalResourceManagementVersionPropertyName();
if (StringUtils.hasLength(CreatedDatePropertyName) &&
!properties.containsKey(CreatedDatePropertyName) &&
(!StringUtils.hasLength(VersionPropertyName) || (!properties.containsKey(VersionPropertyName)))
String createdDatePropertyName = jCloudConfiguration.getExternalResourceManagementCreatedDatePropertyName();
String versionPropertyName = jCloudConfiguration.getExternalResourceManagementVersionPropertyName();
if (StringUtils.hasLength(createdDatePropertyName) &&
!properties.containsKey(createdDatePropertyName) &&
(!StringUtils.hasLength(versionPropertyName) || (!properties.containsKey(versionPropertyName)))
) {
properties.put(jCloudConfiguration.getExternalResourceManagementCreatedDatePropertyName(), DATE_FORMATTER.format(changeDate));
}
Expand Down Expand Up @@ -391,7 +392,7 @@ protected void setPropertiesVersion(final ServiceContext context, final Map<Stri
if (StringUtils.hasLength(jCloudConfiguration.getExternalResourceManagementVersionPropertyName())) {
String versionPropertyName = jCloudConfiguration.getExternalResourceManagementVersionPropertyName();

final int approvedMetadataId = approved ? metadataId : canEdit(context, metadataUuid, true);
final int approvedMetadataId = Boolean.TRUE.equals(approved) ? metadataId : canEdit(context, metadataUuid, true);
// if the current record id equal to the approved record id then it has not been approved and is a draft otherwise we are editing a working copy
final boolean draft = (metadataId == approvedMetadataId);

Expand Down

0 comments on commit 0c35dbf

Please sign in to comment.