Returns the graph configuration screen.

@param link
the link to check
@param request
stapler request
@param response
stapler response
@return the graph configuration or <code>null</code>
341576
public Object getDynamic(final String link, final StaplerRequest request, final StaplerResponse response) {
        if ("configureDefaults".equals(link)) {
            Ancestor ancestor = request.findAncestor(AbstractProject.class);
            if (ancestor.getObject() instanceof AbstractProject) {
                AbstractProject<?, ?> project = (AbstractProject<?, ?>)ancestor.getObject();
                return new DefaultGraphConfigurationView(
                        new GraphConfiguration(WarningsProjectAction.getAllGraphs()), project, "warnings",
                        new NullBuildHistory(),
                        project.getAbsoluteUrl() + "/descriptorByName/WarningsPublisher/configureDefaults/");
            }
        }
        return null;
    }
659320
@GET
	public Response getPages(@QueryParam(Constants.PARAM_PAGINGACTION) String thePageId) throws IOException {
		JaxRsRequest theRequest = getRequest(RequestTypeEnum.GET, RestOperationTypeEnum.GET_PAGE).build();
		try {
			return (Response) myBinding.invokeServer(this, theRequest);
		} catch (JaxRsResponseException theException) {
			return new JaxRsExceptionInterceptor().convertExceptionIntoResponse(theRequest, theException);
		}
	}
90482
public Iterable<GraphObject> getData(final RenderContext renderContext, final String restQuery) throws FrameworkException {

		final Map<Pattern, Class<? extends Resource>> resourceMap = new LinkedHashMap<>();
		final SecurityContext securityContext                     = renderContext.getSecurityContext();

		ResourceProvider resourceProvider = renderContext.getResourceProvider();
		if (resourceProvider == null) {
			try {
				resourceProvider = UiResourceProvider.class.newInstance();
			} catch (Throwable t) {
				logger.error("Couldn't establish a resource provider", t);
				return Collections.EMPTY_LIST;
			}
		}

		// inject resources
		resourceMap.putAll(resourceProvider.getResources());

		Value<String> propertyView = new ThreadLocalPropertyView();
		propertyView.set(securityContext, PropertyView.Ui);

		HttpServletRequest request = securityContext.getRequest();
		if (request == null) {
			request = renderContext.getRequest();
		}

		// initialize variables
		// mimic HTTP request
		final HttpServletRequest wrappedRequest = new HttpServletRequestWrapper(request) {

			@Override
			public Enumeration<String> getParameterNames() {
				return new IteratorEnumeration(getParameterMap().keySet().iterator());
			}

			@Override
			public String getParameter(final String key) {
				String[] p = getParameterMap().get(key);
				return p != null ? p[0] : null;
			}

			@Override
			public String[] getParameterValues(final String key) {
				return getParameterMap().get(key);
			}

			@Override
			public Map<String, String[]> getParameterMap() {
				String[] parts = StringUtils.split(getQueryString(), "&");
				Map<String, String[]> parameterMap = new HashMap();
				for (String p : parts) {
					String[] kv = StringUtils.split(p, "=");
					if (kv.length > 1) {
						parameterMap.put(kv[0], new String[]{kv[1]});
					}
				}
				return parameterMap;
			}

			@Override
			public String getQueryString() {
				return StringUtils.substringAfter(restQuery, "?");
			}

			@Override
			public String getPathInfo() {
				return StringUtils.substringBefore(restQuery, "?");
			}

			@Override
			public StringBuffer getRequestURL() {
				return new StringBuffer(restQuery);
			}
		};

		// store original request
		final HttpServletRequest origRequest = securityContext.getRequest();

		// update request in security context
		securityContext.setRequest(wrappedRequest);

		//HttpServletResponse response = renderContext.getResponse();
		Resource resource = null;
		try {

			resource = ResourceHelper.optimizeNestedResourceChain(securityContext, wrappedRequest, resourceMap, propertyView);

		} catch (IllegalPathException | NotFoundException e) {

			logger.warn("Illegal path for REST query: {}", restQuery);

		}

		// reset request to old context
		securityContext.setRequest(origRequest);

		if (resource == null) {

			return Collections.EMPTY_LIST;

		}

		// TODO: decide if we need to rest the REST request here
		//securityContext.checkResourceAccess(request, resource.getResourceSignature(), resource.getGrant(request, response), PropertyView.Ui);
		// add sorting & paging
		String pageSizeParameter = wrappedRequest.getParameter(JsonRestServlet.REQUEST_PARAMETER_PAGE_SIZE);
		String pageParameter     = wrappedRequest.getParameter(JsonRestServlet.REQUEST_PARAMETER_PAGE_NUMBER);
		String sortOrder         = wrappedRequest.getParameter(JsonRestServlet.REQUEST_PARAMETER_SORT_ORDER);
		String sortKeyName       = wrappedRequest.getParameter(JsonRestServlet.REQUEST_PARAMETER_SORT_KEY);
		boolean sortDescending   = (sortOrder != null && "desc".equals(sortOrder.toLowerCase()));
		int pageSize             = parseInt(pageSizeParameter, NodeFactory.DEFAULT_PAGE_SIZE);
		int page                 = parseInt(pageParameter, NodeFactory.DEFAULT_PAGE);

		PropertyKey sortKey      = null;

		// set sort key
		if (sortKeyName != null) {

			Class<? extends GraphObject> type = resource.getEntityClass();
			if (type == null) {

				// fallback to default implementation
				// if no type can be determined
				type = AbstractNode.class;

			}

			sortKey = StructrApp.getConfiguration().getPropertyKeyForDatabaseName(type, sortKeyName, false);
		}

		try {
			return resource.doGet(sortKey, sortDescending, pageSize, page);

		} catch (NotFoundException nfe) {
			logger.warn("No result from internal REST query: {}", restQuery);
		}

		return Collections.EMPTY_LIST;
	}
