本文整理汇总了Java中org.restlet.data.Response类的典型用法代码示例。如果您正苦于以下问题:Java Response类的具体用法?Java Response怎么用?Java Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Response类属于org.restlet.data包,在下文中一共展示了Response类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: RestletResource
import org.restlet.data.Response; //导入依赖的package包/类
public RestletResource(Context context, Request request, Response response) {
super(context, request, response);
Map<String, Object> attributes = request.getAttributes();
query = !attributes.containsKey("query") ? null : ((String) attributes.get("query")).toLowerCase().trim();
type = !attributes.containsKey("type") ? defaultType : ((String) attributes.get("type")).toLowerCase().trim();
format = attributes.get("format") == null ? defaultFormat : ((String) attributes.get("format"));
count = attributes.get("number") == null ? defaultCount : Integer.parseInt(((String) attributes.get("number")));
startNo = attributes.get("start") == null ? defaultCount : Integer.parseInt(((String) attributes.get("start")));
jsonCallback = !attributes.containsKey("jsoncallback") ? defaultJsonCallback : ((String) attributes.get("jsoncallback"));
if (format.equals("text"))
getVariants().add(new Variant(MediaType.TEXT_PLAIN));
else if (format.equals("json"))
getVariants().add(new Variant(MediaType.APPLICATION_JSON));
}
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:17,代码来源:RestletResource.java
示例2: getInfo
import org.restlet.data.Response; //导入依赖的package包/类
private static List<String> getInfo(ConnectionProperties cp, String listUri) throws RancidApiException{
if (!inited){
throw(new RancidApiException("Error: Api not initialized"));
}
String url = cp.getUrl()+cp.getDirectory()+listUri;
Response response=getMethodRWS(cp, url);
DomRepresentation dmr = response.getEntityAsDom();
List<String> data = new ArrayList<String>();
try {
Document doc = dmr.getDocument();
for (int ii = 0; ii < doc.getElementsByTagName("Resource").getLength() ; ii++) {
data.add(doc.getElementsByTagName("Resource").item(ii).getTextContent());
}
}
catch(final IOException e){
throw(new RancidApiException("Error: IOException Method GET: URL:" +url + ":" + e.getMessage(), RancidApiException.OTHER_ERROR));
}
return data;
}
开发者ID:OpenNMS,项目名称:rancid-api,代码行数:25,代码来源:RWSClientApi.java
示例3: getBucketItem
import org.restlet.data.Response; //导入依赖的package包/类
public static byte[] getBucketItem(ConnectionProperties cp, String bucketName, String filename) throws RancidApiException {
if (!inited){
throw(new RancidApiException("Error: Api not initialized"));
}
String url = cp.getUrl() + cp.getDirectory()+"/storage/buckets/" + bucketName + "?filename=" + filename;
Response response = getMethodRWS(cp, url);
response.getEntity();
throw new RancidApiException("getBucketItem: not implemented");
// response.getEntity().getMediaType().equals(MediaType.APPLICATION_OCTET_STREAM);
// FileRepresentation fr ;
// fr.
// response.getEntityAsObject()
//response.getRe
//InputStream is = null;
// try {
// is = response.getEntityAsForm().getWebRepresentation().getAvailableSize();
// } catch (IOException e) {
// throw(new RancidApiException("Error: IOException Method GET: URL:" +url+ ":" + e.getMessage(), RancidApiException.OTHER_ERROR));
// }
// return null;
}
开发者ID:OpenNMS,项目名称:rancid-api,代码行数:23,代码来源:RWSClientApi.java
示例4: postMethodRWS
import org.restlet.data.Response; //导入依赖的package包/类
static Response postMethodRWS(ConnectionProperties cp, String uriReference, Representation form) throws RancidApiException {
client.setConnectTimeout(cp.getTimeout());
client.setProtocols(cp.getProtocols());;
Request request = new Request(Method.POST, uriReference, form);
if(cp.getAuthOn()){
ChallengeScheme scheme = ChallengeScheme.HTTP_BASIC;
ChallengeResponse authentication = new ChallengeResponse(scheme,cp.getUserName(), cp.getPassword());
request.setChallengeResponse(authentication);
}
else {
}
Response response = client.handle(request);
if (response.getStatus().isSuccess()) {
return response;
} else {
throw(handleException(response, "POST" ,uriReference));
}
}
开发者ID:OpenNMS,项目名称:rancid-api,代码行数:27,代码来源:RWSClientApi.java
示例5: handleException
import org.restlet.data.Response; //导入依赖的package包/类
static RancidApiException handleException(Response response, String method, String uriReference ) throws RancidApiException {
if (response.getStatus() == Status.CLIENT_ERROR_REQUEST_TIMEOUT){
return new RancidApiException("Error: RWS "+ method + " failed for URL:" + uriReference + " Status: "+ response.getStatus(),
RancidApiException.RWS_TIMEOUT);
} else if (response.getStatus() == Status.CLIENT_ERROR_UNAUTHORIZED){
return new RancidApiException("Error: RWS "+ method + " failed for URL:" + uriReference + " Status: "+ response.getStatus(),
RancidApiException.RWS_AUTH_FAILES);
} else if (response.getStatus().getCode() == 404){
return new RancidApiException("Error: RWS "+ method + " failed for URL:" + uriReference + " Status: "+ response.getStatus(),
RancidApiException.RWS_RESOURCE_NOT_FOUND);
} else if (response.getStatus().getCode() == 409){
return new RancidApiException("Error: RWS "+ method + " failed for URL:" + uriReference + " Status: "+ response.getStatus(),
RancidApiException.RWS_RESOURCE_EXISTS);
} else if (response.getStatus().getCode() == 503){
return new RancidApiException("Error: RWS "+ method + " failed for URL:" + uriReference + " Status: "+ response.getStatus(),
RancidApiException.RWS_BUSY);
} else {
return new RancidApiException("Error: RWS "+ method + " failed for URL: "+ uriReference + " Status: "+ response.getStatus(),
RancidApiException.OTHER_ERROR);
}
}
开发者ID:OpenNMS,项目名称:rancid-api,代码行数:24,代码来源:RWSClientApi.java
示例6: findTarget
import org.restlet.data.Response; //导入依赖的package包/类
public Resource findTarget(Request request, Response response) {
String workspaceName = (String) request.getAttributes().get("workspace");
if (workspaceName != null && request.getMethod() == Method.GET) {
return new WorkspaceContentsResource(getContext(), request, response, this.catalog);
}
throw new RestletException("No such workspace: " + workspaceName, Status.CLIENT_ERROR_NOT_FOUND);
}
开发者ID:geops,项目名称:geoserver-documentor,代码行数:10,代码来源:WorkspaceContentsFinder.java
示例7: post
import org.restlet.data.Response; //导入依赖的package包/类
/**
* Update content of passed artifact in the proxy repositories of the passed repository
*/
@POST
@Override
@ResourceMethodSignature(input = ArtifactMetaInfo.class, output = RestResponse.class)
public Object post(Context context, Request request, Response response, Object payload) throws ResourceException {
ArtifactMetaInfo metaInfo = (ArtifactMetaInfo) payload;
if (!metaInfo.isValid()) {
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,
"At least following request parameters have to be given: nexusUrl, groupId, artifactId, version, repositoryId!");
}
boolean artifactResolved = false;
for (Repository repository : getRepositoryRegistry().getRepositories()) {
if (repository instanceof MavenProxyRepository) {
MavenProxyRepository mavenProxyRepository = (MavenProxyRepository) repository;
log.trace(String.format("Processing repository: %s. Remote url: %s", mavenProxyRepository.getId(), mavenProxyRepository.getRemoteUrl()));
if (matchRepository(mavenProxyRepository, metaInfo)) {
ArtifactStoreRequest gavRequest = getResourceStoreRequest(request, false, false,
mavenProxyRepository.getId(), metaInfo.getGroupId(), metaInfo.getArtifactId(),
metaInfo.getVersion(), metaInfo.getPackaging(), metaInfo.getClassifier(), metaInfo.getExtension());
try {
ArtifactStoreHelper helper = mavenProxyRepository.getArtifactStoreHelper();
helper.retrieveArtifact(gavRequest);
artifactResolved = true;
} catch (ItemNotFoundException | IllegalOperationException | StorageException | AccessDeniedException e) {
log.error("Can not resolve artifact", e);
return new RestResponse(false, "Can not resolve artifact. " + e.getMessage());
}
}
}
}
if (artifactResolved) {
return new RestResponse(true, "Artifact is resolved.");
} else {
return new RestResponse(false, "No proxies for this artifact.");
}
}
开发者ID:griddynamics,项目名称:nexus-replication-plugin,代码行数:39,代码来源:ArtifactUpdatePlexusResource.java
示例8: handle
import org.restlet.data.Response; //导入依赖的package包/类
public void handle(Request request, Response response) {
// get value of 'name' url fragment, using pattern '/hello/{name}'
String name = (String) request.getAttributes().get("name");
JPublishContext context = (JPublishContext) request.getAttributes().get(JPRestletModule.JPCONTEXT_RESTLET_TAG);
if (context != null) {
log.info("got a JPublish context ....");
}
// send simple string as response to client
response.setEntity("Hello " + name, MediaType.TEXT_PLAIN);
}
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:12,代码来源:HelloJPRestlet.java
示例9: something
import org.restlet.data.Response; //导入依赖的package包/类
public void something() throws IOException {
Request request = new Request(Method.GET, requestUrl);
Client client = new Client(Protocol.HTTP);
Response response = client.handle(request);
Representation representation = response.getEntity();
System.out.println("http response: " +response.getStatus().getCode()+" "+response.getStatus().getDescription());
System.out.println("text: \n"+representation.getText());
}
开发者ID:paulkling,项目名称:checklooks,代码行数:11,代码来源:TestHttpGet.java
示例10: get
import org.restlet.data.Response; //导入依赖的package包/类
@Override
public Object get(Context context, Request request, Response response, Variant variant)
throws ResourceException {
// try {
//crowdClientHolder.getRestClient().getCookieConfig();
//gitlab.getRestClient().
return "<status>OK</status>";
// } catch (RemoteException e) {
// throw new ResourceException(Status.SERVER_ERROR_SERVICE_UNAVAILABLE,
// "Unable to authenticate. Check configuration.", e);
// }
}
开发者ID:jdamick,项目名称:nexus-gitlab-token-auth-plugin,代码行数:13,代码来源:GitlabTestPlexusResource.java
示例11: getRWSRancidNodeTLO
import org.restlet.data.Response; //导入依赖的package包/类
public static RancidNode getRWSRancidNodeTLO(ConnectionProperties cp ,String group, String devicename) throws RancidApiException{
if (!inited){
throw(new RancidApiException("Error: Api not initialized"));
}
String url = cp.getUrl() + cp.getDirectory()+"/rancid/groups/" + group + "/" + devicename;
Response response =getMethodRWS(cp, url);
DomRepresentation dmr = response.getEntityAsDom();
RancidNode rn = new RancidNode();
try {
Document doc = dmr.getDocument();
rn.setDeviceName(devicename);
rn.setDeviceType(safeGetElement(doc, "deviceType"));
String stateUp = safeGetElement(doc, "state");
rn.setStateUp(stateUp != null && stateUp.compareTo("up") == 0);
rn.setComment(safeGetElement(doc, "comment"));
rn.setGroup(group);
}
catch( IOException e){
throw(new RancidApiException("Error: IOException Method GET: URL:" +url + ":" + e.getMessage(), RancidApiException.OTHER_ERROR));
}
return rn;
}
开发者ID:OpenNMS,项目名称:rancid-api,代码行数:29,代码来源:RWSClientApi.java
示例12: getRWSAuthNode
import org.restlet.data.Response; //导入依赖的package包/类
public static RancidNodeAuthentication getRWSAuthNode(ConnectionProperties cp, String devicename) throws RancidApiException{
if (!inited){
throw(new RancidApiException("Error: Api not initialized"));
}
String url = cp.getUrl() + cp.getDirectory()+"/rancid/clogin/" + devicename;
Response response = getMethodRWS(cp, url);
DomRepresentation dmr = response.getEntityAsDom();
RancidNodeAuthentication rna = new RancidNodeAuthentication();
try {
Document doc = dmr.getDocument();
rna.setDeviceName(devicename);
rna.setUser(safeGetElement(doc, "user"));
rna.setPassword(safeGetElement(doc, "password"));
rna.setEnablePass(safeGetElement(doc, "enablepassword"));
rna.setConnectionMethod(safeGetElement(doc, "method"));
rna.setAutoEnable(false);
final String autoEnable = safeGetElement(doc, "autoenable");
if (autoEnable != null && autoEnable.compareTo("1") == 0) {
rna.setAutoEnable(true);
}
}
catch( IOException e){
throw(new RancidApiException("Error: IOException Method GET: URL:" +url+ ":" + e.getMessage(), RancidApiException.OTHER_ERROR));
}
return rna;
}
开发者ID:OpenNMS,项目名称:rancid-api,代码行数:32,代码来源:RWSClientApi.java
示例13: beforeHandle
import org.restlet.data.Response; //导入依赖的package包/类
@Override
protected int beforeHandle(Request request, Response response) {
int status = CONTINUE;
final String path = request.getResourceRef().getPath();
if(isProtectedResource(path)){
final String ip = request.getClientInfo().getAddress();
if(!isLocalhost(ip)){
response.setStatus(Status.CLIENT_ERROR_FORBIDDEN);
status = STOP;
CappuccinoLogger.logger.warn("Denying access to " + path +
" from IP address: " + ip);
}
}
return status;
}
开发者ID:markkolich,项目名称:cappuccino,代码行数:16,代码来源:LocalhostFilter.java
示例14: WorkspaceContentsResource
import org.restlet.data.Response; //导入依赖的package包/类
public WorkspaceContentsResource(Context context, Request request,
Response response, Catalog catalog) {
super(context, request, response, WorkspaceFullDoc.class, catalog);
// TODO Auto-generated constructor stub
}
开发者ID:geops,项目名称:geoserver-documentor,代码行数:6,代码来源:WorkspaceContentsResource.java
示例15: createSupportedFormats
import org.restlet.data.Response; //导入依赖的package包/类
@Override
protected List<DataFormat> createSupportedFormats(Request request,
Response response) {
List<DataFormat> formats = super.createSupportedFormats(request, response);
return formats;
}
开发者ID:geops,项目名称:geoserver-documentor,代码行数:7,代码来源:WorkspaceContentsResource.java
示例16: CompleteDocumentationResource
import org.restlet.data.Response; //导入依赖的package包/类
public CompleteDocumentationResource(final Context context, final Request request,
final Response response, final Catalog catalog) {
super(context, request, response, DocumentationDoc.class, catalog);
}
开发者ID:geops,项目名称:geoserver-documentor,代码行数:5,代码来源:CompleteDocumentationResource.java
示例17: getBucket
import org.restlet.data.Response; //导入依赖的package包/类
public static RWSBucket getBucket(ConnectionProperties cp, String bucketName ) throws RancidApiException {
if (!inited){
throw(new RancidApiException("Error: Api not initialized"));
}
String url = cp.getUrl() + cp.getDirectory()+"/storage/buckets/" + bucketName;
Response response = getMethodRWS(cp, url);
DomRepresentation dmr = response.getEntityAsDom();
RWSBucket bucket = new RWSBucket(bucketName);
try {
Document doc = dmr.getDocument();
int fileNumber = doc.getElementsByTagName("File").getLength();
bucket.setBucketItem(new ArrayList<BucketItem>(fileNumber));
for (int j = 0 ; j < fileNumber ; j++){
String itemName="";
int itemSize=0;
Date itemDate=null;
for (int i = 0; i < doc.getElementsByTagName("File").item(j).getChildNodes().getLength(); i++) {
LOG.debug("Item:" + i +" NodeName: " + doc.getElementsByTagName("File").item(j).getChildNodes().item(i).getNodeName());
LOG.debug("Item:" + i +" NodeTextContent: " + doc.getElementsByTagName("File").item(j).getChildNodes().item(i).getTextContent());
if ("Name".equals(doc.getElementsByTagName("File").item(j).getChildNodes().item(i).getNodeName())) {
itemName = doc.getElementsByTagName("File").item(j).getChildNodes().item(i).getTextContent();
} else if ("Size".equals(doc.getElementsByTagName("File").item(j).getChildNodes().item(i).getNodeName())) {
itemSize = Integer.parseInt(doc.getElementsByTagName("File").item(j).getChildNodes().item(i).getTextContent());
} else if ("LastModified".equals(doc.getElementsByTagName("File").item(j).getChildNodes().item(i).getNodeName())) {
SimpleDateFormat format = new SimpleDateFormat("yyyy/M/d H:m:s z");
itemDate = format.parse(doc.getElementsByTagName("File").item(j).getChildNodes().item(i).getTextContent());
}
}
bucket.setBucket(j, itemName, itemSize, itemDate);
}
} catch (IOException e) {
throw(new RancidApiException("Error: IOException Method GET: URL:" +url+ ":" + e.getMessage(), RancidApiException.OTHER_ERROR));
} catch (ParseException pe) {
throw(new RancidApiException("Error: ParseException Method GET: URL:" +url+ ":" + pe.getMessage(), RancidApiException.OTHER_ERROR));
}
return bucket;
}
开发者ID:OpenNMS,项目名称:rancid-api,代码行数:49,代码来源:RWSClientApi.java
示例18: ExitResource
import org.restlet.data.Response; //导入依赖的package包/类
public ExitResource(Context context, Request request, Response response) {
super(context, request, response);
getVariants().add(new Variant(MediaType.TEXT_PLAIN));
}
开发者ID:markkolich,项目名称:cappuccino,代码行数:5,代码来源:ExitResource.java
示例19: getMethodRWS
import org.restlet.data.Response; //导入依赖的package包/类
static Response getMethodRWS(ConnectionProperties cp, String uriReference) throws RancidApiException {
client.setConnectTimeout(cp.getTimeout());
client.setProtocols(cp.getProtocols());;
Request request = new Request(Method.GET, uriReference);
if(cp.getUserName() != null){
ChallengeScheme scheme = ChallengeScheme.HTTP_BASIC;
ChallengeResponse authentication = new ChallengeResponse(scheme,cp.getUserName(), cp.getPassword());
request.setChallengeResponse(authentication);
}
else {
}
Response response = client.handle(request);
if (response.getStatus().isSuccess()) {
return response;
} else {
throw(handleException(response, "GET" ,uriReference));
}
}
开发者ID:OpenNMS,项目名称:rancid-api,代码行数:29,代码来源:RWSClientApi.java
示例20: putMethodRWS
import org.restlet.data.Response; //导入依赖的package包/类
static Response putMethodRWS(ConnectionProperties cp, String uriReference, Representation form) throws RancidApiException {
client.setConnectTimeout(cp.getTimeout());
client.setProtocols(cp.getProtocols());;
Request request = new Request(Method.PUT, uriReference, form);
if(cp.getAuthOn()){
ChallengeScheme scheme = ChallengeScheme.HTTP_BASIC;
ChallengeResponse authentication = new ChallengeResponse(scheme,cp.getUserName(), cp.getPassword());
request.setChallengeResponse(authentication);
}
else {
}
Response response = client.handle(request);
if (response.getStatus().isSuccess()) {
return response;
} else {
throw(handleException(response, "PUT" ,uriReference));
}
}
开发者ID:OpenNMS,项目名称:rancid-api,代码行数:28,代码来源:RWSClientApi.java
注:本文中的org.restlet.data.Response类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论