当前位置: 首页>>代码示例>>Java>>正文


Java Verb类代码示例

本文整理汇总了Java中org.scribe.model.Verb的典型用法代码示例。如果您正苦于以下问题:Java Verb类的具体用法?Java Verb怎么用?Java Verb使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Verb类属于org.scribe.model包,在下文中一共展示了Verb类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: send

import org.scribe.model.Verb; //导入依赖的package包/类
private String send(Verb verb, String params) throws Exception {
    String url = apiUrl + ((params != null) ? params : "");
    
    OAuthRequest request = new OAuthRequest(verb, url);
    request.addQuerystringParameter(OAuthConstants.ACCESS_TOKEN, apiAccessToken);
    
    // For more details on the “Bearer” token refer to http://tools.ietf.org/html/draft-ietf-oauth-v2-bearer-23
    StringBuilder sb = new StringBuilder();
    sb.append("Bearer ");
    sb.append(apiAccessToken);
    request.addHeader("Authorization",  sb.toString());

    if (LOG.isDebugEnabled()) {
        LOG.debug("Yammer request url: {}", request.getCompleteUrl());
    }
    
    Response response = request.send();
    if (response.isSuccessful()) {                    
        return response.getBody();
    } else {
        throw new Exception(String.format("Failed to poll %s. Got response code %s and body: %s", getApiUrl(), response.getCode(), response.getBody()));
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:ScribeApiRequestor.java

示例2: afterFinalUriConstructed

import org.scribe.model.Verb; //导入依赖的package包/类
@Override
protected String afterFinalUriConstructed(HttpRequestBase forMethod, String finalUri, Map<String, ? extends Object> parameters)
{
    long start = System.currentTimeMillis();
	//
	// generate oauth 1.0 params for 2LO - use scribe so far for that ...
	//
	OAuthService service = createOauthService();
	OAuthRequest request = new OAuthRequest(Verb.valueOf(forMethod.getMethod()), finalUri);

	addParametersForSigning(request, parameters);

	service.signRequest(new EmptyToken(), request);
	Map<String, String> oauthParams = request.getOauthParameters();
	//
	//
	log.debug("2LO signing took [{}] ms ", System.currentTimeMillis() - start);

	return finalUri + paramsToString(oauthParams, finalUri.indexOf("?") != -1);
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:21,代码来源:TwoLegged10aOauthRemoteRequestor.java

示例3: addParametersForSigning

import org.scribe.model.Verb; //导入依赖的package包/类
protected void addParametersForSigning(final OAuthRequest request, final Map<String, ? extends Object> parameters)
{
    if (parameters == null)
    {
        return;
    }
    Verb method = request.getVerb();
    if (method == Verb.POST || method == Verb.PUT)
    {
        processParams(parameters, new ParameterProcessor()
        {
            @Override
            public void process(String key, String value)
            {
                request.addBodyParameter(key, value);
            }

        });
    }
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:21,代码来源:ScribeOauthRemoteRequestor.java

示例4: onConnectionCreated

import org.scribe.model.Verb; //导入依赖的package包/类
@Override
protected void onConnectionCreated(HttpClient client, HttpRequestBase method, Map<String, ? extends Object> parameters)
        throws IOException
{
    long start = System.currentTimeMillis();
    //
    // generate oauth 1.0 params for 3LO - use scribe so far for that ...
    //
    OAuthService service = createOauthService();
    OAuthRequest request = new OAuthRequest(Verb.valueOf(method.getMethod()), method.getURI().toString());

    addParametersForSigning(request, parameters);

    service.signRequest(generateAccessTokenObject(accessTokenWithSecret), request);

    String header = authHeaderCreator.extract(request);
    method.addHeader(OAuthConstants.HEADER, header);

    log.debug("3LO signing took [{}] ms ", System.currentTimeMillis() - start);
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:21,代码来源:ThreeLegged10aOauthRemoteRequestor.java

示例5: getClusters

import org.scribe.model.Verb; //导入依赖的package包/类
/**
 * 获取当前用户所有集群信息
 * 
 * @return
 * @throws Fit2CloudException
 */
public List<Cluster> getClusters() throws Fit2CloudException {
	OAuthRequest request = new OAuthRequest(Verb.GET, restApiEndpoint + "/clusters");
	Token accessToken = new Token("", "");
	service.signRequest(accessToken, request);
	Response response = request.send();
	int code = response.getCode();
	String responseString = response.getBody();
	if (code == 200) {
		Type listType = new TypeToken<ArrayList<Cluster>>() {
		}.getType();
		return new GsonBuilder().create().fromJson(responseString, listType);
	} else {
		throw new Fit2CloudException(responseString);
	}
}
 
开发者ID:fit2cloud,项目名称:fit2cloud-general-java-sdk,代码行数:22,代码来源:Fit2CloudClient.java

示例6: getClusterRoles

import org.scribe.model.Verb; //导入依赖的package包/类
/**
 * 获取指定集群下所有虚机组信息
 * 
 * @param clusterId
 *            集群ID
 * @return
 * @throws Fit2CloudException
 */
public List<ClusterRole> getClusterRoles(long clusterId) throws Fit2CloudException {
	OAuthRequest request = new OAuthRequest(Verb.GET, restApiEndpoint + "/cluster/" + clusterId + "/roles");
	Token accessToken = new Token("", "");
	service.signRequest(accessToken, request);
	Response response = request.send();
	int code = response.getCode();
	String responseString = response.getBody();
	if (code == 200) {
		Type listType = new TypeToken<ArrayList<ClusterRole>>() {
		}.getType();
		return new GsonBuilder().create().fromJson(responseString, listType);
	} else {
		throw new Fit2CloudException(responseString);
	}
}
 
开发者ID:fit2cloud,项目名称:fit2cloud-general-java-sdk,代码行数:24,代码来源:Fit2CloudClient.java

示例7: executeScript

import org.scribe.model.Verb; //导入依赖的package包/类
/**
 * 在指定虚机上执行指定脚本
 * 
 * @param serverId
 *            虚机ID
 * @param scriptContent
 *            脚本内容
 * @return 返回执行脚本事件ID, 可根据此ID获取返回的所有执行日志
 * @throws Fit2CloudException
 */
public long executeScript(long serverId, String scriptContent) throws Fit2CloudException {
	OAuthRequest request = new OAuthRequest(Verb.POST, executeScriptInServerUrl);
	request.addBodyParameter("serverId", String.valueOf(serverId));
	request.addBodyParameter("scriptContent", scriptContent);
	request.setCharset("UTF-8");
	Token accessToken = new Token("", "");
	service.signRequest(accessToken, request);
	Response response = request.send();
	int code = response.getCode();
	String responseString = response.getBody();
	if (code == 200) {
		return Long.parseLong(responseString);
	} else {
		throw new Fit2CloudException(responseString);
	}
}
 
开发者ID:fit2cloud,项目名称:fit2cloud-general-java-sdk,代码行数:27,代码来源:Fit2CloudClient.java

示例8: getLoggingsByEventId

import org.scribe.model.Verb; //导入依赖的package包/类
/**
 * 获取事件返回的所有日志信息(如执行脚本事件)
 * 
 * @param eventId
 *            事件ID
 * @return
 * @throws Fit2CloudException
 */
public List<Logging> getLoggingsByEventId(long eventId) throws Fit2CloudException {
	OAuthRequest request = new OAuthRequest(Verb.GET, getLoggingUrl + eventId);
	Token accessToken = new Token("", "");
	service.signRequest(accessToken, request);
	Response response = request.send();
	int code = response.getCode();
	String responseString = response.getBody();
	if (code == 200) {
		Type listType = new TypeToken<ArrayList<Logging>>() {
		}.getType();
		return new GsonBuilder().create().fromJson(responseString, listType);
	} else {
		throw new Fit2CloudException(responseString);
	}
}
 
开发者ID:fit2cloud,项目名称:fit2cloud-general-java-sdk,代码行数:24,代码来源:Fit2CloudClient.java

示例9: launchServer

import org.scribe.model.Verb; //导入依赖的package包/类
/**
 * 创建虚机
 * 
 * @param clusterId
 *            虚机所在的集群
 * @param clusterRoleId
 *            虚机所在的虚机组
 * @param launchConfigurationId
 *            创建虚机所使用的模板
 * @return 创建后的虚机信息
 * @throws Fit2CloudException
 */
public Server launchServer(long clusterId, long clusterRoleId, long launchConfigurationId)
		throws Fit2CloudException {
	OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/launchserver/cluster/" + clusterId
			+ "/clusterrole/" + clusterRoleId + "?launchConfigurationId=" + launchConfigurationId);
	Token accessToken = new Token("", "");
	service.signRequest(accessToken, request);
	Response response = request.send();
	int code = response.getCode();
	String responseString = response.getBody();
	if (code == 200) {
		return new GsonBuilder().create().fromJson(responseString, Server.class);
	} else {
		throw new Fit2CloudException(responseString);
	}
}
 
开发者ID:fit2cloud,项目名称:fit2cloud-general-java-sdk,代码行数:28,代码来源:Fit2CloudClient.java

示例10: launchServerAsync

import org.scribe.model.Verb; //导入依赖的package包/类
/**
 * 创建虚机. 此接口将立刻返回虚机ID,而后台将异步创建虚机. 之后通过返回的虚机信息中的ID来查询完整的虚机信息
 * 
 * @param clusterId
 *            虚机所在的集群
 * @param clusterRoleId
 *            虚机所在的虚机组
 * @param launchConfigurationId
 *            创建虚机所使用的模板
 * @return
 * @throws Fit2CloudException
 */
public Server launchServerAsync(long clusterId, long clusterRoleId, long launchConfigurationId)
		throws Fit2CloudException {
	OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/launchserver/async/cluster/" + clusterId
			+ "/clusterrole/" + clusterRoleId + "?launchConfigurationId=" + launchConfigurationId);
	Token accessToken = new Token("", "");
	service.signRequest(accessToken, request);
	Response response = request.send();
	int code = response.getCode();
	String responseString = response.getBody();
	if (code == 200) {
		return new GsonBuilder().create().fromJson(responseString, Server.class);
	} else {
		throw new Fit2CloudException(responseString);
	}
}
 
开发者ID:fit2cloud,项目名称:fit2cloud-general-java-sdk,代码行数:28,代码来源:Fit2CloudClient.java

示例11: getClusterParams

import org.scribe.model.Verb; //导入依赖的package包/类
/**
 * 获取指定集群的集群参数
 * 
 * @param clusterId
 *            集群ID
 * @return
 * @throws Fit2CloudException
 */
public List<ClusterParam> getClusterParams(long clusterId) throws Fit2CloudException {
	OAuthRequest request = new OAuthRequest(Verb.GET, restApiEndpoint + "/cluster/" + clusterId + "/params");
	Token accessToken = new Token("", "");
	service.signRequest(accessToken, request);
	Response response = request.send();
	int code = response.getCode();
	String responseString = response.getBody();
	if (code == 200) {
		Type listType = new TypeToken<ArrayList<ClusterParam>>() {
		}.getType();
		return new GsonBuilder().create().fromJson(responseString, listType);

	} else {
		throw new Fit2CloudException(responseString);
	}
}
 
开发者ID:fit2cloud,项目名称:fit2cloud-general-java-sdk,代码行数:25,代码来源:Fit2CloudClient.java

示例12: setClusterParam

import org.scribe.model.Verb; //导入依赖的package包/类
/**
 * 设置集群参数, 若之前无此参数,则添加; 若有则替换
 * 
 * @param clusterId
 *            集群ID
 * @param name
 *            集群参数名称
 * @param value
 *            集群参数值
 * @return
 * @throws Fit2CloudException
 */
public boolean setClusterParam(long clusterId, String name, String value) throws Fit2CloudException {
	OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/cluster/" + clusterId + "/param");
	request.addBodyParameter("name", name);
	request.addBodyParameter("value", value);
	request.setCharset("UTF-8");
	Token accessToken = new Token("", "");
	service.signRequest(accessToken, request);
	Response response = request.send();
	int code = response.getCode();
	String responseString = response.getBody();
	if (code == 200) {
		return "true".equals(responseString);
	} else {
		throw new Fit2CloudException(response.getBody());
	}
}
 
开发者ID:fit2cloud,项目名称:fit2cloud-general-java-sdk,代码行数:29,代码来源:Fit2CloudClient.java

示例13: addScript

import org.scribe.model.Verb; //导入依赖的package包/类
/**
 * 添加脚本
 * 
 * @param name
 *            脚本名称
 * @param description
 *            脚本描述
 * @param scriptText
 *            脚本内容
 * @return 脚本ID
 * @throws Fit2CloudException
 */
public Long addScript(String name, String description, String scriptText) throws Fit2CloudException {
	OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/script/add");
	request.addBodyParameter("name", name);
	request.addBodyParameter("description", description);
	request.addBodyParameter("scriptText", scriptText);
	request.setCharset("UTF-8");
	Token accessToken = new Token("", "");
	service.signRequest(accessToken, request);
	Response response = request.send();
	int code = response.getCode();
	String responseString = response.getBody();
	if (code == 200) {
		return Long.parseLong(responseString);
	} else {
		throw new Fit2CloudException(response.getBody());
	}
}
 
开发者ID:fit2cloud,项目名称:fit2cloud-general-java-sdk,代码行数:30,代码来源:Fit2CloudClient.java

示例14: editScript

import org.scribe.model.Verb; //导入依赖的package包/类
/**
 * 编辑指定脚本
 * 
 * @param scriptId
 *            脚本ID
 * @param description
 *            脚本描述
 * @param scriptText
 *            脚本内容
 * @return
 * @throws Fit2CloudException
 */
public boolean editScript(long scriptId, String description, String scriptText) throws Fit2CloudException {
	OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/script/" + scriptId + "/update");
	request.addBodyParameter("description", description);
	request.addBodyParameter("scriptText", scriptText);
	request.setCharset("UTF-8");
	Token accessToken = new Token("", "");
	service.signRequest(accessToken, request);
	Response response = request.send();
	int code = response.getCode();
	String responseString = response.getBody();
	if (code == 200) {
		return "true".equals(responseString);
	} else {
		throw new Fit2CloudException(response.getBody());
	}
}
 
开发者ID:fit2cloud,项目名称:fit2cloud-general-java-sdk,代码行数:29,代码来源:Fit2CloudClient.java

示例15: saveTag

import org.scribe.model.Verb; //导入依赖的package包/类
/**
 * 给指定虚机设置标签. 若无则新增标签; 若有则替换
 * 
 * @param serverId
 *            虚机ID
 * @param tagName
 *            标签名称
 * @param tagValue
 *            标签值
 * @return
 * @throws Fit2CloudException
 */
public Tag saveTag(Long serverId, String tagName, String tagValue) throws Fit2CloudException {
	OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/tags/save");
	if (serverId != null && serverId.intValue() > 0) {
		request.addBodyParameter("serverId", String.valueOf(serverId));
	}
	if (tagName != null && tagName.trim().length() > 0) {
		request.addBodyParameter("tagName", tagName.trim());
	}
	if (tagValue != null && tagValue.trim().length() > 0) {
		request.addBodyParameter("tagValue", tagValue.trim());
	}
	request.setCharset("UTF-8");
	Token accessToken = new Token("", "");
	service.signRequest(accessToken, request);
	Response response = request.send();
	int code = response.getCode();
	String responseString = response.getBody();
	if (code == 200) {
		return new GsonBuilder().create().fromJson(responseString, Tag.class);
	} else {
		throw new Fit2CloudException(response.getBody());
	}
}
 
开发者ID:fit2cloud,项目名称:fit2cloud-general-java-sdk,代码行数:36,代码来源:Fit2CloudClient.java


注:本文中的org.scribe.model.Verb类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。