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

async function isRepositoryVersioned() maybe wrong #67

Open
waldpark opened this issue Aug 28, 2024 · 17 comments
Open

async function isRepositoryVersioned() maybe wrong #67

waldpark opened this issue Aug 28, 2024 · 17 comments

Comments

@waldpark
Copy link

The function

async function isRepositoryVersioned(repoInfo, repositoryId) {
  let repoType = repoInfo.data[repositoryId].capabilities["capabilityContentStreamUpdatability"]
  if (repoType === "pwconly") {
    repoType = "versioned";
  } else {
    repoType = "non-versioned";
  }
  saveRepoToCache(repositoryId, repoType);
  return repoType === "versioned" ? true : false;
}

checks the attribute capabilityContentStreamUpdatability for the value pwconly instead of the value anytime.
I think this is a bug.

Please have a look at the documentation

http://docs.oasis-open.org/cmis/CMIS/v1.0/cd04/cmis-spec-v1.0.pdf

lines 74-80

Can you please provide a fix asap?

Thanks and best regards
Adrian

@ashishjain14
Copy link
Member

Hi Adrian,

Can you elaborate on the issue you are facing?

Regards,
Ashish

@waldpark
Copy link
Author

waldpark commented Aug 28, 2024

Hi Ashish,

according to the cmis-spec

http://docs.oasis-open.org/cmis/CMIS/v1.0/cd04/cmis-spec-v1.0.pdf

"capabilityContentStreamUpdatability"

indicates the support a repository has for updating a document’s content stream. Valid values are:

• none: The content stream may never be updated.
• anytime: The content stream may be updated any time.
• pwconly: The content stream may be updated only when checked out.

That's why I wonder, if the code

if (repoType === "pwconly") {
    repoType = "versioned";
} else {
    repoType = "non-versioned";
}

may better be

if (repoType === "none") {
    repoType = "non-versioned";
} else {
    repoType = "versioned";
}

My specific problem is the following. I have a SAP Document Management Service (Integration Option) repository, which gives me very different results depeding on which API endpoint I use to query its state:

Query 1:

GET https://api-sdm-di.cfapps.eu10.hana.ondemand.com/rest/v2/repositories

Result 1:

{...
        {
          "paramName": "isVersionEnabled",
          "paramValue": false
        },
...}

Query 2:

GET {{cc_api_url}}/browser

Result 2:

{...
    "capabilities": {
        "capabilityContentStreamUpdatability": "anytime",
    ...}
...}

Query 3:

GET https://api-sdm-di.cfapps.eu10.hana.ondemand.com/browser/{{respositoryId}}?cmisselector=repositoryInfo

Result 3:

{...
    "capabilities": {
        "capabilityContentStreamUpdatability": "pwconly",
    ...}
...}

The results all belong to the very same repositoryId.
For me, this looks like a bug in the API's /browser endpoint!

Nonetheless, with my suggested fix for the function isRepositoryVersioned(), the cap-js/sdm module should always work for non-versioned repositories.

Thanks and best regards
Adrian

@waldpark
Copy link
Author

Hello Ashish,

I have read through the cmis documentation once again and my understanding of

  • none: The content stream may never be updated.
  • anytime: The content stream may be updated any time.
  • pwconly: The content stream may be updated only when checked out.

has changed now. I think "none" and "anytime" means: You can either never or always update a file without versioning.
In that case, "pwconly" would be the only option for a versioning of files and your code would be fine.

Can you verify this?

Thanks and best regards
Adrian

@korayyersel
Copy link

I have the same problem. Eventhough I have created a non-versioned repository I am getting an error: 'Attachments are not supported for a versioned repository.'

"repository": { "cmisRepositoryId": "xxx", "createdTime": "2024-08-29T20:49:38.181Z", "id": "xxx", "lastUpdatedTime": "2024-08-29T20:49:38.181Z", "name": "anfrageapp", "repositoryCategory": "Instant", "repositoryParams": [ { "paramName": "isEncryptionEnabled", "paramValue": false }, { "paramName": "isVirusScanEnabled", "paramValue": false }, { "paramName": "skipVirusScanForLargeFile", "paramValue": false }, { "paramName": "isClientCacheEnabled", "paramValue": false }, { "paramName": "hashAlgorithms", "paramValue": "SHA-256" }, { "paramName": "isThumbnailEnabled", "paramValue": false }, { "paramName": "**isVersionEnabled**", "paramValue": false } ], "repositorySubType": "SAP Document Management Service", "repositoryType": "internal" } }

