當前位置: 首頁>>代碼示例>>Java>>正文


Java Verb.POST屬性代碼示例

本文整理匯總了Java中org.scribe.model.Verb.POST屬性的典型用法代碼示例。如果您正苦於以下問題:Java Verb.POST屬性的具體用法?Java Verb.POST怎麽用?Java Verb.POST使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.scribe.model.Verb的用法示例。


在下文中一共展示了Verb.POST屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: launchServer

/**
 * 創建虛機
 * 
 * @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,代碼行數:27,代碼來源:Fit2CloudClient.java

示例2: launchServerAsync

/**
 * 創建虛機. 此接口將立刻返回虛機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,代碼行數:27,代碼來源:Fit2CloudClient.java

示例3: editScript

/**
 * 編輯指定腳本
 * 
 * @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,代碼行數:28,代碼來源:Fit2CloudClient.java

示例4: saveTag

/**
 * 給指定虛機設置標簽. 若無則新增標簽; 若有則替換
 * 
 * @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,代碼行數:35,代碼來源:Fit2CloudClient.java

示例5: deleteTag

/**
 * 刪除指定虛機的標簽
 * 
 * @param serverId
 *            虛機ID
 * @param tagName
 *            標簽名稱
 * @return
 * @throws Fit2CloudException
 */
public boolean deleteTag(Long serverId, String tagName) throws Fit2CloudException {
	OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/tags/delete");
	if (serverId != null && serverId.intValue() > 0) {
		request.addBodyParameter("serverId", String.valueOf(serverId));
	}
	if (tagName != null && tagName.trim().length() > 0) {
		request.addBodyParameter("tagName", tagName.trim());
	}
	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

示例6: addApplicationRevision

/**
 * 添加應用版本
 * 
 * @param name
 *            應用版本名稱
 * @param description
 *            應用版本描述
 * @param applicationName
 *            所屬應用名稱
 * @param repositoryName
 *            所屬倉庫名稱
 * @param location
 *            應用版本文件的下載路徑
 * @param md5
 *            應用版本文件的md5值
 * @return
 * @throws Fit2CloudException
 */
public ApplicationRevision addApplicationRevision(String name, String description, String applicationName,
		String repositoryName, String location, String md5) throws Fit2CloudException {
	OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/deploy/app/revision/add.json");
	request.addBodyParameter("revName", name);
	request.addBodyParameter("revDescription", description);
	request.addBodyParameter("appName", applicationName);
	if (repositoryName != null) {
		request.addBodyParameter("repoName", repositoryName);
	}
	request.addBodyParameter("location", location);
	if (md5 != null && md5.trim().length() > 0) {
		request.addBodyParameter("md5", md5);
	}
	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, ApplicationRevision.class);
	} else {
		throw new Fit2CloudException(response.getBody());
	}
}
 
開發者ID:fit2cloud,項目名稱:fit2cloud-general-java-sdk,代碼行數:43,代碼來源:Fit2CloudClient.java

示例7: getAccessTokenByAuthCode

/**
 * Receive oauth2 token from authentication server and store it in the session context
 *
 * @param authorizationCode from authentication server
 * @return oauth2 token
 * @throws IOException
 */
@Override
public OAuth2AccessToken getAccessTokenByAuthCode(String authorizationCode) throws ParseException {
    LOGGER.info("get oauth2 access token", TokenServiceImpl.class);

    OAuthRequest oAuthRequest = new OAuthRequest(Verb.POST, ACCESS_TOKEN_URI);
    oAuthRequest.addHeader("Content-Type", HEADER_CONTENT_TYPE);
    oAuthRequest.addHeader("Authorization", HEADER_AUTHORIZATION_TYPE + Base64.encodeBase64String(new String(CLIENT_ID + ":" + CLIENT_SECRET).getBytes()));
    oAuthRequest.setCharset(HEADER_CHAR_SET_TYPE);
    oAuthRequest.addBodyParameter("grant_type", AUTHORIZATION_CODE_GRANT_TYPE);
    oAuthRequest.addBodyParameter("code", authorizationCode);

    LOGGER.info("send request for access token", TokenServiceImpl.class);
    String accessTokenResponse = oAuthRequest.send().getBody();

    if (accessTokenResponse != null) {
        LOGGER.info("successfully received authorization token");
        // store accessToken in session context
        this.accessToken = new DefaultOAuth2AccessToken(new JSONObject(accessTokenResponse).get("access_token").toString());
        ((DefaultOAuth2AccessToken) this.accessToken).setRefreshToken(new DefaultOAuth2RefreshToken(new JSONObject(accessTokenResponse).get("refresh_token").toString()));
        ((DefaultOAuth2AccessToken) this.accessToken).setExpiration((new Date(System.currentTimeMillis() + (Long
                .valueOf(new JSONObject(accessTokenResponse).get("expires_in").toString()) * 60000))));

        String idToken = new JSONObject(accessTokenResponse).get("id_token").toString();
        this.jwtDTO = parseJWTToken(idToken);
        this.userId = this.jwtDTO.getUserId();

    } else {
        LOGGER.warn("failed to get authorization token", TokenServiceImpl.class);
    }

    return accessToken;
}
 
