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 support for external management named properties in JCloud #8357

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ianwallen
Copy link
Contributor

@ianwallen ianwallen commented Sep 8, 2024

Update external management url

  • Add {objectId} property in external management url (base64 unique identifier for the record)
  • Change external management type url property {type} so that it is fixed values so that same value can be used in {objectId}

CMIS

  • Fixed property names used for validation fields to be consistent with other names.

Jcloud

  • Updgade from jcloud 2.3.0 to jcloud 2.5.0
  • Add support for external management named properties similar to cmis
  • Fix bug with deleting all resources as it was failing to identify folders correctly for azure blob.

After this update, it will be possible to set parameters similar to the following

JCLOUD_EXTERNAL_RESOURCE_MANAGEMENT_CHANGE_DATE_PROPERTY_NAME=changedate
JCLOUD_EXTERNAL_RESOURCE_MANAGEMENT_VALIDATION_STATUS_PROPERTY_NAME=validationstatus
JCLOUD_METADATA_UUID_PROPERTY_NAME=geonetworkcatalogueuuid

And this will set the metadata properties in the jcloud storage when uploading data.

Here is a sample of the metadata properties saved in Azure Blob storage using these property settings.

image


Unlike CMIS which contains an cmisobjectId that can be used to go identify the object, jcloud is more similar to a file system and did not have a file identifier. Therefor JCLOUD_EXTERNAL_RESOURCE_MANAGEMENT_URL was updated to support a new {objectId} was for identifying the object.
It is a base64 object which contains the following information

  • type to identify type of storage - document/folder
  • visibility of the resource public/private
  • metadataId internal metadata id
  • version identifier which can be used to directly get this version.
  • resourceId or filename of the resource

Another option could be to supply the full path to the object however it seems like this could expose more information that was required and there was concern about how much information should be included. i.e. storage account, container name... The full path could always be added in the future as a new replacement variable if required. For now this new {objectId} contains all the information that already available to end users.

Also added similar option in CMIS urls

Checklist

  • I have read the contribution guidelines
  • Pull request provided for main branch, backports managed with label
  • Good housekeeping of code, cleaning up comments, tests, and documentation
  • Clean commit history broken into understandable chucks, avoiding big commits with hundreds of files, cautious of reformatting and whitespace changes
  • Clean commit messages, longer verbose messages are encouraged
  • API Changes are identified in commit messages
  • Testing provided for features or enhancements using automatic tests
  • User documentation provided for new features or enhancements in manual
  • Build documentation provided for development instructions in README.md files
  • Library management using pom.xml dependency management. Update build documentation with intended library use and library tutorials or documentation

@josegar74 josegar74 added this to the 4.2.11 milestone Sep 9, 2024
Copy link
Member

@josegar74 josegar74 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not tested the changed providers. Tested with the default filesystem provider to verify that everything looks fine with that provider and it seems to.

The code changes look fine, see some comments to clarify some of the changes.

