Package org.apache.sling.api.resource

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


        // Now know how to get the input stream, we still have to decide
        // on the encoding of the stream's data. Primarily we assume it is
        // UTF-8, which is a default in many places in JCR. Secondarily
        // we try to get a jcr:encoding property besides the data property
        // to provide a possible encoding
        ResourceMetadata meta = getScriptResource().getResourceMetadata();
        String encoding = meta.getCharacterEncoding();
        if (encoding == null) {
            encoding = "UTF-8";
        }

        // access the value as a stream and return a buffered reader
View Full Code Here


            }

            Resource resource = scanPath(mappedUri);
            if (resource != null) {

                ResourceMetadata rm = resource.getResourceMetadata();
                String path = rm.getResolutionPath();
                String uriPath = mappings[i].mapHandle(path);
                if (uriPath != null && !uriPath.equals(path)) {
                    resource.getResourceMetadata().setResolutionPath(uriPath);
                }
View Full Code Here

        super.assertEquals(expected, actual);
    }

    private void assertResourceMetaData(Object metaData) throws Exception {
        if (metaData instanceof ResourceMetadata) {
            ResourceMetadata rm = (ResourceMetadata) metaData;
            rm.getResolutionPath().equals(node.getPath());
        } else {
            fail("Expected ResourceMetadata, got " + metaData);
        }
    }
View Full Code Here

        private final ResourceMetadata metadata;

        TestResource(Node node) throws RepositoryException {
            this.node = node;
            this.path = node.getPath();
            this.metadata = new ResourceMetadata();
            this.metadata.setResolutionPath(this.path);
        }
View Full Code Here

        this.resourceResolver = resourceResolver;
        this.servlet = servlet;
        this.path = path;
        this.resourceType = ServletResourceProviderFactory.ensureServletNameExtension(path);

        this.metadata = new ResourceMetadata();
        metadata.setResolutionPath(path);
    }
View Full Code Here

        this.resourceResolver = resourceResolver;
        this.bundle = bundle;
        this.mappedPath = mappedPath;

        metadata = new ResourceMetadata();
        metadata.setResolutionPath(resourcePath);
        metadata.setCreationTime(bundle.getBundle().getLastModified());
        metadata.setModificationTime(bundle.getBundle().getLastModified());

        if (resourcePath.endsWith("/")) {
View Full Code Here

          this.resourceType = "sling:group";
        } else {
          this.resourceType = "sling:user";
        }

        this.metadata = new ResourceMetadata();
        metadata.setResolutionPath(path);
  }
View Full Code Here

import org.apache.sling.api.resource.ResourceMetadata;

/** Test the StarResource */
public class StarResourceTest extends TestCase {
  private void assertSplit(String requestPath, String path, String pathInfo) {
    final ResourceMetadata rm = StarResource.getResourceMetadata(requestPath);
    assertEquals("For requestPath=" + requestPath + ", path matches", path, rm.getResolutionPath());
    assertEquals("For requestPath=" + requestPath + ", pathInfo matches", pathInfo, rm.getResolutionPathInfo());
  }
View Full Code Here

     * length, last modification time and the resource path (same as
     * {@link #getPath()}).
     */
    public ResourceMetadata getResourceMetadata() {
        if (metaData == null) {
            metaData = new ResourceMetadata();
            metaData.setContentLength(file.length());
            metaData.setModificationTime(file.lastModified());
            metaData.setResolutionPath(resourcePath);
        }
        return metaData;
View Full Code Here

        return resourceSuperType;
    }

    /** Get our ResourceMetadata for given path */
    static ResourceMetadata getResourceMetadata(String path) {
      ResourceMetadata result = new ResourceMetadata();

      // The path is up to /*, what follows is pathInfo
        final int index = path.indexOf(SLASH_STAR);
        if(index >= 0) {
            result.setResolutionPath(path.substring(0, index) + SLASH_STAR);
            result.setResolutionPathInfo(path.substring(index + SLASH_STAR.length()));
        } else {
            result.setResolutionPath(path);
        }
        return result;
    }
View Full Code Here

TOP

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

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.