Skip to content

Commit

Permalink
Jcloud does not really support version numbers and will instead creat…
Browse files Browse the repository at this point in the history
…e an ETAG which is not comprehensible by the end users. We need to use jcloud storage metadata properties to manage the versions being created.

Added the following new properties for identifying the version property name to be used as well as the strategy.
- jcloud.external.resource.management.version.property.name
- jcloud.versioning.strategy
The strategy is to indicate how versioning will be performed based on how the system is configured.
- ALL - each file uploaded will create a new version (Default)
- DRAFT - each file updloaded will create a new version - but once approved, it can only create one version for each approval
- APPROVED - Can only create one version per approval process.

Jcloud does not allow specifying the creation date on the object.  It will always assume that it was created on the date loaded and updated on the date loaded. So if loading older data and we want the date to reflect that older date, we need to store the data in a custom property.  Added support for specifying the created date property name as well.
jcloud.external.resource.management.created.date.property.name
Updates the existing change date so that it always specifies the changed date. Prior to this change it would leave the change date property empty when it was equal to the current date.

Also fixed some other minor issue
 - remove finalize() as it was deprecated.
  • Loading branch information
ianwallen committed Nov 24, 2024
1 parent 97bdd7b commit 16b666b
Show file tree
Hide file tree
Showing 7 changed files with 410 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public String toString() {

private String escapeResourceManagementExternalProperties(String value) {
return value.replace(RESOURCE_MANAGEMENT_EXTERNAL_PROPERTIES_SEPARATOR, RESOURCE_MANAGEMENT_EXTERNAL_PROPERTIES_ESCAPED_SEPARATOR);
}
}

/**
* Create an encoded base 64 object id contains the following fields to uniquely identify the resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -779,14 +779,14 @@ public String toString() {
}

protected static class ResourceHolderImpl implements ResourceHolder {
private CmisObject cmisObject;
private final CmisObject cmisObject;
private Path tempFolderPath;
private Path path;
private final MetadataResource metadataResource;

public ResourceHolderImpl(final CmisObject cmisObject, MetadataResource metadataResource) throws IOException {
// Preserve filename by putting the files into a temporary folder and using the same filename.
tempFolderPath = Files.createTempDirectory("gn-meta-res-" + String.valueOf(metadataResource.getMetadataId() + "-"));
tempFolderPath = Files.createTempDirectory("gn-meta-res-" + metadataResource.getMetadataId() + "-");
tempFolderPath.toFile().deleteOnExit();
path = tempFolderPath.resolve(getFilename(cmisObject.getName()));
this.metadataResource = metadataResource;
Expand Down Expand Up @@ -817,11 +817,5 @@ public void close() throws IOException {
path=null;
tempFolderPath = null;
}

@Override
protected void finalize() throws Throwable {
close();
super.finalize();
}
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public class JCloudConfiguration {
*/
private String externalResourceManagementChangedDatePropertyName;

/**
* Property name for storing the creation date of the record.
*/
private String externalResourceManagementCreatedDatePropertyName;

/**
* Property name for validation status that is expected to be an integer with values of null, 0, 1, 2
* (See MetadataResourceExternalManagementProperties.ValidationStatus for code meaning)
Expand All @@ -86,7 +91,39 @@ public class JCloudConfiguration {
* Enable option to add versioning in the link to the resource.
*/
private Boolean versioningEnabled;
/**
* Property name for storing the version information JCloud does not support versioning.
*/
private String externalResourceManagementVersionPropertyName;

/**
* Property to identify the version strategy to be used.
*/
public enum VersioningStrategy {
/**
* Each new resource change should generate a new version
* i.e. All new uploads will increase the version including draft and working copy.
* For workflow, this could cause confusion on working copies which would increase the version in the working copy
* but when merged only the last version would be merged and could make it look like there are missing versions.
*/
ALL,
/**
* Each new resource change should generate a new version, But working copies will only increase by one version.
* This will avoid working copy version increases more than one to avoid the issues from ALL (lost versions on merge)
* This option may be preferred to ALL when workflow is enabled.
*/
DRAFT,
/**
* Add a new version each time a metadata is approved.
* i.e. draft will remain as version 1 until approved and working copy will only increase by 1 which is what would be used once approved.
*/
APPROVED
}

/**
* Version strategy to use when generating new versions
*/
private VersioningStrategy versioningStrategy = VersioningStrategy.ALL;

