if (element instanceof Edge && direction == null) {
throw new IllegalArgumentException("Direction cannot be null");
}
ExtensionResponse extensionResponse;
FramedGraph framedGraph = factory.create(graph);
ExtensionConfiguration extensionConfig = rexsterResourceContext.getRexsterApplicationGraph()
.findExtensionConfiguration(EXTENSION_NAMESPACE, EXTENSION_NAME);
Map<String, String> mapFrames = extensionConfig.tryGetMapFromConfiguration();
if (mapFrames != null && !mapFrames.isEmpty()) {
UriInfo uriInfo = rexsterResourceContext.getUriInfo();
List<PathSegment> pathSegmentList = uriInfo.getPathSegments();
String domainObjectMappingName = "";
if (pathSegmentList.size() > 6) {
domainObjectMappingName = pathSegmentList.get(6).getPath();
}
if (domainObjectMappingName.isEmpty()) {
return ExtensionResponse.error(
"A Frames class was not specified in the URI", generateErrorJson());
}
String frameClassName = mapFrames.get(domainObjectMappingName);
if (frameClassName == null || frameClassName.isEmpty()) {
return ExtensionResponse.error(
"Frames configuration does not contain a Frames class for " + domainObjectMappingName, generateErrorJson());
}
try {
Class clazz = Class.forName(frameClassName);
Object obj = null;
if (element instanceof Vertex) {
obj = framedGraph.frame((Vertex) element, clazz);
} else if (element instanceof Edge) {
obj = framedGraph.frame((Edge) element, Direction.BOTH, clazz);
}
Map map = new HashMap();
Method[] methods = clazz.getMethods();