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/09/08 18:09:45 UTC
svn commit: r812570 [23/24] - in /jackrabbit/sandbox/JCR-1456: ./
jackrabbit-api/ jackrabbit-api/src/main/appended-resources/
jackrabbit-api/src/main/appended-resources/META-INF/
jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/ jackrabb...
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeDefinitionTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeDefinitionTemplateImpl.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeDefinitionTemplateImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeDefinitionTemplateImpl.java Tue Sep 8 16:09:28 2009
@@ -16,11 +16,19 @@
*/
package org.apache.jackrabbit.spi.commons.nodetype;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import javax.jcr.nodetype.NodeDefinitionTemplate;
import javax.jcr.RepositoryException;
+import javax.jcr.NamespaceException;
import javax.jcr.nodetype.NodeDefinition;
import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.ConstraintViolationException;
/**
* A <code>NodeDefinitionTemplateImpl</code> ...
@@ -29,53 +37,77 @@
extends AbstractItemDefinitionTemplate
implements NodeDefinitionTemplate {
+ private static final Logger log = LoggerFactory.getLogger(NodeDefinitionTemplateImpl.class);
+
private NodeType[] requiredPrimaryTypes;
- private String[] requiredPrimaryTypeNames;
- private String defaultPrimaryTypeName;
+ private Name[] requiredPrimaryTypeNames;
+ private Name defaultPrimaryTypeName;
private boolean allowSameNameSiblings;
/**
* Package private constructor
*
- * @param ntBase
+ * @param resolver
* @throws RepositoryException
*/
- NodeDefinitionTemplateImpl(NodeType ntBase) throws RepositoryException {
- requiredPrimaryTypes = new NodeType[] {ntBase};
- requiredPrimaryTypeNames = new String[] {requiredPrimaryTypes[0].getName()};
+ NodeDefinitionTemplateImpl(NamePathResolver resolver) throws RepositoryException {
+ super(resolver);
+ requiredPrimaryTypes = null;
+ requiredPrimaryTypeNames = null;
}
/**
* Package private constructor
*
* @param def
+ * @param resolver
+ * @throws javax.jcr.nodetype.ConstraintViolationException
*/
- NodeDefinitionTemplateImpl(NodeDefinition def) {
- super(def);
+ NodeDefinitionTemplateImpl(NodeDefinition def, NamePathResolver resolver) throws ConstraintViolationException {
+ super(def, resolver);
requiredPrimaryTypes = def.getRequiredPrimaryTypes();
- // FIXME temporary workaround until JSR 283 has been finalized
- requiredPrimaryTypeNames = new String[requiredPrimaryTypes.length];
- for (int i = 0; i < requiredPrimaryTypes.length; i++) {
- requiredPrimaryTypeNames[i] = requiredPrimaryTypes[i].getName();
- }
- defaultPrimaryTypeName =
- def.getDefaultPrimaryType() == null ? null : def.getDefaultPrimaryType().getName();
allowSameNameSiblings = def.allowsSameNameSiblings();
+
+ if (def instanceof NodeDefinitionImpl) {
+ QNodeDefinition qDef = (QNodeDefinition) ((NodeDefinitionImpl) def).itemDef;
+ requiredPrimaryTypeNames = qDef.getRequiredPrimaryTypes();
+ defaultPrimaryTypeName = qDef.getDefaultPrimaryType();
+ } else {
+ setRequiredPrimaryTypeNames(def.getRequiredPrimaryTypeNames());
+ setDefaultPrimaryTypeName(def.getDefaultPrimaryTypeName());
+ }
}
//-----------------------------------------------< NodeDefinitionTemplate >
/**
* {@inheritDoc}
*/
- public void setRequiredPrimaryTypeNames(String[] requiredPrimaryTypeNames) {
- this.requiredPrimaryTypeNames = requiredPrimaryTypeNames;
+ public void setRequiredPrimaryTypeNames(String[] requiredPrimaryTypeNames) throws ConstraintViolationException {
+ if (requiredPrimaryTypeNames == null) {
+ throw new ConstraintViolationException("null isn't a valid array of JCR names.");
+ } else {
+ this.requiredPrimaryTypeNames = new Name[requiredPrimaryTypeNames.length];
+ for (int i = 0; i < requiredPrimaryTypeNames.length; i++) {
+ try {
+ this.requiredPrimaryTypeNames[i] = resolver.getQName(requiredPrimaryTypeNames[i]);
+ } catch (RepositoryException e) {
+ throw new ConstraintViolationException(e);
+ }
+ }
+ }
}
/**
* {@inheritDoc}
*/
- public void setDefaultPrimaryTypeName(String defaultPrimaryType) {
- this.defaultPrimaryTypeName = defaultPrimaryType;
+ public void setDefaultPrimaryTypeName(String defaultPrimaryType) throws ConstraintViolationException {
+ try {
+ this.defaultPrimaryTypeName = defaultPrimaryType == null
+ ? null
+ : resolver.getQName(defaultPrimaryType);
+ } catch (RepositoryException e) {
+ throw new ConstraintViolationException(e);
+ }
}
/**
@@ -97,7 +129,21 @@
* {@inheritDoc}
*/
public String[] getRequiredPrimaryTypeNames() {
- return requiredPrimaryTypeNames;
+ if (requiredPrimaryTypeNames == null) {
+ return null;
+ } else {
+ String[] rptNames = new String[requiredPrimaryTypeNames.length];
+ for (int i = 0; i < requiredPrimaryTypeNames.length; i++) {
+ try {
+ rptNames[i] = resolver.getJCRName(requiredPrimaryTypeNames[i]);
+ } catch (NamespaceException e) {
+ // should never get here
+ log.error("invalid node type name: " + requiredPrimaryTypeNames[i], e);
+ rptNames[i] = requiredPrimaryTypeNames[i].toString();
+ }
+ }
+ return rptNames;
+ }
}
/**
@@ -111,7 +157,17 @@
* {@inheritDoc}
*/
public String getDefaultPrimaryTypeName() {
- return defaultPrimaryTypeName;
+ if (defaultPrimaryTypeName == null) {
+ return null;
+ } else {
+ try {
+ return resolver.getJCRName(defaultPrimaryTypeName);
+ } catch (NamespaceException e) {
+ // should never get here
+ log.error("encountered unregistered namespace in default primary type name", e);
+ return defaultPrimaryTypeName.toString();
+ }
+ }
}
/**
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java Tue Sep 8 16:09:28 2009
@@ -153,6 +153,7 @@
pt.setFullTextSearchable(qPd.isFullTextSearchable());
pt.setValueConstraints(createValueConstraints(qPd.getRequiredType(), qPd.getValueConstraints()));
pt.setAvailableQueryOperators(qPd.getAvailableQueryOperators());
+ pt.setQueryOrderable(qPd.isQueryOrderable());
pt.setDefaultValues(createValues(qPd.getDefaultValues()));
return pt;
}
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionImpl.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionImpl.java Tue Sep 8 16:09:28 2009
@@ -40,7 +40,7 @@
*/
private static final Logger log = LoggerFactory.getLogger(NodeTypeDefinitionImpl.class);
- private final QNodeTypeDefinition ntd;
+ protected final QNodeTypeDefinition ntd;
private final NamePathResolver resolver;
private final ValueFactory valueFactory;
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeTemplateImpl.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeTemplateImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeTemplateImpl.java Tue Sep 8 16:09:28 2009
@@ -16,24 +16,35 @@
*/
package org.apache.jackrabbit.spi.commons.nodetype;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.util.LinkedList;
import java.util.List;
import javax.jcr.nodetype.NodeDefinition;
import javax.jcr.nodetype.NodeDefinitionTemplate;
-import javax.jcr.nodetype.NodeTypeDefinition;
import javax.jcr.nodetype.NodeTypeTemplate;
import javax.jcr.nodetype.PropertyDefinition;
import javax.jcr.nodetype.PropertyDefinitionTemplate;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NodeTypeDefinition;
+import javax.jcr.NamespaceException;
+import javax.jcr.RepositoryException;
/**
* A <code>NodeTypeTemplateImpl</code> ...
*/
public class NodeTypeTemplateImpl implements NodeTypeTemplate {
- private String name;
- private String[] superTypeNames;
- private String primaryItemName;
+ private static final Logger log = LoggerFactory.getLogger(NodeTypeTemplateImpl.class);
+
+ private Name name;
+ private Name[] superTypeNames;
+ private Name primaryItemName;
private boolean abstractStatus;
private boolean queryable;
private boolean mixin;
@@ -41,38 +52,58 @@
private List<NodeDefinitionTemplate> nodeDefinitionTemplates;
private List<PropertyDefinitionTemplate> propertyDefinitionTemplates;
+ private final NamePathResolver resolver;
+
/**
* Package private constructor
+ *
+ * @param resolver
*/
- NodeTypeTemplateImpl() {
+ NodeTypeTemplateImpl(NamePathResolver resolver) {
+ // TODO: see https://jsr-283.dev.java.net/issues/show_bug.cgi?id=798
queryable = true;
+ // TODO see https://jsr-283.dev.java.net/issues/show_bug.cgi?id=797
+ superTypeNames = new Name[0];
+ this.resolver = resolver;
}
/**
* Package private constructor
*
* @param def
+ * @param resolver
*/
- NodeTypeTemplateImpl(NodeTypeDefinition def) {
- name = def.getName();
- superTypeNames = def.getDeclaredSupertypeNames();
- primaryItemName = def.getPrimaryItemName();
+ NodeTypeTemplateImpl(NodeTypeDefinition def, NamePathResolver resolver) throws RepositoryException {
+ this.resolver = resolver;
+
+ if (def instanceof NodeTypeDefinitionImpl) {
+ QNodeTypeDefinition qDef = ((NodeTypeDefinitionImpl) def).ntd;
+ name = qDef.getName();
+ superTypeNames = qDef.getSupertypes();
+ primaryItemName = qDef.getPrimaryItemName();
+ } else {
+ setName(def.getName());
+ setDeclaredSuperTypeNames(def.getDeclaredSupertypeNames());
+ setPrimaryItemName(def.getPrimaryItemName());
+ }
+
abstractStatus = def.isAbstract();
mixin = def.isMixin();
queryable = def.isQueryable();
orderableChildNodes = def.hasOrderableChildNodes();
+
NodeDefinition[] nodeDefs = def.getDeclaredChildNodeDefinitions();
if (nodeDefs != null) {
List list = getNodeDefinitionTemplates();
for (NodeDefinition nodeDef : nodeDefs) {
- list.add(new NodeDefinitionTemplateImpl(nodeDef));
+ list.add(new NodeDefinitionTemplateImpl(nodeDef, resolver));
}
}
PropertyDefinition[] propDefs = def.getDeclaredPropertyDefinitions();
if (propDefs != null) {
List list = getPropertyDefinitionTemplates();
for (PropertyDefinition propDef : propDefs) {
- list.add(new PropertyDefinitionTemplateImpl(propDef));
+ list.add(new PropertyDefinitionTemplateImpl(propDef, resolver));
}
}
}
@@ -81,15 +112,31 @@
/**
* {@inheritDoc}
*/
- public void setName(String name) {
- this.name = name;
+ public void setName(String name) throws ConstraintViolationException {
+ try {
+ this.name = resolver.getQName(name);
+ } catch (RepositoryException e) {
+ throw new ConstraintViolationException(e);
+ }
}
/**
* {@inheritDoc}
*/
- public void setDeclaredSuperTypeNames(String[] names) {
- superTypeNames = names;
+ public void setDeclaredSuperTypeNames(String[] names) throws ConstraintViolationException {
+ // TODO see https://jsr-283.dev.java.net/issues/show_bug.cgi?id=797
+ if (names == null) {
+ throw new ConstraintViolationException("null isn't a valid array of JCR names.");
+ } else {
+ superTypeNames = new Name[names.length];
+ for (int i = 0; i < names.length; i++) {
+ try {
+ superTypeNames[i] = resolver.getQName(names[i]);
+ } catch (RepositoryException e) {
+ throw new ConstraintViolationException(e);
+ }
+ }
+ }
}
/**
@@ -116,8 +163,16 @@
/**
* {@inheritDoc}
*/
- public void setPrimaryItemName(String name) {
- primaryItemName = name;
+ public void setPrimaryItemName(String name) throws ConstraintViolationException {
+ if (name == null) {
+ primaryItemName = null;
+ } else {
+ try {
+ primaryItemName = resolver.getQName(name);
+ } catch (RepositoryException e) {
+ throw new ConstraintViolationException(e);
+ }
+ }
}
/**
@@ -152,14 +207,34 @@
* {@inheritDoc}
*/
public String getName() {
- return name;
+ if (name == null) {
+ return null;
+ } else {
+ try {
+ return resolver.getJCRName(name);
+ } catch (NamespaceException e) {
+ // should never get here
+ log.error("encountered unregistered namespace in node type name", e);
+ return name.toString();
+ }
+ }
}
/**
* {@inheritDoc}
*/
public String[] getDeclaredSupertypeNames() {
- return superTypeNames;
+ String[] names = new String[superTypeNames.length];
+ for (int i = 0; i < superTypeNames.length; i++) {
+ try {
+ names[i] = resolver.getJCRName(superTypeNames[i]);
+ } catch (NamespaceException e) {
+ // should never get here
+ log.error("encountered unregistered namespace in super type name", e);
+ names[i] = superTypeNames[i].toString();
+ }
+ }
+ return names;
}
/**
@@ -191,7 +266,17 @@
* {@inheritDoc}
*/
public String getPrimaryItemName() {
- return primaryItemName;
+ if (primaryItemName == null) {
+ return null;
+ } else {
+ try {
+ return resolver.getJCRName(primaryItemName);
+ } catch (NamespaceException e) {
+ // should never get here
+ log.error("encountered unregistered namespace in primary type name", e);
+ return primaryItemName.toString();
+ }
+ }
}
/**
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionTemplateImpl.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionTemplateImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionTemplateImpl.java Tue Sep 8 16:09:28 2009
@@ -17,11 +17,13 @@
package org.apache.jackrabbit.spi.commons.nodetype;
import org.apache.jackrabbit.spi.commons.query.qom.Operator;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
import javax.jcr.PropertyType;
import javax.jcr.Value;
import javax.jcr.nodetype.PropertyDefinition;
import javax.jcr.nodetype.PropertyDefinitionTemplate;
+import javax.jcr.nodetype.ConstraintViolationException;
/**
* A <code>PropertyDefinitionTemplateImpl</code> ...
@@ -40,8 +42,11 @@
/**
* Package private constructor
+ *
+ * @param resolver
*/
- PropertyDefinitionTemplateImpl() {
+ PropertyDefinitionTemplateImpl(NamePathResolver resolver) {
+ super(resolver);
type = PropertyType.STRING;
fullTextSearchable = true;
queryOrderable = true;
@@ -52,23 +57,29 @@
* Package private constructor
*
* @param def
+ * @param resolver
+ * @throws javax.jcr.nodetype.ConstraintViolationException
*/
- PropertyDefinitionTemplateImpl(PropertyDefinition def) {
- super(def);
+ PropertyDefinitionTemplateImpl(PropertyDefinition def, NamePathResolver resolver) throws ConstraintViolationException {
+ super(def, resolver);
type = def.getRequiredType();
- constraints = def.getValueConstraints();
defaultValues = def.getDefaultValues();
multiple = def.isMultiple();
fullTextSearchable = def.isFullTextSearchable();
queryOrderable = def.isQueryOrderable();
queryOperators = def.getAvailableQueryOperators();
+ setValueConstraints(def.getValueConstraints());
}
//-------------------------------------------< PropertyDefinitionTemplate >
/**
* {@inheritDoc}
+ *
+ * @throws IllegalArgumentException If an invalid type is passed.
*/
public void setRequiredType(int type) {
+ // validate
+ PropertyType.nameFromValue(type);
this.type = type;
}
@@ -76,6 +87,7 @@
* {@inheritDoc}
*/
public void setValueConstraints(String[] constraints) {
+ // TODO: see https://jsr-283.dev.java.net/issues/show_bug.cgi?id=794
this.constraints = constraints;
}
@@ -126,6 +138,7 @@
* {@inheritDoc}
*/
public String[] getValueConstraints() {
+ // TODO: see https://jsr-283.dev.java.net/issues/show_bug.cgi?id=794
return constraints;
}
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefReader.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefReader.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefReader.java Tue Sep 8 16:09:28 2009
@@ -118,7 +118,7 @@
* SingleQuotedString ::= ''' UnquotedString '''
* DoubleQuotedString ::= '"' UnquotedString '"'
* UnquotedString ::= XmlChar {XmlChar}
- * XmlChar ::= see ยค3.2.2 Local Names
+ * XmlChar ::= see 3.2.2 Local Names
* </pre>
*/
public class CompactNodeTypeDefReader {
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java Tue Sep 8 16:09:28 2009
@@ -331,19 +331,19 @@
if (readIf("*")) {
read(",");
c = factory.fullTextSearch(
- name, null, factory.literal(readString()));
+ name, null, parseStaticOperand());
} else {
String selector = name;
name = readName();
read(",");
c = factory.fullTextSearch(
- selector, name, factory.literal(readString()));
+ selector, name, parseStaticOperand());
}
} else {
read(",");
c = factory.fullTextSearch(
getOnlySelectorName(), name,
- factory.literal(readString()));
+ parseStaticOperand());
}
} else if ("ISSAMENODE".equalsIgnoreCase(functionName)) {
String name = readName();
@@ -455,7 +455,7 @@
}
}
if (currentTokenType == VALUE) {
- Literal literal = factory.literal(currentValue);
+ Literal literal = getUncastLiteral(currentValue);
read();
return literal;
} else if (currentTokenType == PARAMETER) {
@@ -471,10 +471,10 @@
}
return var;
} else if (readIf("TRUE")) {
- Literal literal = factory.literal(valueFactory.createValue(true));
+ Literal literal = getUncastLiteral(valueFactory.createValue(true));
return literal;
} else if (readIf("FALSE")) {
- Literal literal = factory.literal(valueFactory.createValue(false));
+ Literal literal = getUncastLiteral(valueFactory.createValue(false));
return literal;
} else if (readIf("CAST")) {
read("(");
@@ -487,6 +487,7 @@
read("AS");
value = parseCastAs(value);
read(")");
+ // CastLiteral
literal = factory.literal(value);
return literal;
} else {
@@ -494,6 +495,16 @@
}
}
+ /**
+ * Create a literal from a parsed value.
+ *
+ * @param value the original value
+ * @return the literal
+ */
+ private Literal getUncastLiteral(Value value) throws RepositoryException {
+ return factory.literal(value);
+ }
+
private Value parseCastAs(Value value) throws RepositoryException {
if (readIf("STRING")) {
return valueFactory.createValue(value.getString());
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValue.java Tue Sep 8 16:09:28 2009
@@ -16,30 +16,31 @@
*/
package org.apache.jackrabbit.spi.commons.value;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.apache.jackrabbit.spi.QValue;
import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.Path;
import org.apache.jackrabbit.util.ISO8601;
+import org.apache.commons.io.IOUtils;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.ValueFormatException;
+import javax.jcr.Binary;
+
import java.util.Calendar;
import java.util.TimeZone;
import java.math.BigDecimal;
import java.net.URI;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.Serializable;
/**
* <code>AbstractQValue</code>...
*/
-public abstract class AbstractQValue implements QValue {
+public abstract class AbstractQValue implements QValue, Serializable {
- /**
- * logger instance
- */
- private static final Logger log = LoggerFactory.getLogger(AbstractQValue.class);
+ private static final long serialVersionUID = 6976433831974695272L;
protected Object val;
protected final int type;
@@ -310,9 +311,9 @@
*/
public boolean getBoolean() throws RepositoryException {
if (type == PropertyType.BOOLEAN) {
- return ((Boolean) val).booleanValue();
+ return (Boolean) val;
} else {
- return Boolean.valueOf(getString()).booleanValue();
+ return Boolean.valueOf(getString());
}
}
@@ -332,6 +333,58 @@
}
/**
+ * @see QValue#getPath()
+ */
+ public String getString() throws RepositoryException {
+ if (type == PropertyType.BINARY) {
+ InputStream stream = getStream();
+ try {
+ return IOUtils.toString(stream, "UTF-8");
+ } catch (IOException e) {
+ throw new RepositoryException("conversion from stream to string failed", e);
+ } finally {
+ IOUtils.closeQuietly(stream);
+ }
+ } else if (type == PropertyType.DATE) {
+ return ISO8601.format(((Calendar) val));
+ } else {
+ return val.toString();
+ }
+ }
+
+ /**
+ * This implementation creates a binary instance that uses
+ * {@link #getStream()} and skipping on the given stream as its underlying
+ * mechanism to provide random access defined on {@link Binary}.
+ *
+ * @see QValue#getBinary()
+ */
+ public Binary getBinary() throws RepositoryException {
+ return new Binary() {
+ public InputStream getStream() throws RepositoryException {
+ return AbstractQValue.this.getStream();
+ }
+
+ public int read(byte[] b, long position) throws IOException, RepositoryException {
+ InputStream in = getStream();
+ try {
+ in.skip(position);
+ return in.read(b);
+ } finally {
+ in.close();
+ }
+ }
+
+ public long getSize() throws RepositoryException {
+ return getLength();
+ }
+
+ public void dispose() {
+ }
+ };
+ }
+
+ /**
* @see QValue#discard()
*/
public void discard() {
@@ -339,13 +392,18 @@
}
//---------------------------------------------------------< Object >---
+
/**
* Returns the string representation of this internal value.
*
* @return string representation of this internal value
*/
public String toString() {
- return val.toString();
+ if (type == PropertyType.DATE) {
+ return ISO8601.format((Calendar) val);
+ } else {
+ return val.toString();
+ }
}
/**
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValueFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValueFactory.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValueFactory.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/AbstractQValueFactory.java Tue Sep 8 16:09:28 2009
@@ -16,22 +16,27 @@
*/
package org.apache.jackrabbit.spi.commons.value;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.jackrabbit.spi.QValueFactory;
-import org.apache.jackrabbit.spi.QValue;
-import org.apache.jackrabbit.spi.QPropertyDefinition;
+import java.util.Calendar;
+import java.util.UUID;
+import java.math.BigDecimal;
+import java.net.URI;
+import java.io.UnsupportedEncodingException;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
+
import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.PathFactory;
import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.Path;
import org.apache.jackrabbit.spi.commons.name.NameConstants;
-import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
-import org.apache.jackrabbit.uuid.UUID;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.PropertyType;
-import java.util.Calendar;
+import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
+import org.apache.jackrabbit.util.ISO8601;
/**
* <code>AbstractQValueFactory</code>...
@@ -39,12 +44,6 @@
public abstract class AbstractQValueFactory implements QValueFactory {
/**
- * logger instance
- */
- private static final Logger log = LoggerFactory.getLogger(AbstractQValueFactory.class);
-
-
- /**
* the default encoding
*/
public static final String DEFAULT_ENCODING = "UTF-8";
@@ -58,17 +57,169 @@
* @see QValueFactory#computeAutoValues(org.apache.jackrabbit.spi.QPropertyDefinition)
*/
public QValue[] computeAutoValues(QPropertyDefinition propertyDefinition) throws RepositoryException {
- Name nodeType = propertyDefinition.getDeclaringNodeType();
+ Name declaringNT = propertyDefinition.getDeclaringNodeType();
Name name = propertyDefinition.getName();
- if ((NameConstants.NT_HIERARCHYNODE.equals(nodeType) || NameConstants.MIX_CREATED.equals(nodeType))&& NameConstants.JCR_CREATED.equals(name)) {
- return new QValue[] { create(Calendar.getInstance()) };
- } else if (NameConstants.NT_RESOURCE.equals(nodeType) && NameConstants.JCR_LASTMODIFIED.equals(name)) {
- return new QValue[] { create(Calendar.getInstance()) };
- } else if (NameConstants.MIX_REFERENCEABLE.equals(nodeType) && NameConstants.JCR_UUID.equals(name)) {
- return new QValue[] { create(UUID.randomUUID().toString(), PropertyType.STRING) };
+ if (NameConstants.JCR_UUID.equals(name)
+ && NameConstants.MIX_REFERENCEABLE.equals(declaringNT)) {
+ // jcr:uuid property of a mix:referenceable
+ return new QValue[]{create(UUID.randomUUID().toString(), PropertyType.STRING)};
+
} else {
throw new RepositoryException("createFromDefinition not implemented for: " + name);
}
}
+
+ /**
+ * @see QValueFactory#create(String, int)
+ */
+ public QValue create(String value, int type) throws RepositoryException {
+ if (value == null) {
+ throw new IllegalArgumentException("Cannot create QValue from null value.");
+ }
+
+ try {
+ switch (type) {
+ case PropertyType.BOOLEAN:
+ return create(Boolean.valueOf(value));
+ case PropertyType.DATE: {
+ Calendar cal = ISO8601.parse(value);
+ if (cal == null) {
+ throw new ValueFormatException("not a valid date: " + value);
+ }
+ return create(cal);
+ }
+ case PropertyType.DOUBLE:
+ return create(Double.valueOf(value));
+ case PropertyType.LONG:
+ return create(Long.valueOf(value));
+ case PropertyType.DECIMAL:
+ return create(new BigDecimal(value));
+ case PropertyType.URI:
+ return create(URI.create(value));
+ case PropertyType.PATH:
+ return create(PATH_FACTORY.create(value));
+ case PropertyType.NAME:
+ return create(NAME_FACTORY.create(value));
+ case PropertyType.STRING:
+ return createString(value);
+ case PropertyType.REFERENCE:
+ return createReference(value, false);
+ case PropertyType.WEAKREFERENCE:
+ return createReference(value, true);
+ case PropertyType.BINARY:
+ return create(value.getBytes(DEFAULT_ENCODING));
+ // default: invalid type specified -> see below.
+ }
+ } catch (IllegalArgumentException ex) {
+ // given String value cannot be converted to Long/Double/Path/Name
+ throw new ValueFormatException(ex);
+ } catch (UnsupportedEncodingException ex) {
+ throw new RepositoryException(ex);
+ }
+
+ // invalid type specified:
+ throw new IllegalArgumentException("illegal type " + type);
+ }
+
+ /**
+ * @see QValueFactory#create(Calendar)
+ */
+ public QValue create(Calendar value) throws RepositoryException {
+ if (value == null) {
+ throw new IllegalArgumentException("Cannot create QValue from null value.");
+ }
+ // Calendar is not constant, must create a clone
+ return new DefaultQValue((Calendar) value.clone());
+ }
+
+ /**
+ * @see QValueFactory#create(double)
+ */
+ public QValue create(double value) throws RepositoryException {
+ return new DefaultQValue(value);
+ }
+
+ /**
+ * @see QValueFactory#create(long)
+ */
+ public QValue create(long value) throws RepositoryException {
+ return new DefaultQValue(value);
+ }
+
+ /**
+ * @see QValueFactory#create(boolean)
+ */
+ public QValue create(boolean value) throws RepositoryException {
+ if (value) {
+ return DefaultQValue.TRUE;
+ } else {
+ return DefaultQValue.FALSE;
+ }
+ }
+
+ /**
+ * @see QValueFactory#create(Name)
+ */
+ public QValue create(Name value) throws RepositoryException {
+ if (value == null) {
+ throw new IllegalArgumentException("Cannot create QValue from null value.");
+ }
+ return new DefaultQValue(value);
+ }
+
+ /**
+ * @see QValueFactory#create(Path)
+ */
+ public QValue create(Path value) throws RepositoryException {
+ if (value == null) {
+ throw new IllegalArgumentException("Cannot create QValue from null value.");
+ }
+ return new DefaultQValue(value);
+ }
+
+ /**
+ * @see QValueFactory#create(URI)
+ */
+ public QValue create(URI value) throws RepositoryException {
+ if (value == null) {
+ throw new IllegalArgumentException("Cannot create QValue from null value.");
+ }
+ return new DefaultQValue(value);
+ }
+
+ /**
+ * @see QValueFactory#create(URI)
+ */
+ public QValue create(BigDecimal value) throws RepositoryException {
+ if (value == null) {
+ throw new IllegalArgumentException("Cannot create QValue from null value.");
+ }
+ return new DefaultQValue(value);
+ }
+
+ /**
+ * Creates a new QValue of type STRING.
+ *
+ * @param value the string value.
+ * @return a new QValue.
+ */
+ protected QValue createString(String value) {
+ return new DefaultQValue(value, PropertyType.STRING);
+ }
+
+ /**
+ * Creates a new QValue of type REFERENCE or WEAKREFERENCE.
+ *
+ * @param ref the reference value.
+ * @param weak whether the reference is weak.
+ * @return a new QValue.
+ */
+ protected QValue createReference(String ref, boolean weak) {
+ if (weak) {
+ return new DefaultQValue(ref, PropertyType.WEAKREFERENCE);
+ } else {
+ return new DefaultQValue(ref, PropertyType.REFERENCE);
+ }
+ }
}
\ No newline at end of file
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueFactoryImpl.java Tue Sep 8 16:09:28 2009
@@ -20,15 +20,11 @@
import org.apache.jackrabbit.spi.Path;
import org.apache.jackrabbit.spi.QValue;
import org.apache.jackrabbit.spi.QValueFactory;
-import org.apache.jackrabbit.util.ISO8601;
import org.apache.jackrabbit.util.TransientFileFactory;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
-import javax.jcr.ValueFormatException;
-import javax.jcr.Binary;
import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -39,157 +35,22 @@
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
-import java.io.RandomAccessFile;
import java.util.Arrays;
-import java.util.Calendar;
-import java.math.BigDecimal;
-import java.net.URI;
-import java.net.URISyntaxException;
/**
* <code>QValueFactoryImpl</code>...
*/
-public final class QValueFactoryImpl extends AbstractQValueFactory {
+public class QValueFactoryImpl extends AbstractQValueFactory {
private static final QValueFactory INSTANCE = new QValueFactoryImpl();
- private QValueFactoryImpl() {
+ protected QValueFactoryImpl() {
}
public static QValueFactory getInstance() {
return INSTANCE;
}
- //------------------------------------------------------< QValueFactory >---
- /**
- * @see QValueFactory#create(String, int)
- */
- public QValue create(String value, int type) throws RepositoryException {
- if (value == null) {
- throw new IllegalArgumentException("Cannot create QValue from null value.");
- }
-
- try {
- switch (type) {
- case PropertyType.BOOLEAN:
- return (Boolean.valueOf(value).booleanValue()) ?
- QValueImpl.TRUE :
- QValueImpl.FALSE;
- case PropertyType.DATE: {
- Calendar cal = ISO8601.parse(value);
- if (cal == null) {
- throw new ValueFormatException("not a valid date: " + value);
- }
- return new DateQValue(cal);
- }
- case PropertyType.DOUBLE:
- return new QValueImpl(Double.valueOf(value));
- case PropertyType.LONG:
- return new QValueImpl(Long.valueOf(value));
- case PropertyType.DECIMAL:
- return new QValueImpl(new BigDecimal(value));
- case PropertyType.URI:
- return new QValueImpl(URI.create(value));
- case PropertyType.PATH:
- return new QValueImpl(PATH_FACTORY.create(value));
- case PropertyType.NAME:
- return new QValueImpl(NAME_FACTORY.create(value));
- case PropertyType.STRING:
- case PropertyType.REFERENCE:
- case PropertyType.WEAKREFERENCE:
- return new QValueImpl(value, type);
- case PropertyType.BINARY:
- return new BinaryQValue(value.getBytes(DEFAULT_ENCODING));
- // default: invalid type specified -> see below.
- }
- } catch (IllegalArgumentException ex) {
- // given String value cannot be converted to Long/Double/Path/Name
- throw new ValueFormatException(ex);
- } catch (UnsupportedEncodingException ex) {
- throw new RepositoryException(ex);
- }
-
- // invalid type specified:
- throw new IllegalArgumentException("illegal type " + type);
- }
-
- /**
- * @see QValueFactory#create(Calendar)
- */
- public QValue create(Calendar value) {
- if (value == null) {
- throw new IllegalArgumentException("Cannot create QValue from null value.");
- }
- // Calendar is not constant, must create a clone
- return new DateQValue((Calendar) value.clone());
- }
-
- /**
- * @see QValueFactory#create(double)
- */
- public QValue create(double value) {
- return new QValueImpl(Double.valueOf(value));
- }
-
- /**
- * @see QValueFactory#create(long)
- */
- public QValue create(long value) {
- return new QValueImpl(Long.valueOf(value));
- }
-
- /**
- * @see QValueFactory#create(boolean)
- */
- public QValue create(boolean value) {
- if (value) {
- return QValueImpl.TRUE;
- } else {
- return QValueImpl.FALSE;
- }
- }
-
- /**
- * @see QValueFactory#create(Name)
- */
- public QValue create(Name value) {
- if (value == null) {
- throw new IllegalArgumentException("Cannot create QValue from null value.");
- }
- return new QValueImpl(value);
- }
-
- /**
- * @see QValueFactory#create(Path)
- */
- public QValue create(Path value) {
- if (value == null) {
- throw new IllegalArgumentException("Cannot create QValue from null value.");
- }
- return new QValueImpl(value);
- }
-
- /**
- * @see QValueFactory#create(URI)
- */
- public QValue create(URI value) {
- if (value == null) {
- throw new IllegalArgumentException("Cannot create QValue from null value.");
- }
- return new QValueImpl(value);
- }
-
- /**
- * @see QValueFactory#create(URI)
- */
- public QValue create(BigDecimal value) {
- if (value == null) {
- throw new IllegalArgumentException("Cannot create QValue from null value.");
- }
- return new QValueImpl(value);
- }
-
/**
* @see QValueFactory#create(byte[])
*/
@@ -220,162 +81,23 @@
return new BinaryQValue(value);
}
-
//--------------------------------------------------------< Inner Class >---
- /**
- * <code>QValue</code> implementation for all valid <code>PropertyType</code>s
- * except for BINARY and DATE.
- * @see QValueFactoryImpl.BinaryQValue
- */
- private static class QValueImpl extends AbstractQValue implements Serializable {
-
- private static final QValue TRUE = new QValueImpl(Boolean.TRUE);
- private static final QValue FALSE = new QValueImpl(Boolean.FALSE);
-
-
- private QValueImpl(Object value, int type) {
- super(value, type);
- }
-
- private QValueImpl(String value, int type) {
- super(value, type);
- }
-
- private QValueImpl(Long value) {
- super(value);
- }
-
- private QValueImpl(Double value) {
- super(value);
- }
-
- private QValueImpl(BigDecimal value) {
- super(value);
- }
-
- private QValueImpl(Boolean value) {
- super(value);
- }
-
- private QValueImpl(Name value) {
- super(value);
- }
-
- private QValueImpl(Path value) {
- super(value);
- }
-
- private QValueImpl(URI value) {
- super(value);
- }
-
- //---------------------------------------------------------< QValue >---
- /**
- * @see QValue#getString()
- */
- public String getString() {
- return val.toString();
- }
-
- /**
- * @see QValue#getBinary()
- */
- public Binary getBinary() throws RepositoryException {
- // TODO FIXME consolidate Binary implementations
- return new Binary() {
- public InputStream getStream() throws RepositoryException {
- return QValueImpl.this.getStream();
- }
-
- public int read(byte[] b, long position) throws IOException, RepositoryException {
- InputStream in = getStream();
- try {
- in.skip(position);
- return in.read(b);
- } finally {
- in.close();
- }
- }
-
- public long getSize() throws RepositoryException {
- return getLength();
- }
- public void dispose() {
- }
-
- };
- }
-
- /**
- * @see QValue#getStream()
- */
- public InputStream getStream() throws RepositoryException {
- try {
- // convert via string
- return new ByteArrayInputStream(getString().getBytes(DEFAULT_ENCODING));
- } catch (UnsupportedEncodingException e) {
- throw new RepositoryException(QValueFactoryImpl.DEFAULT_ENCODING + " is not supported encoding on this platform", e);
- }
- }
- }
-
- //--------------------------------------------------------< Inner Class >---
- /**
- * Extension for values of type {@link PropertyType#DATE}.
- */
- private static class DateQValue extends QValueImpl {
-
- private final String formattedStr;
-
- private DateQValue(Calendar value) {
- super(value, PropertyType.DATE);
- formattedStr = ISO8601.format(value);
- }
-
- /**
- * @return The formatted String of the internal Calendar value.
- * @see QValue#getString()
- * @see ISO8601#format(Calendar)
- */
- public String getString() {
- return formattedStr;
- }
-
- /**
- * @param obj
- * @return true if the given Object is a <code>DateQValue</code> with an
- * equal String representation.
- * @see Object#equals(Object)
- */
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DateQValue) {
- DateQValue other = (DateQValue) obj;
- return formattedStr.equals(other.formattedStr);
- }
- return false;
- }
-
- /**
- * @return the hashCode of the formatted String of the Calender value.
- * @see Object#hashCode()
- */
- public int hashCode() {
- return formattedStr.hashCode();
- }
- }
-
- //--------------------------------------------------------< Inner Class >---
/**
* <code>BinaryQValue</code> represents a binary <code>Value</code> which is
* backed by a resource or byte[]. Unlike <code>BinaryValue</code> it has no
* state, i.e. the <code>getStream()</code> method always returns a fresh
* <code>InputStream</code> instance.
*/
- private static class BinaryQValue implements QValue, Binary, Serializable {
+ private static class BinaryQValue extends AbstractQValue implements Serializable {
+
+ /**
+ * A dummy value for calling the constructor of AbstractQValue
+ */
+ private static final Object DUMMY_VALUE = new Serializable() {
+ private static final long serialVersionUID = 2849470089518940117L;
+ };
+
/**
* empty array
*/
@@ -404,11 +126,6 @@
private byte[] buffer = BinaryQValue.EMPTY_BYTE_ARRAY;
/**
- * Converted text
- */
- private transient String text = null;
-
- /**
* Creates a new <code>BinaryQValue</code> instance from an
* <code>InputStream</code>. The contents of the stream is spooled
* to a temporary file or to a byte buffer if its size is smaller than
@@ -444,6 +161,7 @@
* writing to the temporary file
*/
private BinaryQValue(InputStream in, boolean temp) throws IOException {
+ super(DUMMY_VALUE, PropertyType.BINARY);
byte[] spoolBuffer = new byte[0x2000];
int read;
int len = 0;
@@ -495,6 +213,7 @@
* instance
*/
private BinaryQValue(byte[] bytes) {
+ super(DUMMY_VALUE, PropertyType.BINARY);
buffer = bytes;
file = null;
// this instance is not backed by a temporarily allocated buffer
@@ -508,6 +227,7 @@
* @throws IOException if the file can not be read
*/
private BinaryQValue(File file) throws IOException {
+ super(DUMMY_VALUE, PropertyType.BINARY);
String path = file.getCanonicalPath();
if (!file.isFile()) {
throw new IOException(path + ": the specified file does not exist");
@@ -523,12 +243,6 @@
}
//---------------------------------------------------------< QValue >---
- /**
- * @see QValue#getType()
- */
- public int getType() {
- return PropertyType.BINARY;
- }
/**
* Returns the length of this <code>BinaryQValue</code>.
@@ -552,32 +266,6 @@
}
/**
- * @see QValue#getString()
- */
- public String getString() throws RepositoryException {
- if (text == null) {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- try {
- spool(out);
- byte[] data = out.toByteArray();
- text = new String(data, QValueFactoryImpl.DEFAULT_ENCODING);
- } catch (UnsupportedEncodingException e) {
- throw new RepositoryException(QValueFactoryImpl.DEFAULT_ENCODING
- + " not supported on this platform", e);
- } catch (IOException e) {
- throw new ValueFormatException("conversion from stream to string failed", e);
- } finally {
- try {
- out.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
- return text;
- }
-
- /**
* @see QValue#getStream()
*/
public InputStream getStream() throws RepositoryException {
@@ -603,47 +291,6 @@
}
/**
- * @see QValue#getCalendar()
- */
- public Calendar getCalendar() throws RepositoryException {
- Calendar cal = ISO8601.parse(getString());
- if (cal == null) {
- throw new ValueFormatException("not a date string: " + getString());
- } else {
- return cal;
- }
- }
-
- /**
- * @see QValue#getDouble()
- */
- public double getDouble() throws RepositoryException {
- try {
- return Double.parseDouble(getString());
- } catch (NumberFormatException ex) {
- throw new ValueFormatException(ex);
- }
- }
-
- /**
- * @see QValue#getLong()
- */
- public long getLong() throws RepositoryException {
- try {
- return Long.parseLong(getString());
- } catch (NumberFormatException ex) {
- throw new ValueFormatException(ex);
- }
- }
-
- /**
- * @see QValue#getBoolean()
- */
- public boolean getBoolean() throws RepositoryException {
- return Boolean.valueOf(getString());
- }
-
- /**
* @see QValue#getPath()
*/
public Path getPath() throws RepositoryException {
@@ -651,35 +298,6 @@
}
/**
- * @see QValue#getDecimal()
- */
- public BigDecimal getDecimal() throws RepositoryException {
- try {
- return new BigDecimal(getString());
- } catch (NumberFormatException ex) {
- throw new ValueFormatException(ex);
- }
- }
-
- /**
- * @see QValue#getURI()
- */
- public URI getURI() throws RepositoryException {
- try {
- return new URI(getString());
- } catch (URISyntaxException ex) {
- throw new ValueFormatException(ex);
- }
- }
-
- /**
- * @see QValue#getBinary()
- */
- public Binary getBinary() throws RepositoryException {
- return this;
- }
-
- /**
* Frees temporarily allocated resources such as temporary file, buffer, etc.
* If this <code>BinaryQValue</code> is backed by a persistent resource
* calling this method will have no effect.
@@ -700,10 +318,6 @@
}
}
- public void dispose() {
- discard();
- }
-
//-----------------------------------------------< java.lang.Object >---
/**
* Returns a string representation of this <code>BinaryQValue</code>
@@ -750,73 +364,6 @@
return 0;
}
- //----------------------------------------------------------------------
- /**
- * Spools the contents of this <code>BinaryQValue</code> to the given
- * output stream.
- *
- * @param out output stream
- * @throws RepositoryException if the input stream for this
- * <code>BinaryQValue</code> could not be obtained
- * @throws IOException if an error occurs while while spooling
- */
- private void spool(OutputStream out) throws RepositoryException, IOException {
- InputStream in;
- if (file != null) {
- // this instance is backed by a 'real' file
- try {
- in = new FileInputStream(file);
- } catch (FileNotFoundException fnfe) {
- throw new RepositoryException("file backing binary value not found",
- fnfe);
- }
- } else {
- // this instance is backed by an in-memory buffer
- in = new ByteArrayInputStream(buffer);
- }
- try {
- byte[] buffer = new byte[0x2000];
- int read;
- while ((read = in.read(buffer)) > 0) {
- out.write(buffer, 0, read);
- }
- } finally {
- try {
- in.close();
- } catch (IOException ignore) {
- }
- }
- }
-
- //-----------------------------< javx.jcr.Binary >----------------------
- /**
- * {@inheritDoc}
- */
- public int read(byte[] b, long position) throws IOException, RepositoryException {
- if (file != null) {
- // this instance is backed by a temp file
- RandomAccessFile raf = new RandomAccessFile(file, "r");
- raf.seek(position);
- return raf.read(b);
- } else {
- // this instance is backed by an in-memory buffer
- int length = Math.min(b.length, buffer.length - (int) position);
- if (length > 0) {
- System.arraycopy(buffer, (int) position, b, 0, length);
- return length;
- } else {
- return -1;
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public long getSize() throws RepositoryException {
- return getLength();
- }
-
//-----------------------------< Serializable >-------------------------
private void writeObject(ObjectOutputStream out)
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java Tue Sep 8 16:09:28 2009
@@ -38,15 +38,6 @@
*/
public final class QValueValue implements Value {
- private static final short STATE_UNDEFINED = 0;
-
- private static final short STATE_VALUE_CONSUMED = 1;
-
- private static final short STATE_STREAM_CONSUMED = 2;
-
- // the state of this value instance
- private short state = STATE_UNDEFINED;
-
// wrapped QValue
private final QValue qvalue;
@@ -82,7 +73,6 @@
* @see javax.jcr.Value#getBoolean()
*/
public boolean getBoolean() throws RepositoryException {
- setValueConsumed();
if (getType() == PropertyType.STRING || getType() == PropertyType.BINARY || getType() == PropertyType.BOOLEAN) {
return Boolean.valueOf(qvalue.getString()).booleanValue();
} else {
@@ -94,7 +84,6 @@
* @see javax.jcr.Value#getDecimal()
*/
public BigDecimal getDecimal() throws ValueFormatException, IllegalStateException, RepositoryException {
- setValueConsumed();
switch (getType()) {
case PropertyType.DECIMAL:
case PropertyType.DOUBLE:
@@ -118,7 +107,6 @@
* @see javax.jcr.Value#getDate()
*/
public Calendar getDate() throws RepositoryException {
- setValueConsumed();
return qvalue.getCalendar();
}
@@ -126,7 +114,6 @@
* @see javax.jcr.Value#getDouble()
*/
public double getDouble() throws RepositoryException {
- setValueConsumed();
return qvalue.getDouble();
}
@@ -134,7 +121,6 @@
* @see javax.jcr.Value#getLong()
*/
public long getLong() throws RepositoryException {
- setValueConsumed();
return qvalue.getLong();
}
@@ -142,7 +128,6 @@
* @see javax.jcr.Value#getStream()
*/
public InputStream getStream() throws IllegalStateException, RepositoryException {
- setStreamConsumed();
if (stream == null) {
if (getType() == PropertyType.NAME || getType() == PropertyType.PATH) {
// needs namespace mapping
@@ -165,7 +150,6 @@
* @see javax.jcr.Value#getString()
*/
public String getString() throws RepositoryException {
- setValueConsumed();
if (getType() == PropertyType.NAME) {
// needs formatting
return resolver.getJCRName(qvalue.getName());
@@ -202,38 +186,4 @@
public int hashCode() {
return qvalue.hashCode();
}
-
- //--------------------------------------------------------------------------
- /**
- * Checks if the non-stream value of this instance has already been
- * consumed (if any getter methods except <code>{@link #getStream()}</code> and
- * <code>{@link #getType()}</code> have been previously called at least once) and
- * sets the state to <code>STATE_STREAM_CONSUMED</code>.
- *
- * @throws IllegalStateException if any getter methods other than
- * <code>getStream()</code> and
- * <code>getType()</code> have been
- * previously called at least once.
- */
- private void setStreamConsumed() throws IllegalStateException {
- if (state == STATE_VALUE_CONSUMED) {
- throw new IllegalStateException("non-stream value has already been consumed");
- }
- state = STATE_STREAM_CONSUMED;
- }
-
- /**
- * Checks if the stream value of this instance has already been
- * consumed (if {@link #getStream()} has been previously called
- * at least once) and sets the state to <code>STATE_VALUE_CONSUMED</code>.
- *
- * @throws IllegalStateException if <code>getStream()</code> has been
- * previously called at least once.
- */
- private void setValueConsumed() throws IllegalStateException {
- if (state == STATE_STREAM_CONSUMED) {
- throw new IllegalStateException("stream value has already been consumed");
- }
- state = STATE_VALUE_CONSUMED;
- }
}
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/batch/ConsolidatedBatchTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/batch/ConsolidatedBatchTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/batch/ConsolidatedBatchTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/batch/ConsolidatedBatchTest.java Tue Sep 8 16:09:28 2009
@@ -418,11 +418,6 @@
return this;
}
- public ChangeLog removeProperty(String propertyId) throws RepositoryException {
- remove(createPropertyId(propertyId));
- return this;
- }
-
public TestChangeLog ordNode(String nodeId) throws RepositoryException {
NodeId srcNodeId = createNodeId(nodeId);
NodeId parentId = createNodeId(srcNodeId.getPath());
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/DummyIdentifierResolver.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/DummyIdentifierResolver.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/DummyIdentifierResolver.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/DummyIdentifierResolver.java Tue Sep 8 16:09:28 2009
@@ -19,12 +19,11 @@
import org.apache.jackrabbit.spi.Path;
import org.apache.jackrabbit.spi.PathFactory;
import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
-import org.apache.jackrabbit.uuid.UUID;
import javax.jcr.RepositoryException;
import java.util.List;
import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.UUID;
/**
* <code>DummyIdentifierResolver</code>...
@@ -34,14 +33,14 @@
private static final PathFactory FACTORY = PathFactoryImpl.getInstance();
public static final String JCR_PATH = "/a/b/c";
- private final List validIds;
- private final List invalidFormats;
- private final List invalidPaths;
+ private final List<String> validIds;
+ private final List<String> invalidFormats;
+ private final List<String> invalidPaths;
private final Path path;
DummyIdentifierResolver() throws RepositoryException {
path = FACTORY.create(FACTORY.getRootPath(), FACTORY.create("{}a\t{}b\t{}c"), true);
- validIds = new ArrayList();
+ validIds = new ArrayList<String>();
validIds.add(UUID.randomUUID().toString());
validIds.add("a:b");
validIds.add("a[3]");
@@ -52,14 +51,13 @@
validIds.add("{}\"\"\t{}a[3]\t{}b\t{}c:d");
String invalidID = UUID.randomUUID().toString();
- String invalidIdSegment = "["+invalidID+"]";
- String validSegment = "[" + validIds.get(0).toString() + "]";
+ String invalidIdSegment = "[" + invalidID + "]";
+ String validSegment = "[" + validIds.get(0) + "]";
- invalidFormats = new ArrayList();
- invalidPaths = new ArrayList();
+ invalidFormats = new ArrayList<String>();
+ invalidPaths = new ArrayList<String>();
- for (Iterator it = validIds.iterator(); it.hasNext();) {
- String validId = it.next().toString();
+ for (String validId : validIds) {
if (!validId.endsWith("]")) {
invalidFormats.add("[" + validId);
} else {
@@ -88,18 +86,18 @@
invalidPaths.addAll(invalidFormats);
}
- List getValidIdentifiers() {
+ List<String> getValidIdentifiers() {
return validIds;
}
- List getInvalidIdentifierPaths() {
+ List<String> getInvalidIdentifierPaths() {
return invalidPaths;
}
- List getInvalidIdentifierFormats() {
+ List<String> getInvalidIdentifierFormats() {
return invalidFormats;
}
-
+
public Path getPath(String identifier) throws MalformedPathException {
if (validIds.contains(identifier)) {
return path;
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/PathFactoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/PathFactoryTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/PathFactoryTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/name/PathFactoryTest.java Tue Sep 8 16:09:28 2009
@@ -20,16 +20,16 @@
import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.Path;
import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.Path.Element;
import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
import org.apache.jackrabbit.spi.commons.conversion.PathResolver;
import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
-import org.apache.jackrabbit.uuid.UUID;
import javax.jcr.NamespaceException;
import javax.jcr.RepositoryException;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
+import java.util.UUID;
/**
* <code>PathFactoryTest</code>...
@@ -284,11 +284,10 @@
Path.Element rootEl = factory.getRootElement();
Path.Element pe = factory.getParentElement();
- Path.Element ce = factory.getCurrentElement();
Path.Element element = factory.createElement(NameConstants.JCR_NAME, 3);
Path.Element element2 = factory.createElement(NameConstants.JCR_DATA, 3);
- List elementArrays = new ArrayList();
+ List<Element[]> elementArrays = new ArrayList<Element[]>();
elementArrays.add(new Path.Element[]{rootEl, rootEl});
elementArrays.add(new Path.Element[] {element, rootEl, pe});
elementArrays.add(new Path.Element[] {pe, rootEl, element});
@@ -296,9 +295,9 @@
elementArrays.add(new Path.Element[] {rootEl, pe});
elementArrays.add(new Path.Element[] {rootEl, element, element2, pe, pe, pe});
- for (Iterator it = elementArrays.iterator(); it.hasNext(); ) {
+ for (Element[] elementArray : elementArrays) {
try {
- Path p = factory.create((Path.Element[]) it.next());
+ Path p = factory.create(elementArray);
fail("Invalid path " + getString(p));
} catch (IllegalArgumentException e) {
// ok
@@ -311,19 +310,19 @@
Name rootName = factory.getRootElement().getName();
Name parentName = factory.getParentElement().getName();
- List list = new ArrayList();
+ List<ParentPathNameIndexDoNormalize> list =
+ new ArrayList<ParentPathNameIndexDoNormalize>();
list.add(new ParentPathNameIndexDoNormalize(root, rootName, -1, true));
list.add(new ParentPathNameIndexDoNormalize(root, rootName, -1, false));
list.add(new ParentPathNameIndexDoNormalize(root, rootName, 3, false));
list.add(new ParentPathNameIndexDoNormalize(factory.create(parentName), rootName, 3, true));
- for (Iterator it = list.iterator(); it.hasNext();) {
- ParentPathNameIndexDoNormalize test = (ParentPathNameIndexDoNormalize) it.next();
+ for (ParentPathNameIndexDoNormalize test : list) {
try {
if (test.index == -1) {
- Path p = factory.create(test.parentPath, test.name, test.doNormalize);
+ factory.create(test.parentPath, test.name, test.doNormalize);
} else {
- Path p = factory.create(test.parentPath, test.name, test.index, test.doNormalize);
+ factory.create(test.parentPath, test.name, test.index, test.doNormalize);
}
fail("Invalid path " + test.parentPath + " + " + test.name);
} catch (Exception e) {
@@ -333,7 +332,6 @@
}
public void testCreateInvalidPath3() {
- Path root = factory.getRootPath();
JcrPath[] tests = JcrPath.getTests();
for (int i = 0; i < tests.length; i++) {
if (!tests[i].isValid()) {
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/value/QValueTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/value/QValueTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/value/QValueTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/value/QValueTest.java Tue Sep 8 16:09:28 2009
@@ -30,6 +30,7 @@
import java.io.FileWriter;
import java.util.Arrays;
import java.util.Calendar;
+import java.util.UUID;
import java.math.BigDecimal;
import java.net.URI;
import java.net.URISyntaxException;
@@ -47,7 +48,6 @@
import org.apache.jackrabbit.spi.commons.name.NameConstants;
import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
import org.apache.jackrabbit.util.ISO8601;
-import org.apache.jackrabbit.uuid.UUID;
/**
* <code>QValueTest</code>...
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/value/ValueFormatTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/value/ValueFormatTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/value/ValueFormatTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/value/ValueFormatTest.java Tue Sep 8 16:09:28 2009
@@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.spi.commons.value;
-import org.apache.jackrabbit.uuid.UUID;
import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
import org.apache.jackrabbit.spi.commons.conversion.ParsingPathResolver;
import org.apache.jackrabbit.spi.commons.conversion.IdentifierResolver;
@@ -40,6 +39,7 @@
import javax.jcr.Value;
import java.util.List;
import java.util.ArrayList;
+import java.util.UUID;
import java.math.BigDecimal;
import java.net.URI;
import java.net.URISyntaxException;
@@ -81,7 +81,7 @@
* @throws RepositoryException
*/
public void testGetPathQValue() throws RepositoryException {
- List<String> l = new ArrayList();
+ List<String> l = new ArrayList<String>();
// a non-normalized absolute path
l.add("/a/.././b/c/.");
// an identifier based path
@@ -128,7 +128,7 @@
}
public void testGetJCRString() throws RepositoryException, URISyntaxException {
- List<QValue> qvs = new ArrayList();
+ List<QValue> qvs = new ArrayList<QValue>();
String reference = UUID.randomUUID().toString();
qvs.add(qvFactory.create(reference, PropertyType.WEAKREFERENCE));
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/resources/org/apache/jackrabbit/spi/commons/query/sql2/test.sql2.txt
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/resources/org/apache/jackrabbit/spi/commons/query/sql2/test.sql2.txt?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/resources/org/apache/jackrabbit/spi/commons/query/sql2/test.sql2.txt (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/resources/org/apache/jackrabbit/spi/commons/query/sql2/test.sql2.txt Tue Sep 8 16:09:28 2009
@@ -86,6 +86,7 @@
# 6.7.19 FullTextSearch (p 113)
select * from test where contains(name, 'hello -world')
+select * from test where contains(name, $x)
select * from test as t where contains(t.*, 'hello -world')
select * from test as t where contains([t].name, 'hello -world')
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QValue.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QValue.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QValue.java Tue Sep 8 16:09:28 2009
@@ -82,7 +82,7 @@
/**
* Returns an <code>InputStream</code> representation of this <code>QValue</code>
- * object.
+ * object. This method always returns a new stream.
*
* @return A stream representation of this value.
* @throws RepositoryException
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java Tue Sep 8 16:09:28 2009
@@ -37,9 +37,9 @@
import javax.jcr.ValueFormatException;
import javax.jcr.lock.LockException;
import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
import javax.jcr.nodetype.NoSuchNodeTypeException;
import javax.jcr.nodetype.NodeTypeExistsException;
-import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
import javax.jcr.query.InvalidQueryException;
import javax.jcr.version.Version;
import javax.jcr.version.VersionException;
@@ -121,7 +121,7 @@
* @see javax.jcr.Repository#getDescriptorKeys()
* @see javax.jcr.Repository#getDescriptor(String)
*/
- public Map<String, String> getRepositoryDescriptors() throws RepositoryException;
+ public Map<String, QValue[]> getRepositoryDescriptors() throws RepositoryException;
//-----------------------------------< SessionInfo creation and release >---
/**
@@ -266,8 +266,7 @@
* Method used to 'batch-read' from the persistent storage. It returns the
* <code>NodeInfo</code> for the given <code>NodeId</code> as the first
* element in the <code>Iterator</code>. In addition the iterator may contain
- * child <code>ItemInfo</code>s down to a certain depth. The configuration
- * process however is left to the implementation.
+ * arbitrary <code>ItemInfo</code>s.
*
* @param sessionInfo
* @param nodeId
@@ -275,8 +274,7 @@
* at least a single element: the <code>NodeInfo</code> that represents
* the Node identified by the given <code>NodeId</code>. If the Iterator
* contains multiple elements, the first is expected to represent the Node
- * identified by the given <code>NodeId</code> and all subsequent elements
- * must represent children of that <code>Node</code>.
+ * identified by the given <code>NodeId</code>.
* @throws javax.jcr.ItemNotFoundException
* @throws javax.jcr.RepositoryException
* @see javax.jcr.Session#getItem(String)
@@ -615,7 +613,8 @@
/**
* Performs a checkout for the <code>Node</code> identified by the given
- * <code>NodeId</code>.
+ * <code>NodeId</code>. Same as {@link #checkout(SessionInfo, NodeId, NodeId)}
+ * where the <code>activityId</code> is <code>null</code>.
*
* @param sessionInfo
* @param nodeId
@@ -627,6 +626,23 @@
public void checkout(SessionInfo sessionInfo, NodeId nodeId) throws UnsupportedRepositoryOperationException, LockException, RepositoryException;
/**
+ * Performs a checkout for the <code>Node</code> identified by the given
+ * <code>NodeId</code> and for activity identified by the specified
+ * <code>activityId</code>. If the <code>activityId</code> is <code>null</code>
+ * this corresponds to {@link #checkout(SessionInfo, NodeId)}
+ *
+ * @param sessionInfo
+ * @param nodeId
+ * @param activityId Id of the activity node set to the editing session or
+ * <code>null</code> if no activity is in effect.
+ * @throws UnsupportedRepositoryOperationException
+ * @throws LockException
+ * @throws RepositoryException
+ * @since JCR 2.0
+ */
+ public void checkout(SessionInfo sessionInfo, NodeId nodeId, NodeId activityId) throws UnsupportedRepositoryOperationException, LockException, RepositoryException;
+
+ /**
* Performs a checkpoint for the <code>Node</code> identified by the given
* <code>NodeId</code>.
*
@@ -841,17 +857,18 @@
* @throws UnsupportedRepositoryOperationException
* @throws RepositoryException
*/
- public Iterator mergeActivity(SessionInfo sessionInfo, NodeId activityId) throws UnsupportedRepositoryOperationException, RepositoryException;
+ public Iterator<NodeId> mergeActivity(SessionInfo sessionInfo, NodeId activityId) throws UnsupportedRepositoryOperationException, RepositoryException;
/**
*
* @param sessionInfo
* @param nodeId
- * @param baselineId @return @throws UnsupportedRepositoryOperationException
+ * @return
+ * @throws UnsupportedRepositoryOperationException
* @throws RepositoryException
- * @see javax.jcr.version.VersionManager#createConfiguration(String, Version)
+ * @see javax.jcr.version.VersionManager#createConfiguration(String)
*/
- public NodeId createConfiguration(SessionInfo sessionInfo, NodeId nodeId, NodeId baselineId) throws UnsupportedRepositoryOperationException, RepositoryException;
+ public NodeId createConfiguration(SessionInfo sessionInfo, NodeId nodeId) throws UnsupportedRepositoryOperationException, RepositoryException;
//----------------------------------------------------------< Searching >---
/**
@@ -1193,7 +1210,7 @@
/**
* Unregisters the node types with the specified <code>names</code>.
- *
+ *
* @param sessionInfo
* @param nodeTypeNames
* @throws UnsupportedRepositoryOperationException If unregistering node types