Examples of adaptTo()


Examples of com.day.cq.dam.api.Asset.adaptTo()

            // ...)
            wrapper = new FFMpegWrapper(tmpFile, tmpWorkingDir);
            wrapper.setExecutableLocator(locator);

            final ResourceResolver resolver = getResourceResolver(wfSession.getSession());
            final Resource assetResource = asset.adaptTo(Resource.class);
            final Resource metadata = resolver.getResource(assetResource, JCR_CONTENT + "/" + METADATA_FOLDER);

            if (null != metadata) {

                final Node metadataNode = metadata.adaptTo(Node.class);
View Full Code Here

Examples of com.day.cq.wcm.api.Page.adaptTo()

        List<Resource> twitterResources = findTwitterResources(resourceResolver);

        for (Resource twitterResource : twitterResources) {
            Page page = pageManager.getContainingPage(twitterResource);
            if (page != null) {
                Twitter client = page.adaptTo(Twitter.class);
                if (client != null) {
                    try {
                        ValueMap properties = ResourceUtil.getValueMap(twitterResource);
                        String username = properties.get("username", String.class);
View Full Code Here

Examples of com.dooapp.fxform.adapter.Adapter.adaptTo()

        try {
            Adapter adapter = annotationAdapterProvider.getAdapter(getElement().getWrappedType(), getNode().getProperty().getClass(), getElement(), getNode());
            if (adapter == null) {
                adapter = getFxForm().getAdapterProvider().getAdapter(getElement().getWrappedType(), getNode().getProperty().getClass(), getElement(), getNode());
            }
            fxFormNode.getProperty().setValue(adapter.adaptTo(getElement().getValue()));
        } catch (AdapterException e) {
            logger.log(Level.FINE, e.getMessage(), e);
        }
    }
View Full Code Here

Examples of org.apache.sling.api.SlingHttpServletRequest.adaptTo()

     */
    private XSSAPI getXssApi(Object adaptable) {
        if (adaptable instanceof SlingHttpServletRequest) {
            SlingHttpServletRequest request = (SlingHttpServletRequest) adaptable;

            return request.adaptTo(XSSAPI.class);
        }
        // otherwise will fetch generic XSSAPI from OSGiServiceInjector

        return null;
    }
View Full Code Here

Examples of org.apache.sling.api.adapter.Adaptable.adaptTo()

    public <AdapterType> AdapterType adaptTo(final ResourceResolverContext ctx, final Class<AdapterType> type) {
        final Iterator<Adaptable> i = this.adaptableProviders.getProviders(ctx, null);
        AdapterType result = null;
        while ( result == null && i.hasNext() ) {
            final Adaptable adap = i.next();
            result = adap.adaptTo(type);
        }
        return result;
    }

    /**
 
View Full Code Here

Examples of org.apache.sling.api.resource.Resource.adaptTo()

    @Test
    public void testBinaryData() throws IOException {
        Resource resource1 = this.resourceResolver.getResource(getTestRootResource().getPath() + "/node1");

        Resource binaryPropResource = resource1.getChild("binaryProp");
        InputStream is = binaryPropResource.adaptTo(InputStream.class);
        byte[] dataFromResource = IOUtils.toByteArray(is);
        is.close();
        assertArrayEquals(BINARY_VALUE, dataFromResource);

        // read second time to ensure not the original input stream was returned
View Full Code Here

Examples of org.apache.sling.api.resource.Resource.adaptTo()

        assertEquals(BOOLEAN_VALUE, props.get("booleanProp", Boolean.class));
        assertEquals(DATE_VALUE, props.get("dateProp", Date.class));
        assertEquals(CALENDAR_VALUE.getTime(), props.get("calendarProp", Calendar.class).getTime());

        Resource binaryPropResource = resource1.getChild("binaryProp");
        InputStream is = binaryPropResource.adaptTo(InputStream.class);
        byte[] dataFromResource = IOUtils.toByteArray(is);
        is.close();
        assertArrayEquals(BINARY_VALUE, dataFromResource);

        // read second time to ensure not the original input stream was returned
View Full Code Here

Examples of org.apache.sling.api.resource.Resource.adaptTo()

        byte[] dataFromResource = IOUtils.toByteArray(is);
        is.close();
        assertArrayEquals(BINARY_VALUE, dataFromResource);

        // read second time to ensure not the original input stream was returned
        InputStream is2 = binaryPropResource.adaptTo(InputStream.class);
        byte[] dataFromResource2 = IOUtils.toByteArray(is2);
        is2.close();
        assertArrayEquals(BINARY_VALUE, dataFromResource2);

        List<Resource> children = ImmutableList.copyOf(resource1.listChildren());
View Full Code Here

Examples of org.apache.sling.api.resource.Resource.adaptTo()

        Resource child = resourceResolver.create(parent, "nodeTypeResource", ImmutableMap.<String, Object> builder()
                .put("sling:resourceType", JcrConstants.NT_UNSTRUCTURED).build());
        assertNotNull(child);
        assertEquals(JcrConstants.NT_UNSTRUCTURED, child.getResourceType());
        assertEquals(JcrConstants.NT_UNSTRUCTURED, child.adaptTo(Node.class).getPrimaryNodeType().getName());
    }

}
View Full Code Here

Examples of org.apache.sling.api.resource.Resource.adaptTo()

        map.put("intProperty", new Integer(3));
        map.put("arrayProperty", new String[] { "three", "four" });
        ValueMap vm = new ValueMapDecorator(map);

        Resource res = mock(Resource.class);
        when(res.adaptTo(ValueMap.class)).thenReturn(vm);

        SimplePropertyModel model = factory.getAdapter(res, SimplePropertyModel.class);
        assertNotNull(model);
        assertEquals("first-value", model.getFirst());
        assertNull(model.getSecond());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.