org.restlet.data.Reference.addQueryParameter()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(14.2k)|赞(0)|评价(0)|浏览(104)

本文整理了Java中org.restlet.data.Reference.addQueryParameter方法的一些代码示例,展示了Reference.addQueryParameter的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Reference.addQueryParameter方法的具体详情如下:
包路径:org.restlet.data.Reference
类名称:Reference
方法名:addQueryParameter

Reference.addQueryParameter介绍

[英]Adds a parameter to the query component. The name and value are automatically URL encoded if necessary.
[中]向查询组件添加参数。如果需要,名称和值会自动进行URL编码。

代码示例

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

/**
 * Adds several parameters to the query component. The name and value are
 * automatically URL encoded if necessary.
 * 
 * @param parameters
 *            The parameters to add.
 * @return The updated reference.
 */
public Reference addQueryParameters(Iterable<Parameter> parameters) {
  for (Parameter param : parameters) {
    addQueryParameter(param);
  }
  return this;
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Adds several parameters to the query component. The name and value are
 * automatically URL encoded if necessary.
 * 
 * @param parameters
 *            The parameters to add.
 * @return The updated reference.
 */
public Reference addQueryParameters(Iterable<Parameter> parameters) {
  for (Parameter param : parameters) {
    addQueryParameter(param);
  }
  return this;
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Adds a parameter to the query component. The name and value are
 * automatically encoded if necessary.
 * 
 * @param parameter
 *            The parameter to add.
 * @return The updated reference.
 * @see Reference#addQueryParameter(Parameter)
 */
public Reference addQueryParameter(Parameter parameter) {
  return getReference().addQueryParameter(parameter);
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Adds a parameter to the query component. The name and value are
 * automatically encoded if necessary.
 * 
 * @param name
 *            The parameter name.
 * @param value
 *            The optional parameter value.
 * @return The updated reference.
 * @see Reference#addQueryParameter(String, String)
 */
public Reference addQueryParameter(String name, String value) {
  return getReference().addQueryParameter(name, value);
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Adds a parameter to the query component. The name and value are
 * automatically URL encoded if necessary.
 * 
 * @param parameter
 *            The parameter to add.
 * @return The updated reference.
 */
public Reference addQueryParameter(Parameter parameter) {
  return addQueryParameter(parameter.getName(), parameter.getValue());
}

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

/**
 * Adds a parameter to the query component. The name and value are
 * automatically URL encoded if necessary.
 * 
 * @param parameter
 *            The parameter to add.
 * @return The updated reference.
 */
public Reference addQueryParameter(Parameter parameter) {
  return addQueryParameter(parameter.getName(), parameter.getValue());
}

代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs

private void addQueryParam(Request request, String representationAsText,
    Annotation annotation) {
  request.getResourceRef().addQueryParameter(
      new Parameter(((QueryParam) annotation).value(),
          representationAsText));
}

代码示例来源:origin: com.github.ansell.oas/oas-webservice-impl

@Test
public void testOntologyBrowserDirectJson() throws Exception
{
  final ClientResource ontologyBrowserClientResource =
      new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_ONTOLOGY_BROWSER_PATH,
          OasProps.DEF_ONTOLOGY_BROWSER_PATH)));
  
  ontologyBrowserClientResource.getReference().addQueryParameter("ontologyUri", this.ontologyUri);
  ontologyBrowserClientResource.getReference().addQueryParameter("ontologyVersionUri", this.ontologyVersionUri);
  ontologyBrowserClientResource.getReference().addQueryParameter("directChildrenOnly", "true");
  
  final Representation representation = ontologyBrowserClientResource.get(MediaType.APPLICATION_JSON);
  
  Assert.assertNotNull(representation);
  Assert.assertEquals(Status.SUCCESS_OK.getCode(), ontologyBrowserClientResource.getStatus().getCode());
  
  // this.log.trace("result={}", representation.getText());
}

代码示例来源:origin: com.github.ansell.oas/oas-webservice-impl

@Test
public void testOntologyBrowserDirectRdfXml() throws Exception
{
  final ClientResource ontologyBrowserClientResource =
      new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_ONTOLOGY_BROWSER_PATH,
          OasProps.DEF_ONTOLOGY_BROWSER_PATH)));
  
  ontologyBrowserClientResource.getReference().addQueryParameter("ontologyUri", this.ontologyUri);
  ontologyBrowserClientResource.getReference().addQueryParameter("ontologyVersionUri", this.ontologyVersionUri);
  ontologyBrowserClientResource.getReference().addQueryParameter("directChildrenOnly", "true");
  
  final Representation representation = ontologyBrowserClientResource.get(MediaType.APPLICATION_RDF_XML);
  
  Assert.assertNotNull(representation);
  Assert.assertEquals(Status.SUCCESS_OK.getCode(), ontologyBrowserClientResource.getStatus().getCode());
  
  // this.log.trace("result={}", representation.getText());
  
}