1001576
public Graph links(Link... values) {
        if (values == null || values.length == 0) {
            return this;
        }
        this.links().addAll(Arrays.asList(values));
        return this;
    }
1119514
@Override
    public Configuration configuration() {
    	if (this.origConfig != null) {
    		return this.origConfig;
    	} else {
            Configuration ans = new BaseConfiguration();
            ans.setProperty(DB_PATH_KEY, dbPath.toString());
            ans.setProperty(ALLOW_FULL_GRAPH_SCANS_KEY, allowFullGraphScans);
            ans.setProperty(DEFAULT_ISOLATION_LEVEL_KEY, defaultIsolationLevel.toString());
            ans.setProperty(TX_LOG_THRESHOLD_KEY, getTxLogThreshold());
            ans.setProperty(REORG_FACTOR_KEY, getReorgFactor());
            ans.setProperty(CREATE_DIR_IF_MISSING_KEY, createDirIfMissing);

            ans.setProperty(VERTEX_INDICES_KEY, String.join(",", getIndexedKeys(Vertex.class)));
            ans.setProperty(EDGE_INDICES_KEY, String.join(",", getIndexedKeys(Vertex.class)));

            return ans;
    	}
    }
575710
protected String getFacebookGraphVideoEndpointUrl() {
    if (apiVersion.isUrlElementRequired()) {
      return getFacebookEndpointUrls().getGraphVideoEndpoint() + '/' + apiVersion.getUrlElement();
    } else {
      return getFacebookEndpointUrls().getGraphVideoEndpoint();
    }
  }
1133143
@WebMethod(name = "config.xml")
    public void doConfigDotXml(StaplerRequest req, StaplerResponse rsp)
            throws IOException, ServletException {

        if (req.getMethod().equals("GET")) {
            // read
            checkPermission(EXTENDED_READ);
            rsp.setContentType("application/xml");
            Node node = getNode();
            if (node == null) {
                throw HttpResponses.notFound();
            }
            Jenkins.XSTREAM2.toXMLUTF8(node, rsp.getOutputStream());
            return;
        }
        if (req.getMethod().equals("POST")) {
            // submission
            updateByXml(req.getInputStream());
            return;
        }

        // huh?
        rsp.sendError(SC_BAD_REQUEST);
    }
225710
public static OrientStandardGraph open(String url, String user, String password) {
    BaseConfiguration configuration = new BaseConfiguration();
    configuration.setProperty(CONFIG_URL, url);
    configuration.setProperty(CONFIG_USER, user);
    configuration.setProperty(CONFIG_PASS, password);
    return open(configuration);

  }
514235
@SuppressWarnings("null")
  public static @Nullable Page getContentPage(@NotNull HttpServletRequest request) {
    SlingHttpServletRequest slingRequest = (SlingHttpServletRequest)request;
    Resource contentResource = getContentResourceOrParent(request);
    if (contentResource != null) {
      PageManager pageManager = slingRequest.getResourceResolver().adaptTo(PageManager.class);
      return pageManager.getContainingPage(contentResource);
    }
    else {
      return null;
    }
  }
1355025
@Override
    public final Map<String, Object> getParameters(
            HttpServletRequest request, HttpServletResponse response) {
        final PreferencesScope stylesheetPreferencesScope =
                this.getStylesheetPreferencesScope(request);

        final LinkedHashMap<String, Object> stylesheetParameters =
                new LinkedHashMap<String, Object>();

        this.stylesheetUserPreferencesService.populateStylesheetParameters(
                request,
                stylesheetPreferencesScope,
                new MapPopulator<String, String>(stylesheetParameters));

        return stylesheetParameters;
    }
84107
Optional<Span> configuredSpan(HttpRequest<?> request, HttpResponse<?> response) {
        Optional<Object> routeTemplate = request.getAttribute(HttpAttributes.URI_TEMPLATE);
        routeTemplate.ifPresent(o -> response.setAttribute(HttpAttributes.URI_TEMPLATE, o));
        response.setAttribute(HttpAttributes.METHOD_NAME, request.getMethod().name());
        return request.getAttribute(TraceRequestAttributes.CURRENT_SPAN, Span.class);
    }
1303426
private void handleGraphQLRequest(final HttpServletRequest request, final HttpServletResponse response, final String query) throws IOException, FrameworkException {

		final SecurityContext securityContext;
		final Authenticator authenticator;

		try {

			setCustomResponseHeaders(response);

			// isolate request authentication in a transaction
			try (final Tx tx = StructrApp.getInstance().tx()) {

				authenticator   = config.getAuthenticator();
				securityContext = authenticator.initializeAndExamineRequest(request, response);

				tx.success();
			}

			final App app = StructrApp.getInstance(securityContext);

			if (securityContext != null) {

				// isolate write output
				try (final Tx tx = app.tx()) {

					final Document doc = GraphQLRequest.parse(new Parser(), query);
					if (doc != null) {

						final List<ValidationError> errors = new Validator().validateDocument(SchemaService.getGraphQLSchema(), doc);
						if (errors.isEmpty()) {

							// no validation errors in query, do request
							final GraphQLWriter graphQLWriter  = new GraphQLWriter(true);

							// no trailing semicolon so we dont trip MimeTypes.getContentTypeWithoutCharset
							response.setContentType("application/json; charset=utf-8");

							final Writer writer = response.getWriter();

							graphQLWriter.stream(securityContext, writer, new GraphQLRequest(securityContext, doc, query));
							writer.append("\n");    // useful newline

						} else {

							final Map<String, Object> map = new LinkedHashMap<>();
							final Writer writer           = response.getWriter();
							final Gson gson               = getGson();

							map.put("errors", errors);

							gson.toJson(map, writer);

							writer.append("\n");    // useful newline

							// send 422 status
							response.setStatus(422);
						}
					}

					tx.success();
				}
			}

		} catch (FrameworkException frameworkException) {

			// set status & write JSON output
			response.setStatus(frameworkException.getStatus());
			getGson().toJson(frameworkException, response.getWriter());
			response.getWriter().println();

		} catch (IllegalStateException | IllegalArgumentException iex) {

			final Map<String, Object> map = new LinkedHashMap<>();

			map.put("code", 422);
			map.put("message", iex.getMessage());

			// set status & write JSON output
			response.setStatus(422);
			getGson().toJson(map, response.getWriter());
			response.getWriter().println();

		} catch (UnsupportedOperationException uoe) {

			logger.warn("POST not supported");

			int code = HttpServletResponse.SC_BAD_REQUEST;

			response.setStatus(code);
			response.getWriter().append(RestMethodResult.jsonError(code, "POST not supported: " + uoe.getMessage()));

		} catch (Throwable t) {

			logger.warn("Exception in POST", t);

			int code = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;

			response.setStatus(code);
			response.getWriter().append(RestMethodResult.jsonError(code, "JsonSyntaxException in POST: " + t.getMessage()));

		} finally {

			try {
				//response.getWriter().flush();
				response.getWriter().close();

			} catch (Throwable t) {

				logger.warn("Unable to flush and close response: {}", t.getMessage());
			}
		}
	}
