You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by dp...@apache.org on 2010/03/30 14:46:27 UTC
svn commit: r929114 -
/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java
Author: dpfister
Date: Tue Mar 30 12:46:26 2010
New Revision: 929114
URL: http://svn.apache.org/viewvc?rev=929114&view=rev
Log:
CMIS-186 - Adding folder fails: ""Read-only property: cmis:path"
Modified:
incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java
Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java?rev=929114&r1=929113&r2=929114&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java Tue Mar 30 12:46:26 2010
@@ -61,12 +61,14 @@ import org.apache.chemistry.ObjectNotFou
import org.apache.chemistry.Paging;
import org.apache.chemistry.Policy;
import org.apache.chemistry.Property;
+import org.apache.chemistry.PropertyDefinition;
import org.apache.chemistry.Relationship;
import org.apache.chemistry.Rendition;
import org.apache.chemistry.SPI;
import org.apache.chemistry.Tree;
import org.apache.chemistry.Type;
import org.apache.chemistry.Unfiling;
+import org.apache.chemistry.Updatability;
import org.apache.chemistry.VersioningState;
import org.apache.chemistry.impl.simple.SimpleListPage;
import org.apache.chemistry.impl.simple.SimpleObjectId;
@@ -686,7 +688,7 @@ class JcrConnection implements Connectio
* {@inheritDoc}
*/
public Folder getFolder(String path) {
- JcrObjectEntry entry = (JcrObjectEntry) getObjectByPath(path, null);
+ JcrObjectEntry entry = getObjectByPath(path, null);
if (entry == null) {
return null;
}
@@ -879,7 +881,29 @@ class JcrConnection implements Connectio
if (object == null) {
return null;
}
- object.setValues(properties);
+
+ Type type = object.getType();
+ for (String key : properties.keySet()) {
+ if (key.equals(Property.ID) || key.equals(Property.TYPE_ID)) {
+ continue;
+ }
+
+ PropertyDefinition pd = type.getPropertyDefinition(key);
+ Updatability updatability = pd.getUpdatability();
+ if (updatability == Updatability.ON_CREATE || updatability == Updatability.READ_ONLY) {
+ // ignore attempts to write a read-only prop, as clients
+ // may want to take an existing entry, change a few values,
+ // and write the new one
+ continue;
+ }
+ Serializable value = properties.get(key);
+ if (value == null && pd.isRequired()) {
+ throw new RuntimeException("Required property: " + key); // TODO
+ } else {
+ object.getProperty(key).setValue(value);
+ }
+ }
+
object.save();
return object;
}