Alfresco: Unable to CMIS query by path - alfresco

I am trying to find out the contents of a folder in Alfresco, using the following CMIS query:
SELECT *
FROM cmis:document
WHERE CONTAINS('PATH:"/app:company_home/st:sites/cm:GM/cm:emir/cm:FAQ//*"')
In Node Browser, if I navigate to that folder I see the following value for Primary Path
(I have added line breaks to make it easier to read):
/{http://www.alfresco.org/model/application/1.0}company_home
/{http://www.alfresco.org/model/site/1.0}sites
/{http://www.alfresco.org/model/content/1.0}GM
/{http://www.alfresco.org/model/content/1.0}EMIR
/{http://www.alfresco.org/model/content/1.0}FAQ
But Alfresco is failing with the following message:
Caused by: org.alfresco.scripts.ScriptException: 05120032 Failed to
execute script
'classpath*:alfresco/templates/webscripts/org/alfresco/cmis/queries.post.cmisquery.js':
05120 031 Unknown column/property PATH
I am testing against Alfresco Community 3.3.

You can use the following query for simple search
SELECT * FROM cmis:document WHERE IN_FOLDER('id_of_folder')
or the following query for recursive search
SELECT * FROM cmis:document WHERE IN_TREE('id_of_folder').
if you want search by path, you can use:
SELECT * FROM cmis:folder
WHERE CONTAINS('PATH:\"/app:company_home/st:sites/cm:my_site/cm:documentLibrary//*\"')
For more details view also the official specification
http://docs.oasis-open.org/cmis/CMIS/v1.1/os/CMIS-v1.1-os.html

Do yourself a favor and upgrade.
Your query works for me in the share node browser (does not throw exceptions) as either cmis-strict or cmis-alfresco .
SELECT *
FROM cmis:document
WHERE CONTAINS('PATH:"/app:company_home/st:sites//*"')
Gives me a whole lot of results.

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)

find alfresco nodeRef without using luceneSearch

I have a js webscript who return a list of documents from a specific repository in Alfresco. i used the luceneSearch to get the nodeRef of the repository, this works fine.
The repository primary path is: /app:company_home/app:dictionary/cm:StarXpert_x0020_Workflow/cm:fichiers_x0020_JSON and i used the luceneSearch like this to get the nodeRef from the primary path
var nodes = search.luceneSearch("PATH:\"/app:company_home/app:dictionary/cm:StarXpert_x0020_Workflow/cm:fichiers_x0020_JSON//*\" AND TYPE:\"cm:content\"","#cm:name", true);
But when i execute my code in the server side, i have an error, that my webScript can't get the nodes from the path i took it. I searched and i found that the problem is an indexation problem on the server alfresco version.
So my question is: can us get a nodeRef from a primary path, whithout using luceneSearch?
Thanks for any help
If I understand the documentation, you can use other methods with the search root object. The xpathSearch seems interesting :
org.mozilla.javascript.Scriptable xpathSearch(String search)
Execute a XPath search
The selectNodes(String search) might be interesting too.

CMIS QL get folder path using CONTAIN (ALL:)

I am having a problem retrieving the path of a folder which contains '(' and ')' when I do a query in CMIS.
how can i get the below working ?
SELECT cmis:path FROM cmis:folder WHERE IN_TREE('a53471aa-b447-4fdd-a451-4a2beb494226') AND CONTAINS('ALL:Tom_(Robot)')
So (Robot) that's causing not to find the path.
Any idea how I can make ( and ) as part of my query?
Solution to this problem is
SELECT cmis:path FROM cmis:folder WHERE IN_TREE('a53471aa-b447-4fdd-a451-4a2beb494226') AND CONTAINS('ALL:Tom_Robot')
By removing the brackets it returns me folder path, somehow it gives me the correct result, but I am still interested on other peoples opinion on this, this does not sound good to me, whether this is openCMIS issue or an Alfresco.

Filter property based searches in Artifactory

I'm looking to use the Artifactory property search
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-ArtifactSearch%28QuickSearch%29
Currently this will pull json listing any artifact that matches my properties.
"results" : [
{
"uri": "http://localhost:8080/artifactory/api/storage/libs-release-local/org/acme/lib/ver/lib-ver.pom"
},{
"uri": "http://localhost:8080/artifactory/api/storage/libs-release-local/org/acme/lib/ver2/lib-ver2.pom"
}
]
I need to be able to filter the artifacts I get back as i'm only interested in a certain classifier. The GAVC Search has this with &c=classifier
I can do it in code if this isn't possible via the interface
Any help appreciated
Since the release of AQL in Artifactory 3.5, it's now the official and the preferred way to find artifacts.
Here's an example similar to your needs:
items.find
(
{
"$and":[
{"#license":{"$eq":"GPL"}},
{"#version":{"$match":"1.1.*"}},
{"name":{"$match":"*.jar"}}
]
}
)
To run the query in Artifactory, copy the query to a file and name it aql.query
Run the following command from the directory that contains the aql.query file
curl -X POST -uUSER:PASSWORD 'http://HOST:PORT/artifactory/api/search/aql' -Taql.query
Don't forget to replace the templates (USER, PASSWORD,HOST and PORT) to real values.
In the example
The first two criteria are used to filter items by properties.
The third criteria filters items by the artifact name (in our case the artifact name should end with .jar)
For more details on how to write AQL query are in AQL
Old answer
Currently you can't combine the property search with GAVC search.
So you have two options:
Executing one of them (whichever gives you more precise results) and then filter the JSON list on the client by a script
Writing an execution user plugin that will execute the search by using the Searches service and then filter the results on the server side.
Of course, the later is preferable.

Get Alfresco extension properties with OpenCMIS

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() ...

Resources