代码示例来源:origin: com.github.ansell.oas/oas-webservice-impl

@Test
public void testOntologyBrowserDirectHtml() throws Exception
{
  final ClientResource ontologyBrowserClientResource =
      new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_ONTOLOGY_BROWSER_PATH,
          OasProps.DEF_ONTOLOGY_BROWSER_PATH)));
  
  ontologyBrowserClientResource.getReference().addQueryParameter("ontologyUri", this.ontologyUri);
  ontologyBrowserClientResource.getReference().addQueryParameter("ontologyVersionUri", this.ontologyVersionUri);
  ontologyBrowserClientResource.getReference().addQueryParameter("directChildrenOnly", "true");
  
  final Representation representation = ontologyBrowserClientResource.get(MediaType.TEXT_HTML);
  
  Assert.assertNotNull(representation);
  Assert.assertEquals(Status.SUCCESS_OK.getCode(), ontologyBrowserClientResource.getStatus().getCode());
  
  // this.log.trace("result={}", representation.getText());
  final String resultsText = representation.getText();
  this.assertFreemarker(resultsText);
  Assert.assertTrue(resultsText.contains("OAS-testwebsite test Ajaxified Ontology Browser template"));
  
}

代码示例来源:origin: com.github.ansell.oas/oas-webservice-impl

/**
 * Test whether Ontologies can be deleted after creating the ontology using an RDF/XML file.
 * 
 * Specifically tests deletion with only the ontologyUri and no managedOntologyVersionUri
 * parameter.
 * 
 */
@Test
public void testOntologyDeleteNoUploadWithDeleteAllFalse()
{
  try
  {
    final ClientResource deletionClientResource =
        new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_ONTOLOGY_MANAGER_DELETE_PATH,
            OasProps.DEF_ONTOLOGY_MANAGER_DELETE_PATH)));
    
    deletionClientResource.getReference().addQueryParameter("ontologyUri", "http://purl.org/obo/owl/test");
    deletionClientResource.getReference().addQueryParameter("deleteAllVersions", "true");
    
    RestletTestUtils.doTestAuthenticatedRequest(deletionClientResource, Method.POST, null,
        MediaType.TEXT_PLAIN, Status.SUCCESS_NO_CONTENT, this.testWithAdminPrivileges);
    
    Assert.fail("Did not find expected exception while attempting to call the delete service with just an ontology URI");
  }
  catch(final ResourceException ex)
  {
    Assert.assertEquals(Status.CLIENT_ERROR_BAD_REQUEST, ex.getStatus());
  }
}

代码示例来源:origin: com.github.ansell.oas/oas-webservice-impl

OasProps.DEF_ONTOLOGY_MANAGER_DELETE_PATH)));
deletionClientResource.getReference().addQueryParameter("ontologyUri", "http://purl.org/obo/owl/test");
deletionClientResource.getReference().addQueryParameter("ontologyVersionUri",
    "http://does.not.exist.example.org/test/delete/ontology");

代码示例来源:origin: com.github.ansell.oas/oas-webservice-impl

/**
 * Test whether Ontologies can be searched using a JSON result type
 */