@yashmeet29
Copy link
Member

I have the same problem. Eventhough I have created a non-versioned repository I am getting an error: 'Attachments are not supported for a versioned repository.'

"repository": { "cmisRepositoryId": "xxx", "createdTime": "2024-08-29T20:49:38.181Z", "id": "xxx", "lastUpdatedTime": "2024-08-29T20:49:38.181Z", "name": "anfrageapp", "repositoryCategory": "Instant", "repositoryParams": [ { "paramName": "isEncryptionEnabled", "paramValue": false }, { "paramName": "isVirusScanEnabled", "paramValue": false }, { "paramName": "skipVirusScanForLargeFile", "paramValue": false }, { "paramName": "isClientCacheEnabled", "paramValue": false }, { "paramName": "hashAlgorithms", "paramValue": "SHA-256" }, { "paramName": "isThumbnailEnabled", "paramValue": false }, { "paramName": "**isVersionEnabled**", "paramValue": false } ], "repositorySubType": "SAP Document Management Service", "repositoryType": "internal" } }

Hi @korayyersel, Can you send me the response by executing getRepositoryInfo for above repositoryId
GET: request "{{URL}}/{{respositoryId}}?cmisselector=repositoryInfo"

@korayyersel
Copy link

Hi @yashmeet29 of course! Thx for the quick response

