本文整理汇总了Java中org.restlet.data.Form.add方法的典型用法代码示例。如果您正苦于以下问题:Java Form.add方法的具体用法?Java Form.add怎么用?Java Form.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.restlet.data.Form
的用法示例。
在下文中一共展示了Form.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import org.restlet.data.Form; //导入方法依赖的package包/类
/**
* Reads all the parameters.
*
* @return The form read.
* @throws IOException
* If the parameters could not be read.
*/
public Form read() throws IOException {
Form result = new Form();
if (this.stream != null) {
Parameter param = readNextParameter();
while (param != null) {
result.add(param);
param = readNextParameter();
}
this.stream.close();
}
return result;
}
示例2: getAccessToken
import org.restlet.data.Form; //导入方法依赖的package包/类
/**
* Exchange and authorization code for an auth token from ORCID
*
* @see <a href='http://support.orcid.org/knowledgebase/articles/120107'>GET oauth/authorize</a>
* @see
* <a href='http://support.orcid.org/knowledgebase/articles/179969-methods-to-generate-an-access-token-for-testing'>
* Methods to Generate an Access Token for Testing</a>
*
* @param authorizationCode
* The authorization code returned from a request built with
* {@link #getAuthzCodeRequest(String, OrcidAuthScope)}
*
* @return the parsed response
* @throws IOException
* if result unparsable or network unreachable.
* @throws ResourceException
* if there's a http problem (e.g. 404, 400)
*/
public OrcidAccessToken getAccessToken(String authorizationCode) throws IOException {
Reference ref = new Reference(apiUriToken + TOKEN_ENDPOINT);
if (Context.getCurrent() == null) {
Context.setCurrent(new Context());
}
ClientResource client = new ClientResource(ref);
Form f = new Form();
f.add("client_id", clientID);
f.add("client_secret", clientSecret);
f.add("grant_type", "authorization_code");
f.add("code", authorizationCode);
f.add("redirect_uri", redirectUri);
client.getContext().getParameters().add("followRedirects", "true");
log.fine(f.toString());
log.fine(client.toString());
Representation rep = client.post(f, MediaType.APPLICATION_JSON);
String json = rep.getText();
return new ObjectMapper().reader(OrcidAccessToken.class).readValue(json);
}
示例3: putAccessToken
import org.restlet.data.Form; //导入方法依赖的package包/类
public RpcResultInfo putAccessToken(String companyId, SocialConnectorAccessInfo accessToken) throws ServiceFailedException {
// new token - generate Id
if ((accessToken.getId() == null) || (accessToken.getId().isEmpty()))
accessToken.setId(UUID.randomUUID().toString());
String url = createAccessTokenResource(companyId, accessToken.getNetworkType().toString(), accessToken.getId());
Form form = new Form();
form.add(AccessTokenAttribute.NAME, accessToken.getName());
form.add(AccessTokenAttribute.VALUE, accessToken.getValue());
form.add(AccessTokenAttribute.DEFAULT, ServerUtils.BooleanToStr(accessToken.isDefault()));
put(url, form);
return new RpcResultInfo(accessToken.getId());
}
示例4: checkDistribution
import org.restlet.data.Form; //导入方法依赖的package包/类
public RpcResultInfo checkDistribution(String companyId, ScheduleInfo schedule) throws ServiceFailedException {
if ((schedule.getId() == null) || (schedule.getId().isEmpty()))
schedule.setId(UUID.randomUUID().toString());
String url = createCheckDistributionResource(companyId, schedule.getId());
Form form = new Form();
form.add(ScheduleAttribute.DISTRIBUTE_TO_ALL, ServerUtils.BooleanToStr(schedule.getDistributionToAll()));
form.add(ScheduleAttribute.DISTRIBUTION, ServerUtils.ListToString(schedule.getDistribution(),","));
Document d = post(url, form);
RpcResultInfo result = new RpcResultInfo();
if (d != null) {
DistributionCheckInfo distributionCheck = docToDistributionCheck(d);
if (distributionCheck != null) {
String resultString = distributionCheck.parseDistributionCheck();
if (!resultString.isEmpty()){
result.setErrorMessage(resultString);
}
}
}
return result;
}
示例5: putSchedule
import org.restlet.data.Form; //导入方法依赖的package包/类
public RpcResultInfo putSchedule(String companyId, ScheduleInfo schedule) throws ServiceFailedException {
// new user- generate userId
if ((schedule.getId() == null) || (schedule.getId().isEmpty()))
schedule.setId(UUID.randomUUID().toString());
String url = createScheduleResource(companyId, schedule.getId());
Form form = new Form();
form.add(ScheduleAttribute.ID, schedule.getId());
form.add(ScheduleAttribute.NAME, schedule.getName());
TimeLineUtils.addToForm(form, schedule.getTimeline());
form.add(ScheduleAttribute.DISTRIBUTE_TO_ALL, ServerUtils.BooleanToStr(schedule.getDistributionToAll()));
form.add(ScheduleAttribute.DISTRIBUTION, ServerUtils.ListToString(schedule.getDistribution(),","));
form.add(ScheduleAttribute.CONTENT, schedule.getContent());
// form.add(ScheduleAttribute.TRANSITION, schedule.getTransition());
// form.add(ScheduleAttribute.SCALE, schedule.getScale());
// form.add(ScheduleAttribute.POSITION, schedule.getPosition());
put(url, form);
//putPlayListItems(companyId, schedule.getId(), schedule.getPlayListItems());
return new RpcResultInfo(schedule.getId());
}
示例6: testDoGetNormal
import org.restlet.data.Form; //导入方法依赖的package包/类
@Test
public void testDoGetNormal() throws Exception {
Request request = createGetRequest("{\"gadgets\":[]}", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._");;
Response response = createResponse(request, MediaType.APPLICATION_JSON,
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._({\"GADGETS\":[]})", Status.SUCCESS_OK);
Form params = new Form();
params.add(Disposition.NAME_FILENAME, "rpc.txt");
Disposition disposition = new Disposition(Disposition.TYPE_ATTACHMENT, params);
response.getEntity().setDisposition(disposition);
resource.init(Context.getCurrent(), request, response);
JSONObject handlerResponse = new JSONObject("{\"GADGETS\":[]}");
expect(handler.process(isA(JSONObject.class))).andReturn(handlerResponse);
replay(handler);
resource.doGet();
// verify(response);
}
示例7: noReadRightOnTarget
import org.restlet.data.Form; //导入方法依赖的package包/类
@Test
public void noReadRightOnTarget() throws ConfigurationException,
SlipStreamClientException {
String targetName = "noReadRightOnTarget";
Form form = new Form();
form.add(ModuleResource.COPY_SOURCE_FORM_PARAMETER_NAME,
image.getResourceUri());
form.add(ModuleResource.COPY_TARGET_FORM_PARAMETER_NAME, targetName);
Request request = createPostRequest(privateProjectAnother.getName(),
form.getWebRepresentation(), user);
addUserToRequest(user, request);
Response response = executeRequest(request);
assertThat(response.getStatus(), is(Status.CLIENT_ERROR_FORBIDDEN));
}
示例8: updateRWSRancidNode
import org.restlet.data.Form; //导入方法依赖的package包/类
public static void updateRWSRancidNode(ConnectionProperties cp, RancidNode rnode) throws RancidApiException{
if (!inited){
throw(new RancidApiException("Error: Api not initialized"));
}
Form form = new Form();
form.add("deviceType", rnode.getDeviceType());
form.add("state", rnode.getState());
form.add("comment", rnode.getComment());
Representation rep = form.getWebRepresentation();
String url = cp.getUrl()+cp.getDirectory()+"/rancid/groups/"+rnode.getGroup()+"/"+rnode.getDeviceName();
postMethodRWS(cp, url,rep);
}
示例9: createRWSAuthNode
import org.restlet.data.Form; //导入方法依赖的package包/类
public static void createRWSAuthNode(ConnectionProperties cp, RancidNodeAuthentication rnodea) throws RancidApiException{
if (!inited){
throw(new RancidApiException("Error: Api not initialized"));
}
Form form = new Form();
form.add("user", rnodea.getUser());
form.add("password", rnodea.getPassword());
form.add("enablepassword", rnodea.getEnablePass());
String autoenable = "0";
if (rnodea.isAutoEnable()){
autoenable="1";
}
form.add("autoenable", autoenable);
form.add("method", rnodea.getConnectionMethodString());
Representation rep = form.getWebRepresentation();
String url = cp.getUrl() + cp.getDirectory() + "/rancid/clogin/" +rnodea.getDeviceName();
putMethodRWS(cp, url,rep);
}
示例10: allGood
import org.restlet.data.Form; //导入方法依赖的package包/类
@Test
public void allGood() throws ConfigurationException,
SlipStreamClientException {
String targetName = "allGood";
Form form = new Form();
form.add(ModuleResource.COPY_SOURCE_FORM_PARAMETER_NAME,
image.getResourceUri());
form.add(ModuleResource.COPY_TARGET_FORM_PARAMETER_NAME, targetName);
Request request = createPostRequest(publicProject.getName(),
form.getWebRepresentation(), user);
addUserToRequest(user, request);
Response response = executeRequest(request);
assertThat(response.getStatus(), is(Status.SUCCESS_CREATED));
Module.load(
Module.constructResourceUri(publicProject.getName() + "/"
+ targetName)).remove();
}
示例11: newNameIllegal
import org.restlet.data.Form; //导入方法依赖的package包/类
@Test
public void newNameIllegal() throws BadlyFormedElementException,
SlipStreamClientException {
User user = UserTest.createUser("test");
String imageName = "newNameIllegal";
Module image = new ImageModule(imageName);
image.store();
ImageFormProcessor processor = new ImageFormProcessor(user);
Form form = new Form();
form.add("name", "new");
try {
processor.processForm(form);
fail("Illegal name not checked");
} catch (ValidationException e) {
}
image.remove();
}
示例12: deploymentWithMissingMappingAndNoDefaultValue
import org.restlet.data.Form; //导入方法依赖的package包/类
@Test(expected = ValidationException.class)
public void deploymentWithMissingMappingAndNoDefaultValue()
throws ConfigurationException, SlipStreamClientException {
User user = UserTest.createUser("test");
String imageName = "deploymentWithMissingMappingAndNoDefaultValue";
Module image = new ImageModule(imageName);
image.setParameter(new ModuleParameter("pi1", null, "",
ParameterCategory.Input));
image.store();
Form form = new Form();
form.add("name", "node1");
form.add("node--1--shortname", "node1");
form.add("node--1--imagelink", "module/" + imageName);
DeploymentFormProcessor processor = new DeploymentFormProcessor(user);
try {
processor.processForm(form);
} finally {
image.remove();
}
}
示例13: missingName
import org.restlet.data.Form; //导入方法依赖的package包/类
@Test(expected = SlipStreamClientException.class)
public void missingName() throws BadlyFormedElementException,
SlipStreamClientException {
user = new User("test");
Form form = createForm();
UserParameter parameter = new UserParameter("p", "v", "d");
fillForm(parameter, form);
form.removeAll(prefix + count + "--name");
form.add(prefix + count + "--name", null);
UserFormProcessor processor = new UserFormProcessor(user);
processor.processForm(form);
}
示例14: testValueDatatypeFORM
import org.restlet.data.Form; //导入方法依赖的package包/类
@Test
public void testValueDatatypeFORM() throws IOException {
Form form = new Form();
form.add("value", "v1");
form.add("datatype", DataTypes.TYPE_STRING.getAddress());
Collection<VariantName> variants = post(null, REF, form);
Assert.assertNotNull(variants);
Assert.assertEquals(2, variants.size());
assertContainsTopics(variants, "4", "12");
}
示例15: testValueDatatypeFORM
import org.restlet.data.Form; //导入方法依赖的package包/类
@Test
public void testValueDatatypeFORM() throws IOException {
Form form = new Form();
form.add("value", "Opera");
form.add("datatype", DataTypes.TYPE_STRING.getAddress());
Collection<Occurrence> occurrences = post("value", REF, form);
Assert.assertNotNull(occurrences);
Assert.assertEquals(1, occurrences.size());
assertContainsTopics(occurrences, "9");
}