Get Alfresco extension properties with OpenCMIS - alfresco

I'm writing an OpenCMIS based application, which extracts some data from Alfresco 3.3.
It works fine with standard CMIS properties such as cmis:name or cmis:contentStreamMimeType; however, I can't access Alfresco especific properties, which are present on the CMIS AtomPub feed as "Alfresco extensions":
<cmisra:object>
<cmis:properties>
<cmis:propertyString propertyDefinitionId="cmis:name" displayName="Name" queryName="cmis:name">
<cmis:value>test document</cmis:value>
</cmis:propertyString>
<cmis:propertyString propertyDefinitionId="cmis:contentStreamMimeType" displayName="Content Stream MIME Type" queryName="cmis:contentStreamMimeType">
<cmis:value>text/html</cmis:value>
</cmis:propertyString>
...
<alf:aspects>
...
<alf:properties>
<cmis:propertyString propertyDefinitionId="cm:description" displayName="Description" queryName="cm:description">
<cmis:value>This is just a test document</cmis:value>
</cmis:propertyString>
</alf:properties>
</alf:aspects>
</cmis:properties>
</cmisra:object>
Is there any way in which I can get the value of cm:descripcion, with OpenCMIS?
My guess is that I need to use the DocumentType interface instead of Document, and then call its getExtensions() method. But I don't know how to get an instance of DocumentType.
Any help would be really appreciated.
Regards
Edit: altough Florian's answer already worked out for me, I've just realized that I can get these properties' values with CMIS SQL, too:
select d.*, t.*, a.*
from cmis:document d
join cm:titled t on d.cmis:objectid = t.cmis:objectid
join cm:author a on d.cmis:objectid = a.cmis:objectid
where t.cm:description like ...

I'm afraid the OpenCMIS high-level API cannot access all extensions yet. It's on our to-do list. For now, you have to use the low-level API.
Something like this should work:
ObjectData doc = session.getBinding().getObjectService().getObject(...);
org.w3c.dom.Node domNode = (org.w3c.dom.Node) doc.getProperties().getExtensions().get(0); // <alf:aspects>
domNode.getFirstChild() ...

Related

Microsoft Graph API- list all users with OneDrive license

