-
-
Notifications
You must be signed in to change notification settings - Fork 489
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"))) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Line 79 in d7ec517
private final static String AZURE_BLOB_IS_FOLDER_PROPERTY_NAME="hdi_isfolder"; |
This is the new code.
Lines 352 to 356 in d7ec517
for (StorageMetadata storageMetadata : page) { | |
if (!isFolder(storageMetadata)) { | |
jCloudConfiguration.getClient().getBlobStore().removeBlob(jCloudConfiguration.getContainerName(), storageMetadata.getName()); | |
} | |
} |
And this is the new isFolder()
function
Lines 503 to 506 in d7ec517
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)); | |
} |
There was a problem hiding this comment.
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"))); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
682c86c
to
175eac6
Compare
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.
175eac6
to
d7ec517
Compare
There was a problem hiding this 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.
Update external management url
CMIS
Jcloud
After this update, it will be possible to set parameters similar to the following
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.
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
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
main
branch, backports managed with labelREADME.md
filespom.xml
dependency management. Update build documentation with intended library use and library tutorials or documentation