Skip to content

Commit

Permalink
Fixed result parsing in NeoFullRESTInteraction
Browse files Browse the repository at this point in the history
  • Loading branch information
fickludd committed Jun 28, 2016
1 parent caae114 commit 4aa02ca
Showing 1 changed file with 32 additions and 4 deletions.
Expand Up @@ -20,8 +20,12 @@
package org.neo4j.server.rest.security;

import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.node.ArrayNode;
import org.codehaus.jackson.node.ObjectNode;
import org.codehaus.jackson.node.TextNode;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;
import java.util.TreeMap;
import java.util.function.Consumer;
Expand All @@ -35,6 +39,7 @@
import org.neo4j.server.rest.domain.JsonHelper;
import org.neo4j.server.rest.domain.JsonParseException;
import org.neo4j.server.security.enterprise.auth.EnterpriseAuthManager;
import org.neo4j.server.security.enterprise.auth.EnterpriseUserManager;
import org.neo4j.server.security.enterprise.auth.NeoInteractionLevel;
import org.neo4j.test.server.HTTP;

Expand All @@ -55,9 +60,9 @@ public NeoFullRESTInteraction() throws IOException
}

@Override
public EnterpriseAuthManager getManager()
public EnterpriseUserManager getManager()
{
return server.getDependencyResolver().resolveDependency( EnterpriseAuthManager.class );
return server.getDependencyResolver().resolveDependency( EnterpriseAuthManager.class ).getUserManager();
}

@Override
Expand Down Expand Up @@ -146,7 +151,7 @@ protected String commitURL()
return server.baseUri().resolve( COMMIT_PATH ).toString();
}

class RESTResult implements ResourceIterator<Map<String, Object>>
class RESTResult implements ResourceIterator<Map<String,Object>>
{
private JsonNode data;
private JsonNode columns;
Expand Down Expand Up @@ -178,7 +183,30 @@ public Map<String,Object> next()
for ( int i = 0; i < columns.size(); i++ )
{
String key = columns.get( i ).asText();
map.put( key, row.get( i ).asText() );
JsonNode value = row.get( i );
if ( value instanceof TextNode )
{
map.put( key, row.get( i ).asText() );
}
else if ( value instanceof ArrayNode )
{
ArrayNode aNode = (ArrayNode) value;
ArrayList<String> listValue = new ArrayList( aNode.size() );
for ( int j = 0; j < aNode.size(); j++ )
{
listValue.add( aNode.get( j ).asText() );
}
map.put( key, listValue );
}
else if ( value instanceof ObjectNode )
{
map.put( key, value );
}
else
{
throw new RuntimeException( "Unhandled REST value type '" + value.getClass() +
"'. Need String (TextNode) or List (ArrayNode)." );
}
}

return map;
Expand Down

0 comments on commit 4aa02ca

Please sign in to comment.