@@ -657,14 +658,22 @@ protected MetadataResourceExternalManagementProperties getMetadataResourceExtern
) {
String metadataResourceExternalManagementPropertiesUrl = cmisConfiguration.getExternalResourceManagementUrl();
if (!StringUtils.isEmpty(metadataResourceExternalManagementPropertiesUrl)) {
// {objectid} objectId // It will be the type:visibility:metadataId:version:resourceId in base64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a new property for CMIS. I don't fully understand this change. Is this a new property or something missing in previous implementations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These properties are objects that can be supplied to the third party application.

As JCLOUD does not have any special ID to identify the record like CMIS did, I added a new {objectId} for JCLOUD so that the 3rd party application could use that value to identify the record.

In order to make some of these parameters consistent between storage solutions, I simply added the new {objectId} to CMIS as well so that CMIS applications could use it as well if needed.

I can remove it if you think there are issues with adding this new parameters.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ianwallen it's ok to keep it. I just wanted to have clear the reason. Thanks for the clarification.

@@ -254,7 +347,8 @@ public String delResources(final ServiceContext context, final int metadataId) t
PageSet<? extends StorageMetadata> page = jCloudConfiguration.getClient().getBlobStore().list(jCloudConfiguration.getContainerName(), opts);

for (StorageMetadata storageMetadata : page) {
if (storageMetadata.getType() == StorageType.BLOB) {
// For azure Blob if the type is folder then tye storage type will be BLOB and hdi_isfolder=true so we cannot only rely on StorageType.FOLDER
if (storageMetadata.getType().equals(StorageType.BLOB) && !"true".equals(storageMetadata.getUserMetadata().get("hdi_isfolder"))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move the string hdi_isfolder to a constant, with some documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a new function for isFolder and also created a constant for hdi_isfolder

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok,, but I don't see any change yet, I guess you are working on the change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Odd that you don't see the changes

This is the new static field

private final static String AZURE_BLOB_IS_FOLDER_PROPERTY_NAME="hdi_isfolder";

This is the new code.

for (StorageMetadata storageMetadata : page) {
if (!isFolder(storageMetadata)) {
jCloudConfiguration.getClient().getBlobStore().removeBlob(jCloudConfiguration.getContainerName(), storageMetadata.getName());
}
}

And this is the new isFolder() function

private boolean isFolder(StorageMetadata storageMetadata) {
// For azure Blob ADSL if the type is folder then the storage type will be BLOB and hdi_isfolder=true so we cannot only rely on StorageType.FOLDER
return storageMetadata.getType().equals(StorageType.FOLDER) || "true".equals(storageMetadata.getUserMetadata().get(AZURE_BLOB_IS_FOLDER_PROPERTY_NAME));
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I had an old version in the browser, I see it has been done a push force, but now I see the changes, thanks.

metadataResourceExternalManagementPropertiesUrl = metadataResourceExternalManagementPropertiesUrl.replaceAll("\\{type:([a-zA-Z0-9]*?):([a-zA-Z0-9]*?)\\}",
(type==null?"":(type instanceof Folder?"$1":"$2")));
metadataResourceExternalManagementPropertiesUrl = metadataResourceExternalManagementPropertiesUrl.replaceAll("(\\{type\\})",
(type == null ? "document" : (type instanceof Folder ? "folder" : "document")));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously it was used "$1":"$2" instead of "folder" : "document". To check that this can not break existing setups?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this would have broken existing setup.

The problem with this type is that it could be set to return custom values for the type but this was inconsistent with the type being returned in the {objectId} which was a hard coded value.

I had removed the old logic to no longer allow for custom name as I thought it could be confusing.

Looking at the code, I noticed that the old code was looking for "{type:" while the new code is supposed to looks for {type}

As they are different - I readded the old one so that it remains unchanged and I added the new {type} to be consistent with other providers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how many users use this storage, but If it can break existing setups, it might be good to add a label changelog to the pull request and a comment about any change required in existing setups, so it can be added in the release notes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted the changes and added a new one so it will not break any existing setup.

@ianwallen ianwallen force-pushed the jcloud_properties branch 2 times, most recently from 682c86c to 175eac6 Compare September 9, 2024 11:19
@ianwallen ianwallen modified the milestones: 4.2.11, 4.4.6 Sep 9, 2024
   Add {objectId} property in external management url (base64 unique identifier for the record)
   Change external management type url property {type} so that it is fixed values so that same value can be used in {objectId}
CMIS
   Fixed property names used for validation fields to be consistent with other names.
Jcloud
   Updgade from jcloud 2.3.0 to jcloud 2.5.0
   Add support for external management named properties similar to cmis
   Fix bug with deleting all resources as it was failing to identify folders correctly for azure blob.
Copy link
Member

@josegar74 josegar74 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with the file system storage, to check that it doesn't break and looks fine.

Code changes also look good.

Check the comment about information for the release notes, in case it can be relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants