You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2009/04/06 15:03:24 UTC
svn commit: r762319 - in
/jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi:
client/ClientNode.java client/ClientProperty.java
value/SerialValueFactory.java
Author: jukka
Date: Mon Apr 6 13:03:24 2009
New Revision: 762319
URL: http://svn.apache.org/viewvc?rev=762319&view=rev
Log:
JCRRMI-17: Multiple TCK test failures
Avoid duplicating the String[] to Value[] conversion code.
Streamlined some remote method calls.
Modified:
jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientNode.java
jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientProperty.java
jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/SerialValueFactory.java
Modified: jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientNode.java?rev=762319&r1=762318&r2=762319&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientNode.java (original)
+++ jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientNode.java Mon Apr 6 13:03:24 2009
@@ -18,9 +18,7 @@
import java.io.InputStream;
import java.rmi.RemoteException;
-import java.util.ArrayList;
import java.util.Calendar;
-import java.util.List;
import javax.jcr.Item;
import javax.jcr.ItemVisitor;
@@ -122,7 +120,7 @@
throws RepositoryException {
try {
if (value == null) {
- remote.setProperty(name, (Value) null);
+ remote.setProperty(name, value);
return null;
} else {
RemoteProperty property = remote.setProperty(
@@ -139,7 +137,7 @@
throws RepositoryException {
try {
if (values == null) {
- remote.setProperty(name, (Value[]) null);
+ remote.setProperty(name, values);
return null;
} else {
Value[] serials = SerialValueFactory.makeSerialValueArray(values);
@@ -154,18 +152,17 @@
/** {@inheritDoc} */
public Property setProperty(String name, String[] strings)
throws RepositoryException {
- if (strings == null) {
- return setProperty(name, (Value[]) null);
- } else {
- List values = new ArrayList();
- for (int i = 0; i < strings.length; i++) {
- if (strings[i] != null) {
- values.add(getSession().getValueFactory().createValue(
- strings[i]));
- }
+ try {
+ if (strings == null) {
+ remote.setProperty(name, (Value[]) null);
+ return null;
+ } else {
+ Value[] serials = SerialValueFactory.makeSerialValueArray(strings);
+ RemoteProperty property = remote.setProperty(name, serials);
+ return getFactory().getProperty(getSession(), property);
}
- return setProperty(
- name, (Value[]) values.toArray(new Value[values.size()]));
+ } catch (RemoteException ex) {
+ throw new RemoteRepositoryException(ex);
}
}
@@ -526,11 +523,18 @@
/** {@inheritDoc} */
public Property setProperty(String name, String[] strings, int type)
throws RepositoryException {
- Value[] values = new Value[strings.length];
- for (int i = 0; i < strings.length; i++) {
- values[i] = getSession().getValueFactory().createValue(strings[i]);
+ try {
+ if (strings == null) {
+ remote.setProperty(name, (Value[]) null);
+ return null;
+ } else {
+ Value[] serials = SerialValueFactory.makeSerialValueArray(strings);
+ RemoteProperty property = remote.setProperty(name, serials, type);
+ return getFactory().getProperty(getSession(), property);
+ }
+ } catch (RemoteException ex) {
+ throw new RemoteRepositoryException(ex);
}
- return setProperty(name, values, type);
}
/** {@inheritDoc} */
Modified: jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientProperty.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientProperty.java?rev=762319&r1=762318&r2=762319&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientProperty.java (original)
+++ jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientProperty.java Mon Apr 6 13:03:24 2009
@@ -18,9 +18,7 @@
import java.io.InputStream;
import java.rmi.RemoteException;
-import java.util.ArrayList;
import java.util.Calendar;
-import java.util.List;
import javax.jcr.ItemNotFoundException;
import javax.jcr.ItemVisitor;
@@ -30,7 +28,6 @@
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Value;
-import javax.jcr.ValueFactory;
import javax.jcr.ValueFormatException;
import javax.jcr.nodetype.PropertyDefinition;
@@ -241,34 +238,27 @@
}
/**
- * Sets the string values of this property. Implemented as
- * setValue(new Value[] { new StringValue(strings[0]), ... }).
- *
* {@inheritDoc}
*/
public void setValue(String[] strings) throws RepositoryException {
- if (strings == null) {
- setValue((Value[]) null);
- } else {
- ValueFactory factory = getSession().getValueFactory();
- List values = new ArrayList(strings.length);
- for (int i = 0; i < strings.length; i++) {
- if (strings[i] != null) {
- values.add(factory.createValue(strings[i]));
- }
+ try {
+ Value[] values = null;
+ if (strings != null) {
+ values = SerialValueFactory.makeSerialValueArray(strings);
}
- setValue((Value[]) values.toArray(new Value[values.size()]));
+ remote.setValue(values);
+ } catch (RemoteException ex) {
+ throw new RemoteRepositoryException(ex);
}
}
/** {@inheritDoc} */
public void setValue(Value value) throws RepositoryException {
try {
- if (value == null) {
- remote.setValue((Value) null);
- } else {
- remote.setValue(SerialValueFactory.makeSerialValue(value));
+ if (value != null) {
+ value = SerialValueFactory.makeSerialValue(value);
}
+ remote.setValue(value);
} catch (RemoteException ex) {
throw new RemoteRepositoryException(ex);
}
@@ -277,11 +267,10 @@
/** {@inheritDoc} */
public void setValue(Value[] values) throws RepositoryException {
try {
- if (values == null) {
- remote.setValue((Value[]) null);
- } else {
- remote.setValue(SerialValueFactory.makeSerialValueArray(values));
+ if (values != null) {
+ values = SerialValueFactory.makeSerialValueArray(values);
}
+ remote.setValue(values);
} catch (RemoteException ex) {
throw new RemoteRepositoryException(ex);
}
Modified: jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/SerialValueFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/SerialValueFactory.java?rev=762319&r1=762318&r2=762319&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/SerialValueFactory.java (original)
+++ jackrabbit/commons/jcr-rmi/trunk/jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/value/SerialValueFactory.java Mon Apr 6 13:03:24 2009
@@ -100,6 +100,28 @@
}
/**
+ * Utility method for converting an array of strings to serializable
+ * string values.
+ * <p>
+ * If the given array is <code>null</code>, then an empty array is
+ * returned.
+ *
+ * @param values the string array
+ * @return array of string values
+ */
+ public static Value[] makeSerialValueArray(String[] values) {
+ List serials = new ArrayList();
+ if (values != null) {
+ for (int i = 0; i < values.length; i++) {
+ if (values[i] != null) {
+ serials.add(INSTANCE.createValue(values[i]));
+ }
+ }
+ }
+ return (Value[]) serials.toArray(new Value[serials.size()]);
+ }
+
+ /**
* Default constructor only visible to extensions of this class. See
* class comments for details.
*/