@Test
public void testOntologySearchJson() throws Exception
{
  // Get the resource and dump it to the console
  final ClientResource searchOntologyClientResource =
      new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_SEARCH_ONTOLOGIES_PATH,
          OasProps.DEF_SEARCH_ONTOLOGIES_PATH)));
  
  searchOntologyClientResource.getReference().addQueryParameter("searchterm", "leaf");
  
  final Representation searchResults = searchOntologyClientResource.get(MediaType.APPLICATION_JSON);
  
  final StatementCollector results = new StatementCollector();
  
  final RDFParser parser = Rio.createParser(RDFFormat.RDFJSON);
  
  parser.setRDFHandler(results);
  
  parser.parse(searchResults.getStream(), "");
  
  Assert.assertEquals(474, results.getStatements().size());
  
}

代码示例来源:origin: com.github.ansell.oas/oas-webservice-impl

/**
 * Test whether Ontologies can be searched using a JSON result type
 */
@Test
public void testOntologySearchJson() throws Exception
{
  // Get the resource and dump it to the console
  final ClientResource searchOntologyClientResource =
      new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_SEARCH_ONTOLOGY_LABELS_PATH,
          OasProps.DEF_SEARCH_ONTOLOGY_LABELS_PATH)));
  
  searchOntologyClientResource.getReference().addQueryParameter("searchterm", "plant");
  
  final Representation searchResults = searchOntologyClientResource.get(MediaType.APPLICATION_JSON);
  
  final StatementCollector results = new StatementCollector();
  
  final RDFParser parser = Rio.createParser(RDFFormat.RDFJSON);
  
  parser.setRDFHandler(results);
  
  parser.parse(searchResults.getStream(), "");
  
  Assert.assertEquals(2, results.getStatements().size());
  
}

代码示例来源:origin: com.github.ansell.oas/oas-webservice-impl

/**
 * Test whether Ontologies can be searched using an RDF/XML result type.
 */
@Test
public void testOntologySearchRdfXml() throws Exception
{
  // Get the resource and dump it to the console
  final ClientResource searchOntologyClientResource =
      new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_SEARCH_ONTOLOGIES_PATH,
          OasProps.DEF_SEARCH_ONTOLOGIES_PATH)));
  
  searchOntologyClientResource.getReference().addQueryParameter("searchterm", "leaf");
  
  final Representation searchResults = searchOntologyClientResource.get(MediaType.APPLICATION_RDF_XML);
  
  final StatementCollector results = new StatementCollector();
  
  final RDFParser parser = Rio.createParser(RDFFormat.RDFXML);
  
  parser.setRDFHandler(results);
  
  parser.parse(searchResults.getStream(), "");
  
  Assert.assertEquals(474, results.getStatements().size());
  
}

代码示例来源:origin: com.github.ansell.oas/oas-webservice-impl

/**
 * Test whether Ontologies can be searched using a JSON result type
 */
@Test
public void testOntologySearchJson() throws Exception
{
  // Get the resource and dump it to the console
  final ClientResource searchOntologyClientResource =
      new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_SEARCH_ONTOLOGIES_PATH,
          OasProps.DEF_SEARCH_ONTOLOGIES_PATH)));
  
  searchOntologyClientResource.getReference().addQueryParameter("searchterm", "leaf");
  
  final Representation searchResults = searchOntologyClientResource.get(MediaType.APPLICATION_JSON);
  
  final StatementCollector results = new StatementCollector();
  
  final RDFParser parser = Rio.createParser(RDFFormat.RDFJSON);
  
  parser.setRDFHandler(results);
  
  parser.parse(searchResults.getStream(), "");
  
  Assert.assertEquals(474, results.getStatements().size());
  
}

代码示例来源:origin: com.github.ansell.oas/oas-webservice-impl

/**
 * Test whether Ontologies can be searched using an RDF/XML result type.
 */
