Package org.apache.sling.api.resource

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


        assertFalse(aliasMapEntry.containsKey("aliasJcrContentUpdated"));
        assertEquals("child", aliasMapEntry.get("aliasJcrContent"));
       
        assertEquals(1, aliasMap.size());
       
        when(jcrContentResult.adaptTo(ValueMap.class)).thenReturn(buildValueMap("sling:alias", "aliasJcrContentUpdated"));
        method1.invoke(mapEntries, "/parent/child/jcr:content"new String[] { "sling:alias" }, false);
       
        aliasMapEntry = mapEntries.getAliasMap("/parent");
        assertNotNull(aliasMapEntry);
        assertEquals(2, aliasMapEntry.size());
View Full Code Here


        final Resource secondResult = mock(Resource.class);
        when(resourceResolver.getResource("/parent/child2")).thenReturn(secondResult);
        when(secondResult.getParent()).thenReturn(parent);
        when(secondResult.getPath()).thenReturn("/parent/child2");
        when(secondResult.getName()).thenReturn("child2");
        when(secondResult.adaptTo(ValueMap.class)).thenReturn(buildValueMap("sling:alias", "alias2"));
              
        method.invoke(mapEntries, "/parent/child2");
        assertEquals(1, aliasMap.size());
       
        aliasMapEntry = mapEntries.getAliasMap("/parent");
View Full Code Here

        props.clear();
        props.put(ResourceResolver.PROPERTY_RESOURCE_TYPE, SlingshotConstants.RESOURCETYPE_RATING);
        final Resource r = ResourceUtil.getOrCreateResource(resource.getResourceResolver(),
                ratingsResource.getPath() + "/" + userId, props, null, false);

        final ModifiableValueMap mv = r.adaptTo(ModifiableValueMap.class);
        mv.put(SlingshotConstants.PROPERTY_RATING, rating);

        r.getResourceResolver().commit();
    }
}
View Full Code Here

        final Resource result = mock(Resource.class);
        when(resourceResolver.getResource("/parent/child")).thenReturn(result);
        when(result.getParent()).thenReturn(parent);
        when(result.getPath()).thenReturn("/parent/child");
        when(result.getName()).thenReturn("child");
        when(result.adaptTo(ValueMap.class)).thenReturn(buildValueMap("sling:alias", "alias"));
       
        method.invoke(mapEntries, "/parent/child");
       
        Map<String, String> aliasMapEntry = mapEntries.getAliasMap("/parent");
        assertNotNull(aliasMapEntry);
View Full Code Here

        ResourceResolver resolver = requestResourceResolver.get();
        if (resolver != null) {
            try {
                final Resource resource = resolver.getResource(cleanPath(path, true));
                if (resource != null) {
                    final InputStream stream = resource.adaptTo(InputStream.class);
                    if (stream != null) {
                        return stream;
                    }
                }
            } catch (final SlingException se) {
View Full Code Here

        final Resource result = mock(Resource.class);
        when(resourceResolver.getResource("/parent/child")).thenReturn(result);
        when(result.getParent()).thenReturn(parent);
        when(result.getPath()).thenReturn("/parent/child");
        when(result.getName()).thenReturn("child");
        when(result.adaptTo(ValueMap.class)).thenReturn(buildValueMap());
       
        //testing jcr:content node removal
        final Resource jcrContentResult = mock(Resource.class);
        when(resourceResolver.getResource("/parent/child/jcr:content")).thenReturn(jcrContentResult);
        when(jcrContentResult.getParent()).thenReturn(result);
View Full Code Here

    URL getURL(final String path) throws MalformedURLException {
        ResourceResolver resolver = requestResourceResolver.get();
        if (resolver != null) {
            try {
                final Resource resource = resolver.getResource(cleanPath(path, true));
                return (resource != null) ? resource.adaptTo(URL.class) : null;
            } catch (final SlingException se) {
                throw (MalformedURLException) new MalformedURLException(
                    "Cannot get URL for " + path).initCause(se);
            }
        }
View Full Code Here

        final Resource jcrContentResult = mock(Resource.class);
        when(resourceResolver.getResource("/parent/child/jcr:content")).thenReturn(jcrContentResult);
        when(jcrContentResult.getParent()).thenReturn(result);
        when(jcrContentResult.getPath()).thenReturn("/parent/child/jcr:content");
        when(jcrContentResult.getName()).thenReturn("jcr:content");
        when(jcrContentResult.adaptTo(ValueMap.class)).thenReturn(buildValueMap("sling:alias", "aliasJcrContent"));
        when(result.getChild("jcr:content")).thenReturn(jcrContentResult);
       
        method.invoke(mapEntries, "/parent/child/jcr:content");
       
        Map<String, String> aliasMapEntry = mapEntries.getAliasMap("/parent");
View Full Code Here

            }
            if ( exception != null ) {
                throw exception;
            }
            // order node at the top (if jcr based)
            final Node newNode = newResource.adaptTo(Node.class);
            if ( newNode != null ) {
                try {
                    final Node parent = newNode.getParent();
                    final Node firstNode = parent.getNodes().nextNode();
                    if ( !firstNode.getName().equals(newNode.getName()) ) {
View Full Code Here

        final Resource result = mock(Resource.class);
        when(resourceResolver.getResource("/parent/child")).thenReturn(result);
        when(result.getParent()).thenReturn(parent);
        when(result.getPath()).thenReturn("/parent/child");
        when(result.getName()).thenReturn("child");
        when(result.adaptTo(ValueMap.class)).thenReturn(buildValueMap("sling:alias", "alias"));
       
        method.invoke(mapEntries, "/parent/child");
       
        final Resource jcrContentResult = mock(Resource.class);
        when(resourceResolver.getResource("/parent/child/jcr:content")).thenReturn(jcrContentResult);
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.