public void setProvider(String provider) {
this.provider = provider;
Expand Down Expand Up @@ -225,6 +262,24 @@ public void setVersioningEnabled(String versioningEnabled) {
this.versioningEnabled = BooleanUtils.toBooleanObject(versioningEnabled);
}

public String getExternalResourceManagementVersionPropertyName() {
return externalResourceManagementVersionPropertyName;
}

public void setExternalResourceManagementVersionPropertyName(String externalResourceManagementVersionPropertyName) {
this.externalResourceManagementVersionPropertyName = externalResourceManagementVersionPropertyName;
}

public VersioningStrategy getVersioningStrategy() {
return versioningStrategy;
}

public void setVersioningStrategy(String versioningStrategy) {
if (StringUtils.hasLength(versioningStrategy)) {
this.versioningStrategy = VersioningStrategy.valueOf(versioningStrategy);
}
}

public String getMetadataUUIDPropertyName() {
return metadataUUIDPropertyName;
}
Expand All @@ -240,6 +295,15 @@ public String getExternalResourceManagementChangedDatePropertyName() {
public void setExternalResourceManagementChangedDatePropertyName(String externalResourceManagementChangedDatePropertyName) {
this.externalResourceManagementChangedDatePropertyName = externalResourceManagementChangedDatePropertyName;
}

public String getExternalResourceManagementCreatedDatePropertyName() {
return externalResourceManagementCreatedDatePropertyName;
}

public void setExternalResourceManagementCreatedDatePropertyName(String externalResourceManagementCreatedDatePropertyName) {
this.externalResourceManagementCreatedDatePropertyName = externalResourceManagementCreatedDatePropertyName;
}

public String getExternalResourceManagementValidationStatusPropertyName() {
return externalResourceManagementValidationStatusPropertyName;
}
Expand Down Expand Up @@ -311,7 +375,9 @@ private void validateMetadataPropertyNames() throws IllegalArgumentException {
String[] names = {
getMetadataUUIDPropertyName(),
getExternalResourceManagementChangedDatePropertyName(),
getExternalResourceManagementValidationStatusPropertyName()
getExternalResourceManagementValidationStatusPropertyName(),
getExternalResourceManagementCreatedDatePropertyName(),
getExternalResourceManagementVersionPropertyName()
};

JCloudMetadataNameValidator.validateMetadataNamesForProvider(provider, names);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ jcloud.external.resource.management.validation.status.property.name=${JCLOUD_EXT
jcloud.external.resource.management.validation.status.default.value=${JCLOUD_EXTERNAL_RESOURCE_MANAGEMENT_VALIDATION_STATUS_DEFAULT_VALUE:#{null}}

jcloud.external.resource.management.changed.date.property.name=${JCLOUD_EXTERNAL_RESOURCE_MANAGEMENT_CHANGE_DATE_PROPERTY_NAME:#{null}}
jcloud.external.resource.management.created.date.property.name=${JCLOUD_EXTERNAL_RESOURCE_MANAGEMENT_CREATED_DATE_PROPERTY_NAME:#{null}}

jcloud.versioning.enabled=${JCLOUD_VERSIONING_ENABLED:#{null}}
jcloud.versioning.strategy=${JCLOUD_VERSIONING_STRATEGY:#{null}}
jcloud.external.resource.management.version.property.name=${JCLOUD_EXTERNAL_RESOURCE_MANAGEMENT_VERSION_PROPERTY_NAME:#{null}}

jcloud.metadata.uuid.property.name=${JCLOUD_METADATA_UUID_PROPERTY_NAME:#{null}}
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@
<property name="externalResourceManagementValidationStatusPropertyName" value="${jcloud.external.resource.management.validation.status.property.name}"/>
<property name="externalResourceManagementValidationStatusDefaultValue" value="${jcloud.external.resource.management.validation.status.default.value}"/>
<property name="externalResourceManagementChangedDatePropertyName" value="${jcloud.external.resource.management.changed.date.property.name}"/>
<property name="externalResourceManagementCreatedDatePropertyName" value="${jcloud.external.resource.management.created.date.property.name}"/>

<property name="versioningEnabled" value="${jcloud.versioning.enabled}"/>
<!-- Supported versioning Strategy: ALL, DRAFT, APPROVED -->
<property name="versioningStrategy" value="${jcloud.versioning.strategy}"/>
<property name="externalResourceManagementVersionPropertyName" value="${jcloud.external.resource.management.version.property.name}"/>

<property name="metadataUUIDPropertyName" value="${jcloud.metadata.uuid.property.name}"/>
</bean>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,5 @@ public void close() throws IOException {
path = null;
}
}

@Override
protected void finalize() throws Throwable {
close();
super.finalize();
}
}
}

0 comments on commit 16b666b

Please sign in to comment.