public void writeXML(final Document document, final org.w3c.dom.Element currentElement) { org.w3c.dom.Element xmlServer = document.createElement(XML_TAG_NAME); xmlServer.setAttribute(XML_ATTRIBUTE_NAME, server.getName()); xmlServer.setAttribute(XML_ATTRIBUTE_HOST, server.getHost()); xmlServer.setAttribute(XML_ATTRIBUTE_PORT, server.getPort()); xmlServer.setAttribute(XML_ATTRIBUTE_SSL, String.valueOf("https".equals(server.getScheme().orElse("http")))); xmlServer.setAttribute(XML_ATTRIBUTE_UID, server.getName()); currentElement.appendChild(xmlServer); } }
@Override protected String getJavascriptContent() { final StringBuilder content = new StringBuilder(CONTENT_FIRST_PART); content.append("\"").append(((AddCookie)element).getServer().getName()).append("\""); content.append(",\"").append(buildCookie(((AddCookie)element))).append("\""); content.append(");"); return content.toString(); }
@Override protected void fillXML(final Document document, final Element xmlRequest, final Request theRequest) { super.fillXML(document, xmlRequest, theRequest); final PostSubmitFormRequest postSubmitFormRequest = (PostSubmitFormRequest)theRequest; xmlRequest.setAttribute(XML_ATTR_LINKEXTRACTORTYPE, ACTION_LINKEXTRACTOR_TYPE_MATCH_DEFINITION); xmlRequest.setAttribute(XML_ATTR_EXTRACTORPATH, theRequest.getPath().orElse(theRequest.getName())); xmlRequest.setAttribute(XML_ATTR_CONF_FORM_EXTRACTOR_PARAMETERS, buildConfFormExtractorParameters(postSubmitFormRequest)); final Element recordHtmlInfos = document.createElement(XML_TAG_RECORD_HTML_INFOS); recordHtmlInfos.setAttribute(XML_ATTR_EXTRACTOR_REGEXP, "false"); recordHtmlInfos.setAttribute(XML_ATTR_EXTRACTOR_OCCURENCE, "1"); recordHtmlInfos.setAttribute(XML_ATTR_HTML_TYPE, "2"); xmlRequest.appendChild(recordHtmlInfos); final Element extractorHtmlInfos = document.createElement(XML_TAG_EXTRACTOR_HTML_INFOS); extractorHtmlInfos.setAttribute(XML_ATTR_EXTRACTOR_REGEXP, "false"); extractorHtmlInfos.setAttribute(XML_ATTR_EXTRACTOR_OCCURENCE, "1"); extractorHtmlInfos.setAttribute(XML_ATTR_HTML_TYPE, "2"); xmlRequest.appendChild(extractorHtmlInfos); final Request referer = postSubmitFormRequest.getReferer(); xmlRequest.setAttribute(XML_ATTR_REFERER_UID, WriterUtils.getElementUid(referer)); theRequest.getServer().ifPresent(server -> xmlRequest.setAttribute(XML_ATTR_SERV_UID, server.getName())); theRequest.getServer().ifPresent(server -> xmlRequest.setAttribute(XML_ATTR_EXTRACTOR_SERVER_UID, server.getName())); }
@Override protected void fillXML(final Document document, final Element xmlRequest, final Request theRequest) { super.fillXML(document, xmlRequest, theRequest); final GetFollowLinkRequest getFollowLinkRequest = (GetFollowLinkRequest)theRequest; xmlRequest.setAttribute(XML_ATTR_LINKEXTRACTORTYPE, ACTION_LINKEXTRACTOR_TYPE_MATCHCONTENT); xmlRequest.setAttribute(XML_ATTR_EXTRACTORPATH, theRequest.getPath().orElse(theRequest.getName())); final Element recordHtmlInfos = document.createElement(XML_TAG_RECORD_HTML_INFOS); recordHtmlInfos.setAttribute(XML_ATTR_EXTRACTOR_CONTENT, getFollowLinkRequest.getText()); recordHtmlInfos.setAttribute(XML_ATTR_EXTRACTOR_OCCURENCE, "1"); recordHtmlInfos.setAttribute(XML_ATTR_HTML_TYPE, "1"); xmlRequest.appendChild(recordHtmlInfos); final Element extractorHtmlInfos = document.createElement(XML_TAG_EXTRACTOR_HTML_INFOS); extractorHtmlInfos.setAttribute(XML_ATTR_EXTRACTOR_CONTENT, getFollowLinkRequest.getText()); extractorHtmlInfos.setAttribute(XML_ATTR_EXTRACTOR_OCCURENCE, "1"); extractorHtmlInfos.setAttribute(XML_ATTR_HTML_TYPE, "1"); xmlRequest.appendChild(extractorHtmlInfos); final Request referer = getFollowLinkRequest.getReferer(); xmlRequest.setAttribute(XML_ATTR_REFERER_UID, WriterUtils.getElementUid(referer)); theRequest.getServer().ifPresent(server -> xmlRequest.setAttribute(XML_ATTR_SERV_UID, server.getName())); theRequest.getServer().ifPresent(server -> xmlRequest.setAttribute(XML_ATTR_EXTRACTOR_SERVER_UID, server.getName())); } }
protected void fillXML(final Document document, final Element xmlRequest, final Request theRequest) { xmlRequest.setAttribute(XML_ATTR_METHOD, theRequest.getHttpMethod().toString()); theRequest.getContentType().ifPresent(c -> xmlRequest.setAttribute(XML_ATTR_CONTENT_TYPE, c)); theRequest.getServer().ifPresent(server -> xmlRequest.setAttribute(XML_ATTR_SERV_UID, server.getName())); xmlRequest.setAttribute(XML_ATTR_ACTION_TYPE, String.valueOf(getActionType())); theRequest.getPath().ifPresent(path -> xmlRequest.setAttribute(XML_ATTR_PATH, path)); theRequest.getExtractors().forEach(extractElem -> ExtractorWriter.of(extractElem).writeXML(document, xmlRequest)); writeValidationSection(theRequest, document, xmlRequest); writeParameters(theRequest, document, xmlRequest); theRequest.getHeaders().forEach(header -> HeaderWriter.writeXML(document, xmlRequest, header)); }
/** * Check if a identical server already exist, if exist the function return it * If not but there exist a server with the same "uid", we create a new server with a different uid. * @return the unique server to use */ public Server getOrAddServerIfNotExist(final String name, final String host, final String port, final Optional<String> scheme) { // Search if exact same server exists for (final Server server : currentProjectServers.values()) { if (server.getHost().equals(host) && server.getPort().equals(port) && server.getScheme().equals(scheme) && server.getName().equals(name)) { return server; } } final Server server = ImmutableServer.builder().name( currentProjectServers.get(name) == null ? name : findUniqueName(name, currentProjectServers.keySet())).host(host).port(port).scheme( scheme).build(); currentProjectServers.put(server.getName(), server); return server; }
/** * Fill a builder with attribute values from the provided {@code Server} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(Server instance) { Objects.requireNonNull(instance, "instance"); name(instance.getName()); host(instance.getHost()); port(instance.getPort()); Optional<String> schemeOptional = instance.getScheme(); if (schemeOptional.isPresent()) { scheme(schemeOptional); } return this; }
builder.name("Set cookie " + cookieName + " for server " + server.getName()) .cookieName(cookieName) .cookieValue(cookieValue)