Package org.apache.sling.api.resource

Examples of org.apache.sling.api.resource.Resource


        }
    }

    @Test
    public void testCalendarEcmaFormat() {
        Resource resource = this.resourceResolver.getResource("/content/sample/en/jcr:content");
        ValueMap props = ResourceUtil.getValueMap(resource);

        Calendar calendar = props.get("app:lastModified", Calendar.class);
        assertNotNull(calendar);
View Full Code Here


        assertEquals(24, calendar.get(Calendar.SECOND));
    }
   
    @Test
    public void testCalendarISO8601Format() {
        Resource resource = this.resourceResolver.getResource("/content/sample/en/jcr:content");
        ValueMap props = ResourceUtil.getValueMap(resource);

        Calendar calendar = props.get("dateISO8601String", Calendar.class);
        assertNotNull(calendar);
View Full Code Here

    @Rule
    public SlingContext context = new SlingContext(ResourceResolverType.RESOURCERESOLVER_MOCK);

    @Test
    public void testResource() {
        Resource resource = context.create().resource("/content/test1/resource1");
        assertNotNull(resource);
        assertEquals("resource1", resource.getName());
        assertTrue(ResourceUtil.getValueMap(resource).isEmpty());
    }
View Full Code Here

        assertTrue(ResourceUtil.getValueMap(resource).isEmpty());
    }

    @Test
    public void testResourceWithProperties() {
        Resource resource = context.create().resource(
                "/content/test1/resource2",
                ImmutableMap.<String, Object> builder().put("jcr:title", "Test Title").put("stringProp", "value1")
                        .build());
        assertNotNull(resource);
        assertEquals("resource2", resource.getName());
        ValueMap props = ResourceUtil.getValueMap(resource);
        assertEquals("Test Title", props.get("jcr:title", String.class));
        assertEquals("value1", props.get("stringProp", String.class));
    }
View Full Code Here

                                    List<Modification> changes)
            throws RepositoryException {

        ApplyToIterator iterator = new ApplyToIterator(baseResource, paths);
        while (iterator.hasNext()) {
            Resource resource = iterator.next();
            Authorizable item = resource.adaptTo(Authorizable.class);
            if (item != null) {
                item.remove();
                changes.add(Modification.onDeleted(resource.getPath()));
            }
        }
    }
View Full Code Here

            }
            if ( path != null && path.length() > 0 && this.running ) {
                ResourceResolver resolver = null;
                try {
                    resolver = this.resourceResolverFactory.getAdministrativeResourceResolver(null);
                    final Resource eventResource = resolver.getResource(path);
                    if ( DistributedEventAdminImpl.RESOURCE_TYPE_EVENT.equals(eventResource.getResourceType())) {
                        final Event e = this.readEvent(eventResource);
                        if ( e != null ) {
                            // we check event admin as processing is async
                            final EventAdmin localEA = this.eventAdmin;
                            if ( localEA != null ) {
View Full Code Here

        public Resource next() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }

            Resource result = nextResource;
            nextResource = seek();

            return result;
        }
View Full Code Here

        private Resource seek() {
            while (pathIndex < paths.length) {
                String path = paths[pathIndex];
                pathIndex++;

                Resource res = resolver.getResource(baseResource, path);
                if (res != null) {
                    return res;
                }
            }
View Full Code Here

            memberAuthorizable = userManager.getAuthorizable(member);
        } catch (RepositoryException e) {
            // if we can't find the members then it may be resolvable as a resource.
        }
        if ( memberAuthorizable == null ) {
            Resource res = resolver.getResource(baseResource, member);
            if (res != null) {
                memberAuthorizable = res.adaptTo(Authorizable.class);
            }
        }
        return memberAuthorizable;
    }
View Full Code Here

        Node rootNode = session.getRootNode();
        createdNode = rootNode.addNode("test_" + RandomStringUtils.randomAlphanumeric(10));
        createdNode.setProperty("testProperty", value);
        session.save();

        Resource resource = resolver.getResource(createdNode.getPath());

        SlingPropertyAnnotationTestModel model = resource.adaptTo(SlingPropertyAnnotationTestModel.class);

        assertNotNull("Model is null", model);
        assertEquals("Test Property is not set correctly", value, model.getTestProperty());
    } finally {
        if (createdNode != null) {
View Full Code Here

TOP

Related Classes of org.apache.sling.api.resource.Resource

Copyright © 2018 www.massapicom. 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.