You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by dp...@apache.org on 2009/04/15 12:49:35 UTC

svn commit: r765129 [5/5] - in /jackrabbit/sandbox/chemistry: ./ chemistry-api/ chemistry-api/src/ chemistry-api/src/main/ chemistry-api/src/main/java/ chemistry-api/src/main/java/org/ chemistry-api/src/main/java/org/apache/ chemistry-api/src/main/java...

Added: jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimplePropertyDefinition.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimplePropertyDefinition.java?rev=765129&view=auto
==============================================================================
--- jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimplePropertyDefinition.java (added)
+++ jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimplePropertyDefinition.java Wed Apr 15 10:49:31 2009
@@ -0,0 +1,260 @@
+/*
+ * Copyright 2009 Nuxeo SA <http://nuxeo.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Florent Guillaume
+ */
+package org.apache.chemistry.impl.simple;
+
+import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.math.BigDecimal;
+import java.net.URI;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.chemistry.property.Choice;
+import org.apache.chemistry.property.PropertyDefinition;
+import org.apache.chemistry.property.PropertyType;
+import org.apache.chemistry.property.Updatability;
+
+public class SimplePropertyDefinition implements PropertyDefinition {
+
+    private final String name;
+
+    private final String id;
+
+    private final String displayName;
+
+    private final String description;
+
+    private final boolean inherited;
+
+    private final PropertyType type;
+
+    private final boolean multiValued;
+
+    private final List<Choice> choices;
+
+    private final boolean openChoice;
+
+    private final boolean required;
+
+    private final Serializable defaultValue;
+
+    private final Updatability updatability;
+
+    private final boolean queryable;
+
+    private final boolean orderable;
+
+    private final int precision;
+
+    private final Integer minValue;
+
+    private final Integer maxValue;
+
+    private final int maxLength;
+
+    private final URI schemaURI;
+
+    private final String encoding;
+
+    public SimplePropertyDefinition(String name, String id, String displayName,
+            String description, boolean inherited, PropertyType type,
+            boolean multiValued, List<Choice> choices, boolean openChoice,
+            boolean required, Serializable defaultValue,
+            Updatability updatability, boolean queryable, boolean orderable,
+            int precision, Integer minValue, Integer maxValue, int maxLength,
+            URI schemaURI, String encoding) {
+        super();
+    	if (name.equals(SimpleDocument.CONTENT_BYTES_KEY)) {
+    		throw new IllegalArgumentException(SimpleDocument.CONTENT_BYTES_KEY + " is a reserved name");
+    	}
+        this.name = name;
+        this.id = id;
+        this.displayName = displayName;
+        this.description = description;
+        this.inherited = inherited;
+        this.type = type;
+        this.multiValued = multiValued;
+        this.choices = choices == null ? null
+                : Collections.unmodifiableList(choices);
+        this.openChoice = openChoice;
+        this.required = required;
+        this.defaultValue = defaultValue;
+        this.updatability = updatability;
+        this.queryable = queryable;
+        this.orderable = orderable;
+        this.precision = precision;
+        this.minValue = minValue;
+        this.maxValue = maxValue;
+        this.maxLength = maxLength;
+        this.schemaURI = schemaURI;
+        this.encoding = encoding;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public boolean isInherited() {
+        return inherited;
+    }
+
+    public PropertyType getType() {
+        return type;
+    }
+
+    public boolean isMultiValued() {
+        return multiValued;
+    }
+
+    public List<Choice> getChoices() {
+        return choices;
+    }
+
+    public boolean isOpenChoice() {
+        return openChoice;
+    }
+
+    public boolean isRequired() {
+        return required;
+    }
+
+    public Serializable getDefaultValue() {
+        return defaultValue;
+    }
+
+    public Updatability getUpdatability() {
+        return updatability;
+    }
+
+    public boolean isQueryable() {
+        return queryable;
+    }
+
+    public boolean isOrderable() {
+        return orderable;
+    }
+
+    public int getPrecision() {
+        return precision;
+    }
+
+    public Integer getMinValue() {
+        return minValue;
+    }
+
+    public Integer getMaxValue() {
+        return maxValue;
+    }
+
+    public int getMaxLength() {
+        return maxLength;
+    }
+
+    public URI getSchemaURI() {
+        return schemaURI;
+    }
+
+    public String getEncoding() {
+        return encoding;
+    }
+
+    public boolean validates(Serializable value) {
+        return validationError(value) == null;
+    }
+
+    public String validationError(Serializable value) {
+        if (getUpdatability() == Updatability.READ_ONLY) {
+            // TODO Updatability.WHEN_CHECKED_OUT
+            return "Property is read-only";
+        }
+        if (value == null) {
+            if (isRequired()) {
+                return "Property is required";
+            }
+            return null;
+        }
+        boolean multi = isMultiValued();
+        if (multi != value.getClass().isArray()) {
+            return multi ? "Property is multi-valued"
+                    : "Property is single-valued";
+        }
+        Class<?> klass;
+        switch (type) {
+        case STRING:
+        case ID:
+            klass = String.class;
+            break;
+        case DECIMAL:
+            klass = BigDecimal.class;
+            break;
+        case INTEGER:
+            klass = Integer.class; // TODO Long
+            break;
+        case BOOLEAN:
+            klass = Boolean.class;
+            break;
+        case DATETIME:
+            klass = Calendar.class;
+            break;
+        case URI:
+            klass = URI.class;
+            break;
+        case XML:
+            klass = String.class; // TODO
+            break;
+        case HTML:
+            klass = String.class; // TODO
+            break;
+        default:
+            throw new UnsupportedOperationException(type.toString());
+        }
+        if (multi) {
+            for (int i = 0; i < Array.getLength(value); i++) {
+                Object v = Array.get(value, i);
+                if (v == null) {
+                    return "Array value cannot contain null elements";
+                }
+                if (!klass.isInstance(v)) {
+                    return "Array value has type " + v.getClass()
+                            + " instead of " + klass.getName();
+                }
+            }
+        } else {
+            if (!klass.isInstance(value)) {
+                return "Value has type " + value.getClass() + " instead of "
+                        + klass.getName();
+            }
+        }
+        return null;
+    }
+
+}

Propchange: jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimplePropertyDefinition.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimplePropertyDefinition.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRelationship.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRelationship.java?rev=765129&view=auto
==============================================================================
--- jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRelationship.java (added)
+++ jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRelationship.java Wed Apr 15 10:49:31 2009
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2009 Nuxeo SA <http://nuxeo.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Florent Guillaume
+ */
+package org.apache.chemistry.impl.simple;
+
+import org.apache.chemistry.Relationship;
+
+public class SimpleRelationship extends SimpleObject implements Relationship {
+
+    public SimpleRelationship(SimpleData data, SimpleConnection connection) {
+        super(data, connection);
+    }
+
+}

Propchange: jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRelationship.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRelationship.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRepository.java?rev=765129&view=auto
==============================================================================
--- jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRepository.java (added)
+++ jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRepository.java Wed Apr 15 10:49:31 2009
@@ -0,0 +1,327 @@
+/*
+ * Copyright 2009 Nuxeo SA <http://nuxeo.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Florent Guillaume
+ */
+package org.apache.chemistry.impl.simple;
+
+import java.io.Serializable;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.chemistry.Connection;
+import org.apache.chemistry.property.Property;
+import org.apache.chemistry.repository.JoinCapability;
+import org.apache.chemistry.repository.QueryCapability;
+import org.apache.chemistry.repository.Repository;
+import org.apache.chemistry.repository.RepositoryCapabilities;
+import org.apache.chemistry.repository.RepositoryEntry;
+import org.apache.chemistry.repository.RepositoryInfo;
+import org.apache.chemistry.type.BaseType;
+import org.apache.chemistry.type.ContentStreamPresence;
+import org.apache.chemistry.type.Type;
+
+public class SimpleRepository implements Repository, RepositoryInfo,
+        RepositoryCapabilities {
+
+    // from the spec
+    public static final String ROOT_FOLDER_NAME = "CMIS_Root_Folder";
+
+    public static final String ROOT_TYPE_ID = "Root";
+
+    public static final String DOCUMENT_TYPE_ID = "document";
+
+    public static final String FOLDER_TYPE_ID = "folder";
+
+    public static final String RELATIONSHIP_TYPE_ID = "relationship";
+
+    public static final String POLICY_TYPE_ID = "policy";
+
+    protected static SimpleType ROOT_TYPE = new SimpleType(ROOT_TYPE_ID,
+            FOLDER_TYPE_ID, "Root", "Root Folder Type", BaseType.FOLDER, "",
+            false, false, false, false, false, false,
+            ContentStreamPresence.NOT_ALLOWED, null, null,
+            Collections.<SimplePropertyDefinition> emptyList());
+
+    protected static SimpleType DOCUMENT_TYPE = new SimpleType(
+            DOCUMENT_TYPE_ID, null, "Document", "Document Type",
+            BaseType.DOCUMENT, "", true, true, true, true, true, true,
+            ContentStreamPresence.ALLOWED, null, null,
+            Collections.<SimplePropertyDefinition> emptyList());
+
+    protected static SimpleType FOLDER_TYPE = new SimpleType(FOLDER_TYPE_ID,
+            null, "Folder", "Folder Type", BaseType.FOLDER, "", true, true,
+            false, true, true, false, ContentStreamPresence.NOT_ALLOWED, null,
+            null, Collections.<SimplePropertyDefinition> emptyList());
+
+    protected static SimpleType RELATIONSHIP_TYPE = new SimpleType(
+            RELATIONSHIP_TYPE_ID, null, "Relationship", "Relationship Type",
+            BaseType.RELATIONSHIP, "", true, true, false, true, false, false,
+            ContentStreamPresence.NOT_ALLOWED, null, null,
+            Collections.<SimplePropertyDefinition> emptyList());
+
+    protected static SimpleType POLICY_TYPE = new SimpleType(POLICY_TYPE_ID,
+            null, "Policy", "Policy Type", BaseType.POLICY, "", true, true,
+            false, true, false, false, ContentStreamPresence.NOT_ALLOWED, null,
+            null, Collections.<SimplePropertyDefinition> emptyList());
+
+    public static final String USERNAME = "USERNAME";
+
+    public static final String PASSWORD = "PASSWORD";
+
+    protected static final Set<String> NO_PARENT = Collections.unmodifiableSet(new HashSet<String>());
+
+    private final String name;
+
+    private final String rootFolderId;
+
+    private final Map<String, Type> types;
+
+    /** Map of id -> data */
+    protected final Map<String, SimpleData> datas;
+
+    /** Map of id -> contentBytes */
+    protected final Map<String, byte[]> contentBytes;
+
+    /** Map of id -> children IDs */
+    protected final Map<String, Set<String>> children;
+
+    /** Map of id -> parent IDs, or null if unfiled */
+    protected final Map<String, Set<String>> parents;
+
+    @SuppressWarnings("unchecked")
+    public SimpleRepository(String name, Collection<SimpleType> types) {
+        this.name = name;
+        this.types = new HashMap<String, Type>();
+        for (Collection<SimpleType> ts : Arrays.asList(getDefaultTypes(), types)) {
+            for (Type type : ts) {
+                String tid = type.getId();
+                if (this.types.containsKey(tid)) {
+                    throw new RuntimeException("Type already defined: " + tid);
+                }
+                this.types.put(tid, type);
+            }
+        }
+        rootFolderId = generateId();
+
+        datas = new ConcurrentHashMap<String, SimpleData>();
+        contentBytes = new ConcurrentHashMap<String, byte[]>();
+        children = new ConcurrentHashMap<String, Set<String>>();
+        parents = new ConcurrentHashMap<String, Set<String>>();
+
+        SimpleData rootData = new SimpleData(ROOT_TYPE_ID);
+        rootData.put(Property.ID, rootFolderId);
+        rootData.put(Property.NAME, ROOT_FOLDER_NAME);
+        datas.put(rootFolderId, rootData);
+        children.put(rootFolderId, newSet());
+        parents.put(rootFolderId, NO_PARENT);
+    }
+
+    // private final AtomicLong idCounter = new AtomicLong(0);
+
+    protected String generateId() {
+        return UUID.randomUUID().toString();
+        // return "ID_" + idCounter.incrementAndGet();
+    }
+
+    protected Collection<SimpleType> getDefaultTypes() {
+        return Arrays.asList(DOCUMENT_TYPE, FOLDER_TYPE, RELATIONSHIP_TYPE,
+                POLICY_TYPE, ROOT_TYPE);
+    }
+
+    protected Set<String> newSet() {
+        return Collections.synchronizedSet(new HashSet<String>());
+    }
+
+    /*
+     * ----- RepositoryEntry -----
+     */
+
+    public String getId() {
+        return name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public URI getURI() {
+        // TODO Return a URI
+        return null;
+    }
+
+    public String getRelationshipName() {
+        return null;
+    }
+
+    /*
+     * ----- Repository -----
+     */
+
+    public Connection getConnection(Map<String, Serializable> parameters) {
+        // TODO credentials
+        return new SimpleConnection(this);
+    }
+
+    public RepositoryInfo getInfo() {
+        return this;
+    }
+
+    public Type getType(String typeId) {
+        return types.get(typeId);
+    }
+
+    public Collection<Type> getTypes(String typeId,
+            boolean returnPropertyDefinitions) {
+        // TODO always returns property definitions for now
+        if (typeId == null) {
+            return Collections.unmodifiableCollection(types.values());
+        }
+        if (!types.containsKey(typeId)) {
+            return null; // TODO
+        }
+        // TODO return all descendants as well
+        return Collections.singleton(types.get(typeId));
+    }
+
+    public List<Type> getTypes(String typeId,
+            boolean returnPropertyDefinitions, int maxItems, int skipCount,
+            boolean[] hasMoreItems) {
+        if (maxItems < 0) {
+            throw new IllegalArgumentException(String.valueOf(maxItems));
+        }
+        if (skipCount < 0) {
+            throw new IllegalArgumentException(String.valueOf(skipCount));
+        }
+        if (hasMoreItems.length < 1) {
+            throw new IllegalArgumentException(
+                    "hasMoreItems parameter too small");
+        }
+
+        Collection<Type> t = getTypes(typeId, returnPropertyDefinitions);
+        if (t == null) {
+            hasMoreItems[0] = false;
+            return Collections.emptyList();
+        }
+        List<Type> all = new ArrayList<Type>(t);
+        int fromIndex = skipCount;
+        if (fromIndex < 0 || fromIndex > all.size()) {
+            hasMoreItems[0] = false;
+            return Collections.emptyList();
+        }
+        if (maxItems == 0) {
+            maxItems = all.size();
+        }
+        int toIndex = skipCount + maxItems;
+        if (toIndex > all.size()) {
+            toIndex = all.size();
+        }
+        hasMoreItems[0] = toIndex < all.size();
+        return all.subList(fromIndex, toIndex);
+    }
+
+    /*
+     * ----- RepositoryInfo -----
+     */
+
+    public String getDescription() {
+        return "Repository " + name;
+    }
+
+    public String getRootFolderId() {
+        return rootFolderId;
+    }
+
+    public String getVendorName() {
+        return "Nuxeo";
+    }
+
+    public String getProductName() {
+        return "Chemistry Simple Repository";
+    }
+
+    public String getProductVersion() {
+        // TODO update this when releasing
+        return "0.1-SNAPSHOT";
+    }
+
+    public String getVersionSupported() {
+        // TODO may be overriden by generic client layer
+        return "0.51";
+    }
+
+    public org.w3c.dom.Document getRepositorySpecificInformation() {
+        return null;
+    }
+
+    public RepositoryCapabilities getCapabilities() {
+        return this;
+    }
+
+    public Collection<RepositoryEntry> getRelatedRepositories() {
+        return Collections.emptySet();
+    }
+
+    /*
+     * ----- RepositoryCapabilities -----
+     */
+
+    public boolean hasMultifiling() {
+        return false;
+    }
+
+    public boolean hasUnfiling() {
+        return false;
+    }
+
+    public boolean hasVersionSpecificFiling() {
+        return false;
+    }
+
+    public boolean isPWCUpdatable() {
+        return false;
+    }
+
+    public boolean isPWCSearchable() {
+        return false;
+    }
+
+    public boolean isAllVersionsSearchable() {
+        return false;
+    }
+
+    public JoinCapability getJoinCapability() {
+        return JoinCapability.NO_JOIN;
+    }
+
+    public QueryCapability getQueryCapability() {
+        return QueryCapability.BOTH_COMBINED;
+    }
+
+    public <T> T getExtension(Class<T> klass) {
+        return null; // Not Supported
+    }
+}

Propchange: jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRepository.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRepository.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleType.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleType.java?rev=765129&view=auto
==============================================================================
--- jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleType.java (added)
+++ jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleType.java Wed Apr 15 10:49:31 2009
@@ -0,0 +1,383 @@
+/*
+ * Copyright 2009 Nuxeo SA <http://nuxeo.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Florent Guillaume
+ */
+package org.apache.chemistry.impl.simple;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.property.Property;
+import org.apache.chemistry.property.PropertyDefinition;
+import org.apache.chemistry.property.PropertyType;
+import org.apache.chemistry.property.Updatability;
+import org.apache.chemistry.type.BaseType;
+import org.apache.chemistry.type.ContentStreamPresence;
+import org.apache.chemistry.type.Type;
+
+public class SimpleType implements Type {
+
+    protected static final SimplePropertyDefinition PROP_ID = new SimplePropertyDefinition(
+            Property.ID, "def:id", "Id", "", false, PropertyType.ID, false,
+            null, false, true, null, Updatability.READ_ONLY, true, true, 0,
+            null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_URI = new SimplePropertyDefinition(
+            Property.URI, "def:uri", "URI", "", false, PropertyType.URI, false,
+            null, false, false, null, Updatability.READ_ONLY, true, true, 0,
+            null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_TYPE_ID = new SimplePropertyDefinition(
+            Property.TYPE_ID, "def:typeid", "Type ID", "", false,
+            PropertyType.ID, false, null, false, true, null,
+            Updatability.READ_ONLY, true, true, 0, null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_CREATED_BY = new SimplePropertyDefinition(
+            Property.CREATED_BY, "def:createdby", "Created By", "", false,
+            PropertyType.STRING, false, null, false, true, null,
+            Updatability.READ_ONLY, true, true, 0, null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_CREATION_DATE = new SimplePropertyDefinition(
+            Property.CREATION_DATE, "def:creationdate", "Creation Date", "",
+            false, PropertyType.DATETIME, false, null, false, true, null,
+            Updatability.READ_ONLY, true, true, 0, null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_LAST_MODIFIED_BY = new SimplePropertyDefinition(
+            Property.LAST_MODIFIED_BY, "def:lastmodifiedby",
+            "Last Modified By", "", false, PropertyType.STRING, false, null,
+            false, true, null, Updatability.READ_ONLY, true, true, 0, null,
+            null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_LAST_MODIFICATION_DATE = new SimplePropertyDefinition(
+            Property.LAST_MODIFICATION_DATE, "def:lastmodificationdate",
+            "Last Modification Date", "", false, PropertyType.DATETIME, false,
+            null, false, true, null, Updatability.READ_ONLY, true, true, 0,
+            null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_CHANGE_TOKEN = new SimplePropertyDefinition(
+            Property.CHANGE_TOKEN, "def:changetoken", "Change Token", "",
+            false, PropertyType.STRING, false, null, false, false, null,
+            Updatability.READ_WRITE, true, true, 0, null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_NAME = new SimplePropertyDefinition(
+            Property.NAME, "def:name", "Name", "", false, PropertyType.STRING,
+            false, null, false, true, null, Updatability.READ_WRITE, true,
+            true, 0, null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_IS_LATEST_VERSION = new SimplePropertyDefinition(
+            Property.IS_LATEST_VERSION, "def:islatestversion",
+            "Is Latest Version", "", false, PropertyType.BOOLEAN, false, null,
+            false, true, null, Updatability.READ_ONLY, true, true, 0, null,
+            null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_IS_MAJOR_VERSION = new SimplePropertyDefinition(
+            Property.IS_MAJOR_VERSION, "def:ismajorversion",
+            "Is Major Version", "", false, PropertyType.BOOLEAN, false, null,
+            false, false, null, Updatability.READ_ONLY, true, true, 0, null,
+            null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_IS_LATEST_MAJOR_VERSION = new SimplePropertyDefinition(
+            Property.IS_LATEST_MAJOR_VERSION, "def:islatestmajorversion",
+            "Is Latest Major Version", "", false, PropertyType.BOOLEAN, false,
+            null, false, true, null, Updatability.READ_ONLY, true, true, 0,
+            null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_VERSION_LABEL = new SimplePropertyDefinition(
+            Property.VERSION_LABEL, "def:versionlabel", "Version Label", "",
+            false, PropertyType.STRING, false, null, false, true, null,
+            Updatability.READ_ONLY, true, true, 0, null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_VERSION_SERIES_ID = new SimplePropertyDefinition(
+            Property.VERSION_SERIES_ID, "def:versionseriesid",
+            "Version Series ID", "", false, PropertyType.ID, false, null,
+            false, true, null, Updatability.READ_ONLY, true, true, 0, null,
+            null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_IS_VERSION_SERIES_CHECKED_OUT = new SimplePropertyDefinition(
+            Property.IS_VERSION_SERIES_CHECKED_OUT,
+            "def:isversionseriescheckedout", "Is Version Series Checked Out",
+            "", false, PropertyType.BOOLEAN, false, null, false, true, null,
+            Updatability.READ_ONLY, true, true, 0, null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_VERSION_SERIES_CHECKED_OUT_BY = new SimplePropertyDefinition(
+            Property.VERSION_SERIES_CHECKED_OUT_BY,
+            "def:versionseriescheckedoutby", "Version Series Checked Out By",
+            "", false, PropertyType.STRING, false, null, false, false, null,
+            Updatability.READ_ONLY, true, true, 0, null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_VERSION_SERIES_CHECKED_OUT_ID = new SimplePropertyDefinition(
+            Property.VERSION_SERIES_CHECKED_OUT_ID,
+            "def:versionseriescheckedoutid", "Version Series Checked Out Id",
+            "", false, PropertyType.ID, false, null, false, false, null,
+            Updatability.READ_ONLY, true, true, 0, null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_CHECKIN_COMMENT = new SimplePropertyDefinition(
+            Property.CHECKIN_COMMENT, "def:checkincomment", "Checkin Comment",
+            "", false, PropertyType.STRING, false, null, false, false, null,
+            Updatability.READ_ONLY, true, true, 0, null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_CONTENT_STREAM_ALLOWED = new SimplePropertyDefinition(
+            Property.CONTENT_STREAM_ALLOWED, "def:contentstreamallowed",
+            "Content Stream Allowed", "", false, PropertyType.STRING, false,
+            null, false, true, null, Updatability.READ_ONLY, true, true, 0,
+            null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_CONTENT_STREAM_LENGTH = new SimplePropertyDefinition(
+            Property.CONTENT_STREAM_LENGTH, "def:contentstreamlength",
+            "Content Stream Length", "", false, PropertyType.INTEGER, false,
+            null, false, false, null, Updatability.READ_ONLY, true, true, 0,
+            null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_CONTENT_STREAM_MIME_TYPE = new SimplePropertyDefinition(
+            Property.CONTENT_STREAM_MIME_TYPE, "def:contentstreammimetype",
+            "Content Stream MIME Type", "", false, PropertyType.STRING, false,
+            null, false, false, null, Updatability.READ_ONLY, true, true, 0,
+            null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_CONTENT_STREAM_FILENAME = new SimplePropertyDefinition(
+            Property.CONTENT_STREAM_FILENAME, "def:contentstreamfilename",
+            "Content Stream Filename", "", false, PropertyType.STRING, false,
+            null, false, false, null, Updatability.READ_WRITE, true, true, 0,
+            null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_CONTENT_STREAM_URI = new SimplePropertyDefinition(
+            Property.CONTENT_STREAM_URI, "def:contentstreamuri",
+            "Content Stream URI", "", false, PropertyType.URI, false, null,
+            false, false, null, Updatability.READ_ONLY, true, true, 0, null,
+            null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_PARENT_ID = new SimplePropertyDefinition(
+            Property.PARENT_ID, "def:parentid", "Parent Id", "", false,
+            PropertyType.ID, false, null, false, true, null,
+            Updatability.READ_ONLY, true, true, 0, null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS = new SimplePropertyDefinition(
+            Property.ALLOWED_CHILD_OBJECT_TYPE_IDS,
+            "def:allowedchildobjecttypeids", "Allowed Child Object Type Ids",
+            "", false, PropertyType.ID, true, null, false, false, null,
+            Updatability.READ_ONLY, true, true, 0, null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_SOURCE_ID = new SimplePropertyDefinition(
+            Property.SOURCE_ID, "def:sourceid", "Source Id", "", false,
+            PropertyType.ID, false, null, false, true, null,
+            Updatability.READ_WRITE, true, true, 0, null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_TARGET_ID = new SimplePropertyDefinition(
+            Property.TARGET_ID, "def:targetid", "Target Id", "", false,
+            PropertyType.ID, false, null, false, true, null,
+            Updatability.READ_WRITE, true, true, 0, null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_POLICY_NAME = new SimplePropertyDefinition(
+            Property.POLICY_NAME, "def:policyname", "Policy Name", "", false,
+            PropertyType.STRING, false, null, false, true, null,
+            Updatability.READ_ONLY, true, true, 0, null, null, -1, null, null);
+
+    protected static final SimplePropertyDefinition PROP_POLICY_TEXT = new SimplePropertyDefinition(
+            Property.POLICY_TEXT, "def:policytext", "Policy Text", "", false,
+            PropertyType.STRING, false, null, false, true, null,
+            Updatability.READ_WRITE, true, true, 0, null, null, -1, null, null);
+
+    private final String id;
+
+    private final String parentId;
+
+    private final String queryName;
+
+    private final String displayName;
+
+    private final BaseType baseType;
+
+    private final String description;
+
+    private final boolean creatable;
+
+    private final boolean queryable;
+
+    private final boolean controllable;
+
+    private final boolean includedInSuperTypeQuery;
+
+    private final boolean fileable;
+
+    private final boolean versionable;
+
+    private final ContentStreamPresence contentStreamAllowed;
+
+    private final String[] allowedSourceTypes;
+
+    private final String[] allowedTargetTypes;
+
+    private final Map<String, PropertyDefinition> propertyDefinitions;
+
+    @SuppressWarnings("unchecked")
+    public SimpleType(String id, String parentId, String queryName,
+            String displayName, BaseType baseType, String description,
+            boolean creatable, boolean queryable, boolean controllable,
+            boolean includedInSuperTypeQuery, boolean fileable,
+            boolean versionable, ContentStreamPresence contentStreamAllowed,
+            String[] allowedSourceTypes, String[] allowedTargetTypes,
+            Collection<SimplePropertyDefinition> propertyDefinitions) {
+        this.id = id;
+        this.parentId = parentId;
+        this.queryName = queryName;
+        this.displayName = displayName;
+        this.baseType = baseType;
+        this.description = description;
+        this.creatable = creatable;
+        this.queryable = queryable;
+        this.controllable = controllable;
+        this.includedInSuperTypeQuery = includedInSuperTypeQuery;
+        this.fileable = fileable;
+        this.versionable = versionable;
+        this.contentStreamAllowed = contentStreamAllowed;
+        this.allowedSourceTypes = allowedSourceTypes;
+        this.allowedTargetTypes = allowedTargetTypes;
+        Map<String, PropertyDefinition> map = new HashMap<String, PropertyDefinition>();
+        for (Collection<SimplePropertyDefinition> defs : Arrays.asList(
+                getBasePropertyDefinitions(baseType), propertyDefinitions)) {
+            for (PropertyDefinition def : defs) {
+                String name = def.getName();
+                if (map.containsKey(name)) {
+                    throw new RuntimeException(
+                            "Property already defined for name: " + name);
+                }
+                map.put(name, def);
+            }
+        }
+        this.propertyDefinitions = map;
+    }
+
+    protected List<SimplePropertyDefinition> getBasePropertyDefinitions(
+            BaseType baseType) {
+        List<SimplePropertyDefinition> defs = new ArrayList<SimplePropertyDefinition>(
+                Arrays.asList(PROP_ID, PROP_URI, PROP_TYPE_ID, PROP_CREATED_BY,
+                        PROP_CREATION_DATE, PROP_LAST_MODIFIED_BY,
+                        PROP_LAST_MODIFICATION_DATE, PROP_CHANGE_TOKEN));
+        switch (baseType) {
+        case DOCUMENT:
+            defs.addAll(Arrays.asList(PROP_NAME, PROP_IS_LATEST_VERSION,
+                    PROP_IS_MAJOR_VERSION, PROP_IS_LATEST_MAJOR_VERSION,
+                    PROP_VERSION_LABEL, PROP_VERSION_SERIES_ID,
+                    PROP_IS_VERSION_SERIES_CHECKED_OUT,
+                    PROP_VERSION_SERIES_CHECKED_OUT_BY,
+                    PROP_VERSION_SERIES_CHECKED_OUT_ID, PROP_CHECKIN_COMMENT,
+                    PROP_CONTENT_STREAM_ALLOWED, PROP_CONTENT_STREAM_LENGTH,
+                    PROP_CONTENT_STREAM_MIME_TYPE,
+                    PROP_CONTENT_STREAM_FILENAME, PROP_CONTENT_STREAM_URI));
+            break;
+        case FOLDER:
+            defs.addAll(Arrays.asList(PROP_NAME, PROP_PARENT_ID,
+                    PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS));
+            break;
+        case RELATIONSHIP:
+            defs.addAll(Arrays.asList(PROP_SOURCE_ID, PROP_TARGET_ID));
+            break;
+        case POLICY:
+            defs.addAll(Arrays.asList(PROP_POLICY_NAME, PROP_POLICY_TEXT));
+            break;
+        }
+        return defs;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public String getQueryName() {
+        return queryName;
+    }
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public String getParentId() {
+        return parentId;
+    }
+
+    public BaseType getBaseType() {
+        return baseType;
+    }
+
+    public String getBaseTypeQueryName() {
+        switch (baseType) {
+        case DOCUMENT:
+            return "Document";
+        case FOLDER:
+            return "Folder";
+        case POLICY:
+            return "Policy";
+        case RELATIONSHIP:
+            return "Relationship";
+        }
+        throw new UnsupportedOperationException(baseType.toString());
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public boolean isCreatable() {
+        return creatable;
+    }
+
+    public boolean isQueryable() {
+        return queryable;
+    }
+
+    public boolean isControllable() {
+        return controllable;
+    }
+
+    public boolean isIncludedInSuperTypeQuery() {
+        return includedInSuperTypeQuery;
+    }
+
+    public boolean isFileable() {
+        return fileable;
+    }
+
+    public boolean isVersionable() {
+        return versionable;
+    }
+
+    public ContentStreamPresence getContentStreamAllowed() {
+        return contentStreamAllowed;
+    }
+
+    public String[] getAllowedSourceTypes() {
+        return allowedSourceTypes;
+    }
+
+    public String[] getAllowedTargetTypes() {
+        return allowedTargetTypes;
+    }
+
+    public Collection<PropertyDefinition> getPropertyDefinitions() {
+        return Collections.unmodifiableCollection(propertyDefinitions.values());
+    }
+
+    public PropertyDefinition getPropertyDefinition(String name) {
+        return propertyDefinitions.get(name);
+    }
+
+}

Propchange: jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleType.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: jackrabbit/sandbox/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java?rev=765129&view=auto
==============================================================================
--- jackrabbit/sandbox/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java (added)
+++ jackrabbit/sandbox/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java Wed Apr 15 10:49:31 2009
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2009 Nuxeo SA <http://nuxeo.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Florent Guillaume
+ */
+package org.apache.chemistry.impl.simple;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+import org.apache.chemistry.Connection;
+import org.apache.chemistry.ContentStream;
+import org.apache.chemistry.Document;
+import org.apache.chemistry.Folder;
+import org.apache.chemistry.property.Property;
+import org.apache.chemistry.property.PropertyType;
+import org.apache.chemistry.property.Updatability;
+import org.apache.chemistry.repository.JoinCapability;
+import org.apache.chemistry.repository.QueryCapability;
+import org.apache.chemistry.repository.RepositoryCapabilities;
+import org.apache.chemistry.repository.RepositoryInfo;
+import org.apache.chemistry.type.BaseType;
+import org.apache.chemistry.type.ContentStreamPresence;
+import org.apache.chemistry.type.Type;
+
+public class TestSimpleRepository extends TestCase {
+
+    protected SimpleRepository repo;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        SimplePropertyDefinition d1 = new SimplePropertyDefinition("title",
+                "def:title", "Title", "", false, PropertyType.STRING, false,
+                null, false, false, "", Updatability.READ_WRITE, true, true, 0,
+                null, null, -1, null, null);
+        SimplePropertyDefinition d2 = new SimplePropertyDefinition(
+                "description", "def:description", "Description", "", false,
+                PropertyType.STRING, false, null, false, false, "",
+                Updatability.READ_WRITE, true, true, 0, null, null, -1, null,
+                null);
+        SimplePropertyDefinition d3 = new SimplePropertyDefinition("date",
+                "def:date", "Date", "", false, PropertyType.DATETIME, false,
+                null, false, false, null, Updatability.READ_WRITE, true, true,
+                0, null, null, -1, null, null);
+        SimpleType mt1 = new SimpleType("doc", null, "Doc", "My Doc Type",
+                BaseType.DOCUMENT, "", true, true, true, true, true, true,
+                ContentStreamPresence.ALLOWED, null, null, Arrays.asList(d1,
+                        d2, d3));
+        SimpleType mt2 = new SimpleType("fold", null, "Fold", "My Folder Type",
+                BaseType.FOLDER, "", true, true, true, true, false, false,
+                ContentStreamPresence.NOT_ALLOWED, null, null, Arrays.asList(
+                        d1, d2));
+        repo = new SimpleRepository("test", Arrays.asList(mt1, mt2));
+
+    }
+
+    public void testInit() throws Exception {
+        assertEquals("test", repo.getId());
+        assertEquals("test", repo.getName());
+        RepositoryInfo info = repo.getInfo();
+        assertNotNull(info.getRootFolderId());
+        assertEquals("Nuxeo", info.getVendorName());
+        assertEquals("Chemistry Simple Repository", info.getProductName());
+        assertEquals("0.1-SNAPSHOT", info.getProductVersion());
+        assertEquals("0.51", info.getVersionSupported());
+        assertEquals(null, info.getRepositorySpecificInformation());
+        RepositoryCapabilities capabilities = info.getCapabilities();
+        assertFalse(capabilities.hasMultifiling());
+        assertFalse(capabilities.hasUnfiling());
+        assertFalse(capabilities.hasVersionSpecificFiling());
+        assertFalse(capabilities.isPWCUpdatable());
+        assertFalse(capabilities.isPWCSearchable());
+        assertFalse(capabilities.isAllVersionsSearchable());
+        assertEquals(JoinCapability.NO_JOIN, capabilities.getJoinCapability());
+        assertEquals(QueryCapability.BOTH_COMBINED,
+                capabilities.getQueryCapability());
+        Collection<Type> types = repo.getTypes(null, true);
+        assertEquals(5 + 2, types.size()); // default types have been added
+    }
+
+    public void testRoot() throws Exception {
+        Connection conn = repo.getConnection(null);
+        assertNotNull(conn);
+        Folder root = conn.getRootFolder();
+        assertNotNull(root);
+        assertEquals(repo.getRootFolderId(), root.getId());
+        assertEquals("CMIS_Root_Folder", root.getName());
+        assertEquals(0, root.getChildren(null, null).size());
+        assertNull(root.getParent());
+    }
+
+    public void testChildren() throws Exception {
+        Connection conn = repo.getConnection(null);
+        Folder root = conn.getRootFolder();
+        Folder f1 = root.newFolder("fold");
+        assertEquals(12 + 1, f1.getType().getPropertyDefinitions().size());
+        assertEquals(0, root.getChildren(null, null).size());
+        f1.save();
+        assertEquals(root.getId(), f1.getParent().getId());
+        assertEquals(1, root.getChildren(null, null).size());
+        Folder f2 = root.newFolder("fold");
+        f2.save();
+        assertEquals(root.getId(), f2.getParent().getId());
+        assertEquals(2, root.getChildren(null, null).size());
+    }
+
+    public void testDocument() throws Exception {
+        Connection conn = repo.getConnection(null);
+        Folder root = conn.getRootFolder();
+        Document d1 = root.newDocument("doc");
+        assertEquals(23 + 3, d1.getType().getPropertyDefinitions().size());
+        d1.save();
+        String d1Id = d1.getId();
+        assertEquals(root.getId(), d1.getParent().getId());
+        d1.setValue("title", "Yo!");
+        assertEquals("Yo!", d1.getString("title"));
+        // refetch
+        d1 = (Document) conn.getObject(d1Id, null);
+        assertEquals("Yo!", d1.getString("title"));
+        Property prop = d1.getProperty("title");
+        assertNotNull(prop);
+        assertEquals("Yo!", prop.getValue());
+        assertNotNull(d1.getProperties());
+    }
+
+    public void testContentStream() throws Exception {
+        Connection conn = repo.getConnection(null);
+        Folder root = conn.getRootFolder();
+        Document d1 = root.newDocument("doc");
+        String string = "Houston, we have a problem...";
+        ContentStream cs = new SimpleContentStream(string.getBytes("UTF-8"),
+                "text/plain", "houston.txt", new URI(
+                        "http://houston.example.com"));
+
+        d1.setContentStream(cs);
+        d1.save();
+        cs = d1.getContentStream();
+
+        assertEquals(29, cs.getLength());
+        assertEquals("text/plain", cs.getMimeType());
+        assertEquals("houston.txt", cs.getFilename());
+        assertEquals(new URI("http://houston.example.com"), cs.getURI());
+        byte[] bytes = SimpleContentStream.getBytes(cs.getStream());
+        assertEquals(string, new String(bytes, "UTF-8"));
+    }
+
+}

Propchange: jackrabbit/sandbox/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/chemistry/chemistry-commons/src/test/java/org/apache/chemistry/impl/simple/TestSimpleRepository.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: jackrabbit/sandbox/chemistry/chemistry-parent/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/chemistry/chemistry-parent/pom.xml?rev=765129&view=auto
==============================================================================
--- jackrabbit/sandbox/chemistry/chemistry-parent/pom.xml (added)
+++ jackrabbit/sandbox/chemistry/chemistry-parent/pom.xml Wed Apr 15 10:49:31 2009
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+   Copyright 2009 Nuxeo SA <http://nuxeo.com>
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <prerequisites>
+    <maven>2.0.9</maven>
+  </prerequisites>
+
+  <groupId>org.apache.chemistry</groupId>
+  <artifactId>chemistry-parent</artifactId>
+  <version>0.1-SNAPSHOT</version>
+  <name>Chemistry Parent POM</name>
+  <packaging>pom</packaging>
+
+  <build>
+    <plugins>
+      <!-- Use Java 1.5 everywhere -->
+      <plugin>
+        <inherited>true</inherited>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <target>1.5</target>
+          <source>1.5</source>
+        </configuration>
+      </plugin>
+      <!-- Enable maven-source-plugin -->
+      <plugin>
+        <inherited>true</inherited>
+        <artifactId>maven-source-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>attach-sources</id>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.apache.chemistry</groupId>
+        <artifactId>chemistry-api</artifactId>
+        <version>${version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.chemistry</groupId>
+        <artifactId>chemistry-atompub</artifactId>
+        <version>${version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.chemistry</groupId>
+        <artifactId>chemistry-atompub-server</artifactId>
+        <version>${version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.chemistry</groupId>
+        <artifactId>chemistry-commons</artifactId>
+        <version>${version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.chemistry</groupId>
+        <artifactId>chemistry-tests</artifactId>
+        <version>${version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>javax.jcr</groupId>
+        <artifactId>jcr</artifactId>
+        <version>1.0</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.abdera</groupId>
+        <artifactId>abdera-server</artifactId>
+        <version>0.4.0-incubating</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.abdera</groupId>
+        <artifactId>abdera-client</artifactId>
+        <version>0.4.0-incubating</version>
+      </dependency>
+
+      <dependency>
+        <groupId>junit</groupId>
+        <artifactId>junit</artifactId>
+        <version>3.8.2</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.mortbay.jetty</groupId>
+        <artifactId>jetty</artifactId>
+        <version>6.1.5</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.mortbay.jetty</groupId>
+        <artifactId>jetty-util</artifactId>
+        <version>6.1.5</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-api</artifactId>
+        <version>1.3.0</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-log4j12</artifactId>
+        <version>1.3.0</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>log4j</groupId>
+        <artifactId>log4j</artifactId>
+        <version>1.2.13</version>
+        <scope>test</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <repositories>
+    <repository>
+      <id>apache-incubating</id>
+      <name>Apache Incubating Repository</name>
+      <url>http://people.apache.org/repo/m2-incubating-repository</url>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+    </repository>
+  </repositories>
+
+</project>

Propchange: jackrabbit/sandbox/chemistry/chemistry-parent/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/chemistry/chemistry-tests/README.txt
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/chemistry/chemistry-tests/README.txt?rev=765129&view=auto
==============================================================================
--- jackrabbit/sandbox/chemistry/chemistry-tests/README.txt (added)
+++ jackrabbit/sandbox/chemistry/chemistry-tests/README.txt Wed Apr 15 10:49:31 2009
@@ -0,0 +1 @@
+This is a dummy in-memory implementation of the API, to be used for unit tests.

Propchange: jackrabbit/sandbox/chemistry/chemistry-tests/README.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/chemistry/chemistry-tests/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/chemistry/chemistry-tests/pom.xml?rev=765129&view=auto
==============================================================================
--- jackrabbit/sandbox/chemistry/chemistry-tests/pom.xml (added)
+++ jackrabbit/sandbox/chemistry/chemistry-tests/pom.xml Wed Apr 15 10:49:31 2009
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+   Copyright 2009 Nuxeo SA <http://nuxeo.com>
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.chemistry</groupId>
+    <artifactId>chemistry-parent</artifactId>
+    <version>0.1-SNAPSHOT</version>
+  </parent>
+  <artifactId>chemistry-tests</artifactId>
+  <name>Chemistry Tests</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.chemistry</groupId>
+      <artifactId>chemistry-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.chemistry</groupId>
+      <artifactId>chemistry-atompub-server</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.chemistry</groupId>
+      <artifactId>chemistry-commons</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.1</version>
+      <scope>compile</scope> <!-- override -->
+    </dependency>
+    <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jetty</artifactId>
+      <scope>compile</scope> <!-- override -->
+    </dependency>
+    <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jetty-util</artifactId>
+      <scope>compile</scope> <!-- override -->
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <scope>compile</scope> <!-- override -->
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>compile</scope> <!-- override -->
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <scope>compile</scope> <!-- override -->
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <configuration>
+          <descriptorRefs>
+            <descriptorRef>jar-with-dependencies</descriptorRef>
+          </descriptorRefs>
+          <archive>
+            <manifest>
+              <mainClass>org.apache.chemistry.test.MainServlet</mainClass>
+            </manifest>
+          </archive>
+        </configuration>
+        <executions>
+          <execution>
+            <id>make-assembly</id>
+            <phase>package</phase>
+            <goals>
+              <goal>single</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: jackrabbit/sandbox/chemistry/chemistry-tests/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java?rev=765129&view=auto
==============================================================================
--- jackrabbit/sandbox/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java (added)
+++ jackrabbit/sandbox/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java Wed Apr 15 10:49:31 2009
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2009 Nuxeo SA <http://nuxeo.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Florent Guillaume
+ */
+package org.apache.chemistry.test;
+
+import javax.servlet.Servlet;
+
+import org.apache.chemistry.atompub.server.CMISServlet;
+import org.apache.chemistry.repository.Repository;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+/**
+ * Test class that runs a servlet on a memory repository initialized with a few
+ * simple documents.
+ *
+ * @author Florent Guillaume
+ */
+public class MainServlet {
+
+    private static final Log log = LogFactory.getLog(MainServlet.class);
+
+    private static final int MINUTES = 60 * 1000; // in ms
+
+    public static final int PORT = 8080;
+
+    public static final String SERVLET_PATH = "/cmis";
+
+    public static final String CMIS_SERVICE = "/repository";
+
+ 
+    public static void main(String[] args) throws Exception {
+        Repository repository = RepositoryTestFactory.makeRepository();
+        Server server = new Server(PORT);
+        Servlet servlet = new CMISServlet(repository);
+        ServletHolder servletHolder = new ServletHolder(servlet);
+        Context context = new Context(server, SERVLET_PATH, Context.SESSIONS);
+        context.addServlet(servletHolder, "/*");
+        server.start();
+        String url = "http://localhost:" + PORT + SERVLET_PATH + CMIS_SERVICE;
+        log.info("CMIS server started, AtomPub service url: " + url);
+        Thread.sleep(60 * MINUTES);
+        server.stop();
+        log.info("CMIS server stopped");
+    }
+
+}

Propchange: jackrabbit/sandbox/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: jackrabbit/sandbox/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/RepositoryTestFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/RepositoryTestFactory.java?rev=765129&view=auto
==============================================================================
--- jackrabbit/sandbox/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/RepositoryTestFactory.java (added)
+++ jackrabbit/sandbox/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/RepositoryTestFactory.java Wed Apr 15 10:49:31 2009
@@ -0,0 +1,118 @@
+/*
+ * (C) Copyright 2006-2008 Nuxeo SAS (http://nuxeo.com/) and contributors.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the GNU Lesser General Public License
+ * (LGPL) version 2.1 which accompanies this distribution, and is available at
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Contributors:
+ *     matic
+ */
+package org.apache.chemistry.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+
+import org.apache.chemistry.Connection;
+import org.apache.chemistry.ContentStream;
+import org.apache.chemistry.Document;
+import org.apache.chemistry.Folder;
+import org.apache.chemistry.impl.simple.SimpleContentStream;
+import org.apache.chemistry.impl.simple.SimplePropertyDefinition;
+import org.apache.chemistry.impl.simple.SimpleRepository;
+import org.apache.chemistry.impl.simple.SimpleType;
+import org.apache.chemistry.property.PropertyType;
+import org.apache.chemistry.property.Updatability;
+import org.apache.chemistry.type.BaseType;
+import org.apache.chemistry.type.ContentStreamPresence;
+
+/**
+ * @author matic
+ *
+ */
+public class RepositoryTestFactory {
+
+    public static final String TEST_FILE_CONTENT = "This is a test file.\nTesting, testing...\n";
+
+    public static SimpleRepository makeRepository() throws IOException {
+        SimplePropertyDefinition p1 = new SimplePropertyDefinition("title",
+                "def:title", "Title", "", false, PropertyType.STRING, false,
+                null, false, false, "", Updatability.READ_WRITE, true, true, 0,
+                null, null, -1, null, null);
+        SimplePropertyDefinition p2 = new SimplePropertyDefinition(
+                "description", "def:description", "Description", "", false,
+                PropertyType.STRING, false, null, false, false, "",
+                Updatability.READ_WRITE, true, true, 0, null, null, -1, null,
+                null);
+        SimplePropertyDefinition p3 = new SimplePropertyDefinition("date",
+                "def:date", "Date", "", false, PropertyType.DATETIME, false,
+                null, false, false, null, Updatability.READ_WRITE, true, true,
+                0, null, null, -1, null, null);
+        SimpleType dt = new SimpleType("doc", "document", "Doc", "My Doc Type",
+                BaseType.DOCUMENT, "", true, true, true, true, true, true,
+                ContentStreamPresence.ALLOWED, null, null, Arrays.asList(p1,
+                        p2, p3));
+        SimpleType ft = new SimpleType("fold", "folder", "Fold",
+                "My Folder Type", BaseType.FOLDER, "", true, true, true, true,
+                false, false, ContentStreamPresence.NOT_ALLOWED, null, null,
+                Arrays.asList(p1, p2));
+        SimpleRepository repo = new SimpleRepository("test", Arrays.asList(dt,
+                ft));
+        Connection conn = repo.getConnection(null);
+        Folder root = conn.getRootFolder();
+
+        Folder folder1 = root.newFolder("fold");
+        folder1.setName("folder 1");
+        folder1.setValue("title", "The folder 1 description");
+        folder1.setValue("description", "folder 1 title");
+        folder1.save();
+
+        Folder folder2 = folder1.newFolder("fold");
+        folder2.setName("folder 2");
+        folder2.setValue("title", "The folder 2 description");
+        folder2.setValue("description", "folder 2 title");
+        folder2.save();
+
+        Document doc1 = folder1.newDocument("doc");
+        doc1.setName("doc 1");
+        doc1.setValue("title", "doc 1 title");
+        doc1.setValue("description", "The doc 1 descr");
+        doc1.save();
+
+        Document doc2 = folder2.newDocument("doc");
+        doc2.setName("doc 2");
+        doc2.setValue("title", "doc 2 title");
+        doc2.setValue("description", "The doc 2 descr");
+        doc2.save();
+
+        Document doc3 = folder2.newDocument("doc");
+        doc3.setName("doc 3");
+        doc3.setValue("title", "doc 3 title");
+        doc3.setValue("description", "The doc 3 descr");
+        ContentStream cs = new SimpleContentStream(
+                TEST_FILE_CONTENT.getBytes("UTF-8"), "text/plain", "doc3.txt",
+                null);
+        doc3.setContentStream(cs);
+        doc3.save();
+
+        Document doc4 = folder2.newDocument("doc");
+        doc4.setName("dog.jpg");
+        doc4.setValue("title", "A Dog");
+        doc4.setValue("description", "This is a small dog");
+        InputStream stream = MainServlet.class.getResourceAsStream("/dog.jpg");
+        cs = new SimpleContentStream(stream, "image/jpeg", "dog.jpg", null);
+        doc4.setContentStream(cs);
+        doc4.save();
+
+        conn.close();
+        return repo;
+    }
+
+}

Propchange: jackrabbit/sandbox/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/RepositoryTestFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/RepositoryTestFactory.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: jackrabbit/sandbox/chemistry/chemistry-tests/src/main/resources/dog.jpg
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/chemistry/chemistry-tests/src/main/resources/dog.jpg?rev=765129&view=auto
==============================================================================
Binary file - no diff available.

Propchange: jackrabbit/sandbox/chemistry/chemistry-tests/src/main/resources/dog.jpg
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: jackrabbit/sandbox/chemistry/chemistry-tests/src/main/resources/log4j.properties
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/chemistry/chemistry-tests/src/main/resources/log4j.properties?rev=765129&view=auto
==============================================================================
--- jackrabbit/sandbox/chemistry/chemistry-tests/src/main/resources/log4j.properties (added)
+++ jackrabbit/sandbox/chemistry/chemistry-tests/src/main/resources/log4j.properties Wed Apr 15 10:49:31 2009
@@ -0,0 +1,4 @@
+log4j.rootLogger=INFO, CONSOLE
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%c{1}] %m%n

Propchange: jackrabbit/sandbox/chemistry/chemistry-tests/src/main/resources/log4j.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/chemistry/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/chemistry/pom.xml?rev=765129&view=auto
==============================================================================
--- jackrabbit/sandbox/chemistry/pom.xml (added)
+++ jackrabbit/sandbox/chemistry/pom.xml Wed Apr 15 10:49:31 2009
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+   Copyright 2009 Nuxeo SA <http://nuxeo.com>
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.chemistry</groupId>
+    <artifactId>chemistry-parent</artifactId>
+    <version>0.1-SNAPSHOT</version>
+    <relativePath>chemistry-parent/pom.xml</relativePath>
+  </parent>
+
+  <artifactId>chemistry</artifactId>
+  <name>Chemistry</name>
+  <packaging>pom</packaging>
+  
+  <modules>
+    <module>chemistry-parent</module>
+    <module>chemistry-api</module>
+    <module>chemistry-commons</module>
+    <module>chemistry-tests</module>
+    <module>chemistry-backups</module>
+    <module>chemistry-atompub</module>
+    <module>chemistry-atompub-server</module>
+  </modules>
+
+</project>

Propchange: jackrabbit/sandbox/chemistry/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native