{ "05c47b03-cec6-438c-9f72-00cb73b61cbf": { "repositoryId": "xxx", "repositoryName": "anfrageapp", "repositoryDescription": null, "vendorName": "SAP AG", "productName": "SAP Document Management Service", "productVersion": "1.0", "rootFolderId": "eda8cc7000ed02e92eed0d66", "capabilities": { "capabilityContentStreamUpdatability": "pwconly", "capabilityChanges": "objectidsonly", "capabilityRenditions": "none", "capabilityGetDescendants": true, "capabilityGetFolderTree": true, "capabilityMultifiling": false, "capabilityUnfiling": false, "capabilityVersionSpecificFiling": false, "capabilityPWCSearchable": false, "capabilityPWCUpdatable": true, "capabilityAllVersionsSearchable": false, "capabilityOrderBy": "custom", "capabilityQuery": "metadataonly", "capabilityJoin": "none", "capabilityACL": "manage", "capabilityCreatablePropertyTypes": { "canCreate": [ "boolean", "id", "integer", "datetime", "decimal", "html", "string", "uri" ] }, "capabilityNewTypeSettableAttributes": { "id": true, "localName": true, "localNamespace": true, "displayName": true, "queryName": false, "description": true, "creatable": true, "fileable": false, "queryable": true, "fulltextIndexed": true, "includedInSupertypeQuery": true, "controllablePolicy": false, "controllableACL": false } }, "aclCapabilities": { "supportedPermissions": "both", "propagation": "propagate", "permissions": [ { "permission": "cmis:read", "description": "cmis:read" }, { "permission": "sap:file", "description": "sap:file" }, { "permission": "cmis:write", "description": "cmis:write" }, { "permission": "sap:delete", "description": "sap:delete" }, { "permission": "cmis:all", "description": "cmis:all" } ], "permissionMapping": [ { "key": "canUpdateProperties.Object", "permission": [ "cmis:write" ] }, { "key": "canGetProperties.Object", "permission": [ "cmis:read" ] }, { "key": "canCreateFolder.Folder", "permission": [ "sap:file", "cmis:write" ] }, { "key": "canCreateDocument.Folder", "permission": [ "sap:file", "cmis:write" ] }, { "key": "canCheckout.Document", "permission": [ "cmis:write" ] }, { "key": "canMove.Object", "permission": [ "sap:file", "cmis:write" ] }, { "key": "canGetAllVersions.VersionSeries", "permission": [ "cmis:read" ] }, { "key": "canCheckin.Document", "permission": [ "sap:delete", "cmis:all" ] }, { "key": "canGetDescendents.Folder", "permission": [ "cmis:read" ] }, { "key": "canGetChildren.Folder", "permission": [ "cmis:read" ] }, { "key": "canGetParents.Folder", "permission": [ "cmis:read" ] }, { "key": "canSetContent.Document", "permission": [ "cmis:write" ] }, { "key": "canDeleteContent.Document", "permission": [ "cmis:write" ] }, { "key": "canGetACL.Object", "permission": [ "cmis:read" ] }, { "key": "canMove.Target", "permission": [ "sap:file", "cmis:write" ] }, { "key": "canDelete.Object", "permission": [ "sap:delete", "cmis:all" ] }, { "key": "canCancelCheckout.Document", "permission": [ "sap:delete", "cmis:all" ] }, { "key": "canApplyACL.Object", "permission": [ "cmis:all" ] }, { "key": "canGetFolderParent.Object", "permission": [ "cmis:read" ] }, { "key": "canMove.Source", "permission": [ "sap:file", "cmis:write" ] }, { "key": "canDeleteTree.Folder", "permission": [ "sap:delete", "cmis:all" ] } ] }, "latestChangeLogToken": "1725001293339", "cmisVersionSupported": "1.1", "changesIncomplete": false, "changesOnType": [ "cmis:document", "cmis:folder" ], "principalIdAnonymous": "{sap:builtin}anonymous", "principalIdAnyone": "{sap:builtin}everyone", "extendedFeatures": [ { "id": "http:\/\/docs.oasis-open.org\/ns\/cmis\/extension\/contentstreamhash", "commonName": "Content Stream Hash", "versionLabel": "1.0", "description": "Adds the property cmis:contentStreamHash, which represents the hash of the document content." }, { "id": "ecmRepoInfo", "featureData": { "virusScanner": "false", "disableVirusScannerForLargeFile": "false", "isThumbnailEnabled": "false", "changeLog": "Enabled", "changeLogDuration": "24", "hashAlgorithms": "SHA-256", "isEncryptionEnabled": "false" } }, { "id": "http:\/\/docs.oasis-open.org\/ns\/cmis\/extension\/datetimeformat", "url": "https:\/\/www.oasis-open.org\/committees\/tc_home.php?wg_abbrev=cmis", "commonName": "Browser Binding DateTime Format", "versionLabel": "1.0", "description": "Adds an additional DateTime format for the Browser Binding." }, { "id": "http:\/\/docs.oasis-open.org\/ns\/cmis\/extension\/datetimeformat", "url": "https:\/\/www.oasis-open.org\/committees\/tc_home.php?wg_abbrev=cmis", "commonName": "Browser Binding DateTime Format", "versionLabel": "1.0", "description": "Adds an additional DateTime format for the Browser Binding." } ], "repositoryUrl": "https:\/\/api-sdm-di.cfapps.eu10.hana.ondemand.com\/05c47b03-cec6-438c-9f72-00cb73b61cbf", "rootFolderUrl": "https:\/\/api-sdm-di.cfapps.eu10.hana.ondemand.com\/05c47b03-cec6-438c-9f72-00cb73b61cbf\/root", "cmisRepositoryId": "xxx", "repositoryCategory": "Instant", "externalId": null, "connectionType": "service" } }

@yashmeet29
Copy link
Member

Hi @korayyersel, can you also share how you onboarded the repository and with what parameters?

@korayyersel
Copy link

@yashmeet29 yeah sure
`POST https://api-sdm-di.cfapps.eu10.hana.ondemand.com/rest/v2/repositories
Authorization: Bearer {{request_token.response.body.access_token}}
content-type: application/json

{
"repository": {
"displayName": "anfrageapp",
"repositoryType": "internal",
"isVersionEnabled":"false",
"hashAlgorithms":"SHA-256"
}
}
`

btw FYI I had to call this at least 30-40 times until it worked. I was getting constantly generic errors.

