public Resource create()

in src/main/java/org/apache/sling/nosql/generic/resource/impl/NoSqlResourceProvider.java [137:155]


    public Resource create(ResourceResolver resolver, String path, Map<String, Object> properties)
            throws PersistenceException {
        if (ROOT_PATH.equals(path) || !adapter.validPath(path)) {
            throw new PersistenceException("Illegal path - unable to create resource at " + path, null, path, null);
        }

        // check if already exists
        boolean deleted = this.deletedResources.remove(path);
        boolean exists = changedResources.containsKey(path) || this.adapter.get(path) != null;
        if (!deleted && exists) {
            throw new PersistenceException("Resource already exists at " + path, null, path, null);
        }
        
        // create new resource in changeset
        Map<String, Object> writableMap = properties != null ? new HashMap<String, Object>(properties) : new HashMap<String, Object>();
        NoSqlData data = new NoSqlData(path, NoSqlValueMap.convertForWriteAll(writableMap));
        changedResources.put(path, data);
        return new NoSqlResource(data, resolver, this);
    }