Esta conversación ha sido bloqueada debido a la inactividad. Cree una nueva publicación.
Nivel 1
Nivel 2
Iniciar sesión en la comunidad
Iniciar sesión para ver todas las insignias
Esta conversación ha sido bloqueada debido a la inactividad. Cree una nueva publicación.
I want to list details of all content fragment models present in conf folder. if anybody can help me the loop which i need to reach the content model nodes. That would be great
¡Resuelto! Ir a solución.
Vistas
Respuestas
Total de me gusta
You and get by executing JCR SQL2 query.
Firstly get JCR Session from either ResourceResolver or JcrUtils(depends on your implementation).
Get QueryManager then create and execute Query. Check below code example.
QueryManager qm = session.getWorkspace().getQueryManager();
String queryString = "SELECT * FROM [cq:PageContent] AS comp WHERE ISDESCENDANTNODE(comp, \"/conf\") AND [cq:templateType] = \"/libs/settings/dam/cfm/model-types/fragment\"";
Query query = qm.createQuery(queryString, Query.JCR_SQL2);
QueryResult queryResult = query.execute();
RowIterator rowItr = queryResult.getRows();
while(rowItr.hasNext()){
...
}
Hope this is what you are looking for. Cheers!
AG
Vistas
Respuestas
Total de me gusta
You could do a query like below. Adjust params as required
path=/conf/project/settings/dam/cfm/models
property=sling:resourceType
property.value=dam/cfm/models/console/components/data/entity/default
or
path=/conf/project/settings/dam/cfm/models
property=cq:templateType
property.value=/libs/settings/dam/cfm/model-types/fragment
For looping
can do something like
Resource confProjectRes = readServiceResolver.resolve("/conf/myproject/settings/dam/cfm/models");
List<Resource> list = new ArrayList<>();
//Once you get the above resource, pass it as rootResource in below method. And list as desiredResources
public void getChildren(List<Resource> desiredResources, Resource rootResource,
final String resourceType) {
Iterator<Resource> directChildren = rootResource.listChildren();
while (directChildren.hasNext()) {
Resource childRes = directChildren.next();
if (childRes.isResourceType(resourceType)) {
desiredResources.add(childRes);
} else {
getChildren(desiredResources, childRes, resourceType);
}
}
}
Once you get all the resources, you can get details about the models. Not sure if this is the intention or what the final requirement is but above ways can help getting the CF model nodes as resources.
Unable to find an API to provide available models.. will update in such case..
Vistas
Respuestas
Total de me gusta
Vistas
Respuestas
Total de me gusta
Vistas
Respuestas
Total de me gusta
Vistas
Respuestas
Total de me gusta
Vistas
Respuestas
Total de me gusta
In the query can you try adding type=cq:PageContent ? What query did you use? Not expecting to see such traversing numbers under /conf. Otherwise try to use the java looping by getting the /conf resource and add checks in the loop to ignore unnecessary resources/nodes
Vistas
Respuestas
Total de me gusta
Vistas
Respuestas
Total de me gusta
Vistas
Respuestas
Total de me gusta
if you want to query under /conf, then you can add a condition with Resource Type
isResourceType("dam/cfm/models/console/components/data/entity/default")
Check the Content Fragment model properties (ResourceType and ResourceSuper Type)
Vistas
Respuestas
Total de me gusta
You and get by executing JCR SQL2 query.
Firstly get JCR Session from either ResourceResolver or JcrUtils(depends on your implementation).
Get QueryManager then create and execute Query. Check below code example.
QueryManager qm = session.getWorkspace().getQueryManager();
String queryString = "SELECT * FROM [cq:PageContent] AS comp WHERE ISDESCENDANTNODE(comp, \"/conf\") AND [cq:templateType] = \"/libs/settings/dam/cfm/model-types/fragment\"";
Query query = qm.createQuery(queryString, Query.JCR_SQL2);
QueryResult queryResult = query.execute();
RowIterator rowItr = queryResult.getRows();
while(rowItr.hasNext()){
...
}
Hope this is what you are looking for. Cheers!
AG
Vistas
Respuestas
Total de me gusta
Vistas
me gusta
Respuestas
Vistas
me gusta
Respuestas
Vistas
me gusta
Respuestas