@yashmeet29
Copy link
Member

Hi @korayyersel, I followed below steps and I am not able to reproduce the issue

  1. Onboarded the repository with below parameters
    POST <URL>/rest/v2/repositories
    {
    "repository": {
    "displayName": "anfrageapp",
    "repositoryType": "internal",
    "isVersionEnabled":"false",
    "hashAlgorithms":"SHA-256"
    }
    }
  2. Executed getRepositoryInfo API call <URL>/browser/<repoId>/?cmisselector=repositoryInfo and got below response
    "capabilities": { "capabilityContentStreamUpdatability": "anytime"
  3. Executed getListOfRepositories API call <URL>/browser/ and for the newly onboarded repository i got response as
    "capabilities": { "capabilityContentStreamUpdatability": "anytime"

Conclusion: As per the above responses, i don't see any reason why our logic won't work.
if (repoType === "pwconly") { repoType = "versioned"; } else { repoType = "non-versioned"; }

Can you please cross check at your end as you also mentioned you had to call this at least 30-40 times until it worked and you were getting some generic errors. This doesn't seems to be an issue at our end.
If you still see an issue, please raise a ticket using this link.

Regards,
Yashmeet

@yashmeet29
Copy link
Member

Hello Ashish,

I have read through the cmis documentation once again and my understanding of

  • none: The content stream may never be updated.
  • anytime: The content stream may be updated any time.
  • pwconly: The content stream may be updated only when checked out.

has changed now. I think "none" and "anytime" means: You can either never or always update a file without versioning. In that case, "pwconly" would be the only option for a versioning of files and your code would be fine.

Can you verify this?

Thanks and best regards Adrian

Hi @waldpark, I have cross checked this and summarised my findings in above comment. This doesn't seems to be an issue at our end.

Regards,
Yashmeet

@korayyersel
Copy link

@yashmeet29
Just to confirm:
You mean that there is an error on SAP side while generating the repository? Expected result is "anytime" but in our case it is "pwconly". Do I understand it right?

And can you tell me which datacenter you call for your request? That would be helpful for the SAP incident I guess.

And thx for the quick responses. Highly appreciated!

@yashmeet29
Copy link
Member

Hi @korayyersel, yes for Internal versioned repository only the value should be "pwconly".
I am calling Canary EU12.

Regards,
Yashmeet

@waldpark
Copy link
Author

waldpark commented Sep 2, 2024

Hi @yashmeet29 and @korayyersel,

Thank you for checking! Please do not forget to mention "eu10" if you create an incident. In my case,

GET https://api-sdm-di.cfapps.eu10.hana.ondemand.com/browser/{{respositoryId}}?cmisselector=repositoryInfo

gives the wrong result

"capabilityContentStreamUpdatability": "pwconly"

Best regards
Adrian

@korayyersel
Copy link

Hi @waldpark
Yes of course that's why I've asked Yashmeet about his/her endpoint. I'll give an update her, after I know more. I'll open the incident sometime today.
Best,
Koray

@korayyersel
Copy link

short update: high prio incident is on sap. they are still investigating the issue. they could confirm that there is something wrong on AWS EU10

@korayyersel
Copy link

update:
Response from SAP

After a long analysis, we were finally able to find the root cause of the issue you are facing. I believe that even if the capability reads as pwconly, the repository would still be behaving like a non-versioned repository. Anyways, we are currently working on the fix such that the response is constant and correct throughout all our landscapes.

I have asked for a timeline

@korayyersel
Copy link

if anyone needs a quick fix until SAP fixes this:
You can override this check in your custom service implementation (https://cap.cloud.sap/docs/node.js/core-services#implementing-services)
`
const cds = require('@sap/cds');

module.exports = cds.service.impl(async function () {
const { Request} = this.entities;
const sdmUtils = require('@cap-js/sdm/lib/util/index');

// Override the isRepositoryVersioned function directly in the utility module
sdmUtils.isRepositoryVersioned = function (...args) {
console.error("override isRepositoryVersioned");
return false;
};

this.before('CREATE', Request, async (req) => {
...
`

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

No branches or pull requests

4 participants