Java Code Examples for org.apache.sling.api.resource.Resource#getName()

The following examples show how to use org.apache.sling.api.resource.Resource#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlogEdit.java    From publick-sling-blog with Apache License 2.0 6 votes vote down vote up
/**
 * Get the blog post properties if resource already exists otherwise
 * set the month and year properties to the current date.
 *
 * @param path The resource path to the blog post.
 */
private void getBlog(String path) {
    ResourceResolver resolver = resource.getResourceResolver();
    Resource blog = resolver.getResource(path);

    if (blog != null) {
        ValueMap properties = blog.adaptTo(ValueMap.class);
        title = properties.get("title", String.class);
        month = properties.get("month", Long.class);
        year = properties.get("year", Long.class);
        url = properties.get("url", String.class);
        visible = Boolean.valueOf(properties.get("visible", false));
        keywords = properties.get("keywords", String[].class);
        image = properties.get("image", String.class);
        content = properties.get("content", String.class);
        description = properties.get("description", String.class);
        url = blog.getName();
    } else {
        /* Populate dropdowns with current date if creating new blog. */
        month = ((long)Calendar.getInstance().get(Calendar.MONTH)) + 1;
        year = (long)Calendar.getInstance().get(Calendar.YEAR);
    }
}
 
Example 2
Source File: MapOfChildResourcesInjector.java    From sling-whiteboard with Apache License 2.0 5 votes vote down vote up
private Map.Entry buildSimpleMapEntry(Class<?> valueClass, Resource r) {
    if (valueClass.equals(Resource.class)) {
        return new AbstractMap.SimpleEntry<>(r.getName(), r);
    } else {
        Object adapted = r.adaptTo(valueClass);
        if (adapted == null) {
            return null;
        } else {
            return new AbstractMap.SimpleEntry<>(r.getName(), adapted);
        }
    }
}
 
Example 3
Source File: MappedChildren.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
public MappedChildren(Resource resource) {
    if (resource != null) {
        name = resource.getName();
    }
}
 
Example 4
Source File: ComplexBean.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
public ComplexBean(Resource resource) {
    if (resource != null) {
        name = resource.getName();
    }
}