I want to list all users that have OneDrive license.
I an using this URL but doesn't work.
https://graph.microsoft.com/v1.0/users?$filter=assignedLicenses/any(x:x/skuId eq 4b585984-651b-448a-9e53-3b10f069cf7f or x/skuId eq c7df2760-2c81-4ef7-b578-5b5392b571df)
Do you have any idea how to do it?
Unfortunately complex query (Whatever you're trying to do above) on property assignedLicenses is not supported. If you do so, the API will throw the error:
Complex query on property assignedLicenses is not supported
Being said that i can see it
works for simple filter, like,
https://graph.microsoft.com/v1.0/users?$filter=assignedLicenses/any(x:x/skuId eq 4b585984-651b-448a-9e53-3b10f069cf7f)

CosmosDB - Entity Framework Core - Contains could not be translated

I try to manipulate a CosmosDB (SQL) using entity framework core 3.0 (Microsoft.EntityFrameworkCore.Cosmos 3.0.0).
Everything works fine except when I try to use Contains, StartWith, …
For example:
var query = _context.Challenges.Where(c => c.Name.Contains( "string"));
EF is supposed to translate it to the following SQL (that works perfectly on the CosmosDB – Query Explorer)
SELECT * FROM c WHERE CONTAINS(c.Name, "string")
But I receive the following error message:
The LINQ expression 'Where<Challenge>(\n source: DbSet<Challenge>, \n predicate: (c) => c.Name.Contains(\"string\"))' could not be translated.
Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync().
See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
Of course, I don’t want to code it like the following, that will execute the entire contains on the client, just to make a simple LIKE…
List<Challenge> entities = _context.Challenges.AsEnumerable().Where(c => c.Name.Contains( "string")).ToList();
Anyone has an idea of to evaluate the "contains" on the server side ?
Note: I try the exact same code using UseSqlServer rather than UseCosmos (and by adding the needed [Key] annotation and creating a SQL server) and it works like a charm.... So it's a definitively a CosmosDB vs EF issue.
By posting the same issue on entity framework core forum (https://github.com/aspnet/EntityFrameworkCore/), the answer was that this feature is not yet implemented:
https://github.com/aspnet/EntityFrameworkCore/issues/18673
https://github.com/aspnet/EntityFrameworkCore/issues/16143
https://github.com/aspnet/EntityFrameworkCore/issues/18451
https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/6333414-implement-like-keyword

Marklogic Rest API for directory-query

I have the following XQuery which I use to fetch documents for a directory.
xquery version "1.0-ml";
cts:search(fn:collection(), cts:directory-query("/Path/To/Docs/", "infinity"))
Now I need to translate this into a REST call but I can't seem to crack it following the documentation on this page.
https://docs.marklogic.com/REST/GET/v1/search
Update:
using the Jersey REST API, It tried this but got 406 Error
String query = "{\"queries\":[ {\"directory-query\":{\"uri\":[\"/Path/to/Docs/\"]},\"infinite\":true} ]}";
String encodedQuery = URLEncoder.encode(query, "UTF-8");
WebTarget target = searchWebTarget.queryParam("structuredQuery", encodedQuery);
final Response response = target.request().get();
Any ideas?
As David said, you don't need to use structured query for this purpose, but in case you have future need:
I believe your original issue was that this is not a well-formed structured query:
{\"queries\":[ {\"directory-query\":{\"uri\":[\"/Path/to/Docs/\"]},\"infinite\":true} ]}
You're missing the top level "query" property. You can find an example of a fully formed structured query that uses directory-query here:
http://docs.marklogic.com/guide/search-dev/structured-query#id_97452
Also, you're probably already aware, but there is a native Java API that sits atop the REST API. You can learn more about this API here:
https://docs.marklogic.com/javadoc/client/index.html
http://docs.marklogic.com/guide/java
Constraining by directory is a query parameter directly on the search API. NO other notation needed.
See the docs here: https://docs.marklogic.com/REST/GET/v1/search

AND\OR Query search using MarkLogic (XQuery or equivalent)

I am new to MarkLogic and we are evaluating MarkLogic for our product use case.
We evaluated few NoSQL databases like MongoDB, Couchbase etc.
I am looking for a below type of query search.
(Condition1 OR Condition2) AND (Condition3 OR Condition4) AND (Condition5)
Can MarkLogic provide such type of search query?
I am just started learning MarkLogic and trying to understand the architecture.
Thanks,
Sameer
Yes, MarkLogic provides some high level libraries for this type of functionality. Take a look at Search API.
Start here: https://developer.marklogic.com/learn/2009-07-search-api-walkthrough
And more thorough documentation is here: https://docs.marklogic.com/guide/search-dev/search-api
MarkLogic can handle this kind of logic in many ways as mentioned.
For example, this is how you could setup a search query using the CTS library (I highly recommend the CTS library, since it uses indexes much better, and the construction of them are so much more flexible):
cts:search(//elementName,
cts:and-query((
cts:element-attribute-value-query(xs:QName("entry"), xs:QName("private"), "true"),
cts:or-query((
cts:element-attribute-value-query(xs:QName("entry"), xs:QName("forced"), "false"),
cts:element-attribute-value-query(xs:QName("entry"), xs:QName("forced"), "pending")
))
))
)
This snippet shows both AND and OR logic. The cts:and-query() and cts:or-query() functions can take a list of nodes. The above query says: "Find an element (called elementName) that has an attribute of private='true' AND has either one of the following: forced='true' or forced='pending'".
For much simpler data, you can use xQuery predicates by doing something like the following:
for $node in $xml/parent/child[#param1 eq "test" AND #param2 eq "OK"]/grandchild[#service eq "yahoo" or #service eq "google"]
return $node
The short answer to the original question is "yes". The details of "how" will depend on the approach used to express the queries.
The reference architecture recommends a three-tier approach using the Java or Node.js Client APIs if you use one of those, or HTTP calls to the REST API if you use a different language in your middle tier.
You can also use the Search API (as mentioned by wst) if you're working in MarkLogic's application server (typically as a two-tier architecture). You can do that with either XQuery or Server-side JavaScript, as of MarkLogic 8.

QueryBuilder and path

I'm using Adobe AEM, and I can't fetch the informations I want from the repository with the QueryBuilder.
I could reproduce my problem with the servlet.
When I enter this URL :
http://localhost:4502/bin/querybuilder.json?path=/content/geometrixx/en/products/triangle&type=cq:Page
It returns 2 results : Features and Overview.
But I would like the query to also return Triangle which is a cq:Page.
Can you help me plz ?
Thanks.
This is because, Querybuilder would search only the subtree if the path property alone is set.
In case you want to include the given path too in the search, then you need to add path.self=true to the request.
http://localhost:4502/bin/querybuilder.json?path=/content/geometrixx/en/products/triangle&type=cq:Page&path.self=true
For more info on Path Predicate, refer this (updated link).

Resources