Skip to content

Commit

Permalink
remove NodeService#getObjectNames
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Sep 13, 2014
1 parent a8f5ad3 commit e133826
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 80 deletions.
Expand Up @@ -15,16 +15,13 @@
*/
package org.fcrepo.kernel.impl.services;

import static com.google.common.collect.ImmutableSet.builder;
import static org.fcrepo.kernel.impl.utils.FedoraTypesUtils.getVersionHistory;
import static org.slf4j.LoggerFactory.getLogger;

import java.io.IOException;
import java.io.InputStream;
import java.util.Set;

import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
Expand All @@ -42,8 +39,6 @@
import org.slf4j.Logger;
import org.springframework.stereotype.Component;

import com.google.common.collect.ImmutableSet;

/**
* Service for managing access to Fedora 'nodes' (either datastreams or objects,
* we don't care.)
Expand Down Expand Up @@ -109,43 +104,6 @@ public FedoraResource getObject(final Session session, final String path, final
return new FedoraResourceImpl(version.getFrozenNode());
}

/**
* @return A Set of object names (identifiers)
* @throws RepositoryException
*/
@Override
public Set<String> getObjectNames(final Session session, final String path) throws RepositoryException {
return getObjectNames(session, path, null);
}

/**
* Get the list of child nodes at the given path filtered by the given mixin
*
* @param session
* @param path
* @param mixin
* @return the list of child nodes at the given path filtered by the given mixin
* @throws RepositoryException
*/
@Override
public Set<String> getObjectNames(final Session session, final String path, final String mixin)
throws RepositoryException {

final Node objects = session.getNode(path);
final ImmutableSet.Builder<String> b = builder();
final NodeIterator i = objects.getNodes();

while (i.hasNext()) {
final Node n = i.nextNode();
LOGGER.trace("Child of type {} is named {} at {}", n.getPrimaryNodeType(), n.getName(), n.getPath());
if (mixin == null || n.isNodeType(mixin)) {
b.add(n.getName());
}
}

return b.build();
}

/**
* Delete an existing object from the repository at the given path
*
Expand Down
Expand Up @@ -23,10 +23,8 @@
import static org.powermock.api.mockito.PowerMockito.mockStatic;

import java.io.InputStream;
import java.util.Set;

import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.PropertyIterator;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
Expand Down Expand Up @@ -88,24 +86,6 @@ public void setUp() throws RepositoryException {
when(mockEmptyIterator.hasNext()).thenReturn(false);
}

@SuppressWarnings("unchecked")
@Test
public void testGetObjectNames() throws RepositoryException {
final String objPath = "";
when(mockObjNode.getName()).thenReturn("foo");
when(mockObjNode.isNodeType("nt:folder")).thenReturn(true);
final NodeIterator mockIter = mock(NodeIterator.class);
when(mockIter.hasNext()).thenReturn(true, false);
when(mockIter.nextNode()).thenReturn(mockObjNode).thenThrow(
IndexOutOfBoundsException.class);
when(mockRoot.getNodes()).thenReturn(mockIter);
when(mockSession.getNode(objPath)).thenReturn(mockRoot);
final Set<String> actual = testObj.getObjectNames(mockSession, "");
verify(mockSession).getNode(objPath);
assertEquals(1, actual.size());
assertEquals("foo", actual.iterator().next());
}

@Test
public void testDeleteObject() throws RepositoryException {
final String objPath = "foo";
Expand Down
Expand Up @@ -17,7 +17,6 @@

import java.io.IOException;
import java.io.InputStream;
import java.util.Set;

import javax.jcr.RepositoryException;
import javax.jcr.Session;
Expand Down Expand Up @@ -64,23 +63,6 @@ public interface NodeService extends Service {
*/
FedoraResource getObject(Session session, String path, String versionId) throws RepositoryException;

/**
* @return A Set of object names (identifiers)
* @throws RepositoryException
*/
Set<String> getObjectNames(Session session, String path) throws RepositoryException;

/**
* Get the list of children at the given path filtered by the given mixin
*
* @param session
* @param path
* @param mixin
* @return list of matching children
* @throws RepositoryException
*/
Set<String> getObjectNames(Session session, String path, String mixin) throws RepositoryException;

/**
* Delete an existing object from the repository at the given path
*
Expand Down

0 comments on commit e133826

Please sign in to comment.