Index: java/org/apache/jackrabbit/decorator/DecoratingVersionIterator.java =================================================================== --- java/org/apache/jackrabbit/decorator/DecoratingVersionIterator.java (revision 0) +++ java/org/apache/jackrabbit/decorator/DecoratingVersionIterator.java (revision 0) @@ -0,0 +1,50 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.decorator; + +import org.apache.jackrabbit.decorator.DecoratorFactory; +import org.apache.jackrabbit.decorator.DecoratingRangeIterator; + +import javax.jcr.version.VersionIterator; +import javax.jcr.version.Version; +import javax.jcr.Session; + +/** + */ +public class DecoratingVersionIterator extends DecoratingRangeIterator + implements VersionIterator { + + /** + * Creates a decorating version iterator. + * + * @param factory decorator factory + * @param session decorated session + * @param iterator underlying version iterator + */ + public DecoratingVersionIterator(DecoratorFactory factory, + Session session, + VersionIterator iterator) { + super(factory, session, iterator); + } + + /** + * @inheritDoc + */ + public Version nextVersion() { + return (Version) next(); + } +} Property changes on: java/org/apache/jackrabbit/decorator/DecoratingVersionIterator.java ___________________________________________________________________ Name: svn:eol-style + native Index: java/org/apache/jackrabbit/decorator/DecoratingNodeIterator.java =================================================================== --- java/org/apache/jackrabbit/decorator/DecoratingNodeIterator.java (revision 320755) +++ java/org/apache/jackrabbit/decorator/DecoratingNodeIterator.java (working copy) @@ -30,15 +30,6 @@ public class DecoratingNodeIterator extends DecoratingRangeIterator implements NodeIterator { - /** The decorator factory. Used to decorate all returned node instances. */ - private final DecoratorFactory factory; - - /** The decorated session to which the returned nodes belong. */ - private final Session session; - - /** The underlying node iterator. */ - private final NodeIterator iterator; - /** * Creates a decorating node iterator. * @@ -49,9 +40,6 @@ public DecoratingNodeIterator( DecoratorFactory factory, Session session, NodeIterator iterator) { super(factory, session, iterator); - this.factory = factory; - this.session = session; - this.iterator = iterator; } /** @@ -61,8 +49,7 @@ * @see NodeIterator#nextNode() */ public Node nextNode() { - Node node = iterator.nextNode(); - return factory.getNodeDecorator(session, node); + return (Node) next(); } } Index: java/org/apache/jackrabbit/decorator/WorkspaceDecorator.java =================================================================== --- java/org/apache/jackrabbit/decorator/WorkspaceDecorator.java (revision 320755) +++ java/org/apache/jackrabbit/decorator/WorkspaceDecorator.java (working copy) @@ -43,16 +43,10 @@ /** * Simple workspace decorator. */ -public class WorkspaceDecorator implements Workspace { +public class WorkspaceDecorator extends AbstractDecorator implements Workspace { - /** The decorator factory. */ - private final DecoratorFactory factory; - - /** The session (decorator) instance. */ - private final Session session; - /** The underlying workspace instance. */ - private final Workspace workspace; + protected final Workspace workspace; /** * Creates a workspace decorator. @@ -63,8 +57,7 @@ */ public WorkspaceDecorator( DecoratorFactory factory, Session session, Workspace workspace) { - this.factory = factory; - this.session = session; + super(factory, session); this.workspace = workspace; } @@ -128,14 +121,18 @@ throws ItemExistsException, UnsupportedRepositoryOperationException, VersionException, LockException, InvalidItemStateException, RepositoryException { - workspace.restore(versions, removeExisting); + Version[] tmp = new Version[versions.length]; + for (int i = 0; i < versions.length; i++) { + tmp[i] = VersionDecorator.unwrap(versions[i]); + } + workspace.restore(tmp, removeExisting); } /** * Forwards the method call to the underlying workspace. */ public QueryManager getQueryManager() throws RepositoryException { - return workspace.getQueryManager(); + return factory.getQueryManagerDecorator(session, workspace.getQueryManager()); } /** Index: java/org/apache/jackrabbit/decorator/ItemDecorator.java =================================================================== --- java/org/apache/jackrabbit/decorator/ItemDecorator.java (revision 320755) +++ java/org/apache/jackrabbit/decorator/ItemDecorator.java (working copy) @@ -30,23 +30,52 @@ import javax.jcr.version.VersionException; /** - * TODO */ -public class ItemDecorator implements Item { +public class ItemDecorator extends AbstractDecorator implements Item { - private DecoratorFactory factory; + /** + * The underlying item to decorate. + */ + protected final Item item; - private Session session; - private Item item; - public ItemDecorator(DecoratorFactory factory, Session session, Item item) { - this.factory = factory; - this.session = session; + super(factory, session); this.item = item; } /** + * Returns the underlying item that this + * ItemDecorator decorates. + * + * @return the underlying item. + */ + public Item unwrap() { + return item; + } + + /** + * Returns the underlying item of the item + * that decorates it. Unwrapping null returns null. + * + * @param item decorates the underlying item. + * @return the underlying item. + * @throws IllegalStateException if item is not of type + * {@link ItemDecorator}. + */ + public static Item unwrap(Item item) { + if (item == null) { + return null; + } + if (item instanceof ItemDecorator) { + item = ((ItemDecorator) item).unwrap(); + } else { + throw new IllegalStateException("item is not of type ItemDecorator"); + } + return item; + } + + /** * Returns the decorated session through which this item decorator * was acquired. * @@ -101,14 +130,13 @@ } /** {@inheritDoc} */ - public boolean isSame(Item otherItem) { - // TODO Auto-generated method stub - return false; + public boolean isSame(Item otherItem) throws RepositoryException { + return item.isSame(unwrap(otherItem)); } /** {@inheritDoc} */ public void accept(ItemVisitor visitor) throws RepositoryException { - item.accept(visitor); + item.accept(factory.getItemVisitorDecorator(session, visitor)); } /** {@inheritDoc} */ @@ -131,4 +159,15 @@ item.remove(); } + public boolean equals(Object obj) { + if (obj instanceof ItemDecorator) { + ItemDecorator other = (ItemDecorator)obj; + return item.equals(other.unwrap()); + } + return false; + } + + public int hashCode() { + return item.hashCode(); + } } Index: java/org/apache/jackrabbit/decorator/QueryManagerDecorator.java =================================================================== --- java/org/apache/jackrabbit/decorator/QueryManagerDecorator.java (revision 0) +++ java/org/apache/jackrabbit/decorator/QueryManagerDecorator.java (revision 0) @@ -0,0 +1,64 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.decorator; + +import org.apache.jackrabbit.decorator.DecoratorFactory; +import org.apache.jackrabbit.decorator.NodeDecorator; + +import javax.jcr.query.QueryManager; +import javax.jcr.query.Query; +import javax.jcr.query.InvalidQueryException; +import javax.jcr.RepositoryException; +import javax.jcr.Node; +import javax.jcr.Session; + +/** + */ +public class QueryManagerDecorator + extends AbstractDecorator implements QueryManager { + + protected final QueryManager manager; + + public QueryManagerDecorator(DecoratorFactory factory, Session session, QueryManager manager) { + super(factory, session); + this.manager = manager; + } + + /** + * @inheritDoc + */ + public Query createQuery(String statement, String language) + throws InvalidQueryException, RepositoryException { + return factory.getQueryDecorator(session, + manager.createQuery(statement, language)); + } + + /** + * @inheritDoc + */ + public Query getQuery(Node node) throws InvalidQueryException, RepositoryException { + Query query = manager.getQuery(NodeDecorator.unwrap(node)); + return factory.getQueryDecorator(session, query); + } + + /** + * @inheritDoc + */ + public String[] getSupportedQueryLanguages() throws RepositoryException { + return manager.getSupportedQueryLanguages(); + } +} Property changes on: java/org/apache/jackrabbit/decorator/QueryManagerDecorator.java ___________________________________________________________________ Name: svn:eol-style + native Index: java/org/apache/jackrabbit/decorator/AbstractDecorator.java =================================================================== --- java/org/apache/jackrabbit/decorator/AbstractDecorator.java (revision 0) +++ java/org/apache/jackrabbit/decorator/AbstractDecorator.java (revision 0) @@ -0,0 +1,51 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.decorator; + +import javax.jcr.Session; + +/** + * Provides fields to common objects used by any decorator: + * + */ +public abstract class AbstractDecorator { + + /** + * The decorator factory. Used to decorate returned objects. + */ + protected final DecoratorFactory factory; + + /** + * The decorated session to which the returned objects belong. + */ + protected final Session session; + + /** + * Constructs an abstract decorator. + * + * @param factory decorator factory + * @param session decorated session + */ + public AbstractDecorator(DecoratorFactory factory, Session session) { + this.factory = factory; + this.session = session; + } +} Property changes on: java/org/apache/jackrabbit/decorator/AbstractDecorator.java ___________________________________________________________________ Name: svn:eol-style + native Index: java/org/apache/jackrabbit/decorator/DecoratingRangeIterator.java =================================================================== --- java/org/apache/jackrabbit/decorator/DecoratingRangeIterator.java (revision 320755) +++ java/org/apache/jackrabbit/decorator/DecoratingRangeIterator.java (working copy) @@ -21,6 +21,8 @@ import javax.jcr.Property; import javax.jcr.RangeIterator; import javax.jcr.Session; +import javax.jcr.version.Version; +import javax.jcr.version.VersionHistory; /** * Range iterator that decorates all iterated objects. This class is used @@ -31,16 +33,11 @@ * and best effort is made to decorate the objects returned by the * {@link #next() next()} method. */ -public class DecoratingRangeIterator implements RangeIterator { +public class DecoratingRangeIterator + extends AbstractDecorator implements RangeIterator { - /** The decorator factory. Used to decorate returned objects. */ - private final DecoratorFactory factory; - - /** The decorated session to which the returned objects belong. */ - private final Session session; - /** The underlying iterator. */ - private final RangeIterator iterator; + protected final RangeIterator iterator; /** * Creates a decorating iterator. @@ -51,8 +48,7 @@ */ public DecoratingRangeIterator( DecoratorFactory factory, Session session, RangeIterator iterator) { - this.factory = factory; - this.session = session; + super(factory, session); this.iterator = iterator; } @@ -107,15 +103,18 @@ */ public Object next() { Object object = iterator.next(); - if (object instanceof Node) { + if (object instanceof Version) { + return factory.getVersionDecorator(session, (Version) object); + } else if (object instanceof VersionHistory) { + return factory.getVersionHistoryDecorator(session, (VersionHistory) object); + } else if (object instanceof Node) { return factory.getNodeDecorator(session, (Node) object); } else if (object instanceof Property) { return factory.getPropertyDecorator(session, (Property) object); } else if (object instanceof Item) { return factory.getItemDecorator(session, (Item) object); } else { - throw new UnsupportedOperationException( - "No decorator available for " + object); + throw new UnsupportedOperationException("No decorator available for " + object); } } Index: java/org/apache/jackrabbit/decorator/QueryResultDecorator.java =================================================================== --- java/org/apache/jackrabbit/decorator/QueryResultDecorator.java (revision 0) +++ java/org/apache/jackrabbit/decorator/QueryResultDecorator.java (revision 0) @@ -0,0 +1,61 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.decorator; + +import org.apache.jackrabbit.decorator.DecoratorFactory; +import org.apache.jackrabbit.decorator.DecoratingNodeIterator; + +import javax.jcr.query.QueryResult; +import javax.jcr.query.RowIterator; +import javax.jcr.RepositoryException; +import javax.jcr.NodeIterator; +import javax.jcr.Session; + +/** + */ +public class QueryResultDecorator + extends AbstractDecorator implements QueryResult { + + protected final QueryResult result; + + public QueryResultDecorator(DecoratorFactory factory, Session session, QueryResult result) { + super(factory, session); + this.result = result; + } + + /** + * @inheritDoc + */ + public String[] getColumnNames() throws RepositoryException { + return result.getColumnNames(); + } + + /** + * @inheritDoc + */ + public RowIterator getRows() throws RepositoryException { + return result.getRows(); + } + + /** + * @inheritDoc + */ + public NodeIterator getNodes() throws RepositoryException { + NodeIterator nodes = result.getNodes(); + return new DecoratingNodeIterator(factory, session, nodes); + } +} Property changes on: java/org/apache/jackrabbit/decorator/QueryResultDecorator.java ___________________________________________________________________ Name: svn:eol-style + native Index: java/org/apache/jackrabbit/decorator/ValueFactoryDecorator.java =================================================================== --- java/org/apache/jackrabbit/decorator/ValueFactoryDecorator.java (revision 0) +++ java/org/apache/jackrabbit/decorator/ValueFactoryDecorator.java (revision 0) @@ -0,0 +1,96 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.decorator; + +import javax.jcr.ValueFactory; +import javax.jcr.Value; +import javax.jcr.ValueFormatException; +import javax.jcr.Node; +import javax.jcr.RepositoryException; +import javax.jcr.Session; +import java.util.Calendar; +import java.io.InputStream; + +/** + */ +public class ValueFactoryDecorator + extends AbstractDecorator implements ValueFactory { + + protected final ValueFactory valueFactory; + + public ValueFactoryDecorator(DecoratorFactory factory, Session session, ValueFactory valueFactory) { + super(factory, session); + this.valueFactory = valueFactory; + } + + /** + * @inheritDoc + */ + public Value createValue(String value) { + return valueFactory.createValue(value); + } + + /** + * @inheritDoc + */ + public Value createValue(String value, int type) + throws ValueFormatException { + return valueFactory.createValue(value, type); + } + + /** + * @inheritDoc + */ + public Value createValue(long value) { + return valueFactory.createValue(value); + } + + /** + * @inheritDoc + */ + public Value createValue(double value) { + return valueFactory.createValue(value); + } + + /** + * @inheritDoc + */ + public Value createValue(boolean value) { + return valueFactory.createValue(value); + } + + /** + * @inheritDoc + */ + public Value createValue(Calendar value) { + return valueFactory.createValue(value); + } + + /** + * @inheritDoc + */ + public Value createValue(InputStream value) { + return valueFactory.createValue(value); + } + + /** + * @inheritDoc + */ + public Value createValue(Node value) throws RepositoryException { + return valueFactory.createValue(NodeDecorator.unwrap(value)); + } +} Property changes on: java/org/apache/jackrabbit/decorator/ValueFactoryDecorator.java ___________________________________________________________________ Name: svn:eol-style + native Index: java/org/apache/jackrabbit/decorator/QueryDecorator.java =================================================================== --- java/org/apache/jackrabbit/decorator/QueryDecorator.java (revision 0) +++ java/org/apache/jackrabbit/decorator/QueryDecorator.java (revision 0) @@ -0,0 +1,80 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.decorator; + +import org.apache.jackrabbit.decorator.DecoratorFactory; + +import javax.jcr.query.Query; +import javax.jcr.query.QueryResult; +import javax.jcr.RepositoryException; +import javax.jcr.ItemNotFoundException; +import javax.jcr.Node; +import javax.jcr.ItemExistsException; +import javax.jcr.PathNotFoundException; +import javax.jcr.UnsupportedRepositoryOperationException; +import javax.jcr.Session; +import javax.jcr.lock.LockException; +import javax.jcr.nodetype.ConstraintViolationException; +import javax.jcr.version.VersionException; + +/** + */ +public class QueryDecorator extends AbstractDecorator implements Query { + + protected final Query query; + + public QueryDecorator(DecoratorFactory factory, Session session, Query query) { + super(factory, session); + this.query = query; + } + + /** + * @inheritDoc + */ + public QueryResult execute() throws RepositoryException { + return factory.getQueryResultDecorator(session, query.execute()); + } + + /** + * @inheritDoc + */ + public String getStatement() { + return query.getStatement(); + } + + /** + * @inheritDoc + */ + public String getLanguage() { + return query.getLanguage(); + } + + /** + * @inheritDoc + */ + public String getStoredQueryPath() throws ItemNotFoundException, RepositoryException { + return query.getStoredQueryPath(); + } + + /** + * @inheritDoc + */ + public Node storeAsNode(String absPath) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, UnsupportedRepositoryOperationException, RepositoryException { + Node node = query.storeAsNode(absPath); + return factory.getNodeDecorator(session, node); + } +} Property changes on: java/org/apache/jackrabbit/decorator/QueryDecorator.java ___________________________________________________________________ Name: svn:eol-style + native Index: java/org/apache/jackrabbit/decorator/VersionHistoryDecorator.java =================================================================== --- java/org/apache/jackrabbit/decorator/VersionHistoryDecorator.java (revision 0) +++ java/org/apache/jackrabbit/decorator/VersionHistoryDecorator.java (revision 0) @@ -0,0 +1,142 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.decorator; + +import org.apache.jackrabbit.decorator.NodeDecorator; +import org.apache.jackrabbit.decorator.DecoratorFactory; +import org.apache.jackrabbit.decorator.DecoratingVersionIterator; +import org.apache.jackrabbit.decorator.VersionDecorator; + +import javax.jcr.version.VersionHistory; +import javax.jcr.version.Version; +import javax.jcr.version.VersionIterator; +import javax.jcr.version.VersionException; +import javax.jcr.Session; +import javax.jcr.RepositoryException; +import javax.jcr.ReferentialIntegrityException; +import javax.jcr.AccessDeniedException; +import javax.jcr.UnsupportedRepositoryOperationException; + +/** + */ +public class VersionHistoryDecorator extends NodeDecorator + implements VersionHistory { + + protected final VersionHistory versionHistory; + + public VersionHistoryDecorator(DecoratorFactory factory, + Session session, + VersionHistory versionHistory) { + super(factory, session, versionHistory); + this.versionHistory = versionHistory; + } + + /** + * @inheritDoc + */ + public String getVersionableUUID() throws RepositoryException { + return versionHistory.getVersionableUUID(); + } + + /** + * @inheritDoc + */ + public Version getRootVersion() throws RepositoryException { + Version version = versionHistory.getRootVersion(); + return factory.getVersionDecorator(session, version); + } + + /** + * @inheritDoc + */ + public VersionIterator getAllVersions() throws RepositoryException { + return new DecoratingVersionIterator(factory, session, versionHistory.getAllVersions()); + } + + /** + * @inheritDoc + */ + public Version getVersion(String versionName) throws VersionException, RepositoryException { + Version version = versionHistory.getVersion(versionName); + return factory.getVersionDecorator(session, version); + } + + /** + * @inheritDoc + */ + public Version getVersionByLabel(String label) throws RepositoryException { + Version version = versionHistory.getVersionByLabel(label); + return factory.getVersionDecorator(session, version); + } + + /** + * @inheritDoc + */ + public void addVersionLabel(String versionName, + String label, + boolean moveLabel) throws VersionException, RepositoryException { + versionHistory.addVersionLabel(versionName, label, moveLabel); + } + + /** + * @inheritDoc + */ + public void removeVersionLabel(String label) throws VersionException, RepositoryException { + versionHistory.removeVersionLabel(label); + } + + /** + * @inheritDoc + */ + public boolean hasVersionLabel(String label) throws RepositoryException { + return versionHistory.hasVersionLabel(label); + } + + /** + * @inheritDoc + */ + public boolean hasVersionLabel(Version version, String label) + throws VersionException, RepositoryException { + return versionHistory.hasVersionLabel(VersionDecorator.unwrap(version), label); + } + + /** + * @inheritDoc + */ + public String[] getVersionLabels() throws RepositoryException { + return versionHistory.getVersionLabels(); + } + + /** + * @inheritDoc + */ + public String[] getVersionLabels(Version version) + throws VersionException, RepositoryException { + return versionHistory.getVersionLabels(VersionDecorator.unwrap(version)); + } + + /** + * @inheritDoc + */ + public void removeVersion(String versionName) + throws ReferentialIntegrityException, AccessDeniedException, + UnsupportedRepositoryOperationException, VersionException, + RepositoryException { + versionHistory.removeVersion(versionName); + } + +} Property changes on: java/org/apache/jackrabbit/decorator/VersionHistoryDecorator.java ___________________________________________________________________ Name: svn:eol-style + native Index: java/org/apache/jackrabbit/decorator/DecoratorFactory.java =================================================================== --- java/org/apache/jackrabbit/decorator/DecoratorFactory.java (revision 320755) +++ java/org/apache/jackrabbit/decorator/DecoratorFactory.java (working copy) @@ -22,6 +22,13 @@ import javax.jcr.Repository; import javax.jcr.Session; import javax.jcr.Workspace; +import javax.jcr.ValueFactory; +import javax.jcr.ItemVisitor; +import javax.jcr.query.QueryResult; +import javax.jcr.query.Query; +import javax.jcr.query.QueryManager; +import javax.jcr.version.Version; +import javax.jcr.version.VersionHistory; import javax.jcr.lock.Lock; /** @@ -72,6 +79,9 @@ /** * Creates a node decorator. + *

+ * Note: this method must also take care to create appropriate decorators + * for subtypes of node: Version and VersionHistory! * * @param session the session (decorator) instance used to create the * node decorator @@ -103,10 +113,81 @@ /** * Creates a lock decorator. * - * @param node the node (decorator) instance to which the lock is bound - * @param lock the underlying lock instance + * @param session the session (decorator) instance used to create the + * lock decorator + * @param lock the underlying lock instance * @return lock decorator */ - Lock getLockDecorator(Node node, Lock lock); + Lock getLockDecorator(Session session, Lock lock); + /** + * Creates a version decorator. + * + * @param session the session (decorator) instance used to create the version + * decorator + * @param version the underlying version instance + * @return version decorator + */ + Version getVersionDecorator(Session session, Version version); + + /** + * Creates a version history decorator. + * + * @param session the session (decorator) instance used to create the + * version history decorator. + * @param versionHistory the underlying version history instance + * @return version history decorator + */ + VersionHistory getVersionHistoryDecorator(Session session, + VersionHistory versionHistory); + + /** + * Creates a query manager decorator. + * + * @param session the session (decorator) instance used to create the + * query manager decorator. + * @param queryManager the underlying query manager instance. + * @return query manager decorator. + */ + QueryManager getQueryManagerDecorator(Session session, QueryManager queryManager); + + /** + * Creates a query decorator. + * + * @param session the session (decorator) instance used to create the query + * decorator. + * @param query the underlying query instance. + * @return query decorator. + */ + Query getQueryDecorator(Session session, Query query); + + /** + * Creates a query result decorator. + * + * @param session the session (decorator) instance used to create the query + * result decorator. + * @param result the underlying query result instance. + * @return query result decorator. + */ + QueryResult getQueryResultDecorator(Session session, QueryResult result); + + /** + * Creates a value factory decorator. + * + * @param session the session (decorator) instance used to create the + * value factory decorator. + * @param valueFactory the underlying value factory instance. + * @return value factory decorator. + */ + ValueFactory getValueFactoryDecorator(Session session, ValueFactory valueFactory); + + /** + * Creates a item visitor decorator. + * + * @param session the session (decorator) instance used to create the item + * visitor decorator. + * @param visitor the underlying item visitor instance. + * @return item visitor decorator. + */ + ItemVisitor getItemVisitorDecorator(Session session, ItemVisitor visitor); } Index: java/org/apache/jackrabbit/decorator/TrussDecoratorFactory.java =================================================================== --- java/org/apache/jackrabbit/decorator/TrussDecoratorFactory.java (revision 0) +++ java/org/apache/jackrabbit/decorator/TrussDecoratorFactory.java (revision 0) @@ -0,0 +1,69 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.decorator; + +import org.apache.log4j.Logger; + +import javax.jcr.Node; +import javax.jcr.Session; +import javax.jcr.PathNotFoundException; +import javax.jcr.RepositoryException; +import javax.jcr.NodeIterator; +import javax.jcr.version.Version; +import javax.jcr.version.VersionHistory; + +/** + * + */ +public class TrussDecoratorFactory extends DefaultDecoratorFactory { + + private static final Logger log = Logger.getLogger(TrussDecoratorFactory.class); + + public Node getNodeDecorator(Session session, Node node) { + if (node instanceof Version) { + return getVersionDecorator(session, (Version) node); + } else if (node instanceof VersionHistory) { + return getVersionHistoryDecorator(session, (VersionHistory) node); + } else { + return new TrussNodeDecorator(this, session, node); + } + } + + private static final class TrussNodeDecorator extends NodeDecorator { + + public TrussNodeDecorator(DecoratorFactory factory, Session session, Node node) { + super(factory, session, node); + } + + public Node getNode(String relPath) + throws PathNotFoundException, RepositoryException { + log.info("<" + node.getPath() + ">.getNode(" + relPath + ")"); + return super.getNode(relPath); + } + + public NodeIterator getNodes() throws RepositoryException { + log.info("<" + node.getPath() + ">.getNodes()"); + return super.getNodes(); + } + + public NodeIterator getNodes(String namePattern) + throws RepositoryException { + log.info("<" + node.getPath() + ">.getNodes(" + namePattern + ")"); + return super.getNodes(namePattern); + } + } +} Property changes on: java/org/apache/jackrabbit/decorator/TrussDecoratorFactory.java ___________________________________________________________________ Name: svn:eol-style + native Index: java/org/apache/jackrabbit/decorator/ChainedItemDecorator.java =================================================================== --- java/org/apache/jackrabbit/decorator/ChainedItemDecorator.java (revision 312864) +++ java/org/apache/jackrabbit/decorator/ChainedItemDecorator.java (working copy) @@ -1,120 +0,0 @@ -/* - * Copyright 2004-2005 The Apache Software Foundation or its licensors, - * as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.jackrabbit.decorator; - -import javax.jcr.AccessDeniedException; -import javax.jcr.InvalidItemStateException; -import javax.jcr.Item; -import javax.jcr.ItemNotFoundException; -import javax.jcr.ItemVisitor; -import javax.jcr.Node; -import javax.jcr.ReferentialIntegrityException; -import javax.jcr.RepositoryException; -import javax.jcr.Session; -import javax.jcr.lock.LockException; -import javax.jcr.nodetype.ConstraintViolationException; -import javax.jcr.version.VersionException; - -/** - * TODO - */ -public class ChainedItemDecorator implements Item { - - private ItemDecorator decorator; - - public ChainedItemDecorator(ItemDecorator decorator) { - this.decorator = decorator; - } - - /** {@inheritDoc} */ - public Session getSession() throws RepositoryException { - return decorator.getSession(); - } - - /** {@inheritDoc} */ - public String getPath() throws RepositoryException { - return decorator.getPath(); - } - - /** {@inheritDoc} */ - public String getName() throws RepositoryException { - return decorator.getName(); - } - - /** {@inheritDoc} */ - public Item getAncestor(int depth) throws ItemNotFoundException, - AccessDeniedException, RepositoryException { - return decorator.getAncestor(depth); - } - - /** {@inheritDoc} */ - public Node getParent() throws ItemNotFoundException, - AccessDeniedException, RepositoryException { - return decorator.getParent(); - } - - /** {@inheritDoc} */ - public int getDepth() throws RepositoryException { - return decorator.getDepth(); - } - - /** {@inheritDoc} */ - public boolean isNode() { - return decorator.isNode(); - } - - /** {@inheritDoc} */ - public boolean isNew() { - return decorator.isNew(); - } - - /** {@inheritDoc} */ - public boolean isModified() { - return decorator.isModified(); - } - - /** {@inheritDoc} */ - public boolean isSame(Item otherItem) { - return decorator.isSame(otherItem); - } - - /** {@inheritDoc} */ - public void accept(ItemVisitor visitor) throws RepositoryException { - decorator.accept(visitor); - } - - /** {@inheritDoc} */ - public void save() throws AccessDeniedException, - ConstraintViolationException, InvalidItemStateException, - ReferentialIntegrityException, VersionException, LockException, - RepositoryException { - decorator.save(); - } - - /** {@inheritDoc} */ - public void refresh(boolean keepChanges) throws InvalidItemStateException, - RepositoryException { - decorator.refresh(keepChanges); - } - - /** {@inheritDoc} */ - public void remove() throws VersionException, LockException, - RepositoryException { - decorator.remove(); - } - -} Index: java/org/apache/jackrabbit/decorator/DefaultDecoratorFactory.java =================================================================== --- java/org/apache/jackrabbit/decorator/DefaultDecoratorFactory.java (revision 0) +++ java/org/apache/jackrabbit/decorator/DefaultDecoratorFactory.java (revision 0) @@ -0,0 +1,158 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.decorator; + +import javax.jcr.Item; +import javax.jcr.Node; +import javax.jcr.Property; +import javax.jcr.Repository; +import javax.jcr.Session; +import javax.jcr.Workspace; +import javax.jcr.ValueFactory; +import javax.jcr.ItemVisitor; +import javax.jcr.query.Query; +import javax.jcr.query.QueryResult; +import javax.jcr.query.QueryManager; +import javax.jcr.version.Version; +import javax.jcr.version.VersionHistory; +import javax.jcr.lock.Lock; + +/** + * Default implementation of a {@link DecoratorFactory}. All decorator instances + * simply wrap the original instance and forward the call to it. + */ +public class DefaultDecoratorFactory implements DecoratorFactory { + + /** + * {@inheritDoc} + */ + public Repository getRepositoryDecorator(Repository repository) { + return new RepositoryDecorator(this, repository); + } + + /** + * {@inheritDoc} + */ + public Session getSessionDecorator(Repository repository, Session session) { + return new SessionDecorator(this, repository, session); + } + + /** + * {@inheritDoc} + */ + public Workspace getWorkspaceDecorator(Session session, Workspace workspace) { + return new WorkspaceDecorator(this, session, workspace); + } + + /** + * {@inheritDoc} + */ + public Node getNodeDecorator(Session session, Node node) { + if (node instanceof Version) { + return getVersionDecorator(session, (Version) node); + } else if (node instanceof VersionHistory) { + return getVersionHistoryDecorator(session, (VersionHistory) node); + } else { + return new NodeDecorator(this, session, node); + } + } + + /** + * {@inheritDoc} + */ + public Property getPropertyDecorator(Session session, Property property) { + return new PropertyDecorator(this, session, property); + } + + /** + * {@inheritDoc} + */ + public Lock getLockDecorator(Session session, Lock lock) { + return new LockDecorator(this, session, lock); + } + + /** + * {@inheritDoc} + */ + public Version getVersionDecorator(Session session, Version version) { + return new VersionDecorator(this, session, version); + } + + /** + * {@inheritDoc} + */ + public VersionHistory getVersionHistoryDecorator(Session session, + VersionHistory versionHistory) { + return new VersionHistoryDecorator(this, session, versionHistory); + } + + /** + * {@inheritDoc} + */ + public Item getItemDecorator(Session session, Item item) { + if (item instanceof Version) { + return getVersionDecorator(session, (Version) item); + } else if (item instanceof VersionHistory) { + return getVersionHistoryDecorator(session, (VersionHistory) item); + } else if (item instanceof Node) { + return getNodeDecorator(session, (Node) item); + } else if (item instanceof Property) { + return getPropertyDecorator(session, (Property) item); + } else { + return new ItemDecorator(this, session, item); + } + } + + /** + * {@inheritDoc} + */ + public QueryManager getQueryManagerDecorator(Session session, + QueryManager queryManager) { + return new QueryManagerDecorator(this, session, queryManager); + } + + /** + * {@inheritDoc} + */ + public Query getQueryDecorator(Session session, Query query) { + return new QueryDecorator(this, session, query); + } + + /** + * {@inheritDoc} + */ + public QueryResult getQueryResultDecorator(Session session, + QueryResult result) { + return new QueryResultDecorator(this, session, result); + } + + /** + * {@inheritDoc} + */ + public ValueFactory getValueFactoryDecorator(Session session, + ValueFactory valueFactory) { + return new ValueFactoryDecorator(this, session, valueFactory); + } + + /** + * {@inheritDoc} + */ + public ItemVisitor getItemVisitorDecorator(Session session, + ItemVisitor visitor) { + return new ItemVisitorDecorator(this, session, visitor); + } +} Property changes on: java/org/apache/jackrabbit/decorator/DefaultDecoratorFactory.java ___________________________________________________________________ Name: svn:eol-style + native Index: java/org/apache/jackrabbit/decorator/ItemVisitorDecorator.java =================================================================== --- java/org/apache/jackrabbit/decorator/ItemVisitorDecorator.java (revision 0) +++ java/org/apache/jackrabbit/decorator/ItemVisitorDecorator.java (revision 0) @@ -0,0 +1,50 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.decorator; + +import javax.jcr.ItemVisitor; +import javax.jcr.Property; +import javax.jcr.RepositoryException; +import javax.jcr.Node; +import javax.jcr.Session; + +/** + */ +public class ItemVisitorDecorator + extends AbstractDecorator implements ItemVisitor { + + protected final ItemVisitor visitor; + + public ItemVisitorDecorator(DecoratorFactory factory, Session session, ItemVisitor visitor) { + super(factory, session); + this.visitor = visitor; + } + + /** + * @inheritDoc + */ + public void visit(Property property) throws RepositoryException { + visitor.visit(factory.getPropertyDecorator(session, property)); + } + + /** + * @inheritDoc + */ + public void visit(Node node) throws RepositoryException { + visitor.visit(factory.getNodeDecorator(session, node)); + } +} Property changes on: java/org/apache/jackrabbit/decorator/ItemVisitorDecorator.java ___________________________________________________________________ Name: svn:eol-style + native Index: java/org/apache/jackrabbit/decorator/SimpleDecoratorFactory.java =================================================================== --- java/org/apache/jackrabbit/decorator/SimpleDecoratorFactory.java (revision 312864) +++ java/org/apache/jackrabbit/decorator/SimpleDecoratorFactory.java (working copy) @@ -1,73 +0,0 @@ -/* - * Copyright 2004-2005 The Apache Software Foundation or its licensors, - * as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.jackrabbit.decorator; - -import javax.jcr.Item; -import javax.jcr.Node; -import javax.jcr.Property; -import javax.jcr.Repository; -import javax.jcr.Session; -import javax.jcr.Workspace; -import javax.jcr.lock.Lock; - -/** - * TODO - */ -public class SimpleDecoratorFactory implements DecoratorFactory { - - /** {@inheritDoc} */ - public Repository getRepositoryDecorator(Repository repository) { - return new RepositoryDecorator(this, repository); - } - - /** {@inheritDoc} */ - public Session getSessionDecorator(Repository repository, Session session) { - return new SessionDecorator(this, repository, session); - } - - /** {@inheritDoc} */ - public Workspace getWorkspaceDecorator(Session session, Workspace workspace) { - return new WorkspaceDecorator(this, session, workspace); - } - - /** {@inheritDoc} */ - public Node getNodeDecorator(Session session, Node node) { - return null; - } - - /** {@inheritDoc} */ - public Property getPropertyDecorator(Session session, Property property) { - // TODO Auto-generated method stub - return null; - } - - /** {@inheritDoc} */ - public Item getItemDecorator(Session session, Item item) { - if (item instanceof Node) { - return getNodeDecorator(session, (Node) item); - } else if (item instanceof Property) { - return getPropertyDecorator(session, (Property) item); - } else { - return new ItemDecorator(this, session, item); - } - } - - public Lock getLockDecorator(Node node, Lock lock) { - return new LockDecorator(node, lock); - } - -} Index: java/org/apache/jackrabbit/decorator/SessionDecorator.java =================================================================== --- java/org/apache/jackrabbit/decorator/SessionDecorator.java (revision 320755) +++ java/org/apache/jackrabbit/decorator/SessionDecorator.java (working copy) @@ -47,16 +47,21 @@ import org.xml.sax.SAXException; /** - * TODO */ public class SessionDecorator implements Session { - private DecoratorFactory factory; + protected final DecoratorFactory factory; - private Repository repository; + protected final Repository repository; - private Session session; + protected final Session session; + /** + * @param factory + * @param repository the repository (decorator) that was used to create the + * session decorator. + * @param session + */ public SessionDecorator( DecoratorFactory factory, Repository repository, Session session) { this.factory = factory; @@ -121,7 +126,7 @@ */ public Node getRootNode() throws RepositoryException { Node root = session.getRootNode(); - return factory.getNodeDecorator(session, root); + return factory.getNodeDecorator(this, root); } /** @@ -133,7 +138,7 @@ public Node getNodeByUUID(String uuid) throws ItemNotFoundException, RepositoryException { Node node = session.getNodeByUUID(uuid); - return factory.getNodeDecorator(session, node); + return factory.getNodeDecorator(this, node); } /** @@ -147,13 +152,7 @@ public Item getItem(String absPath) throws PathNotFoundException, RepositoryException { Item item = session.getItem(absPath); - if (item instanceof Node) { - return factory.getNodeDecorator(session, (Node) item); - } else if (item instanceof Property) { - return factory.getPropertyDecorator(session, (Property) item); - } else { - return factory.getItemDecorator(session, item); - } + return factory.getItemDecorator(this, item); } /** @@ -286,7 +285,7 @@ */ public String getNamespaceURI(String prefix) throws NamespaceException, RepositoryException { - return session.getNamespacePrefix(prefix); + return session.getNamespaceURI(prefix); } /** @@ -327,7 +326,7 @@ public ValueFactory getValueFactory() throws UnsupportedRepositoryOperationException, RepositoryException { - return session.getValueFactory(); + return factory.getValueFactoryDecorator(this, session.getValueFactory()); } public boolean isLive() { Index: java/org/apache/jackrabbit/decorator/ChainedDecoratorFactory.java =================================================================== --- java/org/apache/jackrabbit/decorator/ChainedDecoratorFactory.java (revision 312864) +++ java/org/apache/jackrabbit/decorator/ChainedDecoratorFactory.java (working copy) @@ -1,103 +0,0 @@ -/* - * Copyright 2004-2005 The Apache Software Foundation or its licensors, - * as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.jackrabbit.decorator; - -import javax.jcr.Item; -import javax.jcr.Node; -import javax.jcr.Property; -import javax.jcr.Repository; -import javax.jcr.Session; -import javax.jcr.Workspace; -import javax.jcr.lock.Lock; - -import org.apache.jackrabbit.decorator.DecoratorFactory; - -/** - * Creates a chain of decorator factories. Decorated classes extend this class which provides - * basic functinality for changing, especially the #chainedFactory which will be set automatically - * by the DecoratedRepositoryFactoryBean. - * - * @author Costin Leau - */ -public class ChainedDecoratorFactory implements DecoratorFactory { - - protected DecoratorFactory chainedFactory; - - /** - * @see DecoratorFactory#getRepositoryDecorator(javax.jcr.Repository) - */ - public Repository getRepositoryDecorator(Repository repository) { - return chainedFactory.getRepositoryDecorator(repository); - } - - /** - * @see DecoratorFactory#getSessionDecorator(javax.jcr.Repository, - * javax.jcr.Session) - */ - public Session getSessionDecorator(Repository repository, Session session) { - return chainedFactory.getSessionDecorator(repository, session); - } - - /** - * @see DecoratorFactory#getItemDecorator(javax.jcr.Session, javax.jcr.Item) - */ - public Item getItemDecorator(Session session, Item item) { - return chainedFactory.getItemDecorator(session, item); - } - - /** - * @see DecoratorFactory#getNodeDecorator(javax.jcr.Session, javax.jcr.Node) - */ - public Node getNodeDecorator(Session session, Node node) { - return chainedFactory.getNodeDecorator(session, node); - } - - /** - * @see DecoratorFactory#getPropertyDecorator(javax.jcr.Session, javax.jcr.Property) - */ - public Property getPropertyDecorator(Session session, Property property) { - return chainedFactory.getPropertyDecorator(session, property); - } - - /** - * @see DecoratorFactory#getWorkspaceDecorator(javax.jcr.Session, javax.jcr.Workspace) - */ - public Workspace getWorkspaceDecorator(Session session, Workspace workspace) { - return chainedFactory.getWorkspaceDecorator(session, workspace); - } - - /** - * @see DecoratorFactory#getLockDecorator(Node, Lock) - */ - public Lock getLockDecorator(Node node, Lock lock) { - return chainedFactory.getLockDecorator(node, lock); - } - - /** - * @return Returns the factory. - */ - public DecoratorFactory getChainedFactory() { - return chainedFactory; - } - - /** - * @param factory The factory to set. - */ - public void setChainedFactory(DecoratorFactory factory) { - this.chainedFactory = factory; - } -} Index: java/org/apache/jackrabbit/decorator/PropertyDecorator.java =================================================================== --- java/org/apache/jackrabbit/decorator/PropertyDecorator.java (revision 0) +++ java/org/apache/jackrabbit/decorator/PropertyDecorator.java (revision 0) @@ -0,0 +1,225 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.decorator; + +import javax.jcr.Property; +import javax.jcr.Value; +import javax.jcr.ValueFormatException; +import javax.jcr.RepositoryException; +import javax.jcr.Node; +import javax.jcr.Session; +import javax.jcr.nodetype.ConstraintViolationException; +import javax.jcr.nodetype.PropertyDefinition; +import javax.jcr.lock.LockException; +import javax.jcr.version.VersionException; +import java.io.InputStream; +import java.util.Calendar; + +/** + */ +public class PropertyDecorator extends ItemDecorator implements Property { + + protected final Property property; + + public PropertyDecorator(DecoratorFactory factory, + Session session, + Property property) { + super(factory, session, property); + this.property = property; + } + + /** + * @inheritDoc + */ + public void setValue(Value value) + throws ValueFormatException, VersionException, LockException, + ConstraintViolationException, RepositoryException { + property.setValue(value); + } + + /** + * @inheritDoc + */ + public void setValue(Value[] values) + throws ValueFormatException, VersionException, LockException, + ConstraintViolationException, RepositoryException { + property.setValue(values); + } + + /** + * @inheritDoc + */ + public void setValue(String s) + throws ValueFormatException, VersionException, LockException, + ConstraintViolationException, RepositoryException { + property.setValue(s); + } + + /** + * @inheritDoc + */ + public void setValue(String[] strings) + throws ValueFormatException, VersionException, LockException, + ConstraintViolationException, RepositoryException { + property.setValue(strings); + } + + /** + * @inheritDoc + */ + public void setValue(InputStream inputStream) + throws ValueFormatException, VersionException, LockException, + ConstraintViolationException, RepositoryException { + property.setValue(inputStream); + } + + /** + * @inheritDoc + */ + public void setValue(long l) + throws ValueFormatException, VersionException, LockException, + ConstraintViolationException, RepositoryException { + property.setValue(l); + } + + /** + * @inheritDoc + */ + public void setValue(double v) + throws ValueFormatException, VersionException, LockException, + ConstraintViolationException, RepositoryException { + property.setValue(v); + } + + /** + * @inheritDoc + */ + public void setValue(Calendar calendar) + throws ValueFormatException, VersionException, LockException, + ConstraintViolationException, RepositoryException { + property.setValue(calendar); + } + + /** + * @inheritDoc + */ + public void setValue(boolean b) + throws ValueFormatException, VersionException, LockException, + ConstraintViolationException, RepositoryException { + property.setValue(b); + } + + /** + * @inheritDoc + */ + public void setValue(Node node) + throws ValueFormatException, VersionException, LockException, + ConstraintViolationException, RepositoryException { + property.setValue(NodeDecorator.unwrap(node)); + } + + /** + * @inheritDoc + */ + public Value getValue() throws ValueFormatException, RepositoryException { + return property.getValue(); + } + + /** + * @inheritDoc + */ + public Value[] getValues() throws ValueFormatException, RepositoryException { + return property.getValues(); + } + + /** + * @inheritDoc + */ + public String getString() throws ValueFormatException, RepositoryException { + return property.getString(); + } + + /** + * @inheritDoc + */ + public InputStream getStream() throws ValueFormatException, RepositoryException { + return property.getStream(); + } + + /** + * @inheritDoc + */ + public long getLong() throws ValueFormatException, RepositoryException { + return property.getLong(); + } + + /** + * @inheritDoc + */ + public double getDouble() throws ValueFormatException, RepositoryException { + return property.getDouble(); + } + + /** + * @inheritDoc + */ + public Calendar getDate() throws ValueFormatException, RepositoryException { + return property.getDate(); + } + + /** + * @inheritDoc + */ + public boolean getBoolean() throws ValueFormatException, RepositoryException { + return property.getBoolean(); + } + + /** + * @inheritDoc + */ + public Node getNode() throws ValueFormatException, RepositoryException { + return factory.getNodeDecorator(session, property.getNode()); + } + + /** + * @inheritDoc + */ + public long getLength() throws ValueFormatException, RepositoryException { + return property.getLength(); + } + + /** + * @inheritDoc + */ + public long[] getLengths() throws ValueFormatException, RepositoryException { + return property.getLengths(); + } + + /** + * @inheritDoc + */ + public PropertyDefinition getDefinition() throws RepositoryException { + return property.getDefinition(); + } + + /** + * @inheritDoc + */ + public int getType() throws RepositoryException { + return property.getType(); + } +} Property changes on: java/org/apache/jackrabbit/decorator/PropertyDecorator.java ___________________________________________________________________ Name: svn:eol-style + native Index: java/org/apache/jackrabbit/decorator/VersionDecorator.java =================================================================== --- java/org/apache/jackrabbit/decorator/VersionDecorator.java (revision 0) +++ java/org/apache/jackrabbit/decorator/VersionDecorator.java (revision 0) @@ -0,0 +1,98 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.decorator; + +import org.apache.jackrabbit.decorator.NodeDecorator; +import org.apache.jackrabbit.decorator.DecoratorFactory; + +import javax.jcr.Session; +import javax.jcr.RepositoryException; +import javax.jcr.version.Version; +import javax.jcr.version.VersionHistory; +import java.util.Calendar; + +/** + */ +public class VersionDecorator extends NodeDecorator implements Version { + + protected final Version version; + + public VersionDecorator(DecoratorFactory factory, + Session session, + Version version) { + super(factory, session, version); + this.version = version; + } + + /** + * Returns the underlying Version of the version + * that decorates it. Unwrapping null returns null. + * + * @param version decorates the underlying version. + * @return the underlying version. + * @throws IllegalStateException if version is not of type + * {@link VersionDecorator}. + */ + public static Version unwrap(Version version) { + if (version == null) { + return null; + } + if (version instanceof VersionDecorator) { + version = (Version) ((VersionDecorator) version).unwrap(); + } else { + throw new IllegalStateException("version is not of type VersionDecorator"); + } + return version; + } + + /** + * @inheritDoc + */ + public VersionHistory getContainingHistory() throws RepositoryException { + VersionHistory vHistory = version.getContainingHistory(); + return factory.getVersionHistoryDecorator(session, vHistory); + } + + /** + * @inheritDoc + */ + public Calendar getCreated() throws RepositoryException { + return version.getCreated(); + } + + /** + * @inheritDoc + */ + public Version[] getSuccessors() throws RepositoryException { + Version[] successors = version.getSuccessors(); + for (int i = 0; i < successors.length; i++) { + successors[i] = factory.getVersionDecorator(session, successors[i]); + } + return successors; + } + + /** + * @inheritDoc + */ + public Version[] getPredecessors() throws RepositoryException { + Version[] predecessors = version.getPredecessors(); + for (int i = 0; i < predecessors.length; i++) { + predecessors[i] = factory.getVersionDecorator(session, predecessors[i]); + } + return predecessors; + } +} Property changes on: java/org/apache/jackrabbit/decorator/VersionDecorator.java ___________________________________________________________________ Name: svn:eol-style + native Index: java/org/apache/jackrabbit/decorator/NodeDecorator.java =================================================================== --- java/org/apache/jackrabbit/decorator/NodeDecorator.java (revision 320755) +++ java/org/apache/jackrabbit/decorator/NodeDecorator.java (working copy) @@ -35,6 +35,7 @@ import javax.jcr.UnsupportedRepositoryOperationException; import javax.jcr.Value; import javax.jcr.ValueFormatException; +import javax.jcr.MergeException; import javax.jcr.lock.Lock; import javax.jcr.lock.LockException; import javax.jcr.nodetype.ConstraintViolationException; @@ -45,23 +46,39 @@ import javax.jcr.version.VersionException; import javax.jcr.version.VersionHistory; -public class NodeDecorator extends ChainedItemDecorator implements Node { +public class NodeDecorator extends ItemDecorator implements Node { - private DecoratorFactory factory; + protected Node node; - private Session session; - - private Node node; - - public NodeDecorator( - ItemDecorator decorator, - DecoratorFactory factory, Session session, Node node) { - super(decorator); - this.factory = factory; - this.session = session; + public NodeDecorator(DecoratorFactory factory, Session session, Node node) { + super(factory, session, node); this.node = node; } + /** + * Returns the underlying Node of the node + * that decorates it. Unwrapping null returns null. + * + * @param node decorates the underlying node. + * @return the underlying node. + * @throws IllegalStateException if node is not of type + * {@link NodeDecorator}. + */ + public static Node unwrap(Node node) { + if (node == null) { + return null; + } + if (node instanceof NodeDecorator) { + node = (Node) ((NodeDecorator) node).unwrap(); + } else { + throw new IllegalStateException("node is not of type NodeDecorator"); + } + return node; + } + + /** + * @inheritDoc + */ public Node addNode(String name) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, RepositoryException { @@ -69,6 +86,9 @@ return factory.getNodeDecorator(session, child); } + /** + * @inheritDoc + */ public Node addNode(String name, String type) throws ItemExistsException, PathNotFoundException, NoSuchNodeTypeException, LockException, VersionException, ConstraintViolationException, RepositoryException { @@ -76,350 +96,487 @@ return factory.getNodeDecorator(session, child); } - public void orderBefore(String arg0, String arg1) + /** + * @inheritDoc + */ + public void orderBefore(String srcChildRelPath, String destChildRelPath) throws UnsupportedRepositoryOperationException, VersionException, - ConstraintViolationException, ItemNotFoundException, LockException, - RepositoryException { - // TODO Auto-generated method stub - + ConstraintViolationException, ItemNotFoundException, + LockException, RepositoryException { + node.orderBefore(srcChildRelPath, destChildRelPath); } - public Property setProperty(String arg0, Value arg1) + /** + * @inheritDoc + */ + public Property setProperty(String name, Value value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException { - // TODO Auto-generated method stub - return null; + Property prop = node.setProperty(name, value); + return factory.getPropertyDecorator(session, prop); } - public Property setProperty(String arg0, Value arg1, int arg2) + /** + * @inheritDoc + */ + public Property setProperty(String name, Value value, int type) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException { - // TODO Auto-generated method stub - return null; + Property prop = node.setProperty(name, value, type); + return factory.getPropertyDecorator(session, prop); } - public Property setProperty(String arg0, Value[] arg1) + /** + * @inheritDoc + */ + public Property setProperty(String name, Value[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException { - // TODO Auto-generated method stub - return null; + Property prop = node.setProperty(name, values); + return factory.getPropertyDecorator(session, prop); } - public Property setProperty(String arg0, Value[] arg1, int arg2) + /** + * @inheritDoc + */ + public Property setProperty(String name, Value[] values, int type) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException { - // TODO Auto-generated method stub - return null; + Property prop = node.setProperty(name, values, type); + return factory.getPropertyDecorator(session, prop); } - public Property setProperty(String arg0, String[] arg1) + /** + * @inheritDoc + */ + public Property setProperty(String name, String[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException { - // TODO Auto-generated method stub - return null; + Property prop = node.setProperty(name, values); + return factory.getPropertyDecorator(session, prop); } - public Property setProperty(String arg0, String[] arg1, int arg2) + /** + * @inheritDoc + */ + public Property setProperty(String name, String[] values, int type) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException { - // TODO Auto-generated method stub - return null; + Property prop = node.setProperty(name, values, type); + return factory.getPropertyDecorator(session, prop); } - public Property setProperty(String arg0, String arg1) + /** + * @inheritDoc + */ + public Property setProperty(String name, String value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException { - // TODO Auto-generated method stub - return null; + Property prop = node.setProperty(name, value); + return factory.getPropertyDecorator(session, prop); } - public Property setProperty(String arg0, String arg1, int arg2) + /** + * @inheritDoc + */ + public Property setProperty(String name, String value, int type) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException { - // TODO Auto-generated method stub - return null; + Property prop = node.setProperty(name, value, type); + return factory.getPropertyDecorator(session, prop); } - public Property setProperty(String arg0, InputStream arg1) + /** + * @inheritDoc + */ + public Property setProperty(String name, InputStream value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException { - // TODO Auto-generated method stub - return null; + Property prop = node.setProperty(name, value); + return factory.getPropertyDecorator(session, prop); } - public Property setProperty(String arg0, boolean arg1) + /** + * @inheritDoc + */ + public Property setProperty(String name, boolean value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException { - // TODO Auto-generated method stub - return null; + Property prop = node.setProperty(name, value); + return factory.getPropertyDecorator(session, prop); } - public Property setProperty(String arg0, double arg1) + /** + * @inheritDoc + */ + public Property setProperty(String name, double value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException { - // TODO Auto-generated method stub - return null; + Property prop = node.setProperty(name, value); + return factory.getPropertyDecorator(session, prop); } - public Property setProperty(String arg0, long arg1) + /** + * @inheritDoc + */ + public Property setProperty(String name, long value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException { - // TODO Auto-generated method stub - return null; + Property prop = node.setProperty(name, value); + return factory.getPropertyDecorator(session, prop); } - public Property setProperty(String arg0, Calendar arg1) + /** + * @inheritDoc + */ + public Property setProperty(String name, Calendar value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException { - // TODO Auto-generated method stub - return null; + Property prop = node.setProperty(name, value); + return factory.getPropertyDecorator(session, prop); } - public Property setProperty(String arg0, Node arg1) + /** + * @inheritDoc + */ + public Property setProperty(String name, Node value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException { - // TODO Auto-generated method stub - return null; + Property prop = node.setProperty(name, NodeDecorator.unwrap(value)); + return factory.getPropertyDecorator(session, prop); } - public Node getNode(String arg0) throws PathNotFoundException, - RepositoryException { - // TODO Auto-generated method stub - return null; + /** + * @inheritDoc + */ + public Node getNode(String relPath) throws PathNotFoundException, RepositoryException { + Node n = node.getNode(relPath); + return factory.getNodeDecorator(session, n); } + /** + * @inheritDoc + */ public NodeIterator getNodes() throws RepositoryException { - // TODO Auto-generated method stub - return null; + return new DecoratingNodeIterator(factory, session, node.getNodes()); } - public NodeIterator getNodes(String arg0) throws RepositoryException { - // TODO Auto-generated method stub - return null; + /** + * @inheritDoc + */ + public NodeIterator getNodes(String namePattern) + throws RepositoryException { + return new DecoratingNodeIterator(factory, session, node.getNodes(namePattern)); } - public Property getProperty(String arg0) throws PathNotFoundException, - RepositoryException { - // TODO Auto-generated method stub - return null; + /** + * @inheritDoc + */ + public Property getProperty(String relPath) + throws PathNotFoundException, RepositoryException { + Property prop = node.getProperty(relPath); + return factory.getPropertyDecorator(session, prop); } + /** + * @inheritDoc + */ public PropertyIterator getProperties() throws RepositoryException { - // TODO Auto-generated method stub - return null; + return new DecoratingPropertyIterator(factory, session, node.getProperties()); } - public PropertyIterator getProperties(String arg0) + /** + * @inheritDoc + */ + public PropertyIterator getProperties(String namePattern) throws RepositoryException { - // TODO Auto-generated method stub - return null; + return new DecoratingPropertyIterator(factory, session, node.getProperties(namePattern)); } + /** + * @inheritDoc + */ public Item getPrimaryItem() throws ItemNotFoundException, RepositoryException { - // TODO Auto-generated method stub - return null; + return factory.getItemDecorator(session, node.getPrimaryItem()); } + /** + * @inheritDoc + */ public String getUUID() throws UnsupportedRepositoryOperationException, RepositoryException { - // TODO Auto-generated method stub - return null; + return node.getUUID(); } + /** + * @inheritDoc + */ public int getIndex() throws RepositoryException { - // TODO Auto-generated method stub - return 0; + return node.getIndex(); } + /** + * @inheritDoc + */ public PropertyIterator getReferences() throws RepositoryException { - // TODO Auto-generated method stub - return null; + return new DecoratingPropertyIterator(factory, session, node.getReferences()); } - public boolean hasNode(String arg0) throws RepositoryException { - // TODO Auto-generated method stub - return false; + /** + * @inheritDoc + */ + public boolean hasNode(String relPath) throws RepositoryException { + return node.hasNode(relPath); } - public boolean hasProperty(String arg0) throws RepositoryException { - // TODO Auto-generated method stub - return false; + /** + * @inheritDoc + */ + public boolean hasProperty(String relPath) throws RepositoryException { + return node.hasProperty(relPath); } + /** + * @inheritDoc + */ public boolean hasNodes() throws RepositoryException { - // TODO Auto-generated method stub - return false; + return node.hasNodes(); } + /** + * @inheritDoc + */ public boolean hasProperties() throws RepositoryException { - // TODO Auto-generated method stub - return false; + return node.hasProperties(); } + /** + * @inheritDoc + */ public NodeType getPrimaryNodeType() throws RepositoryException { - // TODO Auto-generated method stub - return null; + return node.getPrimaryNodeType(); } + /** + * @inheritDoc + */ public NodeType[] getMixinNodeTypes() throws RepositoryException { - // TODO Auto-generated method stub - return null; + return node.getMixinNodeTypes(); } - public boolean isNodeType(String arg0) throws RepositoryException { - // TODO Auto-generated method stub - return false; + /** + * @inheritDoc + */ + public boolean isNodeType(String nodeTypeName) throws RepositoryException { + return node.isNodeType(nodeTypeName); } - public void addMixin(String arg0) throws NoSuchNodeTypeException, - VersionException, ConstraintViolationException, LockException, - RepositoryException { - // TODO Auto-generated method stub - + /** + * @inheritDoc + */ + public void addMixin(String mixinName) + throws NoSuchNodeTypeException, VersionException, + ConstraintViolationException, LockException, RepositoryException { + node.addMixin(mixinName); } - public void removeMixin(String arg0) throws NoSuchNodeTypeException, - VersionException, ConstraintViolationException, LockException, - RepositoryException { - // TODO Auto-generated method stub - + /** + * @inheritDoc + */ + public void removeMixin(String mixinName) + throws NoSuchNodeTypeException, VersionException, + ConstraintViolationException, LockException, RepositoryException { + node.removeMixin(mixinName); } - public boolean canAddMixin(String arg0) throws NoSuchNodeTypeException, - RepositoryException { - // TODO Auto-generated method stub - return false; + /** + * @inheritDoc + */ + public boolean canAddMixin(String mixinName) + throws NoSuchNodeTypeException, RepositoryException { + return node.canAddMixin(mixinName); } + /** + * @inheritDoc + */ public NodeDefinition getDefinition() throws RepositoryException { - // TODO Auto-generated method stub - return null; + return node.getDefinition(); } + /** + * @inheritDoc + */ public Version checkin() throws VersionException, UnsupportedRepositoryOperationException, InvalidItemStateException, LockException, RepositoryException { - // TODO Auto-generated method stub - return null; + Version version = node.checkin(); + return factory.getVersionDecorator(session, version); } + /** + * @inheritDoc + */ public void checkout() throws UnsupportedRepositoryOperationException, LockException, RepositoryException { - // TODO Auto-generated method stub - + node.checkout(); } - public void doneMerge(Version arg0) throws VersionException, - InvalidItemStateException, UnsupportedRepositoryOperationException, - RepositoryException { - // TODO Auto-generated method stub - + /** + * @inheritDoc + */ + public void doneMerge(Version version) + throws VersionException, InvalidItemStateException, + UnsupportedRepositoryOperationException, RepositoryException { + node.doneMerge(VersionDecorator.unwrap(version)); } - public void cancelMerge(Version arg0) throws VersionException, - InvalidItemStateException, UnsupportedRepositoryOperationException, - RepositoryException { - // TODO Auto-generated method stub - + /** + * @inheritDoc + */ + public void cancelMerge(Version version) + throws VersionException, InvalidItemStateException, + UnsupportedRepositoryOperationException, RepositoryException { + node.cancelMerge(VersionDecorator.unwrap(version)); } - public void update(String arg0) throws NoSuchWorkspaceException, - AccessDeniedException, LockException, InvalidItemStateException, - RepositoryException { - // TODO Auto-generated method stub - + /** + * @inheritDoc + */ + public void update(String srcWorkspaceName) + throws NoSuchWorkspaceException, AccessDeniedException, + LockException, InvalidItemStateException, RepositoryException { + node.update(srcWorkspaceName); } - public NodeIterator merge(String arg0, boolean arg1) + /** + * @inheritDoc + */ + public NodeIterator merge(String srcWorkspace, boolean bestEffort) throws NoSuchWorkspaceException, AccessDeniedException, - VersionException, LockException, InvalidItemStateException, + MergeException, LockException, InvalidItemStateException, RepositoryException { - // TODO Auto-generated method stub - return null; + NodeIterator nodes = node.merge(srcWorkspace, bestEffort); + return new DecoratingNodeIterator(factory, session, nodes); } - public String getCorrespondingNodePath(String arg0) + /** + * @inheritDoc + */ + public String getCorrespondingNodePath(String workspaceName) throws ItemNotFoundException, NoSuchWorkspaceException, AccessDeniedException, RepositoryException { - // TODO Auto-generated method stub - return null; + return node.getCorrespondingNodePath(workspaceName); } + /** + * @inheritDoc + */ public boolean isCheckedOut() throws RepositoryException { - // TODO Auto-generated method stub - return false; + return node.isCheckedOut(); } - public void restore(String arg0, boolean arg1) throws VersionException, - ItemExistsException, UnsupportedRepositoryOperationException, - LockException, InvalidItemStateException, RepositoryException { - // TODO Auto-generated method stub - + /** + * @inheritDoc + */ + public void restore(String versionName, boolean removeExisting) + throws VersionException, ItemExistsException, + UnsupportedRepositoryOperationException, LockException, + InvalidItemStateException, RepositoryException { + node.restore(versionName, removeExisting); } - public void restore(Version arg0, boolean arg1) throws VersionException, - ItemExistsException, UnsupportedRepositoryOperationException, - LockException, RepositoryException { - // TODO Auto-generated method stub - + /** + * @inheritDoc + */ + public void restore(Version version, boolean removeExisting) + throws VersionException, ItemExistsException, + UnsupportedRepositoryOperationException, LockException, + RepositoryException { + node.restore(VersionDecorator.unwrap(version), removeExisting); } - public void restore(Version arg0, String arg1, boolean arg2) + /** + * @inheritDoc + */ + public void restore(Version version, + String relPath, + boolean removeExisting) throws PathNotFoundException, ItemExistsException, VersionException, ConstraintViolationException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException { - // TODO Auto-generated method stub - + node.restore(VersionDecorator.unwrap(version), relPath, removeExisting); } - public void restoreByLabel(String arg0, boolean arg1) + /** + * @inheritDoc + */ + public void restoreByLabel(String versionLabel, boolean removeExisting) throws VersionException, ItemExistsException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException { - // TODO Auto-generated method stub - + node.restoreByLabel(versionLabel, removeExisting); } + /** + * @inheritDoc + */ public VersionHistory getVersionHistory() throws UnsupportedRepositoryOperationException, RepositoryException { - // TODO Auto-generated method stub - return null; + VersionHistory hist = node.getVersionHistory(); + return factory.getVersionHistoryDecorator(session, hist); } + /** + * @inheritDoc + */ public Version getBaseVersion() throws UnsupportedRepositoryOperationException, RepositoryException { - // TODO Auto-generated method stub - return null; + return factory.getVersionDecorator(session, node.getBaseVersion()); } - public Lock lock(boolean arg0, boolean arg1) + /** + * @inheritDoc + */ + public Lock lock(boolean isDeep, boolean isSessionScoped) throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException { - Lock lock = node.lock(arg0, arg1); - return factory.getLockDecorator(this, lock); + Lock lock = node.lock(isDeep, isSessionScoped); + return factory.getLockDecorator(session, lock); } + /** + * @inheritDoc + */ public Lock getLock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, RepositoryException { - return node.getLock(); + Lock lock = node.getLock(); + return factory.getLockDecorator(session, lock); } + /** + * @inheritDoc + */ public void unlock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException { node.unlock(); } + /** + * @inheritDoc + */ public boolean holdsLock() throws RepositoryException { - // TODO Auto-generated method stub return node.holdsLock(); } + /** + * @inheritDoc + */ public boolean isLocked() throws RepositoryException { return node.isLocked(); } - } Index: java/org/apache/jackrabbit/decorator/LockDecorator.java =================================================================== --- java/org/apache/jackrabbit/decorator/LockDecorator.java (revision 320755) +++ java/org/apache/jackrabbit/decorator/LockDecorator.java (working copy) @@ -18,46 +18,68 @@ import javax.jcr.Node; import javax.jcr.RepositoryException; +import javax.jcr.Session; import javax.jcr.lock.Lock; import javax.jcr.lock.LockException; -public class LockDecorator implements Lock { +/** + * + */ +public class LockDecorator extends AbstractDecorator implements Lock { - private final Node node; + protected final Lock lock; - private final Lock lock; - - public LockDecorator(Node node, Lock lock) { - this.node = node; + public LockDecorator(DecoratorFactory factory, Session session, Lock lock) { + super(factory, session); this.lock = lock; } + /** + * @inheritDoc + */ public Node getNode() { - return node; + return factory.getNodeDecorator(session, lock.getNode()); } + /** + * @inheritDoc + */ public String getLockOwner() { return lock.getLockOwner(); } + /** + * @inheritDoc + */ public boolean isDeep() { return lock.isDeep(); } + /** + * @inheritDoc + */ public String getLockToken() { return lock.getLockToken(); } + /** + * @inheritDoc + */ public boolean isLive() throws RepositoryException { return lock.isLive(); } + /** + * @inheritDoc + */ public boolean isSessionScoped() { return lock.isSessionScoped(); } + /** + * @inheritDoc + */ public void refresh() throws LockException, RepositoryException { lock.refresh(); } - } Index: java/org/apache/jackrabbit/decorator/DecoratingPropertyIterator.java =================================================================== --- java/org/apache/jackrabbit/decorator/DecoratingPropertyIterator.java (revision 0) +++ java/org/apache/jackrabbit/decorator/DecoratingPropertyIterator.java (revision 0) @@ -0,0 +1,47 @@ +/* + * Copyright 2004-2005 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.decorator; + +import javax.jcr.Session; +import javax.jcr.PropertyIterator; +import javax.jcr.Property; + +/** + */ +public class DecoratingPropertyIterator extends DecoratingRangeIterator + implements PropertyIterator { + + /** + * Creates a decorating property iterator. + * + * @param factory decorator factory + * @param session decorated session + * @param iterator underlying property iterator + */ + public DecoratingPropertyIterator(DecoratorFactory factory, + Session session, + PropertyIterator iterator) { + super(factory, session, iterator); + } + + /** + * @inheritDoc + */ + public Property nextProperty() { + return (Property) next(); + } +} Property changes on: java/org/apache/jackrabbit/decorator/DecoratingPropertyIterator.java ___________________________________________________________________ Name: svn:eol-style + native