void loadProperties(Resource resource) { ValueMap jcrVM = ResourceUtil.getValueMap(resource); Map<String, Object> localMap = new HashMap<String, Object>(); // copy all items to local map localMap.putAll(jcrVM); // decoarate it as value map ValueMapDecorator localVM = new ValueMapDecorator(localMap); this.vm = localVM; }
public static ValueMap getValueMap(final Resource resource) throws InstantiationException { final ValueMap vm = ResourceUtil.getValueMap(resource); // trigger full loading try { vm.size(); } catch ( final IllegalArgumentException iae) { // the JCR implementation might throw an IAE if something goes wrong throw (InstantiationException)new InstantiationException(iae.getMessage()).initCause(iae); } return vm; }
public static ValueMap getValueMap(final Resource resource) throws InstantiationException { final ValueMap vm = ResourceUtil.getValueMap(resource); // trigger full loading try { vm.size(); } catch ( final IllegalArgumentException iae) { // the JCR implementation might throw an IAE if something goes wrong throw (InstantiationException)new InstantiationException(iae.getMessage()).initCause(iae); } return vm; }
public ModifiableValueMap getProperties(Resource resource) { Iterator<Resource> entries = membersResource.listChildren(); while (entries.hasNext()) { Resource entry = entries.next(); String path = ResourceUtil.getValueMap(entry).get( ResourceCollectionConstants.REF_PROPERTY, ""); if (resource.getPath().equals(path)) { return entry.adaptTo(ModifiableValueMap.class); } } return null; } }
@SuppressWarnings("unchecked") @Override public Iterator<Tenant> call(ResourceResolver resolver) { Resource tenantRootRes = resolver.getResource(tenantRootPath); if ( tenantRootRes != null ) { List<Tenant> tenantList = new ArrayList<Tenant>(); Iterator<Resource> tenantResourceList = tenantRootRes.listChildren(); while (tenantResourceList.hasNext()) { Resource tenantRes = tenantResourceList.next(); if (filter == null || filter.matches(ResourceUtil.getValueMap(tenantRes))) { TenantImpl tenant = new TenantImpl(tenantRes); tenantList.add(tenant); } } return tenantList.iterator(); } return Collections.EMPTY_LIST.iterator(); } });
@Override public Resource create(Resource parent, String name, Map<String, Object> properties) throws PersistenceException { final String path = (parent.getPath().equals("/") ? parent.getPath() + name : parent.getPath() + '/' + name); if ( this.temporaryResources.containsKey(path) ) { throw new PersistenceException("Path already exists: " + path); } synchronized ( this.resources ) { if ( this.resources.containsKey(path) && !this.deletedResources.contains(path) ) { throw new PersistenceException("Path already exists: " + path); } } this.deletedResources.remove(path); if ( properties == null ) { properties = new HashMap<String, Object>(); } Resource mockResource = new MockResource(path, properties, this); this.temporaryResources.put(path, ResourceUtil.getValueMap(mockResource)); return mockResource; }
private Resource findRes(Resource res) { if (res != null) { String resName = res.getName(); if (membersResource.getChild(resName) != null && (res.getPath()).equals(ResourceUtil.getValueMap( membersResource.getChild(resName)).get(ResourceCollectionConstants.REF_PROPERTY, ""))) return membersResource.getChild(resName); // handle multiple res with same name but different paths Iterator<Resource> children = membersResource.listChildren(); while (children.hasNext()) { Resource r = children.next(); if (ResourceUtil.getValueMap(r).get(ResourceCollectionConstants.REF_PROPERTY, "").equals( res.getPath())) return r; } } return null; }
@Override protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response) throws ServletException, IOException { LibraryType libraryType = null; Resource dataSourceResource = request.getResource().getChild(Config.DATASOURCE); if (dataSourceResource != null) { ValueMap dataSourceValueMap = ResourceUtil.getValueMap(dataSourceResource); if (dataSourceValueMap != null) { String type = dataSourceValueMap.get(PN_LIBRARY_TYPE, String.class); if (type != null) { type = type.toUpperCase(); libraryType = LibraryType.valueOf(type); } } } SimpleDataSource clientLibraryCategoriesDataSource = new SimpleDataSource(getCategoryResourceList(request, libraryType).iterator()); request.setAttribute(DataSource.class.getName(), clientLibraryCategoriesDataSource); }
/** * Emulate feature of JCR resource implementation that allows adapting to InputStream for nt:file and nt:resource nodes. * @return InputStream or null if adaption not possible. */ private InputStream getFileResourceInputStream() { String resourceType = getResourceType(); if (NT_RESOURCE.equals(resourceType)) { return getValueMap().get(JCR_DATA, InputStream.class); } else if (NT_FILE.equals(resourceType)) { Resource contentResource = getChild(JCR_CONTENT); if (contentResource != null) { return ResourceUtil.getValueMap(contentResource).get(JCR_DATA, InputStream.class); } } return null; }
while (children.hasNext()) { final Resource child = children.next(); final ValueMap vm = ResourceUtil.getValueMap(child);
final ValueMap vm = ResourceUtil.getValueMap(rsrc); final Calendar changed = (Calendar) vm.get(Job.PROPERTY_JOB_CREATED); if ( changed != null && scheduled.created.compareTo(changed) < 0 ) {
@Override public Resource getResource(final String path) { Resource resource = getResourceInternal(path); // if not resource found check if this is a reference to a property if (resource == null && path != null) { String parentPath = ResourceUtil.getParent(path); if (parentPath != null) { String name = ResourceUtil.getName(path); Resource parentResource = getResourceInternal(parentPath); if (parentResource!=null) { ValueMap props = ResourceUtil.getValueMap(parentResource); if (props.containsKey(name)) { return new MockPropertyResource(path, props, this); } } } } return resource; }
boolean remove = stateList == null; if ( !remove ) { final ValueMap vm = ResourceUtil.getValueMap(jobResource); final String state = vm.get(JobImpl.PROPERTY_FINISHED_STATE, String.class); if ( state != null && stateList.contains(state) ) {