@Test
public void testOntologySearchRdfXml() throws Exception
{
  // Get the resource and dump it to the console
  final ClientResource searchOntologyClientResource =
      new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_SEARCH_ONTOLOGY_LABELS_PATH,
          OasProps.DEF_SEARCH_ONTOLOGY_LABELS_PATH)));
  
  searchOntologyClientResource.getReference().addQueryParameter("searchterm", "plant");
  
  final Representation searchResults = searchOntologyClientResource.get(MediaType.APPLICATION_RDF_XML);
  
  final StatementCollector results = new StatementCollector();
  
  final RDFParser parser = Rio.createParser(RDFFormat.RDFXML);
  
  parser.setRDFHandler(results);
  
  parser.parse(searchResults.getStream(), "");
  
  // DebugUtils.printStatements(results.getStatements());
  
  Assert.assertEquals(2, results.getStatements().size());
  
}

代码示例来源:origin: com.github.ansell.oas/oas-webservice-impl

/**
 * Test whether Ontologies can be searched using an RDF/XML result type.
 */
@Test
public void testOntologySearchRdfXml() throws Exception
{
  // Get the resource and dump it to the console
  final ClientResource searchOntologyClientResource =
      new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_SEARCH_ONTOLOGIES_PATH,
          OasProps.DEF_SEARCH_ONTOLOGIES_PATH)));
  
  searchOntologyClientResource.getReference().addQueryParameter("searchterm", "leaf");
  
  final Representation searchResults = searchOntologyClientResource.get(MediaType.APPLICATION_RDF_XML);
  
  final StatementCollector results = new StatementCollector();
  
  final RDFParser parser = Rio.createParser(RDFFormat.RDFXML);
  
  parser.setRDFHandler(results);
  
  parser.parse(searchResults.getStream(), "");
  
  Assert.assertEquals(474, results.getStatements().size());
  
}

代码示例来源:origin: com.github.ansell.oas/oas-webservice-impl

/**
 * Test whether Ontologies can be deleted after creating the ontology using an RDF/XML file.
 * 
 * Specifically tests deletion with only the ontologyUri and no managedOntologyVersionUri
 * parameter.
 * 
 */
@Test
public void testOntologyDeleteNoUploadWithOntologyUriFalse()
{
  try
  {
    final ClientResource deletionClientResource =
        new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_ONTOLOGY_MANAGER_PATH,
            OasProps.DEF_ONTOLOGY_MANAGER_PATH)));
    
    deletionClientResource.getReference().addQueryParameter("ontologyUri", "http://purl.org/obo/owl/test");
    
    RestletTestUtils.doTestAuthenticatedRequest(deletionClientResource, Method.DELETE, null,
        MediaType.TEXT_PLAIN, Status.SUCCESS_NO_CONTENT, this.testWithAdminPrivileges);
    
    Assert.fail("Did not find expected exception while attempting to call the delete service with just an ontology URI");
  }
  catch(final ResourceException ex)
  {
    Assert.assertEquals(Status.CLIENT_ERROR_BAD_REQUEST, ex.getStatus());
  }
}

代码示例来源:origin: com.github.ansell.oas/oas-webservice-impl

/**
 * Test whether Ontologies can be deleted after creating the ontology using an RDF/XML file.
 * 
 * Specifically tests deletion with only the ontologyUri and no managedOntologyVersionUri
 * parameter.
 * 
 */
@Test
public void testOntologyDeleteNoUploadWithOntologyUriFalse()
{
  try
  {
    final ClientResource deletionClientResource =
        new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_ONTOLOGY_MANAGER_DELETE_PATH,
            OasProps.DEF_ONTOLOGY_MANAGER_DELETE_PATH)));
    
    deletionClientResource.getReference().addQueryParameter("ontologyUri", "http://purl.org/obo/owl/test");
    
    RestletTestUtils.doTestAuthenticatedRequest(deletionClientResource, Method.POST, null,
        MediaType.TEXT_PLAIN, Status.SUCCESS_NO_CONTENT, this.testWithAdminPrivileges);
    
    Assert.fail("Did not find expected exception while attempting to call the delete service with just an ontology URI");
  }
  catch(final ResourceException ex)
  {
    Assert.assertEquals(Status.CLIENT_ERROR_BAD_REQUEST, ex.getStatus());
  }
}

相关文章

微信公众号

最新文章

更多

Reference类方法