📄 clientnode.java
字号:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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.rmi.client;import java.io.InputStream;import java.rmi.RemoteException;import java.util.Calendar;import javax.jcr.Item;import javax.jcr.ItemVisitor;import javax.jcr.Node;import javax.jcr.NodeIterator;import javax.jcr.Property;import javax.jcr.PropertyIterator;import javax.jcr.RepositoryException;import javax.jcr.Session;import javax.jcr.Value;import javax.jcr.lock.Lock;import javax.jcr.nodetype.NodeDefinition;import javax.jcr.nodetype.NodeType;import javax.jcr.version.Version;import javax.jcr.version.VersionHistory;import org.apache.jackrabbit.rmi.remote.RemoteLock;import org.apache.jackrabbit.rmi.remote.RemoteNode;import org.apache.jackrabbit.rmi.remote.RemoteProperty;import org.apache.jackrabbit.rmi.value.SerialValueFactory;/** * Local adapter for the JCR-RMI * {@link org.apache.jackrabbit.rmi.remote.RemoteNode RemoteNode} * inteface. This class makes a remote node locally available using * the JCR {@link javax.jcr.Node Node} interface. * * @author Jukka Zitting * @see javax.jcr.Node * @see org.apache.jackrabbit.rmi.remote.RemoteNode */public class ClientNode extends ClientItem implements Node { /** The adapted remote node. */ private RemoteNode remote; /** * Creates a local adapter for the given remote node. * * @param session current session * @param remote remote node * @param factory local adapter factory */ public ClientNode( Session session, RemoteNode remote, LocalAdapterFactory factory) { super(session, remote, factory); this.remote = remote; } /** * Returns <code>true</code> without contacting the remote node. * * {@inheritDoc} */ public boolean isNode() { return true; } /** * Calls the {@link ItemVisitor#visit(Node) ItemVisitor.visit(Node)} * method of the given visitor. Does not contact the remote node, but * the visitor may invoke other methods that do contact the remote node. * * {@inheritDoc} */ public void accept(ItemVisitor visitor) throws RepositoryException { visitor.visit(this); } /** {@inheritDoc} */ public Node addNode(String path) throws RepositoryException { try { return getNode(getSession(), remote.addNode(path)); } catch (RemoteException ex) { throw new RemoteRepositoryException(ex); } } /** {@inheritDoc} */ public Node addNode(String path, String type) throws RepositoryException { try { RemoteNode node = remote.addNode(path, type); return getNode(getSession(), node); } catch (RemoteException ex) { throw new RemoteRepositoryException(ex); } } /** {@inheritDoc} */ public void orderBefore(String src, String dst) throws RepositoryException { try { remote.orderBefore(src, dst); } catch (RemoteException ex) { throw new RemoteRepositoryException(ex); } } /** {@inheritDoc} */ public Property setProperty(String name, Value value) throws RepositoryException { try { if (value == null) { remote.setProperty(name, (Value) null); return null; } else { RemoteProperty property = remote.setProperty( name, SerialValueFactory.makeSerialValue(value)); return getFactory().getProperty(getSession(), property); } } catch (RemoteException ex) { throw new RemoteRepositoryException(ex); } } /** {@inheritDoc} */ public Property setProperty(String name, Value[] values) throws RepositoryException { try { if (values == null) { remote.setProperty(name, (Value[]) null); return null; } else { Value[] serials = SerialValueFactory.makeSerialValueArray(values); RemoteProperty property = remote.setProperty(name, serials); return getFactory().getProperty(getSession(), property); } } catch (RemoteException ex) { throw new RemoteRepositoryException(ex); } } /** {@inheritDoc} */ public Property setProperty(String name, String[] strings) throws RepositoryException { if (strings == null) { return setProperty(name, (Value[]) null); } else { Value[] values = new Value[strings.length]; for (int i = 0; i < strings.length; i++) { values[i] = getSession().getValueFactory().createValue(strings[i]); } return setProperty(name, values); } } /** {@inheritDoc} */ public Property setProperty(String name, String value) throws RepositoryException { if (value == null) { return setProperty(name, (Value) null); } else { return setProperty(name, getSession().getValueFactory().createValue(value)); } } /** {@inheritDoc} */ public Property setProperty(String name, InputStream value) throws RepositoryException { if (value == null) { return setProperty(name, (Value) null); } else { return setProperty(name, getSession().getValueFactory().createValue(value)); } } /** {@inheritDoc} */ public Property setProperty(String name, boolean value) throws RepositoryException { return setProperty(name, getSession().getValueFactory().createValue(value)); } /** {@inheritDoc} */ public Property setProperty(String name, double value) throws RepositoryException { return setProperty(name, getSession().getValueFactory().createValue(value)); } /** {@inheritDoc} */ public Property setProperty(String name, long value) throws RepositoryException { return setProperty(name, getSession().getValueFactory().createValue(value)); } /** {@inheritDoc} */ public Property setProperty(String name, Calendar value) throws RepositoryException { if (value == null) { return setProperty(name, (Value) null); } else { return setProperty(name, getSession().getValueFactory().createValue(value)); } } /** {@inheritDoc} */ public Property setProperty(String name, Node value) throws RepositoryException { if (value == null) { return setProperty(name, (Value) null); } else { return setProperty(name, getSession().getValueFactory().createValue(value)); } } /** {@inheritDoc} */ public Node getNode(String path) throws RepositoryException { try { return getNode(getSession(), remote.getNode(path)); } catch (RemoteException ex) { throw new RemoteRepositoryException(ex); } } /** {@inheritDoc} */ public NodeIterator getNodes() throws RepositoryException { try { return getFactory().getNodeIterator(getSession(), remote.getNodes()); } catch (RemoteException ex) { throw new RemoteRepositoryException(ex); } } /** {@inheritDoc} */ public NodeIterator getNodes(String pattern) throws RepositoryException { try { return getFactory().getNodeIterator(getSession(), remote.getNodes(pattern)); } catch (RemoteException ex) { throw new RemoteRepositoryException(ex); } } /** {@inheritDoc} */ public Property getProperty(String path) throws RepositoryException { try { RemoteProperty property = remote.getProperty(path); return getFactory().getProperty(getSession(), property); } catch (RemoteException ex) { throw new RemoteRepositoryException(ex); } } /** {@inheritDoc} */ public PropertyIterator getProperties() throws RepositoryException { try { return getFactory().getPropertyIterator(getSession(), remote.getProperties()); } catch (RemoteException ex) { throw new RemoteRepositoryException(ex); } } /** {@inheritDoc} */ public PropertyIterator getProperties(String pattern) throws RepositoryException { try { return getFactory().getPropertyIterator(getSession(), remote.getProperties(pattern)); } catch (RemoteException ex) { throw new RemoteRepositoryException(ex); } } /** {@inheritDoc} */ public Item getPrimaryItem() throws RepositoryException { try { return getItem(getSession(), remote.getPrimaryItem()); } catch (RemoteException ex) { throw new RemoteRepositoryException(ex); } } /** {@inheritDoc} */ public String getUUID() throws RepositoryException { try { return remote.getUUID(); } catch (RemoteException ex) { throw new RemoteRepositoryException(ex); } } /** {@inheritDoc} */ public PropertyIterator getReferences() throws RepositoryException { try { return getFactory().getPropertyIterator(getSession(), remote.getReferences()); } catch (RemoteException ex) { throw new RemoteRepositoryException(ex); } } /** {@inheritDoc} */ public boolean hasNode(String path) throws RepositoryException { try { return remote.hasNode(path); } catch (RemoteException ex) { throw new RemoteRepositoryException(ex); } } /** {@inheritDoc} */ public boolean hasProperty(String path) throws RepositoryException {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -