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.
Related
In a current Project of mine I am using Entity Framework Core together with SQLite in an ASP.Net-Project.
My Problem is, that the Database in the project-files is used, instead of the one in the ./bin-Directory
I followed the instructions of the docs.microsoft-page to create the database:
https://learn.microsoft.com/de-de/ef/core/get-started/overview/first-app?tabs=visual-studio
This is the Connectionstring I am using.
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite("Data Source=MySqliteDatabase.db");
I let the created Database be copyied over, when newer.
I browsed through a number of pages, looking for ways to provide a relative Database path, but I couldnt find a solution to this. It either still uses the project-DB-File, or it wont create the new Database, because it cant be opened, or so.
Does anyone have a solution to this? I noticed that Entity-Framework-Core-5 is kind of a new release, could this be a bug or similar of this particular version?
Thanks #Sergey and #ErikEJ.
So to solve this, I really needed to provide the full path of the directory.
Since Directory.GetCurrentDirectory returned the wrong path, that is, the path to the project-directory instead of the /bin/Debug/... , I looked at the path that is named in the Config-File, as #Sergey suggessted, using the following Code:
AppDomain.CurrentDomain.SetupInformation.ApplicationBase
I got this from the following Stackoverflow page:
How to find path of active app.config file?
It said there, to access the ConfigurationFile-Property, but for ASP.Net it is ApplicationBase I guess.
In there was the correct path, the one of the /bin/Debug/... .
Put together, my new Method looked like this:
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
string databasePath = $"{AppDomain.CurrentDomain.SetupInformation.ApplicationBase}MySqliteDatabase.db";
options.UseSqlite($"Data Source={databasePath}");
}
This works for me as intended, thanks alot for the support, maybe this will help someone else as well.
I'm using insomnia to make calls to the Artifactory API.
I have the following query, which works really well:
items.find({"repo":{"$eq":"my-repository-virt"}}, {"$and":[{"#my.fileType":{"$match": "jar"}},{"#my.otherType":{"$match": "type2"}},{"#prodVersion":{"$match": "false"}}]})
But I have a problem in that there are duplicate files in some sub-folders with the same properties/filename that I would like to exclude.
I would like to add path to this query, but I can never get any results returned.
The repository is a virtual repository that links to 3 other real repositories.
One of my colleagues can call the following query with the command line tool and get the expected results:
jfrog rt search my-repo-snapshots/myproject/subfolder/jars/*.jar
I have tried adding the path parameter to my query, I've tried removing everything except the repo and the path, like this:
items.find({"repo":{"$eq":"my-repo-snapshots"}},{"path" : "my-repo-snapshots/myproject/subfolder/jars/*.jar"})
I've tried with just the path, with variations on the path, including/excluding the repo name, using the virtual repo, the actual repo, but I always get a successful search with 0 results returned.
How can I build this query to search the virtual repo, along a certain path, and including certain properties?
EDIT:
I've also tried:
items.find({"repo":{"$eq":"my-repo-snapshots"}},{"path" : {"$match":"my-repo-snapshots/myproject/subfolder/jars/*.jar"}})
Both with the repo in the path and without, I still get 0 results.
OK I figured it out.
The path part needs to be added in with the {"$and": ...} section where the properties are included. Like so:
items.find({"repo":{"$eq":"my-repository-virt"}},
{"$and":[
{"path":{"$match":"path/to/relevant/folders/*"}},
{"#my.fileType":{"$match": "jar"}},
{"#my.otherType":{"$match": "type2"}},
{"#prodVersion":{"$match": "false"}}
]})
The easier fix would have been:
items.find({"repo":{"$eq":"my-repo-snapshots"}},{"path" : {"$eq":"my-repo-snapshots/myproject/subfolder/jars"}, {"name" : {"$match":"*.jar"}})
So the problem with your initial attempt, is that the "path" should match the folder and the "name" should match the filename
I am using Alfresco Community 5.0.d and I'm getting below error.
ReferenceError: people is not defined
For following code in people-finder.js file:
var currentUser = people.getPerson(person);
I want to use the people methods for further process. Is there anyway to achieve this?
Also my target is to get all groups for the current user and the search result too.
One way I know is making ajax call to /alfresco/service/api/people/{people}?groups=true but this is an expensive way to achieve this.
Is there an alternative to achieve this?
Thanks
The "people" root object as well as any other that depends on repository tier services can not be accessed directly from a web script running in Alfresco Share.
if you wanted to get all the current user details in share webscript then you can get it using user Object
example:
Currently i have logged in with admin user
my webscript files
test.get.js
model.user=user;
test.get.html.ftl
${user}
Output ::
{lastName=, userStatus=null, alfUserLoaded=1489745903574,
userStatusTime=null,
alfUserGroups=GROUP_ALFRESCO_ADMINISTRATORS,GROUP_ALFRESCO_MODEL_ADMINISTRATORS,GROUP_ALFRESCO_SEARCH_ADMINISTRATORS,GROUP_EMAIL_CONTRIBUTORS,GROUP_SITE_ADMINISTRATORS,
firstName=Administrator,
userHome=workspace://SpacesStore/7338666a-7a02-4ab6-aa3b-5a46d06074ee,
id=admin, email=admin#alfresco.com}
list of groups in output::
GROUP_ALFRESCO_ADMINISTRATORS,GROUP_ALFRESCO_MODEL_ADMINISTRATORS,GROUP_ALFRESCO_SEARCH_ADMINISTRATORS,GROUP_EMAIL_CONTRIBUTORS,GROUP_SITE_ADMINISTRATORS
By repo webscript
if you wanted to get all the current user details in repo webscript then you can get it by using
example:
Currently i have logged in with admin user
my repo webscript files
test1.get.js
var users = people.getPerson(person.properties.userName);
var groups=people.getContainerGroups(users);
model["groups"] = groups;
test1.get.html.ftl file
<#list groups as g>
${g.name}
</#list>
output::
GROUP_ALFRESCO_ADMINISTRATORS GROUP_ALFRESCO_MODEL_ADMINISTRATORS
GROUP_ALFRESCO_SEARCH_ADMINISTRATORS GROUP_EMAIL_CONTRIBUTORS
GROUP_SITE_ADMINISTRATORS
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.
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).