Search in sources :

Example 51 with DataSource

use of com.adobe.granite.ui.components.ds.DataSource in project APM by Cognifide.

the class ScriptsDatasourceServlet method doGet.

@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) {
    String path = request.getRequestPathInfo().getSuffix();
    List<Resource> scripts = new ArrayList<>();
    Resource resource = request.getResourceResolver().getResource(path);
    for (Resource child : resource.getChildren()) {
        if (ScriptsRowModel.isFolder(child) || ScriptModel.isScript(child)) {
            scripts.add(new ResourceTypeWrapper(child));
        }
    }
    DataSource dataSource = new SimpleDataSource(scripts.iterator());
    request.setAttribute(DataSource.class.getName(), dataSource);
}
Also used : SimpleDataSource(com.adobe.granite.ui.components.ds.SimpleDataSource) Resource(org.apache.sling.api.resource.Resource) ArrayList(java.util.ArrayList) SimpleDataSource(com.adobe.granite.ui.components.ds.SimpleDataSource) DataSource(com.adobe.granite.ui.components.ds.DataSource)

Aggregations

DataSource (com.adobe.granite.ui.components.ds.DataSource)51 Test (org.junit.jupiter.api.Test)37 Resource (org.apache.sling.api.resource.Resource)17 SimpleDataSource (com.adobe.granite.ui.components.ds.SimpleDataSource)13 ValueMap (org.apache.sling.api.resource.ValueMap)6 EmptyDataSource (com.adobe.granite.ui.components.ds.EmptyDataSource)5 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)5 ArrayList (java.util.ArrayList)3 LinkedList (java.util.LinkedList)3 ValueMapResource (com.adobe.granite.ui.components.ds.ValueMapResource)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 Test (org.junit.Test)2 DataSourceOption (com.adobe.acs.commons.wcm.datasources.DataSourceOption)1 ContentFragment (com.adobe.cq.dam.cfm.ContentFragment)1 CoreComponentTestContext (com.adobe.cq.wcm.core.components.context.CoreComponentTestContext)1 TextValueDataResourceSource (com.adobe.cq.wcm.core.components.internal.servlets.TextValueDataResourceSource)1 EmbeddableDescription (com.adobe.cq.wcm.core.components.internal.servlets.embed.EmbeddablesDataSourceServlet.EmbeddableDescription)1 MockStyle (com.adobe.cq.wcm.core.components.testing.MockStyle)1 Config (com.adobe.granite.ui.components.Config)1