diff --git a/config/alfresco/cmis-api-context.xml b/config/alfresco/cmis-api-context.xml
index 1fe1871dbd..09ba166b9e 100644
--- a/config/alfresco/cmis-api-context.xml
+++ b/config/alfresco/cmis-api-context.xml
@@ -40,7 +40,8 @@
0.7
- workspace/SpacesStore/Company Home
+ workspace://SpacesStore
+ /Company Home
@@ -69,6 +70,7 @@
alfresco/model/cmisModel.xml
+ alfresco/model/cmisTestModel.xml
@@ -91,6 +93,10 @@
+
+
+
+
diff --git a/config/alfresco/model/cmisTestModel.xml b/config/alfresco/model/cmisTestModel.xml
new file mode 100644
index 0000000000..ccfd2e7231
--- /dev/null
+++ b/config/alfresco/model/cmisTestModel.xml
@@ -0,0 +1,61 @@
+
+
+
+
+ CMIS Custom Model
+ Alfresco
+ 1.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Custom Folder
+ cm:folder
+
+
+ Custom Folder Property (string)
+ d:text
+
+
+
+
+
+ Custom Document
+ cm:content
+
+
+ Custom Document Property (string)
+ d:text
+
+
+ Custom Document Property (multi-valued boolean)
+ d:boolean
+ true
+
+
+
+
+
+ false
+ false
+
+
+ cm:content
+ false
+ true
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config/alfresco/version.properties b/config/alfresco/version.properties
index 3d2a7daeb7..ed35ed7563 100644
--- a/config/alfresco/version.properties
+++ b/config/alfresco/version.properties
@@ -11,11 +11,11 @@ version.label=r2
# Edition label
-version.edition=Enterprise
+version.edition=Community
# Build number
-version.build=r17008
+version.build=@build-number@
# Schema number
diff --git a/source/java/org/alfresco/cmis/CMISObjectReference.java b/source/java/org/alfresco/cmis/CMISObjectReference.java
new file mode 100644
index 0000000000..4ba2f919ee
--- /dev/null
+++ b/source/java/org/alfresco/cmis/CMISObjectReference.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2005-2008 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.cmis;
+
+import org.alfresco.service.cmr.repository.NodeRef;
+
+/**
+ * CMIS Object Reference (mapping to Node Ref)
+ *
+ * @author davidc
+ */
+public interface CMISObjectReference
+{
+ /**
+ * @return repository reference
+ */
+ public CMISRepositoryReference getRepositoryReference();
+
+ /**
+ * @return node reference
+ */
+ public NodeRef getNodeRef();
+}
diff --git a/source/java/org/alfresco/cmis/CMISRelationshipReference.java b/source/java/org/alfresco/cmis/CMISRelationshipReference.java
new file mode 100644
index 0000000000..aa29daf6b2
--- /dev/null
+++ b/source/java/org/alfresco/cmis/CMISRelationshipReference.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2005-2008 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.cmis;
+
+import org.alfresco.service.cmr.repository.AssociationRef;
+
+
+/**
+ * CMIS Relationship Reference (mapping to Association Ref)
+ *
+ * @author davidc
+ */
+public interface CMISRelationshipReference
+{
+ /**
+ * @return repository reference
+ */
+ public CMISRepositoryReference getRepositoryReference();
+
+ /**
+ * @return association reference
+ */
+ public AssociationRef getAssocRef();
+}
diff --git a/source/java/org/alfresco/cmis/CMISRepositoryReference.java b/source/java/org/alfresco/cmis/CMISRepositoryReference.java
new file mode 100644
index 0000000000..b3efb72df3
--- /dev/null
+++ b/source/java/org/alfresco/cmis/CMISRepositoryReference.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2005-2008 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.cmis;
+
+import org.alfresco.service.cmr.repository.StoreRef;
+
+
+/**
+ * CMIS Repository Reference (mapping to Store Ref)
+ *
+ * @author davidc
+ */
+public interface CMISRepositoryReference
+{
+ /**
+ * @return store reference
+ */
+ public abstract StoreRef getStoreRef();
+}
diff --git a/source/java/org/alfresco/cmis/CMISServices.java b/source/java/org/alfresco/cmis/CMISServices.java
index 5d671d65d1..29a342f55d 100644
--- a/source/java/org/alfresco/cmis/CMISServices.java
+++ b/source/java/org/alfresco/cmis/CMISServices.java
@@ -67,6 +67,15 @@ public interface CMISServices
*/
public StoreRef getDefaultRootStoreRef();
+ /**
+ * Finds a NodeRef given a repository reference
+ *
+ * @param referenceType node, path
+ * @param reference node => id, path => path
+ * @return nodeRef (or null, if not found)
+ */
+ public NodeRef getNode(String referenceType, String[] reference);
+
/**
* Query for node children
*
diff --git a/source/java/org/alfresco/cmis/mapping/CMISServicesImpl.java b/source/java/org/alfresco/cmis/mapping/CMISServicesImpl.java
index 2e2da38539..c255882bd3 100644
--- a/source/java/org/alfresco/cmis/mapping/CMISServicesImpl.java
+++ b/source/java/org/alfresco/cmis/mapping/CMISServicesImpl.java
@@ -116,6 +116,7 @@ public class CMISServicesImpl implements CMISServices, ApplicationContextAware,
private String cmisVersion = "[undefined]";
// default CMIS store and path
+ private StoreRef defaultStoreRef;
private String defaultRootPath;
private Map defaultRootNodeRefs;
@@ -134,12 +135,20 @@ public class CMISServicesImpl implements CMISServices, ApplicationContextAware,
this.cmisVersion = cmisVersion;
}
+ /**
+ * Sets the default root store
+ *
+ * @param store store_type://store_id
+ */
+ public void setDefaultStore(String store)
+ {
+ this.defaultStoreRef = new StoreRef(store);
+ }
+
/**
* Sets the default root path
*
- * store_type/store_id/path...
- *
- * @param path store_type/store_id/path...
+ * @param path path within default store
*/
public void setDefaultRootPath(String path)
{
@@ -312,8 +321,9 @@ public class CMISServicesImpl implements CMISServices, ApplicationContextAware,
return retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback()
{
public NodeRef execute() throws Exception
- {
- return repository.findNodeRef("path", defaultRootPath.split("/"));
+ {
+ String path = defaultStoreRef.getProtocol() + "/" + defaultStoreRef.getIdentifier() + defaultRootPath;
+ return repository.findNodeRef("path", path.split("/"));
};
});
}
@@ -337,6 +347,16 @@ public class CMISServicesImpl implements CMISServices, ApplicationContextAware,
return getDefaultRootNodeRef().getStoreRef();
}
+ /*
+ * (non-Javadoc)
+ * @see org.alfresco.cmis.CMISServices#getNode(java.lang.String, java.lang.String[])
+ */
+ public NodeRef getNode(String referenceType, String[] reference)
+ {
+ NodeRef nodeRef = repository.findNodeRef(referenceType, reference);
+ return nodeRef;
+ }
+
/*
* (non-Javadoc)
* @see org.alfresco.cmis.CMISServices#getChildren(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.cmis.CMISTypesFilterEnum)
diff --git a/source/java/org/alfresco/cmis/mapping/ObjectIdProperty.java b/source/java/org/alfresco/cmis/mapping/ObjectIdProperty.java
index dba8cecdc7..629c373808 100644
--- a/source/java/org/alfresco/cmis/mapping/ObjectIdProperty.java
+++ b/source/java/org/alfresco/cmis/mapping/ObjectIdProperty.java
@@ -78,7 +78,7 @@ public class ObjectIdProperty extends AbstractProperty
String versionLabel = DefaultTypeConverter.INSTANCE.convert(String.class, value);
StringBuilder builder = new StringBuilder(128);
builder.append(nodeRef.toString());
- builder.append("/");
+ builder.append(";");
builder.append(versionLabel);
return builder.toString();
}
diff --git a/source/java/org/alfresco/cmis/reference/AVMPathReference.java b/source/java/org/alfresco/cmis/reference/AVMPathReference.java
new file mode 100644
index 0000000000..6327bcf87a
--- /dev/null
+++ b/source/java/org/alfresco/cmis/reference/AVMPathReference.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.cmis.reference;
+
+import org.alfresco.cmis.CMISRepositoryReference;
+import org.alfresco.cmis.CMISServices;
+import org.alfresco.service.cmr.repository.NodeRef;
+
+
+/**
+ * AVM Path Reference
+ *
+ * @author davidc
+ */
+public class AVMPathReference extends ObjectPathReference
+{
+ /**
+ * Construct
+ *
+ * @param cmisServices
+ * @param repo
+ * @param path
+ */
+ public AVMPathReference(CMISServices cmisServices, CMISRepositoryReference repo, String path)
+ {
+ super(cmisServices, repo, path);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.alfresco.cmis.reference.ObjectPathReference#getNodeRef()
+ */
+ public NodeRef getNodeRef()
+ {
+ return cmisServices.getNode("avmpath", reference);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "AVMPathReference[storeRef=" + repo.getStoreRef() + ",path=" + path + "]";
+ }
+
+}
diff --git a/source/java/org/alfresco/cmis/reference/AbstractObjectReference.java b/source/java/org/alfresco/cmis/reference/AbstractObjectReference.java
new file mode 100644
index 0000000000..8c59e2494a
--- /dev/null
+++ b/source/java/org/alfresco/cmis/reference/AbstractObjectReference.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.cmis.reference;
+
+import org.alfresco.cmis.CMISObjectReference;
+import org.alfresco.cmis.CMISRepositoryReference;
+import org.alfresco.cmis.CMISServices;
+
+
+/**
+ * Abstract Object Reference
+ *
+ * @author davidc
+ */
+public abstract class AbstractObjectReference implements CMISObjectReference
+{
+ protected CMISServices cmisServices;
+ protected CMISRepositoryReference repo;
+
+ /**
+ * Construct
+ *
+ * @param cmisServices
+ * @param repo
+ */
+ public AbstractObjectReference(CMISServices cmisServices, CMISRepositoryReference repo)
+ {
+ this.cmisServices = cmisServices;
+ this.repo = repo;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.alfresco.cmis.CMISObjectReference#getRepositoryReference()
+ */
+ public CMISRepositoryReference getRepositoryReference()
+ {
+ return repo;
+ }
+}
diff --git a/source/java/org/alfresco/cmis/reference/AbstractRepositoryReference.java b/source/java/org/alfresco/cmis/reference/AbstractRepositoryReference.java
new file mode 100644
index 0000000000..389fa6d519
--- /dev/null
+++ b/source/java/org/alfresco/cmis/reference/AbstractRepositoryReference.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.cmis.reference;
+
+import org.alfresco.cmis.CMISRepositoryReference;
+import org.alfresco.cmis.CMISServices;
+
+
+/**
+ * Abstract Repository Reference
+ *
+ * @author davidc
+ */
+public abstract class AbstractRepositoryReference implements CMISRepositoryReference
+{
+ protected CMISServices cmisServices;
+
+ /**
+ * Construct
+ *
+ * @param cmisServices
+ */
+ public AbstractRepositoryReference(CMISServices cmisServices)
+ {
+ this.cmisServices = cmisServices;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getStoreRef().toString();
+ }
+
+}
diff --git a/source/java/org/alfresco/cmis/reference/DefaultRepositoryReference.java b/source/java/org/alfresco/cmis/reference/DefaultRepositoryReference.java
new file mode 100644
index 0000000000..fdeb04bbca
--- /dev/null
+++ b/source/java/org/alfresco/cmis/reference/DefaultRepositoryReference.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.cmis.reference;
+
+import org.alfresco.cmis.CMISServices;
+import org.alfresco.service.cmr.repository.StoreRef;
+
+
+/**
+ * Default Repository Reference
+ *
+ * @author davidc
+ */
+public class DefaultRepositoryReference extends AbstractRepositoryReference
+{
+ /**
+ * Construct
+ *
+ * @param cmisServices
+ */
+ public DefaultRepositoryReference(CMISServices cmisServices)
+ {
+ super(cmisServices);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.alfresco.cmis.CMISRepositoryReference#getStoreRef()
+ */
+ public StoreRef getStoreRef()
+ {
+ return cmisServices.getDefaultRootStoreRef();
+ }
+
+}
diff --git a/source/java/org/alfresco/cmis/reference/NodeRefReference.java b/source/java/org/alfresco/cmis/reference/NodeRefReference.java
new file mode 100644
index 0000000000..03f524754e
--- /dev/null
+++ b/source/java/org/alfresco/cmis/reference/NodeRefReference.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.cmis.reference;
+
+import java.util.regex.Pattern;
+
+import org.alfresco.cmis.CMISObjectReference;
+import org.alfresco.cmis.CMISRepositoryReference;
+import org.alfresco.cmis.CMISServices;
+import org.alfresco.service.cmr.repository.NodeRef;
+
+/**
+ * NodeRef Object Reference
+ *
+ * NOTE: Also takes into account versioned NodeRefs - protocol://store/id;version
+ *
+ * @author davidc
+ */
+public class NodeRefReference implements CMISObjectReference
+{
+ // versioned objectId pattern
+ // TODO: encapsulate elsewhere
+ private static final Pattern versionedNodeRefPattern = Pattern.compile(".+://.+/.+;.+");
+ private ObjectIdReference reference;
+
+ /**
+ * Construct
+ *
+ * @param cmisServices
+ * @param nodeRef
+ * @param version
+ */
+ public NodeRefReference(CMISServices cmisServices, NodeRef nodeRef, String version)
+ {
+ CMISRepositoryReference repo = new StoreRepositoryReference(cmisServices, nodeRef.getStoreRef());
+ reference = new ObjectIdReference(cmisServices, repo, nodeRef.getId() + ";" + version);
+ }
+
+ /**
+ * Construct
+ *
+ * @param cmisServices
+ * @param nodeRefStr
+ */
+ public NodeRefReference(CMISServices cmisServices, String nodeRefStr)
+ {
+ NodeRef nodeRef;
+ String version = null;
+ if (versionedNodeRefPattern.matcher(nodeRefStr).matches())
+ {
+ int vIdx = nodeRefStr.lastIndexOf(";");
+ nodeRef = new NodeRef(nodeRefStr.substring(0, vIdx));
+ version = nodeRefStr.substring(vIdx +1);
+ }
+ else
+ {
+ nodeRef = new NodeRef(nodeRefStr);
+ }
+
+ CMISRepositoryReference repo = new StoreRepositoryReference(cmisServices, nodeRef.getStoreRef());
+ reference = new ObjectIdReference(cmisServices, repo, nodeRef.getId() + ";" + version);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.alfresco.cmis.CMISObjectReference#getRepositoryReference()
+ */
+ public CMISRepositoryReference getRepositoryReference()
+ {
+ return reference.getRepositoryReference();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.alfresco.cmis.CMISObjectReference#getNodeRef()
+ */
+ public NodeRef getNodeRef()
+ {
+ return reference.getNodeRef();
+ }
+
+ @Override
+ public String toString()
+ {
+ return reference.toString();
+ }
+
+}
diff --git a/source/java/org/alfresco/cmis/reference/ObjectIdReference.java b/source/java/org/alfresco/cmis/reference/ObjectIdReference.java
new file mode 100644
index 0000000000..58b5911f92
--- /dev/null
+++ b/source/java/org/alfresco/cmis/reference/ObjectIdReference.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.cmis.reference;
+
+import org.alfresco.cmis.CMISRepositoryReference;
+import org.alfresco.cmis.CMISServices;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.repository.StoreRef;
+
+
+/**
+ * GUID Object Reference
+ *
+ * @author davidc
+ */
+public class ObjectIdReference extends AbstractObjectReference
+{
+ private String id;
+ private String version;
+ private String[] reference;
+
+ /**
+ * Construct
+ *
+ * @param cmisServices
+ * @param repo
+ * @param id
+ */
+ public ObjectIdReference(CMISServices cmisServices, CMISRepositoryReference repo, String id)
+ {
+ super(cmisServices, repo);
+
+ int vIdx = id.lastIndexOf(";");
+ if (vIdx != -1)
+ {
+ this.id = id.substring(0, vIdx);
+ this.version = id.substring(vIdx +1);
+ }
+ else
+ {
+ this.id = id;
+ this.version = null;
+ }
+
+ StoreRef storeRef = repo.getStoreRef();
+ reference = new String[] {storeRef.getProtocol(), storeRef.getIdentifier(), this.id};
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.alfresco.cmis.CMISObjectReference#getNodeRef()
+ */
+ public NodeRef getNodeRef()
+ {
+ return cmisServices.getNode("node", reference);
+ }
+
+ /**
+ * @return id
+ */
+ public String getId()
+ {
+ return id;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "ObjectIdReference[storeRef=" + repo.getStoreRef() + ",id=" + id + ",v=" + (version == null ? "" : version) + "]";
+ }
+
+}
diff --git a/source/java/org/alfresco/cmis/reference/ObjectPathReference.java b/source/java/org/alfresco/cmis/reference/ObjectPathReference.java
new file mode 100644
index 0000000000..c8002f540a
--- /dev/null
+++ b/source/java/org/alfresco/cmis/reference/ObjectPathReference.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.cmis.reference;
+
+import org.alfresco.cmis.CMISRepositoryReference;
+import org.alfresco.cmis.CMISServices;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.repository.StoreRef;
+
+
+/**
+ * Path Object Reference
+ *
+ * @author davidc
+ */
+public class ObjectPathReference extends AbstractObjectReference
+{
+ protected String path;
+ protected String[] reference;
+
+ /**
+ * Construct
+ *
+ * @param cmisServices
+ * @param repo
+ * @param path
+ */
+ public ObjectPathReference(CMISServices cmisServices, CMISRepositoryReference repo, String path)
+ {
+ super(cmisServices, repo);
+ this.path = path.startsWith("/") ? path : "/" + path;
+ this.path = (!cmisServices.getDefaultRootPath().equals("/")) ? cmisServices.getDefaultRootPath() + this.path : this.path;
+ String[] splitPath = this.path.split("/");
+ String[] pathSegments = new String[splitPath.length -1];
+ System.arraycopy(splitPath, 1, pathSegments, 0, splitPath.length -1);
+ this.reference = new String[2 + pathSegments.length];
+ StoreRef storeRef = repo.getStoreRef();
+ reference[0] = storeRef.getProtocol();
+ reference[1] = storeRef.getIdentifier();
+ System.arraycopy(pathSegments, 0, reference, 2, pathSegments.length);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.alfresco.cmis.CMISObjectReference#getNodeRef()
+ */
+ public NodeRef getNodeRef()
+ {
+ return cmisServices.getNode("path", reference);
+ }
+
+ /**
+ * @return path
+ */
+ public String getPath()
+ {
+ return path;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "ObjectPathReference[storeRef=" + repo.getStoreRef() + ",path=" + path + "]";
+ }
+
+}
diff --git a/source/java/org/alfresco/cmis/reference/ReferenceFactory.java b/source/java/org/alfresco/cmis/reference/ReferenceFactory.java
new file mode 100644
index 0000000000..95976d3746
--- /dev/null
+++ b/source/java/org/alfresco/cmis/reference/ReferenceFactory.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.cmis.reference;
+
+import java.util.Map;
+
+import org.alfresco.cmis.CMISDictionaryModel;
+import org.alfresco.cmis.CMISDictionaryService;
+import org.alfresco.cmis.CMISObjectReference;
+import org.alfresco.cmis.CMISRelationshipReference;
+import org.alfresco.cmis.CMISRepositoryReference;
+import org.alfresco.cmis.CMISServices;
+import org.alfresco.cmis.CMISTypeDefinition;
+import org.alfresco.error.AlfrescoRuntimeException;
+
+
+/**
+ * Reference Factory
+ *
+ * @author davidc
+ */
+public class ReferenceFactory
+{
+ private CMISServices cmisService;
+ private CMISDictionaryService cmisDictionary;
+
+ /**
+ * @param cmisService
+ */
+ public void setCMISService(CMISServices cmisService)
+ {
+ this.cmisService = cmisService;
+ }
+
+ /**
+ * @param cmisDictionary
+ */
+ public void setCMISDictionaryService(CMISDictionaryService cmisDictionary)
+ {
+ this.cmisDictionary = cmisDictionary;
+ }
+
+ /**
+ * Create CMIS Repository Reference from URL segments
+ *
+ * @param args url arguments
+ * @param templateArgs url template arguments
+ * @return Repository Reference (or null, in case of bad url)
+ */
+ public CMISRepositoryReference createRepoReferenceFromUrl(Map args, Map templateArgs)
+ {
+ String store_type = templateArgs.get("store_type");
+ String store_id = templateArgs.get("store_id");
+ if (store_type != null && store_id != null)
+ {
+ return new StoreRepositoryReference(cmisService, store_type + ":" + store_id);
+ }
+
+ String store = templateArgs.get("store");
+ if (store != null)
+ {
+ return new StoreRepositoryReference(cmisService, store);
+ }
+
+ // TODO: repository id
+// String repoId = templateArgs.get("repo");
+// else if (repoId != null)
+// {
+// }
+
+ return new DefaultRepositoryReference(cmisService);
+ }
+
+ /**
+ * Create CMIS Object Reference from URL segments
+ *
+ * @param args url arguments
+ * @param templateArgs url template arguments
+ * @return Repository Reference (or null, in case of bad url)
+ */
+ public CMISObjectReference createObjectReferenceFromUrl(Map args, Map templateArgs)
+ {
+ String nodeRef = args.get("noderef");
+ if (nodeRef != null)
+ {
+ return new NodeRefReference(cmisService, nodeRef);
+ }
+
+ CMISRepositoryReference repo = createRepoReferenceFromUrl(args, templateArgs);
+ String id = templateArgs.get("id");
+ if (id != null)
+ {
+ return new ObjectIdReference(cmisService, repo, id);
+ }
+
+ String path = templateArgs.get("path");
+ if (path == null)
+ {
+ path = args.get("path");
+ }
+ if (path != null)
+ {
+ return new ObjectPathReference(cmisService, repo, path);
+ }
+
+ String avmPath = templateArgs.get("avmpath");
+ if (avmPath != null)
+ {
+ return new AVMPathReference(cmisService, repo, avmPath);
+ }
+
+ return null;
+ }
+
+ /**
+ * Create CMIS Relationship Reference from URL segments
+ *
+ * @param args url arguments
+ * @param templateArgs url template arguments
+ * @return Repository Reference (or null, in case of bad url)
+ */
+ public CMISRelationshipReference createRelationshipReferenceFromUrl(Map args, Map templateArgs)
+ {
+ // retrieve relationship type definition
+ CMISTypeDefinition typeDefinition = null;
+ String relType = templateArgs.get("rel_type");
+ if (relType != null)
+ {
+ try
+ {
+ typeDefinition = cmisDictionary.findType(relType);
+ }
+ catch(AlfrescoRuntimeException e) {}
+ }
+ if (typeDefinition == null)
+ {
+ return null;
+ }
+ if (!typeDefinition.getBaseType().getTypeId().equals(CMISDictionaryModel.RELATIONSHIP_TYPE_ID))
+ {
+ return null;
+ }
+
+ // retrieve source / target nodes
+ String srcStore = templateArgs.get("store");
+ String srcId = templateArgs.get("id");
+ String tgtStore = templateArgs.get("target_store");
+ String tgtId = templateArgs.get("target_id");
+
+ if (srcStore != null && srcId != null && tgtStore != null && tgtId != null)
+ {
+ return new SourceTypeTargetRelationshipReference(cmisService, typeDefinition, srcStore, srcId, tgtStore, tgtId);
+ }
+
+ return null;
+ }
+
+}
diff --git a/source/java/org/alfresco/cmis/reference/SourceTypeTargetRelationshipReference.java b/source/java/org/alfresco/cmis/reference/SourceTypeTargetRelationshipReference.java
new file mode 100644
index 0000000000..950311c016
--- /dev/null
+++ b/source/java/org/alfresco/cmis/reference/SourceTypeTargetRelationshipReference.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.cmis.reference;
+
+import org.alfresco.cmis.CMISRelationshipReference;
+import org.alfresco.cmis.CMISRepositoryReference;
+import org.alfresco.cmis.CMISServices;
+import org.alfresco.cmis.CMISTypeDefinition;
+import org.alfresco.service.cmr.repository.AssociationRef;
+import org.alfresco.service.cmr.repository.NodeRef;
+
+
+/**
+ * Source Node / Rel Type / Target Node Relationship Reference
+ *
+ * @author davidc
+ */
+public class SourceTypeTargetRelationshipReference implements CMISRelationshipReference
+{
+ protected CMISServices cmisServices;
+ protected StoreRepositoryReference repo;
+ protected CMISTypeDefinition type;
+ protected NodeRef source;
+ protected NodeRef target;
+
+
+ /**
+ * Construct
+ *
+ * @param cmisServices
+ * @param type
+ * @param srcStore
+ * @param srcId
+ * @param tgtStore
+ * @param tgtId
+ */
+ public SourceTypeTargetRelationshipReference(CMISServices cmisServices, CMISTypeDefinition type, String srcStore, String srcId, String tgtStore, String tgtId)
+ {
+ this.cmisServices = cmisServices;
+ this.repo = new StoreRepositoryReference(cmisServices, srcStore);
+ this.type = type;
+ this.source = new NodeRef(repo.getStoreRef(), srcId);
+ StoreRepositoryReference tgtStoreRef = new StoreRepositoryReference(cmisServices, tgtStore);
+ this.target = new NodeRef(tgtStoreRef.getStoreRef(), tgtId);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.alfresco.cmis.CMISRelationshipReference#getRepositoryReference()
+ */
+ public CMISRepositoryReference getRepositoryReference()
+ {
+ return repo;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.alfresco.cmis.CMISRelationshipReference#getAssocRef()
+ */
+ public AssociationRef getAssocRef()
+ {
+ return cmisServices.getRelationship(type, source, target);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "SourceTypeTargetRelationshipReference[type=" + type.getTypeId().getId() + ",source=" + source.toString() + ",target=" + target.toString() + "]";
+ }
+
+}
diff --git a/source/java/org/alfresco/cmis/reference/StoreRepositoryReference.java b/source/java/org/alfresco/cmis/reference/StoreRepositoryReference.java
new file mode 100644
index 0000000000..4fa3bc8eef
--- /dev/null
+++ b/source/java/org/alfresco/cmis/reference/StoreRepositoryReference.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.cmis.reference;
+
+import org.alfresco.cmis.CMISServices;
+import org.alfresco.service.cmr.repository.StoreRef;
+
+
+/**
+ * Store Ref Repository Reference
+ *
+ * @author davidc
+ */
+public class StoreRepositoryReference extends AbstractRepositoryReference
+{
+ private StoreRef storeRef;
+
+ /**
+ * Construct
+ *
+ * @param cmisServices
+ * @param storeRef
+ */
+ public StoreRepositoryReference(CMISServices cmisServices, StoreRef storeRef)
+ {
+ super(cmisServices);
+ this.storeRef = storeRef;
+ }
+
+ /**
+ * Construct
+ *
+ * @param cmisServices
+ * @param store accept storeType://storeId, storeType:storeId, storeId
+ */
+ public StoreRepositoryReference(CMISServices cmisServices, String store)
+ {
+ super(cmisServices);
+
+ if (store.indexOf(StoreRef.URI_FILLER) != -1)
+ {
+ storeRef = new StoreRef(store);
+ }
+ else if (store.indexOf(':') != -1)
+ {
+ String[] storeParts = store.split(":");
+ storeRef = new StoreRef(storeParts[0], storeParts[1]);
+ }
+ else
+ {
+ storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, store);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.alfresco.cmis.CMISRepositoryReference#getStoreRef()
+ */
+ public StoreRef getStoreRef()
+ {
+ return storeRef;
+ }
+
+}