開發者ID:Tradeshift,項目名稱:tradeshift-app-samples,代碼行數:39,代碼來源:TokenServiceImpl.java

示例8: refreshToken

/**
 * Obtain a new token by refresh token
 */
@Override
public void refreshToken() {
    if (this.accessToken.getRefreshToken() != null) {
        OAuthRequest oAuthRequest = new OAuthRequest(Verb.POST, ACCESS_TOKEN_URI);
        oAuthRequest.addHeader("Content-Type", HEADER_CONTENT_TYPE);
        oAuthRequest.addHeader("Authorization", HEADER_AUTHORIZATION_TYPE + Base64.encodeBase64String(new String(CLIENT_ID + ":" + CLIENT_SECRET).getBytes()));
        oAuthRequest.setCharset(HEADER_CHAR_SET_TYPE);
        oAuthRequest.addBodyParameter("grant_type", REFRESH_TOKEN_GRANT_TYPE);
        oAuthRequest.addBodyParameter("refresh_token", getAccessTokenFromContext().getRefreshToken().getValue().toString());
        oAuthRequest.addBodyParameter("scope", CLIENT_ID + "." + propertySources.getTradeshiftAppVersion());

        LOGGER.info("send request for access token by refresh token", TokenServiceImpl.class);

        String accessTokenResponse = oAuthRequest.send().getBody();

        if (accessTokenResponse != null) {
            LOGGER.info("successfully received authorization token by refresh token");
            // store accessToken in session context
            this.accessToken = new DefaultOAuth2AccessToken(new JSONObject(accessTokenResponse).get("access_token").toString());
            ((DefaultOAuth2AccessToken) this.accessToken).setExpiration((new Date(System.currentTimeMillis() + Long.valueOf(new JSONObject(accessTokenResponse).get("expires_in").toString()))));
        } else {
            LOGGER.warn("failed to get authorization token by refresh token", TokenServiceImpl.class);
        }
    } else {
        LOGGER.error("Refresh token doesn't exist", TokenServiceImpl.class);
    }

}
 
開發者ID:Tradeshift,項目名稱:tradeshift-app-samples,代碼行數:31,代碼來源:TokenServiceImpl.java

示例9: doInBackground

protected Boolean doInBackground(String... urls) {


            try {
                Request request = new Request(Verb.POST, this.url);

                return true;

            } catch (Exception exception) {
                Log.d("CordovaPostcard", exception.getMessage());
                return null;
            }

            /*
            try {
                HttpRequest request = HttpRequest.post(this.url);
                request.form(this.params);
                Log.d("Postcard", "response -> " + request.body());
                if (request.ok()) {
                    //file = File.createTempFile("download", ".tmp");
                    //request.receive(file);
                    //publishProgress(file.length());
                    return true;
                } else {
                    return null;
                }
            } catch (HttpRequestException exception) {
                return null;
            }
            */
        }
 
開發者ID:bitwit,項目名稱:postcard-android,代碼行數:31,代碼來源:Network.java

示例10: getTokenByAuthorizationCode

public DeepinToken getTokenByAuthorizationCode(String code) {
    Request request = new Request(Verb.POST, OAUTH2_API + "token");
    request.addBodyParameter("grant_type", "authorization_code");
    request.addBodyParameter("code", code);
    request.addBodyParameter("redirect_uri", oauthCallback);
    request.addBodyParameter("client_id", clientID);
    request.addBodyParameter("client_secret", clientSecret);
    Response response = request.send();
    String json = response.getBody();
    Gson gson = new Gson();
    DeepinToken tokenResponse = gson.fromJson(json, DeepinToken.class);
    return tokenResponse;        
}
 
開發者ID:Iceyer,項目名稱:deepin-oauth-plugin,代碼行數:13,代碼來源:DeepinOAuthApiService.java

示例11: registerCmdbServer

public CmdbVm registerCmdbServer(String sfServerId, Long cmdbServerId, boolean installAgent, String user,
		String password, String key, Long port) throws Fit2CloudException {
	OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/cmdbserver/register");
	request.addBodyParameter("sfServerId", sfServerId);
	request.addBodyParameter("cmdbServerId", String.valueOf(cmdbServerId));
	request.addBodyParameter("installAgent", String.valueOf(installAgent));
	if (user != null && user.trim().length() > 0) {
		request.addBodyParameter("user", user);
	}
	if (password != null && password.trim().length() > 0) {
		request.addBodyParameter("password", password);
	}
	if (key != null && key.trim().length() > 0) {
		request.addBodyParameter("key", key);
	}
	if (port == null || port <= 0) {
		port = 22l;
	}
	request.addBodyParameter("port", String.valueOf(port));
	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, CmdbVm.class);
	} else {
		throw new Fit2CloudException(response.getBody());
	}
}
 
開發者ID:fit2cloud,項目名稱:fit2cloud-general-java-sdk,代碼行數:31,代碼來源:Fit2CloudClient.java

示例12: registerServer

/**
 * 將服務器注冊到devops平台
 *
 * @param server
 *            server對象
 * @param installAgent
 *            是否自動安裝agent
 * @param user
 *            係統的登錄用戶名
 * @param password
 *            係統的登錄密碼
 * @param key
 *            係統的登錄秘鑰
 * @param port
 *            係統的登錄端口
 * @return
 * @throws Fit2CloudException
 */
public Server registerServer(Server server, boolean installAgent, String user,
							 String password, String key, Long port) throws Fit2CloudException {
	OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/server/import");
	request.addBodyParameter("server", new Gson().toJson(server));
	request.addBodyParameter("installAgent", String.valueOf(installAgent));
	if (user != null && user.trim().length() > 0) {
		request.addBodyParameter("user", user);
	}
	if (password != null && password.trim().length() > 0) {
		request.addBodyParameter("password", password);
	}
	if (key != null && key.trim().length() > 0) {
		request.addBodyParameter("key", key);
	}
	if (port == null || port <= 0) {
		port = 22l;
	}
	request.addBodyParameter("port", String.valueOf(port));
	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, Server.class);
	} else {
		throw new Fit2CloudException(response.getBody());
	}
}
 
開發者ID:fit2cloud,項目名稱:fit2cloud-general-java-sdk,代碼行數:48,代碼來源:Fit2CloudClient.java

示例13: deleteClusterParam

/**
 * 刪除指定集群的集群參數
 * 
 * @param clusterId
 *            集群ID
 * @param name
 *            集群參數名稱
 * @return
 * @throws Fit2CloudException
 */
public boolean deleteClusterParam(long clusterId, String name) throws Fit2CloudException {
	OAuthRequest request = new OAuthRequest(Verb.POST,
			restApiEndpoint + "/cluster/" + clusterId + "/param/delete?name=" + name);
	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,代碼行數:24,代碼來源:Fit2CloudClient.java

示例14: post

@Override
public String post(String url, byte[] payload, Map.Entry<String, String>... params) {
	OAuthRequest request = new OAuthRequest(Verb.POST, url);
	if (params != null) {
		this.addBodyParams(request, params);
	}

	request.addPayload(payload);

	request.addHeader("Content-Type", "application/json");
	this.service.signRequest(this.accesToken, request);
	Response r = request.send();
	return r.getBody();
}
 
開發者ID:Openredu,項目名稱:mobile,代碼行數:14,代碼來源:ScribeHttpClient.java

示例15: deleteScript

/**
 * 刪除指定腳本
 * 
 * @param scriptId
 *            腳本ID
 * @return
 * @throws Fit2CloudException
 */
public boolean deleteScript(long scriptId) throws Fit2CloudException {
	OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/script/" + scriptId + "/delete");
	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,代碼行數:21,代碼來源:Fit2CloudClient.java


注:本文中的org.scribe.model.Verb.POST屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。