Search in sources :

Example 1 with RemoteRuntimeException

use of org.apache.jackrabbit.rmi.client.RemoteRuntimeException in project jackrabbit by apache.

the class ClientIterator method skip.

/**
 * Skips the given number of elements in this iteration.
 * <p>
 * The elements in the local element buffer are skipped first, and
 * a remote skip method call is made only if more elements are being
 * skipped than remain in the local buffer.
 *
 * @param skipNum the number of elements to skip
 * @throws NoSuchElementException if skipped past the last element
 * @throws RemoteRuntimeException on RMI errors
 * @see RangeIterator#skip(long)
 */
public void skip(long skipNum) throws NoSuchElementException, RemoteRuntimeException {
    if (skipNum < 0) {
        throw new IllegalArgumentException("Negative skip is not allowed");
    } else if (buffer == null && skipNum > 0) {
        throw new NoSuchElementException("Skipped past the last element");
    } else if (positionInBuffer + skipNum <= buffer.length) {
        positionInBuffer += skipNum;
    } else {
        try {
            skipNum -= buffer.length - positionInBuffer;
            remote.skip(skipNum);
            positionInBuffer = buffer.length;
            positionOfBuffer += skipNum;
        } catch (RemoteException e) {
            throw new RemoteRuntimeException(e);
        } catch (NoSuchElementException e) {
            // End of iterator reached
            buffer = null;
            throw e;
        }
    }
}
Also used : RemoteRuntimeException(org.apache.jackrabbit.rmi.client.RemoteRuntimeException) RemoteException(java.rmi.RemoteException) NoSuchElementException(java.util.NoSuchElementException)

Example 2 with RemoteRuntimeException

use of org.apache.jackrabbit.rmi.client.RemoteRuntimeException in project jackrabbit by apache.

the class ClientGroup method members.

public Enumeration<? extends Principal> members() {
    try {
        final RemoteIterator remote = ((RemoteGroup) getRemotePrincipal()).members();
        final Iterator<Principal> pi = factory.getPrincipalIterator(remote);
        return new Enumeration<Principal>() {

            public boolean hasMoreElements() {
                return pi.hasNext();
            }

            public Principal nextElement() {
                return pi.next();
            }
        };
    } catch (RemoteException re) {
        throw new RemoteRuntimeException(re);
    }
}
Also used : RemoteIterator(org.apache.jackrabbit.rmi.remote.RemoteIterator) RemoteGroup(org.apache.jackrabbit.rmi.remote.principal.RemoteGroup) Enumeration(java.util.Enumeration) RemoteRuntimeException(org.apache.jackrabbit.rmi.client.RemoteRuntimeException) RemoteException(java.rmi.RemoteException) Principal(java.security.Principal) GroupPrincipal(org.apache.jackrabbit.api.security.principal.GroupPrincipal) RemotePrincipal(org.apache.jackrabbit.rmi.remote.principal.RemotePrincipal)

Aggregations

RemoteException (java.rmi.RemoteException)2 RemoteRuntimeException (org.apache.jackrabbit.rmi.client.RemoteRuntimeException)2 Principal (java.security.Principal)1 Enumeration (java.util.Enumeration)1 NoSuchElementException (java.util.NoSuchElementException)1 GroupPrincipal (org.apache.jackrabbit.api.security.principal.GroupPrincipal)1 RemoteIterator (org.apache.jackrabbit.rmi.remote.RemoteIterator)1 RemoteGroup (org.apache.jackrabbit.rmi.remote.principal.RemoteGroup)1 RemotePrincipal (org.apache.jackrabbit.rmi.remote.principal.RemotePrincipal)1