1059727
@SuppressWarnings("deprecation")
    String requestImpl(String graphPath, Bundle params, String httpMethod) throws FileNotFoundException,
            MalformedURLException, IOException {
        params.putString("format", "json");
        if (isSessionValid()) {
            params.putString(TOKEN, getAccessToken());
        }
        String url = (graphPath != null) ? GRAPH_BASE_URL + graphPath : RESTSERVER_URL;
        return Util.openUrl(url, httpMethod, params);
    }
401254
public static ComputationGraphConfiguration fromJson(String json) {
        //As per MultiLayerConfiguration.fromJson()
        ObjectMapper mapper = NeuralNetConfiguration.mapper();
        ComputationGraphConfiguration conf;
        try {
            conf = mapper.readValue(json, ComputationGraphConfiguration.class);
        } catch (Exception e) {
            //Check if this exception came from legacy deserializer...
            String msg = e.getMessage();
            if(msg != null && msg.contains("legacy")){
                throw new RuntimeException("Error deserializing ComputationGraphConfiguration - configuration may have a custom " +
                        "layer, vertex or preprocessor, in pre version 1.0.0-alpha JSON format. These layers can be " +
                        "deserialized by first registering them with NeuralNetConfiguration.registerLegacyCustomClassesForJSON(Class...)", e);
            }
            throw new RuntimeException(e);
        }

        //To maintain backward compatibility after activation function refactoring (configs generated with v0.7.1 or earlier)
        // Previously: enumeration used for activation functions. Now: use classes
        int layerCount = 0;
        Map<String, GraphVertex> vertexMap = conf.getVertices();
        JsonNode vertices = null;
        for (Map.Entry<String, GraphVertex> entry : vertexMap.entrySet()) {
            if (!(entry.getValue() instanceof LayerVertex)) {
                continue;
            }

            LayerVertex lv = (LayerVertex) entry.getValue();
            if (lv.getLayerConf() != null && lv.getLayerConf().getLayer() != null) {
                Layer layer = lv.getLayerConf().getLayer();

                if (layer instanceof BaseLayer && ((BaseLayer) layer).getActivationFn() == null) {
                    String layerName = layer.getLayerName();

                    try {
                        if (vertices == null) {
                            JsonNode jsonNode = mapper.readTree(json);
                            vertices = jsonNode.get("vertices");
                        }

                        JsonNode vertexNode = vertices.get(layerName);
                        JsonNode layerVertexNode = vertexNode.get("LayerVertex");
                        if (layerVertexNode == null || !layerVertexNode.has("layerConf")
                                        || !layerVertexNode.get("layerConf").has("layer")) {
                            continue;
                        }
                        JsonNode layerWrapperNode = layerVertexNode.get("layerConf").get("layer");

                        if (layerWrapperNode == null || layerWrapperNode.size() != 1) {
                            continue;
                        }

                        JsonNode layerNode = layerWrapperNode.elements().next();
                        JsonNode activationFunction = layerNode.get("activationFunction"); //Should only have 1 element: "dense", "output", etc

                        if (activationFunction != null) {
                            IActivation ia = Activation.fromString(activationFunction.asText()).getActivationFunction();
                            ((BaseLayer) layer).setActivationFn(ia);
                        }

                    } catch (IOException e) {
                        log.warn("Layer with null ActivationFn field or pre-0.7.2 activation function detected: could not parse JSON",
                                        e);
                    }
                }

                handleLegacyWeightInitFromJson(json, layer, mapper, vertices);
            }
        }

        return conf;
    }
