本文整理了Java中org.restlet.util.Series.add()
方法的一些代码示例,展示了Series.add()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Series.add()
方法的具体详情如下:
包路径:org.restlet.util.Series
类名称:Series
方法名:add
[英]Creates then adds a parameter at the end of the list.
[中]创建,然后在列表末尾添加一个参数。
代码示例来源:origin: internetarchive/heritrix3
public static void addFlash(Response response, String message, Kind kind) {
dropboxes.put(nextdrop,new Flash(message, kind));
Series<CookieSetting> cookies = response.getCookieSettings();
CookieSetting flashdrop = null;
for(CookieSetting cs : cookies) {
if(cs.getName().equals("flashdrop")) {
flashdrop = cs;
}
}
if(flashdrop == null) {
cookies.add(new CookieSetting("flashdrop",Long.toString(nextdrop)));
} else {
flashdrop.setValue(flashdrop.getValue()+","+Long.toString(nextdrop));
}
nextdrop++;
}
代码示例来源:origin: internetarchive/heritrix3
/**
* Create an HTTPS restlet Server instance matching the given parameters.
*
* @param port
* @param address
* @param keystorePath
* @param keystorePassword
* @param keyPassword
*/
protected void setupServer(int port, String address, String keystorePath, String keystorePassword, String keyPassword) {
Server server = new Server(Protocol.HTTPS,address,port,null);
component.getServers().add(server);
server.getContext().getParameters().add("keystorePath", keystorePath);
server.getContext().getParameters().add("keystorePassword", keystorePassword);
server.getContext().getParameters().add("keyPassword", keyPassword);
}
代码示例来源:origin: org.sonatype.nexus.plugins/nexus-restlet1x-plugin
private void addNoCacheHeaders(final Response response) {
// NEXUS-5155 Force browsers to not cache this page
final Series<Parameter> headers = ((HttpResponse) response).getHttpCall().getResponseHeaders();
headers.add("Pragma", "no-cache"); // HTTP/1.0
headers.add("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate"); // HTTP/1.1
headers.add("Cache-Control", "post-check=0, pre-check=0"); // MS IE
headers.add("Expires", "0"); // No caching on Proxies in between client and Nexus
}
代码示例来源:origin: org.restlet/org.restlet
/**
* Creates then adds a parameter at the end of the list.
*
* @param name
* The parameter name.
* @param value
* The parameter value.
* @return True (as per the general contract of the Collection.add method).
*/
public boolean add(String name, String value) {
return add(createEntry(name, value));
}
代码示例来源:origin: org.sonatype.nexus/nexus-rest-api
private void addNoCacheHeaders( final Response response )
{
// NXCM-5155 Force browsers to not cache this page
final Series<Parameter> headers = ((HttpResponse) response).getHttpCall().getResponseHeaders();
headers.add( "Pragma", "no-cache" );
headers.add( "Cache-Control", "no-cache, no-store, max-age=0, must-revalidate" );
}
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Creates then adds a parameter at the end of the list.
*
* @param name
* The parameter name.
* @param value
* The parameter value.
* @return True (as per the general contract of the Collection.add method).
*/
public boolean add(String name, String value) {
return add(createEntry(name, value));
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
/**
* Creates then adds a parameter at the end of the list.
*
* @param name
* The parameter name.
* @param value
* The parameter value.
* @return True (as per the general contract of the Collection.add method).
*/
public boolean add(String name, String value) {
return add(createEntry(name, value));
}
代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-launcher
@Override
public Series<Parameter> getResponseHeaders() {
final Series<Parameter> result = super.getResponseHeaders();
if (!this.responseHeadersAdded) {
for (final Header header : getHttpResponse().getAllHeaders()) {
result.add(header.getName(), header.getValue());
}
this.responseHeadersAdded = true;
}
return result;
}
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Adds a Date parameter.
*
* @param name
* The name of the parameter.
* @param value
* Its value as a date.
*/
public void addDate(String name, Date value) {
getParameters().add(name,
DateUtils.format(value, DateUtils.FORMAT_RFC_822.get(0)));
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
/**
* Adds a Date parameter.
*
* @param name
* The name of the parameter.
* @param value
* Its value as a date.
*/
public void addDate(String name, Date value) {
getParameters().add(name,
DateUtils.format(value, DateUtils.FORMAT_RFC_822.get(0)));
}
代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs
private void addHeaderParam(Request request, String representationAsText,
Annotation annotation) {
Util.getHttpHeaders(request).add(((HeaderParam) annotation).value(),
representationAsText);
}
代码示例来源:origin: jtalks-org/jcommune
private void addHeaderAttribute(ClientResource clientResource, String attrName, String attrValue) {
ConcurrentMap<String, Object> attrs = clientResource.getRequest().getAttributes();
Series<Header> headers = (Series<Header>) attrs.get(HeaderConstants.ATTRIBUTE_HEADERS);
if (headers == null) {
headers = new Series<>(Header.class);
Series<Header> prev = (Series<Header>) attrs.putIfAbsent(HeaderConstants.ATTRIBUTE_HEADERS, headers);
if (prev != null) {
headers = prev;
}
}
headers.add(attrName, attrValue);
}
代码示例来源:origin: org.restlet.osgi/org.restlet.ext.oauth
private String setupState(Response response) {
String sessionId = UUID.randomUUID().toString();
byte[] secret = new byte[20];
random.nextBytes(secret);
String state = Base64.encode(secret, false);
CookieSetting cs = new CookieSetting("_state", sessionId);
response.getCookieSettings().add(cs);
getContext().getAttributes().put(sessionId, state);
return state;
}
代码示例来源:origin: jtalks-org/jcommune
private ClientResource createClientResource(String url, boolean buffering) {
ClientResource clientResource = new ClientResource(new Context(), url);
clientResource.getContext().getParameters().add("socketConnectTimeoutMs", String.valueOf(CONNECTION_TIMEOUT));
clientResource.getContext().getParameters().add("maxIoIdleTimeMs", String.valueOf(CONNECTION_TIMEOUT));
clientResource.setEntityBuffering(buffering);
return clientResource;
}
代码示例来源:origin: cdelmas/microservices-comparison
@Get("json")
public List<CarRepresentation> all() {
List<io.github.cdelmas.spike.common.domain.Car> cars = carRepository.all();
getResponse().getHeaders().add("total-count", String.valueOf(cars.size()));
return cars.stream().map(c -> {
CarRepresentation carRepresentation = new CarRepresentation(c);
carRepresentation.addLink(Link.self(new Reference(getReference()).addSegment(String.valueOf(c.getId())).toString()));
return carRepresentation;
}).collect(toList());
}
代码示例来源:origin: org.restlet.jse/org.restlet.example
@Override
protected void outboundServerRedirect(Reference targetRef, Request request,
Response response) {
SipRequest r = (SipRequest) request;
SipRecipientInfo sri = new SipRecipientInfo();
sri.setProtocol(Protocol.SIP);
sri.setTransport("TCP");
sri.setName("127.0.0.1:5060");
sri.getParameters().add("branch", "z9hG4bK-20369-1-0");
r.getSipRecipientsInfo().add(0, sri);
super.outboundServerRedirect(targetRef, r, response);
};
代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs
private void addCookieParam(Request request, String representationAsText,
Annotation annotation) {
Series<Cookie> cookies = request.getCookies();
if (cookies == null) {
cookies = new Series<Cookie>(Cookie.class);
}
cookies.add(new Cookie(((CookieParam) annotation).value(),
representationAsText));
request.setCookies(cookies);
}
代码示例来源:origin: apache/attic-polygene-java
public Representation login( String name, String password )
{
context( Login.class ).login( name, password );
EmptyRepresentation rep = new EmptyRepresentation();
Response.getCurrent().getCookieSettings().add( "user", name );
return rep;
}
}
代码示例来源:origin: cdelmas/microservices-comparison
@Inject
public RestComponent(@Hello Application helloApp, @Car Application carApp, Verifier authTokenVerifier) {
getClients().add(Protocol.HTTPS);
Server secureServer = getServers().add(Protocol.HTTPS, 8043);
Series<Parameter> parameters = secureServer.getContext().getParameters();
parameters.add("sslContextFactory", "org.restlet.engine.ssl.DefaultSslContextFactory");
parameters.add("keyStorePath", System.getProperty("javax.net.ssl.keyStorePath"));
getDefaultHost().attach("/api/hello", secure(helloApp, authTokenVerifier, "ame"));
getDefaultHost().attach("/api/cars", secure(carApp, authTokenVerifier, "ame"));
replaceConverter(JacksonConverter.class, new JacksonCustomConverter());
}
代码示例来源:origin: org.restlet.jse/org.restlet.example
public static void main(String[] args) throws Exception {
ClientResource mailClient = new ClientResource(
"http://localhost:8111/accounts/chunkylover53/mails/123");
mailClient.getRequest().getCookies()
.add(new Cookie("Credentials", "chunkylover53=pwd"));
Form form = new Form();
form.add("subject", "Message to Jérôme");
form.add("content", "Doh!\n\nAllo?");
System.out.println(form.getWebRepresentation());
mailClient.put(form).write(System.out);
}
内容来源于网络,如有侵权,请联系作者删除!