Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add better Jcloud versioning supports #8512

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}
}