1249546
public static ResultStream getSchemaOverviewResult() throws FrameworkException {

		final List<GraphObjectMap> resultList = new LinkedList<>();
		final ConfigurationProvider config    = StructrApp.getConfiguration();

		// extract types from ModuleService
		final Set<String> nodeEntityKeys = config.getNodeEntities().keySet();
		final Set<String> relEntityKeys  = config.getRelationshipEntities().keySet();

		Set<String> entityKeys = new HashSet<>();
		entityKeys.addAll(nodeEntityKeys);
		entityKeys.addAll(relEntityKeys);

		for (String rawType : entityKeys) {

			// create & add schema information
			Class type            = SchemaHelper.getEntityClassForRawType(rawType);
			GraphObjectMap schema = new GraphObjectMap();
			resultList.add(schema);

			if (type != null) {

				String url = "/".concat(rawType);

				final boolean isRel = AbstractRelationship.class.isAssignableFrom(type);

				schema.setProperty(urlProperty, url);
				schema.setProperty(typeProperty, type.getSimpleName());
				schema.setProperty(nameProperty, type.getSimpleName());
				schema.setProperty(classNameProperty, type.getName());
				schema.setProperty(extendsClassNameProperty, type.getSuperclass().getName());
				schema.setProperty(isRelProperty, isRel);
				schema.setProperty(flagsProperty, SecurityContext.getResourceFlags(rawType));

				if (!isRel) {

					final List<GraphObjectMap> relatedTo   = new LinkedList<>();
					final List<GraphObjectMap> relatedFrom = new LinkedList<>();

					for (final PropertyKey key : config.getPropertySet(type, PropertyView.All)) {

						if (key instanceof RelationProperty) {

							final RelationProperty relationProperty = (RelationProperty)key;
							final Relation relation                 = relationProperty.getRelation();

							if (!relation.isHidden()) {

								switch (relation.getDirectionForType(type)) {

									case OUTGOING:
										relatedTo.add(relationPropertyToMap(config, relationProperty));
										break;

									case INCOMING:
										relatedFrom.add(relationPropertyToMap(config, relationProperty));
										break;

									case BOTH:
										relatedTo.add(relationPropertyToMap(config, relationProperty));
										relatedFrom.add(relationPropertyToMap(config, relationProperty));
										break;
								}
							}
						}
					}

					if (!relatedTo.isEmpty()) {
						schema.setProperty(relatedToProperty, relatedTo);
					}

					if (!relatedFrom.isEmpty()) {
						schema.setProperty(relatedFromProperty, relatedFrom);
					}
				}

			}

		}

		return new PagingIterable<>(resultList);

	}
958147
@Override
    public Map<String, Object> getParameters(
            HttpServletRequest request, HttpServletResponse response) {
        return null;
    }
1231260
@Override
    public RequestCtx handleResponse(HttpServletRequest request,
                                     HttpServletResponse response)
            throws IOException, ServletException {
        ParameterRequestWrapper req = (ParameterRequestWrapper) request;
        DataResponseWrapper res = (DataResponseWrapper) response;

        String body = new String(res.getData());

        if (body.startsWith("<html>")) {
            return null;
        }

        DocumentBuilder docBuilder = null;
        Document doc = null;

        try {
            docBuilder =
                    DocumentBuilderFactory.newInstance().newDocumentBuilder();
            doc = docBuilder.parse(new ByteArrayInputStream(res.getData()));
        } catch (Exception e) {
            throw new ServletException(e);
        }

        Map<String, List<Node>> nodeMap = new HashMap<String, List<Node>>();

        NodeList nodes = doc.getElementsByTagName("rdf:Description");
        for (int x = 0; x < nodes.getLength(); x++) {
            String pid =
                    nodes.item(x).getAttributes().getNamedItem("rdf:about")
                            .getNodeValue();
            if (logger.isDebugEnabled()) {
                logger.debug("RISearchIndexFilter PID: " + pid);
            }

            List<Node> nodeList = nodeMap.get(pid);
            if (nodeList == null) {
                nodeList = new ArrayList<Node>();
                nodeMap.put(pid, nodeList);
            }

            nodeList.add(nodes.item(x));
        }

        if (nodeMap.keySet().size() > 0) {
            Map<String, List<String>> resultMap =
                    new HashMap<String, List<String>>();
            Set<Result> results =
                    evaluatePids(nodeMap.keySet(), resultMap, request, res);

            for (Result r : results) {
                String rid = r.getResource();
                if (rid == null || rid.isEmpty()) {
                    logger.warn("This resource has no resource identifier in the xacml response results!");
                } else {
                    logger.debug("Checking: {}", rid);
                }

                if (r.getStatus().getCode().contains(Status.STATUS_OK)
                        && r.getDecision() != Result.DECISION_PERMIT) {
                    List<String> pids = resultMap.get(rid);
                    for (String pid : pids) {
                        List<Node> nodeList = nodeMap.get(pid);

                        for (Node node : nodeList) {
                            if (node != null && node.getParentNode() != null) {
                                node.getParentNode().removeChild(node);
                                if (logger.isDebugEnabled()) {
                                    logger.debug("Removing: " + pid + " [" + rid
                                            + "]");
                                }
                            } else {
                                logger.warn("Could not locate and/or remove: "
                                        + pid + " [" + rid + "]");
                            }
                        }
                    }
                }
            }
        }

        String[] formats = req.getFormat();
        String format = null;
        if (formats != null
                && formats.length > 0
                && ("RDF/XML".equals(formats[0]) || "N-Triples"
                        .equals(formats[0]))) {
            format = formats[0];
        } else {
            format = "RDF/XML";
        }

        Source src = new DOMSource(doc);
        ByteArrayOutputStream os = null;
        new ByteArrayOutputStream();
        javax.xml.transform.Result dst = null;
        new StreamResult(os);
        if (logger.isDebugEnabled()) {
            os = new ByteArrayOutputStream();
            dst = new StreamResult(os);

            Transformer xFormer = m_transformers.get("RDF/XML");
            try {
                xFormer.transform(src, dst);
            } catch (Exception e) {
                logger.error(e.getMessage());
            }

            logger.debug("RDF/XML:\n" + new String(os.toByteArray()));
        }

        os = new ByteArrayOutputStream();
        dst = new StreamResult(os);
        try {
            if (logger.isDebugEnabled()) {
                logger.debug("Transforming format: " + format);
            }
            Transformer xFormer = m_transformers.get(format);
            xFormer.transform(src, dst);
        } catch (TransformerException te) {
            throw new ServletException("error generating output", te);
        }

        if (logger.isDebugEnabled()) {
            logger.debug("RDF/XML:\n" + new String(os.toByteArray()));
        }

        res.setData(os.toByteArray());
        res.setContentType(m_mimeType.get(format));

        return null;
    }